1
\$\begingroup\$

I came across the following declaration on unity tutorial

#pragma surface surf BlinnPhong addshadow fullforwardshadows 
vertex:disp tessellate:tessEdge nolightmap

I think disp is the displacement shader but what does vertex:disp mean? Likewise for tesselate:tessEdge.

from https://docs.unity3d.com/Manual/SL-SurfaceShaderTessellation.html

Thanks. I am rather new to HLSL.

\$\endgroup\$
2
  • \$\begingroup\$ if you don't use it your vertex function not work any way. \$\endgroup\$ Nov 4, 2018 at 6:43
  • \$\begingroup\$ @SeyedMortezaKamali. What do you mean by vertex function? You mean vertex shader? \$\endgroup\$
    – Chuan
    Nov 4, 2018 at 9:43

1 Answer 1

1
\$\begingroup\$

Vertex shader

It is possible to use a “vertex modifier” function that will modify the incoming vertex data in the vertex Shader. This can be used for things like procedural animation and extrusion along normals. Surface Shader compilation directive vertex:functionName is used for that, with a function that takes inout appdata_full parameter.

https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html

your vertex modifier function named disp.

so vertex:disp mean that your vertex will use disp:

void disp (inout appdata v)
{
float d = tex2Dlod(_DispTex, float4(v.texcoord.xy,0,0)).r * _Displacement;
v.vertex.xyz += v.normal * d;
}

DX11 Tessellation

enter image description here

This controls how many subdivisions you want to split your triangles into. (Note that DirectX is Windows only, requires a DX11 GPU and has to be enabled in Unity)

so tesselate:tessEdge mean that your tesselatation will use tessEdge:

float4 tessEdge (appdata_full v0, appdata_full v1, appdata_full v2)
{
return UnityEdgeLengthBasedTess (v0.vertex, v1.vertex, v2.vertex, _EdgeLength);
}

If you want to understand tesselatation use Shading Mode > WireFrame then move around your object that has this shader:

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ Thank you so much for the detailed response Seyed Morteza Kamali. \$\endgroup\$
    – Chuan
    Nov 5, 2018 at 6:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .