Skip to content

Instantly share code, notes, and snippets.

@Anthelmed
Created February 2, 2019 23:09
Show Gist options
  • Save Anthelmed/e834c647133412553e1cc8e8a351ca8b to your computer and use it in GitHub Desktop.
Save Anthelmed/e834c647133412553e1cc8e8a351ca8b to your computer and use it in GitHub Desktop.
Shader "Custom/SilhouetteShader"
{
Properties
{
_SilhouetteColor("Silhouette Color", Color) = (0,1,0,1)
}
SubShader
{
Tags{"Queue"="Geometry+1" "RenderType" = "Geometry"}
LOD 300
Pass
{
Stencil {
Ref 5
Comp equal
Pass replace
}
Cull Off
ZWrite Off
ZTest Greater
Lighting Off
Blend SrcAlpha OneMinusSrcAlpha
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
#pragma target 2.0
#include "LWRP/ShaderLibrary/Lighting.hlsl"
#pragma vertex vert
#pragma fragment frag
float4 _SilhouetteColor;
struct VertexInput {
float4 vertex : POSITION;
};
struct VertexOutput {
float4 pos : SV_POSITION;
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
float3 posWS = TransformObjectToWorld(v.vertex.xyz);
o.pos = TransformWorldToHClip(posWS);
return o;
}
half4 frag(VertexOutput i) : COLOR {
half4 color = _SilhouetteColor;
return color;
}
ENDHLSL
}
}
FallBack "Hidden/InternalErrorShader"
}
Shader "Custom/ObstacleShader"
{
Properties
{
[...]
}
SubShader
{
Pass
{
Stencil
{
Ref 5
Comp Always
Pass Replace
}
[...]
ENDHLSL
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment