Planar reflections in the BGE
After some request about reflection in the Blender Game Engine (BGE) I decided to write a small post about it.
There are three techniques to achieve this effect in the BGE, as far as I know, which are listed below:
- Shader based (fragment viewport coordinates – GPU expensive)
- Render to texture (with texture.ImageMirror() )
- Duplicated and mirrored geometry
So, lets have a look on each method.
Shader based reflections is the method that modern game engines uses to render planar reflections. Martinsh has developed a demo in the BGE that uses fragment viewport coordinates instead geometry UV map , wich according to his description the reflecting surface size can be unlimited with this method, but take into account that you will need a decent Video Card to run this.
Here is the link to the Blenderartist forums where you can see the Martinsh post about this, with videos and sample files.
Render to texture module allows us to manipulate textures during the game.
Several sources for texture are possible: video files, image files, video capture, memory buffer, camera render or a mix of that.
The video and image files can be loaded from the internet using an URL instead of a file name.
In addition, you can apply filters on the images before sending them to the GPU, allowing video effect: blue screen, color band, gray, normal map.
bge.texture uses FFmpeg to load images and videos. All the formats and codecs that FFmpeg supports are supported by this module, including but not limited to:
- dv1394 camera
- video4linux capture card (this includes many webcams)
- videoForWindows capture card (this includes many webcams)
And watch this video and read the description inthe youtube page (thanks maykon!)
Monster (BlenderArtist forum member) has developed a more friendly module that allow us to manage more easily the video texture module, grab the blend file here with demo and have a look.
More tutorials about this here:
And the last method is by duplicating geometry and mirroring as simple as that, maybe is not the most fancy method but I think is widely used in mobile platforms due to hardware restrictions and optimizations.
Hope you fin this useful, thanks!
Useful post to read about this topic