Then I start from the origin point of the gameObject I attach the script to: in Unity each class that inherits from MonoBehaviour can be attached to any GameObject. I get the length of the side of the hexagon by looking at the scale of the model (that's why I ask the x and z scaling to be the same). So I asked for the 3D model of a hexagon (you can find one attached to this article, modeled using Blender 3D), for the radius of the tessellation, and the field HexSideMultipler is for multiply the length of the side of the hexagon by a constant. I would just like to comment some of the implementation choices I made.įirst of all, for anybody that does not know how Unity 3D works, basically each public field of a class that inherits from MonoBehaviour can be set from the editor and used as an input field, so that each instance of the class can have its own parameters easily set from the editor. Having the idea ready, writing the code was very very easy. Let's start with a 2-dimensional euclidean space where we fix a point O to be the centre and the basis ", mult, hn) The idea is to generate the centre for a new hexagon by looking at the last generated centre. The algorithm can output the centre of every hexagon generated however, in this implementation, we are going to use Unit圓D to draw the hexagons. Side - The length of the side of the hexagon. In the following image, the original centre is coloured in red, the first loop in yellow and the second loop is green (and the centre for the second loop is formed by the red and yellow hexagons). The generation finishes when a given number of loops is reached. Then another loop of hexagon will surround the centre and this becomes the centre for a new loop of hexagons. The hexagons generation starts in a point which will be the centre. After that, I will draw it using Unit圓D The Idea Return UnityEdgeLengthBasedTess (v0.vertex, v1.vertex, v2.vertex, _EdgeLength) įloat d = tex2Dlod(_DispTex, float4(v.texcoord.xy,0,0)).In this article I will design an algorithm to generate a hexagonal tessellation in a plane. #pragma surface surf BlinnPhong addshadow fullforwardshadows vertex:disp tessellate:tessEdge nolightmapįloat4 tessEdge (appdata v0, appdata v1, appdata v2) It just moves vertices along their normals based on the amount coming from a displacement map: Shader "Tessellation Sample" This next example shows a surface shader that does some displacement mapping without using tessellation. No GPU tessellation, displacement in the vertex modifier When you use tessellation, the shader is automatically compiled into the Shader Model 4.6 target, which prevents support for running on older graphics targets.More info See in Glossary, no isoline tessellation. Only triangle domain - no quads A primitive object that resembles a plane but its edges are only one unit long, it uses only 4 vertices, and the surface is oriented in the XY plane of the local coordinate space.Surface shaders can optionally compute phong tessellation to smooth model surface even without any displacement mapping.Ĭurrent limitations of tessellation support:.Here you’d typically to displacement mapping. When tessellation is used, “vertex modifier” ( vertex:FunctionName) is invoked after tessellation, for each generated vertex in the domain shader A program that runs on the GPU.That function computes triangle edge and inside tessellation factors. Tessellation is indicated by tessellate:FunctionName modifier.Render pipeline compatibility Feature nameįor a streamlined way of creating Shader objects in URP, see Shader Graph.įor a streamlined way of creating Shader objects in HDRP, see Shader Graph. More info See in Glossary have some support for DirectX 11 / OpenGL Core GPU Tessellation. More info See in Glossary, Surface Shaders A streamlined way of writing shaders for the Built-in Render Pipeline. Unity lets you choose from pre-built render pipelines, or write your own. In the Built-in Render Pipeline A series of operations that take the contents of a Scene, and displays them on a screen.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |