Document: RotatingHDRI Link: https://horo.ch/docs/mine/pdf/RotatingHDRI.pdf Rotating HDRI affects the Horizon With Yaw, Pitch and Roll the HDRI can be rotated in all three directions X, Y and Z. This is not only useful for the backdrop but also the direction from where the light comes. To get a particular orientation with these three direction controls is not very obvious. HDRI Rotation In Bryce IBL the HDRI is mapped on a sphere of "infinite" size and the camera is in the centre of this sphere. Assuming the perspective camera has all rotation angles at zero it then looks ahead, the horizon is a straight line in the vertical and the 0° meridian in the horizontal centre. Rotating one axes at the time The HDRI orientation matches the camera X=Y=Z=0 rotation if Yaw is 0, Pitch 90 and Roll 0. Yaw rotates the sphere with the HDRI horizontally from 0° to 360°. The degrees work in the clockwise direction (CW). The meridian (vertical line) moves to the right and into the camera view comes what is left of the centre. With camera Y at 0°, moving Yaw from 0° to 90° shows the same as if Yaw were left at 0° and camera Y rotation to 270°. Rotating Yaw CW can be compensated by rotating the camera Y counter clockwise (CCW). Pitch tilts the sphere up and down from +90° to -90°, 180° in total. It may be a bit counter intuitive that the horizontal Pitch is +90°, not 0° (equator). Pitch 0° looks up to the zenith and Pitch -90° down to the nadir. This is different to the camera X rotation: here 0° is horizontal, at X -90° the camera looks to the zenith and +90° down to the nadir. Pitch 0° is the same as the camera rotation X -90°; Pitch -90° the same as camera rotation X +90°. This is a bit confusing but the default Pitch is 90°, which is helpful. Roll banks the sphere sideways from 0° to 360°. The degrees work CCW. For example, Roll at 30° moves the right side of the horizon upwards and the left side downwards. This is the other way around for the camera Z rotation: here Z -30 does the same. [4 Pictures] {The renders show from left to right: HDRI default orientation; Yaw 30°; Pitch 60° (30° up); Roll 30°.} The HDRI was made with the camera within the sphere shown. Provided the HDRI is at the default orientation Yaw at 0°, Pitch at +90° and Roll at 0°, the same renders (from left to right) result with the perspective camera rotate settings: X 0° - Y 0° - Z 0°; X 0° - Y -30° - Z 0°; X -30° - Y 0° - Z 0°; X 0° - Y 0° - Z -30°. Camera X, Y and Z -30° can also be 330° (360° - 30° = 330°). [Picture] <<<< Page 2 >>>> The Problem There is usually no problem if you use some sort of abstract HDRI. You rotate the HDRI in all three axes until the backdrop looks appealing to you and the light cast onto the objects in the scene is what you want. [2 Pictures] If you take an HDRI made inside of a room and want it rendered as backdrop, the only rotation you need is Yaw in order to move a certain part into the back of the objects. The light may be less important since within a room there is mostly ambient light without an isolated very strong key light. If there is one outside of the camera view - or a window letting in bright light - those can be dimmed with a 2D face as long as it is out of the camera's view. In a room you will add key lights manually (spots, radials) most of the time anyway. [2 Pictures] Another matter is if you use an outdoor HDRI with the sun as prominent light source. You might want to lower the sun toward the horizon and also move it to a side. This means that the HDRI must be rotated and tilted. Whenever Yaw and Pitch are both out of the default position, the horizon banks and is not a horizontal line anymore. Obviously, this can be compensated for with Roll. The problem is to determine the angle for Roll. Even if the HDRI is not rendered as backdrop, the orientation of the horizon is important for the ambient light. You may have set the sun to the desired position with Yaw and Pitch and the key light shines from the correct location. If the horizon is vertical instead of horizontal, however, one side gets the ambient from skylight and the other side a bit from the ground. We all expect the skylight comes from above, not from any side. Setting the horizon straight does make sense. Rotating the HDRI revisited To visualise how the pattern on a sphere change when rotating it on any or all axes is challenging. On the previous page, the camera is set in the "world" centre and a ribcage HDRI was rotated. Depicted is what the camera sees. In this manner, it can be shown that the horizon can be straightened by compensating the Yaw and Pitch rotation by rotating Roll. <<<< Page 3 >>>> [2 Pictures] {The renders show from left to right: HDRI default orientation; Yaw 0°, Pitch 45°, Roll 0°, Yaw 60°, Pitch 45°, Roll 0°; Yaw 60°, Pitch 45°, Roll 40.9°.} After rotating Pitch the horizon moved lower, now moving Yaw too then the banked horizon is compensated by Roll. This looks fine at first glance but it is not fine at all. Although the horizon is now horizontal and the meridian in the centre of the rightmost picture is vertical, the horizon moved up by about 30° and the centre meridian is about 8° off-centre at 292° instead of 300°. The result shown in the rightmost picture above is correct but we expected something else. The horizon moved down by 45° (Pitch) in picture 2 and the vertical centre of the picture is now at 68°, not 60°. [Picture] At right, the centre of the resulting picture is defined by the pink cross but we expected the centre to be at the yellow cross. We now look at the same manipulations as above but in the spherical projection that depicts not only a part but the entire sphere. [4 Pictures] Above is exactly the same sequence as on top of this page: on top images 1 & 2, below 3 & 4. It begins to dawn on us that when we are in a sphere and tilt (Pitch) down what is in front of us, what is behind us move up by the same amount. If we bank (Roll) the sphere so that the right part move up, the left part move down by the same amount. Between picture 2 and 3 (adding rotation Yaw to Pitch) there seem to be profound changes in the images on top of the page but here (top right, bottom left), the pattern only shifts horizontally to the right by 60° around the sphere. Are you confused? Well, you are in good company. Rotating a sphere on all three axes is a mind boggling challenge to visualise. <<<< Page 4 >>>> More practical examples Up to now, we looked at a ribcage HDRI that is rotated around all three axes. This is a bit theoretical. Now we place such a ribcage as object in the "world" centre (as shown on page 1) and put the perspective camera into it. But we will not move this ribcage object, it will be our frame of reference and we use an HDRI with a visible sun to rotate. [2 Pictures] The camera FOV at left is 138° which results in a horizontal and vertical angle of view of 110°. The render at right is a spherical panorama made with the Spherical Mapper as lens for the camera. It shows the full circle of the scene 360° and from zenith to nadir +/-90°. The sun is at azimuth 0° and 45° above the horizon. [2 Pictures] Rotating Yaw to 45 shows the sun moved 45° to the right, which is more intuitive than the theoretical examples above that rotated the ribcage HDRI. Yaw rotates CW and this we see. The horizon is straight and in the centre of the picture. Everything looks natural. [2 Pictures] Yaw at 0 but Pitch set to 60, which is 30° below 90° and hence horizon and sun moved down by 30°. In the panorama render we see that the opposite side moved up by 30° and the <<<< Page 5 >>>> horizon is curved. Although we observe a curved horizon in the panorama render within +/-45° (blue vertical lines), the perspective render at left does not show a curved horizon. Therefore, as long as Yaw stays at 0, there is no problem tilting the HDRI - as long as we render as Perspective Projection and not as 360° Panoramic Projection. [2 Pictures] Yaw and Pitch at the default setting and Roll 45. The perspective render at left shows the horizon banked by 45° and the panoramic render at right depicts the horizon as a sinewave. Below, we have identical HDRI position settings as above but the camera Z rotation was set to 45° to compensate the 45° of Roll in order to get a flat horizon line. [2 Pictures] The HDRI backdrop looks fine in the perspective render and in the panoramic render the horizon is indeed horizontal and straight. However, the scene - which is the ribcage - looks rather funny. Imagine how a skyscraper would look. [2 Pictures] Above banking is compensated by Roll 22.2 for Yaw 45 and Pitch 60. With the Yaw and Pitch settings, the sun ought to appear 45° to the right of centre and 15° above the horizon in the HDRI as shown in the second and third picture on the previous page. But instead of azimuth <<<< Page 6 >>>> 45°, the sun is at about 37°, missing 8° and the elevation is about 30°, which is 15° higher than set with pitch. At least, the horizon is flat for the perspective render. We observed the same in the far right picture on top of page 3. In the panoramic render the horizon is curved. [2 Pictures If the horizon does not matter but the position of the sun as key light is important, keep Roll at 0 and adjust Yaw (here 45) and Pitch (here 60: sun in the HDRI at 45° to be moved to 15° makes 30° lower; horizontal Pitch 90 - 30 = 60). As mentioned before, the ambient light distribution changes, particularly the light that originates from the opposite direction of Yaw. Light from the HDRI after Rotation The same HDRI, the same settings to show the light on a white sphere placed on a dark grey ground without casting shadows so that the light from below shines up. [3 Pictures] {Default HDRI position; Yaw 45°; Pitch 60° (same as pictures on page 4).} [3 Pictures] {Roll 45°; Yaw 45°, Pitch 60°, Roll 22.5°; Yaw 45°, Pitch 60°, Roll 0° (see page 5 first & last, top page 6).} <<<< Page 7 >>>> The examples above are very simple. That the brightly lit part moves on the sphere and also the shadow cast are to be expected. Look at the fainter brownish light on the underside of the sphere. This is the light shining up from the ground and if the horizon is slanted, this light also changes position on the sphere. Straightening the horizon The table shows approximate Roll settings for all Yaw and Pitch settings in 15° steps to straighten the horizon in front of the perspective camera. What it does not show is whether the horizon line moves up or down - or whether the HDRI shows its back or front side or is upside down; it is just a crude help. [Table: Roll Settings for a straight Horizon] Other Methods If it is important that the sun in the HDRI shines from a defined position, Roll cannot be used to compensate for the banked horizon. All examples below show that the sun shines from right, at azimuth 95° and 25° above the horizon. The sun in the HDRI is, as shown on top of page 4, at azimuth 0° and elevation 45°. The sun position 95°/25° in the examples below is important, so Yaw was set to 95 and Pitch to 70, which is 20° lower and places the HDRI sun to 25° elevation; therefore Roll was left at 0. Another means to have the sun in the HDRI at the desired position is grouping the whole scene, parent it to the camera and rotate the camera and keep the HDRI in its default position. <<<< Page 8 >>>> [2 Pictures] {Left: Yaw 95°, Pitch 70° and Roll 0°. Right: HDRI at default rotation but scene and camera rotated.} For the right render the triple stacked terrain was grouped and linked to the perspective camera. The HDRI was left at the default position but the camera with the parented terrains moved to the other side Y -95° or 265° and tilted from X -10 to X -30°. Relative to the scene, the HDRI sun is at the same position as at left. [2 Pictures] {Spherical panorama: left with rotated HDRI, right with HDRI default but rotated scene and camera.} Even though the scene is rotated to compensate for the HDRI default position, the two renders are different. There are two reasons. The overall light is different because the camera is looking more to the zenith and the ambient light is also different because it comes from another side as is evident in the two panorama renders. Another reason for the difference in the two examples is that the materials applied to the terrains are World Space mapped and the terrains moved through the "world". This would not happen if the materials were the Object Space mapped. Such details should be kept in mind when moving the objects around in the scene. Conclusion The HDRI can be rotated to have the prominent light source, like the sun, shining from the desired azimuth and elevation onto the scene. At least for the perspective camera the horizon can be straightened, but turning the camera around will reveal that the horizon is neither straight nor at the same elevation throughout the circle and the sun in the HDRI not exactly where it was placed. Moving the scene with the camera around has also its problems. If the elevation of the sun in the HDRI is where you want it, moving Yaw works fine. If you need the key light higher above the horizon, or lower nearer to the horizon, using the Bryce sun or a Distant Light instead of the HDRI sun may be more efficient. February 2018/horo