• Advertisement

Archived

This topic is now archived and is closed to further replies.

Reflective water using shaders

This topic is 5098 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

I want to create some lakes to go with some randomly generated terrain I’ve made. Preferably I would like to have a nice wind ripple across the lakes. Due to the nature of this terrain being random I can’t just create quads where ever a lake should be, instead I’m having a simple: If (vertex.y < lakeHeight) vertex.y = lakeHeight; To create a flat lake surface, the problem I can see coming from this is the texture coordinates for each quad won’t allow me to apply a reflective texture. This prevents my idea of drawing all the geometry flipped with a clipping plane at the height of the lake, then rendering to texture and applying to the lake from working. I''m fairly new to using cg, so I''m also not sure how to use a fragment shader to do a ripple. I’ve seen some people here doing this (like the rhino island demo). Any one have some suggestions or a good site that may help me?

Share this post


Link to post
Share on other sites
Advertisement
i think you should look into using EMBM (Environment Mapped Bump Mapping).

Why are you changing the terrain, just make a big plain that resides at the lake height and do the reflective textureing on
that rather than modifying your terrain data.

Share this post


Link to post
Share on other sites
The terrain I''m using is VERY large, 8.4 million triangles quadtree/frustrum culled. It takes literally 5 minutes to fly across.

That is too big to make a reflective texture for.

Share this post


Link to post
Share on other sites
bump for mabey some comments from people who used reflective water in there contest entries.

Share this post


Link to post
Share on other sites
i could have a terrain with 2 triangles and make it take 5 mins to fly across.....
1) i could make the triangles really big
2) i could make the camera very low on the terrain (ie the triangle) and move the camera very slowly

i could have a terrain with 10 billion triangles and fly across it in 5 seconds.....

so the number of triangles in your terrain and how long it takes to "fly" across it is really vague

quote:

Why are you changing the terrain, just make a big plain that resides at the lake height and do the reflective textureing on
that rather than modifying your terrain data.


but i agree with that unless you want dynamic lighting...then you run into a problem with one big plain
but for that one big plaqin you could use a light map if you dont need dynamic lighting for it


"A soldier is a part of the 1% of the population that keeps the other 99% free" - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA

[edited by - ncsu121978 on March 8, 2004 12:20:05 PM]

Share this post


Link to post
Share on other sites
For the above post...

It would be 5 mins of "full stride running" on this.
http://www.mines.edu/students/m/mskowron/T1.jpg

The amount of triangles and the time it takes to cross should give you some clue...

The point is it is much to large to make one quad and texture.

I''m looking for some concept help (how am I going to do this) if any one could provide some pointers.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

Share this post


Link to post
Share on other sites
the quad doesn''t need to cover the entire block of terrain, it can simply go as far as the fog cutoff. And it can be more than one, ie, a grid.

For the texture, the texture will need to be projected onto this plane so the size doesn''t matter. It would be just like how you are rendering now, but from the mirrored position on the water plane.

| - My project website - | - email me - |

Share this post


Link to post
Share on other sites
Ok that is do-able.

Will I have to render the terrian upside down to texture unprojected first?

If so how do I unproject the rendering?

Thanks!

Share this post


Link to post
Share on other sites
given the position of the camera above the water, and the direction it's looking, you simply mirror these in the water plane. So the position of the camera for the reflection camera becomes underwater, while the direction is exactly the same, just it's verticle components are flipped.

The project comes when applying the texture to the quad(s) that form the water plane.

[edit]
I did a search, and well. I found this (I seriously can't even remember making that post) and also this which I also don't remember replying to - however, there was a thread all about it, that got really really indepth but I just can't find it! arrgggh!

| - My project website - | - email me - |

[edited by - RipTorn on March 10, 2004 11:57:49 PM]

Share this post


Link to post
Share on other sites
Ohh I don''t have to unproject just flip like:


[]camera
\
\
\
è \
-------------water-------------
è /
/
/
/
[]reflected view


where the è is the same angle.

Will this work for water with waves? doesn''t seem like it would give the right reflection (dependent on the normal). I''ll read those, thanks for looking them up.

Share this post


Link to post
Share on other sites
consider using glScalef(1.0, -1.0, 1.0);

[edited by - aaron_ds on March 11, 2004 10:00:17 AM]

Share this post


Link to post
Share on other sites
quote:

joanusdmentia: ...and watch all your normals flip around the Y axis aswell.


im surprised whenever someone says that, because this has been discussed to death.

when using glScalef(1.0, -1.0, 1.0) use the following to correct all transformed normals:
glNormalize or glFrontFace(GL_CCW)/glFrontFace(GL_CW)

Share this post


Link to post
Share on other sites
Fliping everything isn''t going to be a problem.

Can any one verify this will look decent with waves? It seems to me it wont as the normal of a point directly effects what is reflected.

Share this post


Link to post
Share on other sites
I don''t spose has any one has some pointers in how to distort the texture in cg to get a wave like effect, or a link would be good.

Share this post


Link to post
Share on other sites
Ocean/water rendering is a very large topic. There''s a very good topic about water rendering on gamasutra, can''t remember it''s name, though it''s very apparent if you browse through them. Also, Yann L did an IRC lecture, which extended this approach, perhaps someone can provide a link?

You have to remember that you''re unique, just like everybody else.

Share this post


Link to post
Share on other sites
quote:
Original post by aaron_ds
consider using glScalef(1.0, -1.0, 1.0);

[edited by - aaron_ds on March 11, 2004 10:00:17 AM]


This is a BAD way to do it. It only works if your waterplane is at 0 height and even then it has some problems. Just calculate mirrod camera position & direction and redner with that. A few dot/cross products won't kill you.

Yann L's water lecture

You should never let your fears become the boundaries of your dreams.

[edited by - _DarkWIng_ on March 12, 2004 7:20:50 PM]

Share this post


Link to post
Share on other sites

  • Advertisement