# water plane extends to infinity

This topic is 4895 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How do games like FarCry extend the water plane out to infinity ?

##### Share on other sites
Probably have a super-huge quad that covers a very large area. Far Cry's water actually doesn't extend out to infinity. I've seen some user made maps in which the water DOES end.

If you do want literally infinite water though, you could make a trapezoid or quad that always has one 'side' where the camera is, perpindicular to the view direction, and another side at the cam's far plane.

##### Share on other sites
I haven't seen FarCry's water, but assuming it is just a flat quad(2 triangles) you could do something like the following:

Have 9 quads, each 2 triangles. These would be of the same size, but have different positions. They would look like this:

+--+--+--+|  |  |  |+--+--+--+|  |  |  |+--+--+--+|  |  |  |+--+--+--+

Then if we assume the constants QUAD_WIDTH and QUAD_HEIGHT is the width and height of a single quad and PlayerX and PlayerY is the players x and y coordinate. Each quad should be assigned to exactly tha same texture, shaders, materials etc. So you wouldn't see if all quads was moved along the x or y axis by QUAD_WIDTH or QUAD_HEIGHT. All you need to do is transform the quad so the middle is under the player. In pseudo code(In comments I will explain what happen if player pos is 200,100:

// Calculationsstatic const uint QUAD_WIDTH  = 75;static const uint QUAD_HEIGHT = 75;int XIndex = QUAD_WIDTH/PlayerX; // 200/75 == 2int YIndex = QUAD_HEIGHT/PlayerY; // 100/75 == 1// Subtract one because the XIndex is relative to// the middle quad, but we need relative to left.QuadXTrans = (XIndex-1)*QUAD_WIDTH;    // Subtract one because the YIndex is relative to// the middle quad, but we need relative to bottom.QuadYTrans = (YIndex-1)*QUAD_HEIGHT;//RenderingTransformWorld(Vector3(QuadXTrans,QuadYTrans,WATER_HEIGHT));DrawQuads(WaterQuads,    9 // 9 quads.    );

##### Share on other sites
Perhaps using a technique like this one?

##### Share on other sites
Quote:
 Original post by superpigPerhaps using a technique like this one?

I actually looked at this one and its just a big quad.

##### Share on other sites
Quote:
Original post by oconnellseanm
Quote:
 Original post by superpigPerhaps using a technique like this one?

I actually looked at this one and its just a big quad.

Basically, yeah. Pretty, ain't it?

##### Share on other sites
Yeah the projected grid has a very nice effect. As well as not needing to worry about LOD since it always uses the same number of polys to render no matter the distance from the camera.

That paper however talks about having a second frustum and keeping track of the crazy projector. But a friend and I found that if you do one or two extra collision steps the projector does not back fire anymore, and you get the same results. The only problem was worrying about the depth however to fix this you just set the projection a bit wider. So instead of -1....1 you just grow it depending on the depth you have set. I just played with numbers, so it was not very scientific, anyhow it projected from a slightly wider range to cover up the edges when the swells animated.

I like the idea just not the projector.

##### Share on other sites
The projected grid approach is very interesting and it was employed not only in the aforementioned paper but also in NVidia's Clear Sailing demo (a bad implementation though). It is a very good approach for rendering infinite water areas as an ocean with automatic LOD. One drawback is that water is basically drawn everywhere, which might be a problem in a complete terrain engine (though tricks exist to mask out unwanted areas).
With regards to the projected grid paper, I honestly found the proposed hack of using a modified projector unnecessary. That implementation also suffers from the fact that the number of used triangles is independent of the actual screen area covered by water. Thus, in patological situations (when looking upwards) you can have the full vertex buffer covering only few rows of pixels. I figured out a simple and robust procedure to overcome those issues. If you are interested I can detail the algorithm here.
A simpler technique to fake infinite water is that of rendering a large quad which fades to the same horizon colour of the sky (I guess Far Cry uses this approach).

Cheers

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 27
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634101
• Total Posts
3015528
×