Once more now we have the properties which is a texture and a colour declared on traces 4 and 5. These properties, similar as those within the earlier shader can be seen within the Inspector tab once we choose the fabric which makes use of this shader.
Within the SubShader on line 10 now we have the Queue = Geometry + 5 which is able to draw the thing holding this shader after different objects are drawn as a result of it should test if the thing holding this shader must be drawn behind or in entrance of different objects.
Now the Move code block is barely completely different than what we noticed within the earlier shader.
Once more we’re utilizing ZWrite Off and ZTest Better to verify the thing is rendered behind different objects.
The CGPROGRAM on line 19 signifies the beginning of the block the place the “precise shader code” is and it’s merely HLSL or excessive degree shader language.
Pragma at traces 21 and 22 are declarations of vertex perform referred to as vert on line 21, and fragment perform referred to as frag on line 22.
The vertex perform truly represents a vertex shader which transforms form positions into 3D drawing coordinates.
The fragment shader compute the renderings of a form’s colour and different attributes.
The #embody on line 24 means we’re together with UnityCG.cginc which has the render features that Unity supplies.
We have to use the embody key phrase as a result of shader scripts should not like C# scripts. They don’t inherit performance from different shaders like C# lessons do, so something we wish to use we have to embody it.
float4 on line 24 is definitely a Vector 4 variable which incorporates variables for x, y, z, and w.
Struct vertInput on line 28 is principally an object that incorporates two variables. The primary one is a float4 or Vector 4 variable which we’ll use to go the vertices of the 3D mannequin holding this shader.
float3 regular variable can be used to go the details about the traditional maps on the shader.
On line 33 now we have the fragInput struct which has one float4 variable that can give us details about the display area place.
The vert perform on line 37 makes use of UnityObjectToClipPos which is able to remodel the mesh vertex place from native object area to clip area.
And the frag perform on line 43 will return the silhouette colour which we specified.
Then we point out the tip of the shader code on line 47 with ENDCG.
The brand new shader code block from line 51 to line 67 is taking a texture inside a floor perform and with the assistance from tex2D perform it should use the float2 parameter that’s handed together with the feel parameter and return a colour on the feel on the level the place float2 signifies.
To check this shader, choose the Participant Materials and for the shader choose FX -> Silhouette: