Home » Community » Forums » » Realistic Natural Effect Rendering: Water I
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic

Page:   1 2 »»

 Last Thread Next Thread 
 Realistic Natural Effect Rendering: Water I
Post Reply 
Adding in more code examples like this:

void CMyFrameWnd::WaterRipple(void)
{
double d2Pi = 2 * (22 / 7); // 2Pi Radians = 360 Degree
double dAmplitude;
double dRadians;
double dFrequency;
double h = m_bmp.bmHeight;
double y;
int x;
int w = m_bmp.bmWidth;
int nDisp;
int nFrame;
int h2;

m_nGap = 0;
h2 = (m_ptOverlay.y >= m_bmp.bmHeight) ? 0 : (m_bmp.bmHeight - m_ptOverlay.y);

Also maybe some cool downloads for people to learn from.

for (nFrame = 0; nFrame <= MAX_FRAME; nFrame++) {
x = nFrame * w;
dRadians = (d2Pi * nFrame) / MAX_FRAME;

for (y = 0; y < h; y++) {
dAmplitude = (h / 18) * (y + 28) / h;
dFrequency = (h / 7) * (h - y) / (y + 1);
nDisp = (int)(sin(dRadians + dFrequency) * dAmplitude);

if (y + nDisp < 0) {
nDisp = (int)(y * -1);
}

m_dcRipple.StretchBlt(x, (int)y, w, 1, &m_dcReflection, 0, (int)y + nDisp, w, 1, SRCCOPY);
}

if (nDisp > m_nGap) {
m_nGap = nDisp + 2;
}

// Draw Overlay (bottom part) on Ripple image
if (m_ptOverlay.y + m_bmpOverlay.bmHeight > m_bmp.bmHeight) {
m_dcRipple.StretchBlt(x + m_ptOverlay.x, 0, m_bmpOverlay.bmWidth, m_bmpOverlay.bmHeight - (m_bmp.bmHeight - m_ptOverlay.y), &m_dcTrueMask, 0, h2, m_bmpOverlay.bmWidth, m_bmpOverlay.bmHeight - (h2), SRCAND);
m_dcRipple.StretchBlt(x + m_ptOverlay.x, 0, m_bmpOverlay.bmWidth, m_bmpOverlay.bmHeight - (m_bmp.bmHeight - m_ptOverlay.y), &m_dcOverlay, 0, h2, m_bmpOverlay.bmWidth, m_bmpOverlay.bmHeight - (h2), SRCINVERT);
}
}
}

 User Rating: 729   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Wow. Just wow. Ultra-awesome-ness.


It's really unfortunate I don't have a system that supports PS 1.3

 User Rating: 1893   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

It's nice to see articles of this Calibre. Thanks Yann :)

 User Rating: 1902   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Looks good so far...

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

 User Rating: 1336   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

It would be cool to have a code sample like this on the page.
http://www3.tky.3web.ne.jp/~tkano/archives/tlwater104.zip

Very cool indeed though, and keep it up!

 User Rating: 729   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

nice... looking forward to the rivers/waterfalls part

 User Rating: 1094   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Great! Well written and informative. I particularly like that several different options for implementation are discussed, with both pros and cons.

Keep up the good work!

 User Rating: 1221   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I'm so happy I could dance. So I will:



Thanks Yann

Minister of Propaganda : leighstringer.com : Nobody likes the man who brings bad news - Sophocles (496 BC - 406 BC), Antigone

 User Rating: 1788   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

I was expecting a copious section of resulting pictures of the method you used Yann.. I guess i'd have to implement it myself to get them.

Anyway, great job!

 User Rating: 1506   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Quote:
Original post by Promit
Wow. Just wow. Ultra-awesome-ness.

It's really unfortunate I don't have a system that supports PS 1.3


Even if you don't have one, you may still be able to play with shaders by using swShader by Nicolas Capens. It may require a bit of work to redo the shaders using the shader assembler language.

(returning to the topic)

Great article. The tone is good, explications are deep and interesting. It looks like everything is easy to do. I'm really impressed by Yann's article writer qualities.

"Better than good" job, and thanks a lot Mr. Lombard !

