CarmenSandiego/Assets/Shaders/FrontfaceCulling.shader

56 lines
1.3 KiB
Plaintext

Shader "Custom/FrontfaceCulling"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_Expand ("Expand", Float) = 1.0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
Pass {
Cull Front
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
fixed4 _Color;
float _Expand;
struct Data
{
float4 vertex : POSITION;
float4 normal : NORMAL;
float2 uv : TEXCOORD0;
};
struct V2F
{
float4 position : SV_POSITION;
float4 screenPosition : TEXCOORD0;
};
V2F vert(Data v)
{
V2F o;
o.position = UnityObjectToClipPos(v.vertex + (v.normal * _Expand));
o.screenPosition = ComputeScreenPos(o.position);
return o;
}
fixed4 frag(V2F i) : SV_TARGET
{
float2 textureCoordinate = i.screenPosition.xy / i.screenPosition.w;
fixed4 colour = _Color;
return colour;
}
ENDCG
}
}
FallBack "Diffuse"
}