Replacing a rooms floor in an equirectangular

Written by Paul Bourke
February 2019


The following outlines one possible pipeline to replace a floor plane within an equirectangular image. The goal here is to present the approach rather than necessarily create the highest quality result. The main achievement is to create the correct projection of the fake floor, otherwise attempting the replacement with purely 2D editing is unlikely to be successful.

The example image is shown below.


Image courtesy Hashim Kahily


The first stage is to remove the floor from the equirectangular. This is fairly straightforward with most image editing packages.


Navigable version


In the example here the equirectangular image, with the floor transparent is mapped onto a sphere in PovRay and rendered with the so called spherical camera.

camera {
   spherical
   location <0,0,0>
   up y
   right image_width*x/image_height
   angle 360
   sky <0,0,1>
   look_at <0,1,0>
}

A checker floor pigment is applied to a plane that represents the floor.

#declare H = -52.5; // Depth, the largest value that doesn't clip image features
plane {
   <0,0,1>, 0
   texture {
      pigment {
         checker
         color rgb <0.8,0.2,0.2>
         color rgb <0.2,0.2,0.8>
      }
      finish { diffuse 1 ambient 0.2 specular 0 }
      normal { granite 0.2 scale 1 }
      scale 10
   }
   translate <0,0,H>
}

Navigable version


Similarly a tiling texture can be applied to the plane to represent a more realistic ground cover.


The floor texture: tex3.png

plane {
   <0,0,1>, 0
   texture {
      pigment {
         image_map {
              png "tex3.png" interpolate 2
              map_type 0
           }
      }
      finish { diffuse 0 ambient 1 specular 0 }
      scale 10
   }
   translate <0,0,H>
}

Navigable version


The final stage is lighting. Lights can be placed in the locations matching the light sources in the scene. In the following example no attempt has been made here for a matching representation of the light positions as found in the original, area lights for the windows for example.


Navigable version


Where things get a bit more complicated is if there are shadows cast by objects in the scene. In order to replicate those one can create simple representations of those objects and perform a rendering that only casts the shadows.

The PovRay scene used to create the examples above is provided here: floor.pov. It should be rendered as a 4 frame animation, one frame for each stage above, see: floor.ini.