refracted water shadow artifacts

Hi.
I am using the refracted water (FX/water) with a terrain and deferred rendering.

While everything else works ok when you look into the water you notice constantly shadow artifacts on the terrain below the water. Here are 2 images and a video.

Here is the video where it can be seen better:

http://vimeo.com/15375437

The problem is more obvious when you are near an object that produces shadows.

A workaround for me was to produce a sea floor that gets not lighted from the main sun light.

So my question is: Is that normal or a bug? If that is normal is there a way to solve this?

Thank you.

Here is a webplayer with a simple scene created from scratch that recreates the above problem:

Web-player-refract-terrain-shadows-problem

Nobody is using refracted water with deferred rendering I guess.

I tried to solve this through excluding various (reflect,refract,lighting) layers but with no luck.

Apparently this is a shader issue. Can somebody please give me a hint for another shader (the one used here is nighttime/daytime water from the standard shaders).

I gave your webplayer a try and saw all sorts of weird issues. I’d file a bug report and be sure to include the project folder.

Thanks for the reply.

It seems weird to me that no other reported this before.

I’m sure this has been tested and working, so yeah, something unique must be going on. Set up a project with only the water. If it still happens, submit a bug report.

Alright. I managed a simple workaround for now. I believe the problem is in the water.cs script in the standard/water(pro) resources.

I set the shadow distance to zero and restore it back after the refraction pass:

I get no shadows on the underlying terrain this way, but at least I don’t get the artifacts and the stuttering shadows.

That worked for me, but I had to put the shadow disabling code into the reflection section, not refraction.

Only works for me in fullscreen!

water reflection no light reflect??? I want to make a night water scene?? Is’t any other way?

http://imageupload.org/pm-012929377746.html

I just came across this problem in Unity 3.4 Pro. Looks like shadows do not properly get calculated when Unity renders the reflection texture…I can see the errant shadowing when I watch the preview.

I’m using your script workaround for now.

I had the same problem ( using Unity 3.3 ) but it was even worse. I have a big tree on a tiny island in the middle of shallow pond so I had the whole water surface flashing dark and light as if one big shadow was cast over the surface. The code fix worked (thanks for that by the way elias_T) it’s a pity that I can’t have the shadows working thru the water it was looking really nice with forward lighting, but it’s not worth losing the deferred lighting and all my normal maps I guess.
Hope Unity fixes this.

I have same problem , my shadows generate errors , you have a solution ?
thanks
regards

Probably nobody is using deferred mode here. I ve reported shadow bugs in deferred mode one year ago and what happened? Nothing.

this bug is still in unity4.0.

but not in reflection, it goes to refraction.

Try this workaround: take the camera that renders refraction and add two event handlers for it:

OnPreRender: disable shadows on lights that can cast shadows
OnPostRender: enable shadows back

thanks,alexzzzz.

i have already did what you said.

i just wonder why unity team didn’t fix this problem after two years.

This worked for me too. I created a script called “fixWaterShadows.js” and this code:

Replace “SunPrimaryDay” with the name of your sun. Of course, if you have more than one light casting shadows, you’ll have to revise this code to do it for all such lights.

Just drag and drop this script on your camera and problem solved!

I don’t know if this is still a problem but i had a similar problem and i found a very simple solution.

In your Player Settings, make it Forward Rendering. But in your main camera, make it Deferred Rendering. That’s all. It worked for me