by Amplify_Borba » Mon Feb 04, 2019 3:47 pm
Hey there, there are a few considerations to make in regards to the template you've shared, I'll try to be thorough as possible.
The first pass to be declared must be the Outline pass, and you'll need to pay attention to the ports that are being declared to ensure if they need to be linked or not to the other passes. The reason why they are hidden is because they are currently linked, which is also why the Color Port only assumes the value of the first pass.
You must also need to add the Cull Mode identifier to the new pass that you create, as per the following example:
( ... )
Tags{"LightMode" = "LightweightForward"}
Name "Xray"
Cull Front
Blend One Zero
ZWrite Off
ZTest LEqual
Offset 0,0
ColorMask RGBA
/*ase_stencil*/
( ... )
Then, the Vertex Normal port should be removed, since it won't be used for this specific effect:
( ... )
GraphVertexOutput vert (GraphVertexInput v/*ase_vert_input*/)
{
GraphVertexOutput o = (GraphVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
/*ase_vert_code:v=GraphVertexInput;o=GraphVertexOutput*/
v.vertex.xyz += /*ase_vert_out:Vertex Offset;Float3;3;-1;_Vertex*/ float3( 0, 0, 0 ) /*end*/;
v.ase_normal = /*ase_vert_out:Vertex Normal;Float3;4;-1;_Normal*/ v.ase_normal /*end*/;
o.position = TransformObjectToHClip(v.vertex.xyz);
return o;
}
( ... )
The Vertex Offset port needs to have its linking property removed, so it's not linked to other passes:
Before: v.vertex.xyz += /*ase_vert_out:Vertex Offset;Float3;3;-1;_Vertex*/ float3( 0, 0, 0 ) /*end*/;
After: v.vertex.xyz += /*ase_vert_out:Vertex Offset;Float3;3;-1;*/ float3( 0, 0, 0 ) /*end*/;
Lastly, you should also unlink the Alpha and Alpha Clip ports in the same manner:
( ... )
half4 frag (GraphVertexOutput IN /*ase_frag_input*/) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(IN);
/*ase_frag_code:IN=GraphVertexOutput*/
float3 Color = /*ase_frag_out:Color;Float3;0*/float3(1,1,1)/*end*/;
float Alpha = /*ase_frag_out:Alpha;Float;1;-1;_Alpha*/1/*end*/;
float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;2;-1;_AlphaClip*/0/*end*/;
#if _AlphaClip
clip(Alpha - AlphaClipThreshold);
#endif
return half4(Color, Alpha);
}
ENDHLSL
( ... )
Here's a brief explanation of the tags, for reference:
float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;2;-1;_AlphaClip*/0/*end*/;
- ase_frag_out is the ASE Tag
- Alpha Clip Threshold is the Port Name
- Float is the Port Type
- 1 is the Port identifier
- -1 is the default order for the ports, meaning that they'll be ordered in the same order as they are declared in the template
- _AlphaClip is the linking property for Multi-Pass
With the changes suggested above the template should be working as expected, hope that this helps!