dynamic Reflection?

Started by buffonomics, February 26, 2013, 02:41:22 AM

Previous topic - Next topic

buffonomics

I'm curious, is it possible to achieve real-time dynamic reflection? perhaps via GLSL shaders?
I'm pretty new to shaders in general. Still reading up on them.
But say I wanted to make a chrome ball that reflects everything around it real time, What shaders would I attach to that sphere?

Thanks.

EgonOlsen

You can't do that with a shader alone. Shaders can't access anything outside of their own context, i.e. they can access a mesh's vertex and texturing information, but they can't access the framebuffer (except from writing into it, of course). So for reflections, you would have to render the scene to reflect in textures and map them onto the mesh. In theory, this can be done by using cube mapping (which jPCT doesn't support), but you would have to render the scene 6 times for the cube map alone, which is pretty expensive. It's usually simpler to create a spherical environment map from some static image and apply this as faked reflection. jPCT supports this: http://www.jpct.net/doc/com/threed/jpct/Object3D.html#setEnvmapped(boolean)

buffonomics

Being a complete noob, how will I go about generating this image to use as an envmap texture?

EgonOlsen

The easiest (albeit not "correct" way) is to take some random image and apply a spherical distortion filter on it in the image editor of choice. While the result isn't really spherical environment map, it should look good enough in most cases. Another option is to download a free one. Just search for "environment map" and look at the results that show a sphere with an image projected onto it.