Water depth fogging
by Phil Carlisle · in Torque Game Engine Advanced · 01/26/2007 (12:30 pm) · 6 replies
I was thinking about this today..
Currently, we have a fairly watery looking default water, but if you've tried putting any land in there, you will see that the terrain/land overlap doesnt look great.
One of the reasons for this is that the water doesnt become more transparent near the surface (as the light has less time to diffuse and scatter as it passes through the water before it hits the terrain).
One thing we've been doing in Air Ace, is using two landscapes, one for the the island and one for the sea floor so that as you look through the water, you get a uniform colour under it.
But what I've been thinking is maybe it would be better to actually have what amounts to volumetric fogging under the water, that simulates the scattering seen when looking through water. So basically below a certain depth the colour pushes to a single colour value.
Anyone tried that? Anyone got any ideas on how to implement it?
I guess what you really need is a z depth based scatter function?
Just want to think through it on here really.
Currently, we have a fairly watery looking default water, but if you've tried putting any land in there, you will see that the terrain/land overlap doesnt look great.
One of the reasons for this is that the water doesnt become more transparent near the surface (as the light has less time to diffuse and scatter as it passes through the water before it hits the terrain).
One thing we've been doing in Air Ace, is using two landscapes, one for the the island and one for the sea floor so that as you look through the water, you get a uniform colour under it.
But what I've been thinking is maybe it would be better to actually have what amounts to volumetric fogging under the water, that simulates the scattering seen when looking through water. So basically below a certain depth the colour pushes to a single colour value.
Anyone tried that? Anyone got any ideas on how to implement it?
I guess what you really need is a z depth based scatter function?
Just want to think through it on here really.
About the author
Recent Threads
#2
Yeah, I can use the opacity, but if you increase the opacity, then you see through to the bottom of the skybox, which isnt a single colour the same as I want the water. So basically I need to find some way to make the water shader simply multiply in a base colour dependant on the depth of the water.
01/28/2007 (4:50 am)
Hey Brian,Yeah, I can use the opacity, but if you increase the opacity, then you see through to the bottom of the skybox, which isnt a single colour the same as I want the water. So basically I need to find some way to make the water shader simply multiply in a base colour dependant on the depth of the water.
#3
01/29/2007 (6:05 pm)
Huh? The bottom of what skybox?
#4
But if you look at most skyboxes, they are quire bright under the horizon line, which when you look straight down, appears kind of wrong, as the water should darken the deeper into it you can see. So effectively you should be able to make an island where it "fades" as it gets deeper, with a bit of opacity to sort of merge the water and the island.
Mind you, then again we still have the issue of sea edge to deal with :)
01/30/2007 (1:09 am)
Well, the default skybox, our other skyboxes. Basically, because the water becomes transparent, you can effectively see "forever", forever in this case being the skybox. Now I could get the skybox and add a gradient on it to sort of fake that.. hmm... :)But if you look at most skyboxes, they are quire bright under the horizon line, which when you look straight down, appears kind of wrong, as the water should darken the deeper into it you can see. So effectively you should be able to make an island where it "fades" as it gets deeper, with a bit of opacity to sort of merge the water and the island.
Mind you, then again we still have the issue of sea edge to deal with :)
#5
01/30/2007 (1:12 am)
So to do it right, you really need the z depth of the pixel, then you need to calculate the distance of that z to the plane of the water, then you need to alter the original source colour of the pixel by the water depth * depth colour to get the right original colour before refraction. I think.
#6
Calculating the z depth per pixel can be done, but it's going to require multiple passes to get the z-depth, so it's way more heavy duty.
01/30/2007 (12:09 pm)
Oh right, OK I see what you're saying. What you need to do is set up the water shader so that it becomes more opaque and more reflective in the distance. Tie it to the fresnel calculation that increases the reflection further out. Then use layered fog underneath the water so it looks right in the non-opaque areas. You can also just procedurally pre-shade the terrain that is below the water line - should look fine from the air and would be far less calculation than fog or shader effects.Calculating the z depth per pixel can be done, but it's going to require multiple passes to get the z-depth, so it's way more heavy duty.
Torque Owner Brian Ramage
Black Jacket Games