PDA

View Full Version : rain drops using shaders



hueney79
03-08-2005, 07:51 AM
Disclaimer: This is my first Shader program.

I am looking to render many rain drops on a mesh surface using OpenGl SL, but I have a few questions. My rain drops will not be meshes, but instead I will be bending normals of the surface where the rain drop should be to create the effect of light bending through the drop.

I want to be able to place the texture of the mesh surface into memory, then at scan conversion time look at an array of drops and see if any of them are covering this position of the texture, then bend the normal accordingly, and possibly get a new pixel color.

Does this seem like a GLSL solvable problem?

Do I need a new graphics card in order to loop through the drops? I currently use a Raedon 9500.

Can I access a texture randomly to update its pixel color?

Are there any other concerns I should have?

Thanks in advance for your help with a newbie. :)

Lurker_pas
03-08-2005, 02:11 PM
Disclaimer: it's 00:03, and I'am on my way to bed:)
If I understood you well (please correct me if I am wrong), you could do this this way:
On CPU you select the drops that are on the mesh(the triangle) and precompute their texture coords. You pass the coord array to the shader.
In fragment program you loop through the coord array, compare it with the pixels tex coord and bend the surface's normal if the tex coord is near enough to the drop. (Tex coords, or maybe real positions, which won't be distorted by texture mapping).
1)I don't know how big(if any) loop can be handled by Radeon 9500, especially with kind of conditional inside(which could be smartly substituted with clamp or something).
2)You can access texture randomly(to some extent), but you cannot update it from the pixel shader.
3) Even if this really worked, it would be slooow...
4)I think that there are better ways to do that using geometry...
5)Or maybe you could create a normalmap and then render to it the distorted normals where drops should be(through pbuffer, no FBO yet:().
6) I go to sleep:)

Humus
03-09-2005, 09:30 PM
Perhaps something like this is what you're looking for?
http://www.humus.ca/index.php?page=3D&ID=42
(It's in d3d though, but should be doable in OpenGL as well)