Page 1 of 1

Help with creating spheremap of Irrlicht scene

Posted: Mon May 02, 2011 2:51 pm
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

Posted: Tue May 03, 2011 8:45 am
by xirtamatrix
Ahum.. umm... anybody ??

Posted: Tue May 03, 2011 9:25 am
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;

Posted: Tue May 03, 2011 11:29 am
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.

Posted: Wed May 04, 2011 9:15 am
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 ?

Posted: Wed May 04, 2011 9:42 am
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

Posted: Wed May 04, 2011 10:50 am
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.

Posted: Wed May 04, 2011 11:44 am
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

Posted: Wed May 04, 2011 12:36 pm
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;

Posted: Wed May 04, 2011 3:31 pm
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.

Posted: Thu May 05, 2011 8:52 am
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.

Posted: Thu May 05, 2011 5:00 pm
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.

Posted: Thu May 05, 2011 7:12 pm
by nespa