Shader "Paco/NormalDirection/Vertex" {
|
|
Properties {
|
|
_Positive ("Positive", Color) = (0.737931,1,0,1)
|
|
_Negative ("Negative", Color) = (0,0.9044118,0.8295637,1)
|
|
[MaterialToggle] _UseNegative ("Use Negative", Float ) = 0
|
|
[MaterialToggle] _XZAxis ("X / Z Axis", Float ) = 0
|
|
_SmoothLight ("Smooth Light", Range(0, 1)) = 1
|
|
[MaterialToggle] _ShowNormalDirection ("Show Normal Direction", Float ) = 0.475862
|
|
}
|
|
SubShader {
|
|
Tags {
|
|
"RenderType"="Opaque"
|
|
}
|
|
Pass {
|
|
Name "FORWARD"
|
|
Tags {
|
|
"LightMode"="ForwardBase"
|
|
}
|
|
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#define UNITY_PASS_FORWARDBASE
|
|
#include "UnityCG.cginc"
|
|
#pragma multi_compile_fwdbase_fullshadows
|
|
#pragma multi_compile_fog
|
|
#pragma only_renderers d3d9 d3d11 glcore gles
|
|
#pragma target 3.0
|
|
uniform float4 _Negative;
|
|
uniform fixed _ShowNormalDirection;
|
|
uniform fixed _XZAxis;
|
|
uniform float4 _Positive;
|
|
uniform fixed _UseNegative;
|
|
uniform float _SmoothLight;
|
|
struct VertexInput {
|
|
float4 vertex : POSITION;
|
|
float3 normal : NORMAL;
|
|
float4 vertexColor : COLOR;
|
|
};
|
|
struct VertexOutput {
|
|
float4 pos : SV_POSITION;
|
|
float3 normalDir : TEXCOORD0;
|
|
float4 vertexColor : COLOR;
|
|
UNITY_FOG_COORDS(1)
|
|
};
|
|
VertexOutput vert (VertexInput v) {
|
|
VertexOutput o = (VertexOutput)0;
|
|
o.vertexColor = v.vertexColor;
|
|
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
|
o.pos = UnityObjectToClipPos( v.vertex );
|
|
UNITY_TRANSFER_FOG(o,o.pos);
|
|
return o;
|
|
}
|
|
float4 frag(VertexOutput i) : COLOR {
|
|
i.normalDir = normalize(i.normalDir);
|
|
float3 normalDirection = i.normalDir;
|
|
////// Lighting:
|
|
float2 node_2973 = normalDirection.rb;
|
|
float _XZAxis_var = lerp( node_2973.r, node_2973.g, _XZAxis );
|
|
float node_8533 = (_SmoothLight*48.0+2.0);
|
|
float3 NormalDir = normalDirection;
|
|
float3 finalColor = lerp( lerp(i.vertexColor.rgb,saturate(( lerp(_Negative.rgb,_Positive.rgb,lerp(1.0,saturate(((100.0*_XZAxis_var)*0.5+0.5)),_UseNegative)) > 0.5 ? (1.0-(1.0-2.0*(lerp(_Negative.rgb,_Positive.rgb,lerp(1.0,saturate(((100.0*_XZAxis_var)*0.5+0.5)),_UseNegative))-0.5))*(1.0-i.vertexColor.rgb)) : (2.0*lerp(_Negative.rgb,_Positive.rgb,lerp(1.0,saturate(((100.0*_XZAxis_var)*0.5+0.5)),_UseNegative))*i.vertexColor.rgb) )),floor(saturate(lerp(_XZAxis_var,abs(_XZAxis_var),_UseNegative)) * node_8533) / (node_8533 - 1)), NormalDir, _ShowNormalDirection );
|
|
fixed4 finalRGBA = fixed4(finalColor,1);
|
|
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
|
|
return finalRGBA;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
FallBack "Diffuse"
|
|
}
|