PDA

View Full Version : Water Caustics Problem



unreal
04-08-2005, 12:08 AM
Hello people.
I am trying to implement Caustics...
I have a level and i want to render all of it with caustics (dont ask why all of it! :p )

I am doing something like this:

light_manager->DisableOGLLighting();
CRENDERER->ResetTextureUnits();
CRENDERER->ActiveTextureUnit(0);
CRENDERER->EnableTextureType(TEX2D);
glBindTexture(GL_TEXTURE_2D, caustic);
GLfloat sPlane[4] = { 1.0, 0.0, 0.0, 0.0 };
GLfloat tPlane[4] = { 0.0, 1.0, 0.0, 0.0 };
GLfloat rPlane[4] = { 0.0, 0.0, 1.0, 0.0 };
GLfloat qPlane[4] = { 0.0, 0.0, 0.0, 1.0 };
glTexGenfv(GL_S, GL_OBJECT_PLANE, sPlane);
glTexGenfv(GL_T, GL_OBJECT_PLANE, tPlane);
glTexGenfv(GL_R, GL_OBJECT_PLANE, rPlane);
glTexGenfv(GL_Q, GL_OBJECT_PLANE, qPlane);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_GEN_Q);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
draw(SIMPLE_PASS);

The function draw(SIMPLE_PASS) draw the Level Polygons setting for all the vertices of the same triange the same planar normal. It does not set any texture coordinate or something other.

But the results are not correct. What i am doing wrong?

PS:I dont use any shader.
PS2: keep in mind that instead of this line glBindTexture(GL_TEXTURE_2D, caustic);
i will traverse through a number of textures

Thank you.

T101
04-08-2005, 02:31 AM
OK, maybe I'm stupid (go on knackered, say it ;) ,
but you're generating 4 texture coordinates with a 2D texture. What's with that?

If you ask me, what you want to do, if you are using a 2D texture, is generate 2 coordinates, but use non-identity plane definitions in the glTexGenfv functions.

unreal
04-08-2005, 03:10 AM
yeah you are right. no need to use the other two. I just leave them cause they didnt affect anything :p

but oops.. yes.. the problem was on the identity plane definitions in the glTexGenfv functions.

I place some other and seems to work better but what values i put in there? :p

thank you

michagl
04-10-2005, 11:45 AM
just curious what is going on here and what this looks like.... i'm totally baffled mostly.

i could offer up my best guess, but it would probably just waste space.

caustics are radiosity right?

SirKnight
04-10-2005, 04:02 PM
caustics are radiosity right?
I'm no expert on radiosity but I don't think radiosity calculates caustics. That, I believe, is done usually with photon tracing/mapping.

-SirKnight

Zengar
04-11-2005, 02:08 AM
Well, actually you can can anything radiosity as it computes energy(frequence) of traced photons - that's what computer graphics tries to simulate :-)

back to topic: what dou you mean by "not correct"?

fpo
04-11-2005, 04:17 AM
Radiosity will never compute caustics as it is only diffuse by definition (no specular component is calculated). And caustics is a totaly specular effect. So only thing resolving caustics is a distributive ray tracer (monte carlo ray tracer for example) or a photon mapping system.

michagl
04-11-2005, 12:57 PM
so what is caustics then? what does this effect look like is what i'm asking.

i thought caustics was like placing a red object beside a white object and getting red bleeding onto the white object.

kon
04-11-2005, 01:46 PM
check mjk's tutorial:
http://www.opengl.org/resources/code/rendering/mjktips/caustics/index.html

kon

dorbie
04-11-2005, 02:33 PM
michagl, no that's generally called global illumination.

Caustics can be used to describe several phenomenon, but in graphics it's mostly used to describe the illumination patterns through complex refractive or reflective interfaces. Technically I think the term refers to the divergence & convergence in the energy flux (in this case the energy being light).

Someone might also use caustics to describe reflected light patterns of a curved surface (including the specular highlight) but this isn't common (a real math boffin once used the term this way in a discussion we had). You might also use it to describe the specular component of a global illumination calculation off a curved surface but again that's not really common useage.

Caustics is used most commonly used to refer to the underwater variations in illumination due to complex refraction effects (see mjk's presentation of my technique above).

mogumbo
04-11-2005, 02:34 PM
Caustics usually refers to the effect you see when varying amounts of light energy illuminate different part of a surface. Classic examples are the rippling light patterns on the bottom of a swimming pool and the bright spot you see under a magnifying glass.

Color bleeding from one surface to another is simply called "indirect illumination" (when light does not come directly from a light source). Usually you would use some type of global illumination technique to achieve this effect.

mogumbo
04-11-2005, 02:37 PM
Ha! Angus, you beat me by one minute.

michagl
04-11-2005, 03:07 PM
looks cool... any way to do it in a single pass with a shader?

can the generated texture coordinates be passed to a shader that is?

i take it the coordinates are generated in hardware?

funny i never thought of using the texture generation functionality for anything creative. i didn't know you could move the projections around either.

any other interesting effects that can be achieved in this vein?

edit: at what point in the pipeline is GL_NORMALIZE and texture generation performed? does this functionality come with any costs? or are they performed where the programmable shader would normally do its stuff?

zed
04-11-2005, 11:59 PM
heres a demo i wrote a while ago
http://uk.geocities.com/sloppyturds/stuff/volfog.zip
shows how forward thinking i was then, not, i believe i wrote it on a tnt2, ran it today on a gf5900 whoosh

michagl
04-13-2005, 07:01 AM
i'm thinking about doing this effect for scenes with water... however, i'm not really sure what is an apropriate visual effect for instances when you are looking across the water, or into the water from outside.

this looks better than nothing underwater. but what would be the effect as seen from outside the water. maybe looking into crystal clear tropical type water. would you see pretty much the same thing?

should this effect interact with the water surface?

i guess i'm just curious about visuals for implimenting this effect in an environment where the camera is free to roam in and out of the water.

any good resource that describes the physical processes going on here with references? i don't exactly have a crystal clear beach outside, and i'm not in the mood to go in town to visit a public pool.
also any way to leverage a repeating texture so that the repetition does not appear cheesy seen across a wide swath of geometry? some sort of regular periodic perturbations that is? i assume there are, just like animating water surfaces in a vertex shader.

i'm just curious for resources for water rendering in general. nothing involving render to texture though. i'm not prepared for that.

i'm thinking about doing a depth based water shader, with this caustics effect, an unjulating surface. their will be a height map applied to the water plane as well so that it can go up rivers and bodies of water need not be at 'sea level'.

some sort of static environment map might be doable as well. can you do view based reflections with a static environment map? is the only reason games render water reflections to texture each frame just to capture dynamic geometry in the scene? or does it have something to do with the camera as well?

hope this isn't too tall of an order.

if this stuff is too off topic, i can move it to a new thread.

sincerely,

michael

MickeyMouse
04-13-2005, 07:47 AM
You might want to see my old caustics demo made just for the university presentation. It's dirty, but shows well correct caustics for flat water pool bottom case. Search for caustics in 3d stuff (http://rainbow.mimuw.edu.pl/~ms189438/homepage/3d_graphics.php) .

There's also presentation explaining the whole mathematical (differential) theory behind caustics, but unfortunately it's in polish only :(