Help with creating spheremap of Irrlicht scene

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Help with creating spheremap of Irrlicht scene

Post by xirtamatrix »

Hi,

I have looked around on forum but could not find how to do this.
Irrlicht demo is using the following spheremap:

Image

Could someone please tell me or post link to code/example how this is done? I need to create a similar spheremap of my scene.

Many thanks in advance,

/regards
to live, is natural; to die, is not!
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Post by xirtamatrix »

Ahum.. umm... anybody ??
to live, is natural; to die, is not!
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

see EMaterialTypes.h in include SDK of Irrlicht:

//! Look like a reflection of the environment around it.
/** To make this possible, a texture called 'sphere map' is
used, which must be set as the first texture. */
EMT_SPHERE_MAP,

the texture is obtained from a render target texture;
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, you need a 360 degree view of course. Conversion to a sphere map can be done using gimp or photoshop. I guess it also depends on the image processing app how the original image needs to be arranged.
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Post by xirtamatrix »

hybrid wrote:Well, you need a 360 degree view of course. Conversion to a sphere map can be done using gimp or photoshop. I guess it also depends on the image processing app how the original image needs to be arranged.
Thanks hybrid, do you mean I set the camera's FOV to 360 degrees? Or, as it takes radians, to 6.2831855 before rtt? Also, forgive me for being so dumb I cannot find how would I convert a rectangular image to a spherical one in Photoshop. Is there some filter for this? Or perhaps you could kindly point to some link/example/tutorial ?
to live, is natural; to die, is not!
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Post by xirtamatrix »

To be more precise, here's what I'm trying to do:

I have a large cube in the scene, which is like standing on one of its corners, and rotating slowly. I want the six sides of the cube to reflect the correct environment as the cube rotates.

I initially assumed that if I make a spheremap of the scene, like the one shown above from Irrlicht demo, and apply it to the cube, it would reflect the environment correctly. Is that correct?

Or should I make six textures (cubemap), one for each side of the cube, then apply to the cube, but then if they are applied as regular diffuse textures they would rotate together with the cube, but thats not what we want. Perhaps I should set each one of them as spehermap so they stay in place while the cube rotates, but this is not making any sense to me.

Despertaley needing some help :S
to live, is natural; to die, is not!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The spheremap is created outside the actual rendering app. You would indeed create some kind of a cube map first from the app, using simple screenshots and turning the camera. Then you need a tool to stitch together those shots and create a spheremap from it. Don't know how to do this exactly. Finally, you can load the spheremap as simple texture and use spheremap material. The effect is not as good as one might expect, though, there are better effects for this situation.
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Post by xirtamatrix »

hybrid wrote: The effect is not as good as one might expect, though, there are better effects for this situation.
Thanks again hybrid, could you point me to any code/samples of those better effects you mentioned?

/regards
to live, is natural; to die, is not!
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

take a look at this example with GLSL shader:

http://tfc.duke.free.fr/

and search for Reflective environment mapping demo example in the list, there is a zip file free to download;
Klunk
Posts: 264
Joined: Mon Jan 10, 2011 5:21 pm

Post by Klunk »

further to hybrid's comment a sphere map like that can create by first creating a panorama, as hybrid mentions, of stitched scene imagery, 4 taken @ 90deg intervals with 90 deg fov for example. the sphere map is then created in photoshop (or similar) using the Distortion filter "polar coordinates". In 3ds max You can render one directly using a "fish eye" camera pointing straight up but there's a lot of "wastage" and distortion at the horizon.

a further note on using sphere maps as cheap reflections, they work well if you after a generic reflection and you are not to concerned if they tally with the scene, they actually work best when quite blurred and indistinct. If you want them to be more accurate sphere maps can be tricky. You probably need a lot of trial and error to align the seam up correctly.
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Post by xirtamatrix »

@nespa : thank you very much, your demo is really cool and exactly what I was looking for. I downloaded the source but could not find any hlsl shader, only openGL vertex and fragment programs.
I'd be very thankful if you could provide me or point me to an hlsl version of this shader.
EDIT: ah, sorry, I now see you already mentioned it was GLSL... unfortunately I cannot use this, though this is exactly the kind of effect I need. Do you happen to have a HLSL version of it?


@Klunk: thanks for the tips, I managed to finally make the spheremap as suggested by You and hybrid, arranging the 6 images in photoshop in a vertical cross, then loading with hdrShop and applying filters. The problem I'm having now is, it appears perfectly applied to the cube as a solid material, but as soon as I change material-type to EMT_SPHEREMAP it just disappears. Digging into why this is happening. Tested with lighting on-off, playing with all other material properties but so far no luck.
to live, is natural; to die, is not!
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

I've also got some code to do this:
http://www.youtube.com/watch?v=DN6aXR8f14o

You can grab it here:

http://svn.bitplane.net/misc/trunk/irr/ ... 0renderer/

It's quite old and might not work with new Irrlicht versions, not very well documented either, but should do what you need.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

Post Reply