- Home /
Transparent Shader/Water With Shadows
I modified the Unity water shader (not water4, the other one), but i got some trouble with lighting. There are two issues;
EDIT:
I rewrote the shader to a surface shader instead of fragment, so I don't need a refraction camera anymore and the shadows also show under the plane, the only problem left is the shadows on the surface itself. how can the surface receive shadows. I got a little idea to create a ortho-cam facing from the surface to the main light (sun light), and check in the renderer texture in the shader by color picking or a depth texture. anyone knows how to do this?
OLD (fragment shader issue):
First, the shadows stop under water, this is because the render textures don't render the shadows. I already tried to use forward rendering path, but no effect.
And last, I used this: "http://answers.unity3d.com/questions/180298/how-do-i-sample-a-shadowmap-in-a-custom-shader.html" to get shadows casting on the water surface. but when enabling "Receive shadows" in the mesh renderer component, it becomes completely transparent. But I can manage to get the shadows on the surface but then the depth texture don't work anymore.
Does anyone know how to fix this?
(And sorry for my bad English..)
Note the shadows stop when reaching the plane
Answer by Eno-Khaon · Jun 26, 2015 at 09:00 AM
Just to note: In Unity's shader pipeline, the shadows are applied to all objects rendered prior to "Geometry+500" -- Starting at +501, shadows are no longer applied, for the purposes of transparent objects and the like.
Therefore, among other options, you can use a GrabPass to view the area under the water, then use the rendering queue to determine when it's drawn.
Aside from that, messing with shadow settings (such as having water NOT cast a shadow) should be able to help you fine-tune the actual detail of the shadows.
Now, having said all of that, any vertex animation won't inherently be applied to the shadow-generating process without creating a custom shadow caster pass, so the more detail you have on your water surface, the harder it becomes to fully support it visually, unless you want a flat shadow plane regardless of the current state of vertex positions.