Hi, I’ve been playing around with shadows, and have them cast onto a mesh that doesn’t have any UVs in it’s mesh data.
It complains that my shader doesn’t have UVs, and yet it renders the shadows perfectly.
It’s the ‘LIGHTING_COORDS(3,4)’ that forces the need, which is strange as the shadows render when all the UVs of the mesh are set to NULL!
Is there a way around this, because I would like to save memory and discard all the UV information in this instance.
I’m fallback to Diffuse. It’s the macro LIGHT_ATTENUATION that wants ‘_ShadowCoord’ even though it clearly isn’t using it.
I have set ‘RealtimeOnly’ in the light inspector, so I don’t understand.
Thanks, for the quick response, yes I do have that.
What exactly is ‘_ShadowCoord’ ?
And ‘o’ is:
struct fragmentInput
{
float4 pos : SV_POSITION;
float3 location :TEXCOORD5;
LIGHTING_COORDS(3,4)
};
I need the ‘location’ value to be passed from the VERT to the FRAG.
I have read on these forums a few times that shadows need two UVs, but I have them here rendering without.
They’re not UVs, as such - just values that fill the texcoord semantics. But yes, it requires those to perform lookups into texture for lighting values (shadows and attentuation).
LIGHTING_COORDS specifies those two for you. It’s put in a macro because each light type requires different values.
OK thanks for the link. My original posts asks why I need UVs in the mesh, because when I set them to NULL I STILL get shadows on the mesh.
It complains I don’t have them by shoving warnings to the console, but it renders them fine. I wondered if there was a way around this, other than making a dummy set of UVs that can be shared, which seems silly.
LIGHTING_COORDS(x, x) defines the parameters you need to sample shadow/light maps and TRANSFER_VERTEX_TO_FRAGMENT(o) basically fills up those parameters with values that make sense for your situation (light type, cookies, etc).
When you call LIGHT_ATTENUATION(o) it samples the shadow and light maps with the previously defined parameters, of which _ShadowCoord is one.
Check out the AutoLight.cging file to see all the possibilities and what those macros exactly do in what situation.