Jump to content
  • Advertisement
Sign in to follow this  
soconne

water plane extends to infinity

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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 this post


Link to post
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:



// Calculations
static const uint QUAD_WIDTH = 75;
static const uint QUAD_HEIGHT = 75;

int XIndex = QUAD_WIDTH/PlayerX; // 200/75 == 2
int 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;

//Rendering
TransformWorld(Vector3(QuadXTrans,QuadYTrans,WATER_HEIGHT));
DrawQuads(WaterQuads,
9 // 9 quads.
);




Share this post


Link to post
Share on other sites
Quote:
Original post by oconnellseanm
Quote:
Original post by superpig
Perhaps 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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!