Hi,
I’m trying to read a directional light direction from a fragment shader, but its always 0’s… I have the Directional light in the hierarchy, and I’m including the “LightMode” = “ForwardBase” tag to the pass to ensure it gets updated by the Mesh Renderer…
I’ve simplified my code to this:
Shader "NV Shaders/ComicStyleNoSurfaceFromGroundUp" {
SubShader {
Pass{
Tags { "LightMode" = "ForwardBase" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct vertexInput {
float4 vertex : POSITION;
};
struct vertexOutput {
float4 pos : SV_POSITION;
};
vertexOutput vert( vertexInput v )
{
vertexOutput o;
o.pos = mul( UNITY_MATRIX_MVP, v.vertex );
return o;
}
half4 frag( vertexOutput i ) : COLOR
{
float3 lightDir = normalize( float3(_WorldSpaceLightPos0 ) );
return half4( lightDir, 1 );
}
ENDCG
}
}
}
but the mesh is always drawn in black color…
do you have any idea what could be wrong or what could I be missing?
Thanks!