- Home /
How to Cast Shadows AFTER Vertex Shader/ Updated Geometry?
I have a custom vertex shader on my view model which changes the FOV.
I want the shadows to be cast after the FOV is changed instead of using the original object.
Note how the pistol shadow appears on the projected view model incorrectly.
Answer by BastianUrbach · Feb 08, 2021 at 11:14 PM
Is it a surface shader? You just have to add addshadow to the surface shader directive and it should work:
#pragma surface blah blah blah addshadow
It is a shader graph shader, I don't think I can access the code. And to be clear, the object is casting a shadow, it just isn't being cast from the updated vertex positions.
$$anonymous$$aybe this has something to do with the view projection distorting perception of where the vertices really are??
Despite it's name, addshadow doesn't add a shadow, it just makes it so that the shadow pass also uses the custom vertex shader. But that's a surface shader thing, it doesn't seem to apply to shader graphs. You can actually access the generated code (right click on the master node) but it would be a relatively complicated vertex fragment shader, not a surface shader (surface shaders are more like an alternative to shadergraph; both get translated to much more complex vertex fragment shaders). Unfortunately I don't have much experience with Shader Graph but my understanding is that it should already use the modified vertex position so I don't really know what went wrong in your case.