http://devlog-martinsh.blogspot.fr/2011/09/box-projected-cube-environment-mapping.html

Teaser - click to see the fullsize - bge work from Martinsh Upitis

Can you spot the difference between those two images?

Blender 2.49, 250, 2.51, 2.52

Blender 2.63 and beyond

Of course you can. But it took me 3 years to realize that the Spherical Panorama I coded in the Blender Game Engine was wrong. Holly Coding Christ.

This is one of the BGE “dome” modes, but unlike the others, this one is used for debugging more than for deployment. Those past two days I’ve been investigating with Aldo Zang how to optimize the workflow for scene reconstruction from spherical panoramics (aka equirectangular images). The idea is to avoid the current workflow of setting up an IBL image as background, rendering a shot and using a calibration software to get the camera origin and coordinates. Given that we are talking about a very controlled scenario (where we know the FOV – field of view – of the camera, and can assume tons of other information) we believe we can improve the precision of the calibration process by addressing this particular scenario.

IBL in Cycles? Yup, if you use an HDR image in the background the light of the scene is almost solved. It takes only a few nodes:

Click to see the nodes

Click for the full size - HDR from HDRLabs

Our final goal is to use this with LuxRender (ARLuxrender actually), but all the reconstruction modelling will be done in Blender. Thus the need for a smooth workflow.
So what Cycles has to do with the BGE? Not much. But I was using the BGE spherical panorama to test the calibration software. As it turned out the code was wrong from the source 😛 that’s life I guess. Thanks Aldo for spotting that.

And why to have Spherical Panorama in the BGE again? Well if anything artists can do effects like this:

Spherical Panorama, ready to be transformed in the 1st image of this post - bge work by Martins Upitis

As a bonus you can see an image from the same scene, but warped with the old code:

It may be subtle, but this one can't be planeted like the one before - bge work by Martins Upitis

Using the color coded images from the top of this post you can see why they are different. The ceiling and floor lines are way higher/lower in the fixed warping.

Now for the code savy out there, this was the change made (in a simplified version of the code). For the actual code go to the Blender svn (look for FlattenPanorama).

Original Code:

FlattenPanorama (vert)
{
    φ = atan2(vert.y, vert.x)
    x = φ / π
    y = 0

    z = atan2(vert.z, 1)
    z /= π / 2

    return x,y,z
}

New Code:

FlattenPanorama (vert)
{
    φ = atan2(vert.y, vert.x)
    x = φ / π
    y = 0

    θ = asin(vert.z)
    z /= θ / π

    return x,y,z
}

Happy Easters,

Dalai

Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation