Reflect/blur effect...

I’m trying to make a duck pond and I need to know how to have a reflection in the water, and the blur that comes with the little ripples, and also tone down the alpha in an even way to see the rocks/surface on the bottom…
I need to learn how to use shaders sometime, why not now?
Thanks! :wink:

These sorts of effects don’t necessarily require the use of shaders, although it’s true shaders will generally help you get more photorealistic results. But you limit the use of your application to those graphics cards that do support shaders.

To use Cg shaders in Panda, see the page in the manual: This page also has links to other resources for learning Cg.

To just do a mirror effect, consider using the render-to-a-texture method discussed in this thread (with a link to example code):

To achieve ripples, you could simply apply the mirror texture to animated geometry, for instance ripple.egg, in the Panda distribution. You could animate these ripples the traditional way like ripple.egg does, or you could write a vertex shader to do it. Either way you’d need a lot of vertices, but any card that can handle a vertex shader can deal with a lot of vertices. You could also use a bump map, but that won’t be available until we release Panda 1.1.

To fade out the water’s translucency through the depth of the water, you could even achieve this sort of effect with fog, especially by using the feature of parenting the Fog object itself to the scene graph to make a world-relative fog (start the fog onset at the surface of the pond, and make it at its thickest at the bottom of the pond). This will work well except when the observer is looking across the pond, but in that case it probably doesn’t even matter much.


I would probably much rather use Cg… Well, it really just depends: Is it a bigger CPU/mem hog than the other method?

No. Cg is executed on the GPU, freeing your CPU to do other things.


Neat! Although, CG looks kind of complicated… (I’m looking at a CG file right now) And how come Panda needs 2 CG files not 1? What does each one do?

The vertex program is run once for each vertex in your model, and it allows the shader to modify details about each vertex (for instance, to generate normals, or to offset the vertex slightly. You could implement ripples this way, for instance (if you had a lot of vertices).

The pixel program is run once as each pixel is painted, and it allows the shader to change the look of the pixel. This can be used to compute per-pixel lighting or bump map effects (and might be a different way to achieve ripples).

Getting into shader programming is a topic all to its own, and it’s not one that I have a lot of experience with myself. But there are lots of books on the subject, and there’s plenty of advice out on the net.