Game Development Community

Bug Beta 2 : Water foam not rendering properly also submerged render tearing

by James Brad Barnette · in Torque 3D Professional · 06/11/2009 (11:34 am) · 18 replies

It looks like the water foam is not rendering properly. there water foam only seems to render where the is a DTS behind it. Which is incorrect. The foam should not get clipped in the manner see image below. Also there seems to be some sort of issue with the edges of submerged objects See Image below. there seams to be a flickering white edge along the visual boarder of the dts objects that is submerged.

www.pixollusion.com/T3D/beta2/waterBugT3D.jpg

#1
06/11/2009 (11:35 am)
Also of note, I have tried this on 4 sets of nvidia drives on 2 different machines all produce the same result.
#2
06/11/2009 (11:42 am)
Quote:there water foam only seems to render where the is a DTS behind it.
Thats a limitation of the technique. Go take a peek at Crysis... they use the same effect and have the same limitation.

Quote:there seams to be a flickering white edge along the visual boarder of the dts objects that is submerged
That is a bug... a slight misalignment in the water fogging i think.
#3
06/12/2009 (2:46 am)
@Tom,
Quote:Thats a limitation of the technique. Go take a peek at Crysis... they use the same effect and have the same limitation
is there a way around the limitation? just because crysis shows the same limitation, are we not able to make it better?

from what I am experiencing from a beta that is only at stage 2, I believe that T3D can ultimately equal, indeed surpass, what we are seeing in crysis, ut, and all the other "Uber AAA" engines.

the whole dev team, and you in particular, have done awesome work on T3D, so f**k the limitations, can we fix it?
#4
06/12/2009 (6:37 am)
@deepscratch, I'm sorry to say this, but you're being awfully ignorant and disrespectful. This has nothing to do with "uber engines" or being AAA or not.

*Ahem*

The foam technique is a post processing effect applied to the water surface. Here's how it works:

1) It samples the depth buffer at the current pixel position, and calculates the depth difference to the current pixel (aka: the water surface).
2) The depth difference is used to calculate the alpha value for the foam texture: the smaller the difference, the more opaque the foam becomes. If the difference is too great, the foam isn't visible at all. This creates foam that only appears near banks.

Now, why are you seeing that problem? Like I said, the water uses the depth difference between the water surface and the pixel behind it to know where to show the foam. This means you'll only have foam inside the objects silhouettes.

The only way to have foam outside silhouettes would be by either generating actual geometry or rendering the scene from a top view into a textures, both of which have several drawbacks as well as being complicated to implement.
#5
06/12/2009 (7:23 am)
@Manoel,
thanks for the explaination,
just one question,

*Ahem*

where is the "disrespectful" you speak of? ignorance, maybe, I'm only begining to get a grasp of shaders, but "disrespectful"?
why?
because I said that T3D could surpass crysis? do I need to bow down and show respect for crysis?
maybe because I implied that Tom and the other devs are doing awesome work? sorry Tom & all, no disrespect, but you are.
oh, wait, because I said "uber AAA" as a pun? I uber apologise to the uber engines.
where's the disrespect Manoel??????? maybe read my first post again, slowly this time....
#6
06/12/2009 (8:24 am)
Just the way you said it. Sounded disrespectful for both the Crytek guys (dismissing the amount of time and money they spent on the issue, which is likely to be several times greater than any one of us) and the GG team, as if they didn't make a "better" foam just because Crysis doesn't do it either. Or maybe you just said it as a joke and I failed to notice it. :)
#7
06/12/2009 (9:32 am)
no Manoel,
I think it all just went flying straight over your head.
no disrespect was ever intended, or insinuated, you just took it that way.
cheers.
#8
06/12/2009 (2:55 pm)
I think this is not the place for this please.
#9
06/12/2009 (5:35 pm)
Rest assured we're not happy with just equaliing the quality of other engines... we want to be the best bar none.

The issue is always time.

I could have spent the last year making the best water simulation you've ever seen in a game, but physics, terrain, lighting, and shadows would all suck bad.

I think the best way to make a better foam effect is to do a new overhead render of the scene.

If we limit it to the area around the camera then we don't need to render alot of objects. We can also skip rendering things far under the water as they don't matter. This should make the render pretty fast.

We then to a post process on it using an edge detection to find objects sticking out of the water as well as shallow areas.

We then blur that result a bit to get something not so hard.

I think then we have a texture we can sample to get good looking foam effects, but it isn't gonna be cheap.
#10
06/15/2009 (5:29 am)
The overhead method has one problem: objects which are above the water, but not intersecting it. Even if you cull out any objects which aren't intersecting the water plane, you'll get foam for surfaces which are not touching the water. Example: with water at the player's waist, you would see foams for the arms as well.

A different solution just came to me... but I don't think it would be cheap. Instead of doing a simple depth comparison, fetch multiple depth samples in a disc along the water place to determine how intense the foam should be. Very similar to how the SSAO works, actually.
#11
06/15/2009 (6:31 am)
@Tom -

You could always clip the geometry itself as well, though you would need to be careful about the undulation (and then you couldn't move it unless you recalculated it). Personally, I think the existing solution is good enough - any additional detail could be added as aligned particles or shapes.
#12
06/15/2009 (12:53 pm)
IT seems to me that the calculation could be done with just the information on the geometry above the intersection no? I mean the angle are all known I do not understand the need to clip it by the underwater silhouette of the object.
#13
06/15/2009 (1:18 pm)
@James:

It's not being clipped. It's just not being generated there. It's currently a post processing effect, and has no idea about geometry.
#14
06/15/2009 (1:23 pm)
it has to know have some understanding of geometry to know at what angle to produce it no?

can someone point me at the code that is doing this?
#15
06/15/2009 (1:46 pm)
@James - shaders\common\water\waterP.hlsl and waterV.hlsl.
#16
06/15/2009 (2:13 pm)
hmm I see what you mean from what I can gather the "mask" if you will , that controls where there foam is. is determined by the distance between the ray hitting the water plane and then continuing. then if it hits a second surface then it put foam there and the shorter the distance between the 2 hits the more opaque the foam correct?

But could this not also be done the same as a FSAO? just using the geometry on top of the water to using the intersection area to define the area for the foam?
#17
05/31/2010 (10:45 pm)
Logged as TQA-172.
#18
06/10/2010 (1:06 pm)
Confirmed as fixed for 1.1 Beta2.