I'm giving Unity a go on a diving simulation & i'd like to simulate an underwater environment.
I'm curently using a directional light, updating the color based on the depth of the diver. Red & Greens get absorbed so the color should get gradually more blue the deeper one goes below the water level.
I'm using the code below for that (sunLight is the directional light):
Now the light gets bluer as one descends, yet a red shadow is being cast on the shadow side of the divers mesh. Any ideas how that might come & how to eliminate it?
Also, fog doesn't seem to work. i'd like to limit visibility range by using fog, but it doesn't seem to have much effect...
Looking at your image make me think that that RED is no shadows...at least...it looks more like the shininess color of the material, but in your picture, I can't see the material you are using for the diver!
Fog is based on depth from camera, so if your background is very far away it will converge to a single color, which is what looks like is happening in your scene. Try having some objects stretching away from the camera to see if they become gradually more obscured by the fog.
For the redness: I can create a similar effect by tweaking the Ambient Light Color for the scene (a red ambient creates a red "shadow" for the diffuse falloff), which is accessible from RenderSettings both in the editor and in code. So I would recommend checking to see if that is your issue.
You are on a nice path here with water worlds (no I did not mean the movie in any way, get away silly badgerers and lawyers) , u have chose to edit light based on depth. Maybe it's a good idea to build a modifier on the depth so you can more easily tweek it if you are unhappy about the results. I you have to change all the variables all the time or just a public one in the Unity3D editor you can save yourself some time.
current situation:
sunLight.color=depthColor;
Suggested Situation: Per length of distance
sunLight.color=depthColor*modLigth;
Also u may want to scale the intsensity of the light down based on the distance but I don't dare say I am 100% sure about that. More like 80%
Somehow the distance isn't really showing a big transition more like a domain chunk , so if you can tweak that out it'd look a lot better than it already does.
My apoligies for not giving the answer you were looking for, I was just hoping to help out with a suggestion. Just make sure a modifier with * or / doesn't go to zero, or negative unless you specifically want it to. Best is to just comment it aswell what it does and how it behaves.
I hope you figure it out or someone here does, I am quite curious as to how to build a fog like water environment, in one word: Awesome!