I am working on a shader and I got a problem with the shadows. It seems like LIGHT_ATTENUATION(i) returns the correct values for point and spot lights, but not for directional lights.
For directional lights it is always 1 → no shadow.
I simplified the shader for the pixellights as much as possible:
That is, the problem might be that Cg gets confused when allocating interpolators. LIGHTING_COORDS itself declares a variable number of interpolators based on light/shadow type, so you don’t know whether it used 0, 1, 2 or 3 interpolators.
I am sure… the output of my shader is too weird to mix it up! But perhaps when rendering the shadowmaps, this fallback is needed? Hm, well acually the mesh has a different shader on it. It is rendered with the “RenderWithShader” Method. :roll:
Accually I am “baking” the light on the mesh into its texture each frame, apply some effects and render it on a different mesh on screen.
It works now, but I have some problems with the effects. Unity crashes all the time. I guess I do the GL stuff at the wrong time!?
On LateUpdate I do the following stuff:
Step: RenderWithShader(the shader above) into a RenderTexture A
Step: several fullscreen quad renders with another shader into a RenderTexture B
After that the mesh is rendered normally with my RenderTexture B.
Is LateUpdate ok for that? When are the shadowmaps calculated? I guess I find it in the documentation.
Is there any comprehensive example of RenderTexture usage?
Fallback to VertexLit is needed because VertexLit contains passes that render object as “shadow caster” (as well as “shadow collector” for screen-space accumulated directional light shadows).
Just a quick aside, here: I thought that Fallback only did anything if none of the subshaders in a shader could run on the card. Does Fallback “VertexLit” work in this case because the shadow passes are looking for subshaders with certain tags?
Yes, I was just wondering whether those tags were important because the mesh is rendered multiple times, using a RenderWithShader() equivalent for shadows.