hdrpreptips1I received a question the other day that was asking how I would approach painting out lights from LatLong HDRI’s that are near the bottom or the top of the image. Anything near those poles will usually be heavily distorted and are a pain to remove if you try to paint on the original map. However there’s quite an easy way to remove them in Nuke and at the same time get the lights to a nice and rectangular format for using them on area lights.

The original question came up under the post of my HDR Prepper Gizmo for Nuke:

I have a question, how do you adjust your lights that are skewed and need to be formatted to fit your area lights? Do you adjust your arealights scale to match your bounding boxes? This example is kind of made for this scenario however there are many lights that are distorted and need to be flattened for your arealights. Im curious as to how your workflow solves this.

Which is a more than valid question as I have used a very simple-to-work-on example when I was demoing this Gizmo. However more than often in production the HDR’s you receive will most likely either have lights or other objects you might need to remove at the poles of the LatLong environment map.

A good example for it is this HDR map that I got from HERE:

00baseHDR

 
All the lights on the ceiling (especially the one circled in red) would be very hard to paint out like this and you would need to distort it heavily to get it straight and map it on an arealight.

Luckily there’s a node available in Nuke, that is called SphericalTransform. With this node you can convert between different environment map conventions (Latlong, Mirror ball, etc.). One thing you can do is convert your input Latitude / Longitude map to a cubic map. Visually what you can imagine what it’s doing is that it seemingly puts you in the middle of the environment map (at the original position of the camera) and allows you to look around from that point of view. The output will be undistorted from the point of view of the camera (provided you set your output format to a square format):

01st_ll_to_cubic

As you can see in this example I rotated my input around so that it looks at the ceiling and directly at the light that I am trying to remove. Now that exact light is nice and square and very easy to paint out:

02st_paintout

Or you could also use this handy little thingy: HDR Prepper Gizmo ;)

Once that is done you can convert it back from Cube to Lat Long map with another Spherical Transform Node. There are 2 things to watch out for to make sure it matches your original HDR orientation:

  • Make sure your Input Rotation Order is the inverse of your first Spherical Transform (e.g. ZXY -> YXZ)
  • Negate all the numbers from your first Spherical Transform (e.g. 90 becomes -90 and vice-versa)

 

03st_cubic_to_ll_final_paintover

 

You can then either make sure your alpha is completely opaque before converting it back to LatLong and merge it on top of your original or Keymix it back in in exactly the areas where you need it.