PDA

View Full Version : Current state of the art in water rendering


gjaegy
20-Mar-2009, 11:05
Hi guys,

as I am finally getting some time to implement new features, I was wondering what were the state of the art methods to rendering animated water (using D3D10-class hardware).

I have access to a linear depth buffer for the scene so I will be able to easily fade out edges.

But I would like to have both reflection and refraction, and have no idea where to start...


Anybody has a clue ?

Thanks,
Greg

zhugel_007
20-Mar-2009, 14:24
Very good water rendering from Crysis:
http://www.crytek.com/fileadmin/user_upload/inside/presentations/gdc2008/GDC08_SousaT_CrysisEffects.ppt

gjaegy
27-Mar-2009, 09:44
yes, this one looks good indeed :)

My engine is D3D10 based, however I am still a bit skeptical about vertex texture fetch performance, even on latest HW generation...

Has this improved or is still pretty slow ? I guess updated the VB on the CPU and upload it on the GPU might not be much better...

In Crysis they went for a big world-aligned grid. Any idea how they perform culling ? Is their water surface decomposed into many patches or do they run the VS (and thus the texture fetch) for the whole 100k vertices each frame ?? this doesn't sound realistic to me, any thought ??

MDolenc
27-Mar-2009, 10:17
Vertex texture fetch should be _fast_ on DX10 class hardware.

gjaegy
27-Mar-2009, 10:21
"should be" ? ;) will test then.

But I am still worrying about having to process the whole grid...

Novum
31-Mar-2009, 01:10
My engine is D3D10 based, however I am still a bit skeptical about vertex texture fetch performance, even on latest HW generation...
All Direct3D 10 hardware uses the same hardware for vertex, geometry and pixel shader texture fetches.

You have no reason to be skeptical, because the performance will be identical. If you can fetch multiple textures per pixel on the screen, you will have no problems doing this for a few hundret grid points.

gjaegy
31-Mar-2009, 15:38
Sure, but I guess there will be some latency being introduced by a texture fetch (as originally the vertex shader doesn't contain any).

I will try anyway and see the result.

Arwin
31-Mar-2009, 15:53
Insomniac is sharing their water tech for Resistance 2 on their site, though I'm not sure if this is not just the SPE code and even less sure whether that is any use to you. ;)

gjaegy
01-Apr-2009, 17:09
Thanks for all the feedbacks ! I will check the Insomniac paper [EDIT: I can't actually find it !]

I am nearly done now, however, I am trying to add the caustics as described in Crysis paper referenced above. There are no many details about how it's done.

Has anyone an idea ?

Humus
01-Apr-2009, 18:44
Sure, but I guess there will be some latency being introduced by a texture fetch (as originally the vertex shader doesn't contain any).

I will try anyway and see the result.

You may actually get a performance increase by combining regular vertex fetch with fetches from a texture, especially if the bandwidth requirement per attribute is low (for instance a lot of UBYTE4 attributes). Vertex and texture fetch are done by separate units, so if you're fetch limited rather than bandwidth limited you could theorethically double the performance.

gjaegy
21-Apr-2009, 11:16
Hi humus,

I might sound stupid, but I am not sure I understand the difference between a regular vertex fetch and a fetch from a texture.

You mean, fetching from a vertex stream ? in which case you would update the VB from the CPU ?

Not sure I get the idea ;)

AlStrong
21-Apr-2009, 17:00
Hi humus,

I might sound stupid, but I am not sure I understand the difference between a regular vertex fetch and a fetch from a texture.

You mean, fetching from a vertex stream ? in which case you would update the VB from the CPU ?

Not sure I get the idea ;)


There's a nice explanation here :)

http://blogs.msdn.com/shawnhar/archive/2008/04/11/santa-s-production-line.aspx

Humus
21-Apr-2009, 20:27
You mean, fetching from a vertex stream?

Yes. For instance, here's the shader from my old InfiniteTerrainII demo, which supported either R2VB (Render to Vertex Buffer) or VTF (Vertex Texture Fetch):

float4x4 mvp;
float3 camPos;

struct VsOut {
float4 pos : POSITION;
float2 texCoord : TEXCOORD0;
float3 normal : TEXCOORD1;
float fog : TEXCOORD2;
float2 scale : TEXCOORD3;
};

sampler2D Terrain: register(s0);

VsOut main(float2 pos: POSITION0
#ifdef R2VB
, float4 height: POSITION1
#endif
){

#ifdef VTF
float4 height = tex2Dlod(Terrain, float4(pos.xy + 0.5, 0.0, 0.0));
#endif

float4 vertex = float4(4.0 * pos.x, height.w, 4.0 * pos.y, 1);

VsOut Out;
Out.pos = mul(mvp, vertex);
Out.texCoord = pos * 16.0;
Out.normal = height.xyz;
Out.fog = saturate(0.65 * length(vertex.xyz - camPos));
Out.scale = saturate(height.w * 1.2 - 0.3) * float2(0.6, 0.5);

return Out;
}


In the R2VB case, it's a vertex fetch, and in the VTF case it's a texture fetch. When I tested this back when the HD 2900 was new the VTF path was about 20-30% faster IIRC. I tested now with the HD 4890 and R2VB is 13% faster, so your milage may vary.