[broken link, as spotted by evolutional]

[Edited by - Emmanuel Deloget on September 8, 2004 7:42:36 AM]

-- Emmanuel D. [blog, in French] [blog, very bad googlized translation] [NEW: English version of teh blog! (WIP)]

 User Rating: 1828   |  Rate This User  Send Private MessageView ProfileView JournalView GD Showcase Entries Report this Post to a Moderator | Link

God, I can't wait to get my shader system up and running now. *opens VS*...

If at first you don't succeed, redefine success.

 User Rating: 1552   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

w00t!

I just got my geforce fx card 5 days ago and I've been cg programming when I should've been doing homework...now there's at least one good water tutorial out there.

I've been meaning to find some cg tutorials online, this is awesome. I'm trying to find more about fragment programs, but it seems I can't find too much info...even a reference guide would be good. Maybe I'll suck down and buy The Cg Tutorial book.

Now if Yann wrote a book...that I would buy. Even if it was just a collection of articles he wrote on the internet. :)

 User Rating: 1419   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Perfect timing - thanks



 User Rating: 1254   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

A question to someone - that cubemap that can be used forreflections - where is it's origin? The centre of the body of water or the camera position? Only when you do this for a shiny car I thought you put the camera inside the car and rendered images looking outwards to get the cubemap?

 User Rating: 1295   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Absolutely fantastic.

Thanks Yann.

Jinx

 User Rating: 1027   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Looks good, Yann. I've concentrated on the ground and sky so much that I haven't gotten to the water, so I'm looking forward to the next article.

P.S. - You still haven't sent me a response regarding the scattering article. ;-)



 User Rating: 1215   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Quote:
Original post by d000hg
A question to someone - that cubemap that can be used forreflections - where is it's origin? The centre of the body of water or the camera position? Only when you do this for a shiny car I thought you put the camera inside the car and rendered images looking outwards to get the cubemap?

It doesn't matter where you put it's origin in this case, becouse cubemap only represents objects at (near) infinite distance. This is basicly modified skycube. But if you use cubemap for reflection on small objects, then yes, put origin in it's center.

microcyb: d2Pi = 2 * (22 / 7); ... nice approximation for Pi .

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

 User Rating: 1336   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

impatience... what is going to be the period between two articles :) i reaally want to read many more like this one! :)

 User Rating: 1015    Report this Post to a Moderator | Link

Very well written, especially the bit on projective texturing. Only had to read it once and now fully understand projective texturing and how/why it works. While I've used the technique before, I have never had an intrinsic understanding of the maths. Now its all clear. Thankyou very much.

 User Rating: 1021   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Quote:
Original post by Anonymous Poster
impatience... what is going to be the period between two articles :) i reaally want to read many more like this one! :)
It's up to Yann. I'll post them soon after receiving them.

 User Rating: 2088   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

I don't really understand how the reflection matrix Mf works. First of all, if the water surface is parallel to the XY plane, doesn't that mean that the reflected ray, from a ray (x, y, z) hitting the plane is (-x, -y, z) instead of (x, y, -z) as the article says?

Secondly, I don't understand how transforming vertices of your objects using this reflection matrix and rendering them actually builds the reflection map.

I'd love some more explanation, or a reference to another paper/article that explains this would be nice (maybe with some illustrations).

All an all, a nice article, but schematic illustrations could make it clearer.

--nico

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Quote:
Original post by scratch
I don't really understand how the reflection matrix Mf works. First of all, if the water surface is parallel to the XY plane, doesn't that mean that the reflected ray, from a ray (x, y, z) hitting the plane is (-x, -y, z) instead of (x, y, -z) as the article says?


When a ray going downward is reflected, does it keep going downward? It would have to if you reflected it from (x, y, z) to (-x, -y, z). The article is correct, only the z component is reflected.


 User Rating: 1215   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Very, very cool, thanks for the article Yann! Looking forward to the next one :)

 User Rating: 1049   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Thanks very, very much :D
Another holy grail within grasp.

Reality, is that where the pizza delivery guy comes from ?

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link
Page:   1 2 »»
All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: