Real time cubemap reflection (environment map)

This example shows one way to generate a time cubemap reflection.


For a cubemap you have to render six video textures one for each side.
But in Blender my graphic card only supports 4 textures for a custom material shader. So I used the plot function to stitch the six images to one single cubemap texture (Blender render cubemap alignment) together. The Downside is that the plot function is very slow (+4 ms on my PC).
Actually it is not possible to overtire the Blender environment texture with the video texture. Therefore it is not possible to use an normal environment shader. I modified Martinsh shader to render the single cubemap texture.
If you have an newer ATI graphic card you can use Martinsh shader (http://devlog-martinsh.blogspot.co.at/).

To improve the performance it is possible to reduce the texture size at line 7 in renderCubemap2. Or reduce the update interval for the renderCubemap2 script by increase the frequency from the delay sensor to 1 or 2.

HG1

Attachments

realtime_cubemap V1.0.blend (251 KB)RealtimeCubemapNode V1.0.blend (346 KB)

1 Like

This thing is amazing, actually.

AWESOME! That’s a feature I dreamed for a long, long time. Thanks very much!

Dear HG1,
how lovely!
You force me to be repetitive…thank you very much for sharing.
High-quality eye-candy.
Bye

Can someone make a version that mixes the diffuse, normal, and possibly a mirror amount map into this?

It’s amazing right now for a mirror, etc, but does not help for textured surfaces?

Thank you very much for sharing this…

@BluePrintRandom
Actually I am trying to speed up cubemap render by using BGL or nodes.
If the BGL or nodes variant are not working I will add your requested features to the shader.
So I think you have to wait quit a while.

I have added a node based cubemap shader.
This improves the performance a lot, because I don’t need to stitch the images with the video texture module.
But there is a small seam between the images, which I don’t get solved.

Could you make an add-on for this, so the player can just add a reflective material, set it’s reflection texture size and the reflection texture data(like color(how much of each color is used), reflection amount, blur…)

I have been trying to figure out nodes so I can add a normal map,

anyone able to whip up a example?

it would be very appreciated,

Thanks!

I’ve got a question- is it possible to color the reflection? I would like to use this for my car games(a car body), but for that I need to have something like this:


Not like this:


you can mix in a color using the mix node.

Yes. Like BluePrintRandom has described, you only need to add a mix node between last color mix node and the output node. But you can also put the material node in between.

Which parts should I append to add that item to my game?(I mean, which ones are nessecary for the reflection, but which ones is just a background object.

Well, what to do if I want to use object color as one of the inputs in the last MixRGB you reccomended me?

saw a tech demo where they used a cubemap, to do second bounce lighting

And how would you do first bounce?

I made the car material for preview- this way it looks quite fine, but, of course, the texture on it could be better. Anyway, it is kinda good material thanks to realtime reflections:)

The model is awful. I am still thinking how to transfer this material to my game and how to make it use object color instead of that green that I set…

the did a point light, at the center of the location they used for the cubemap, then I think they projected the cubemap, from the same light, inverted

(I may have misunderstood how they do it)

https://seblagarde.wordpress.com/tag/parallax-corrected/

That’s a 1 bounce global illumination technique called light propagation volumes that ray casts/cone traces through the voxel grid generated from the light camera’s world positions and diffuse buffer per pixel. It’s actually doable in bge if you find out a way to pass video texture buffer to a 2d filter.

Edit: oh and the article provided is irrelevant to “dynamic” light bouncing.