1

On the image below, I have a solid color for my background. I want to use an HDRI texture instead, but so that it doesn't change when I move the camera. The objects on the scene should be lit in the usual way, by the entire HDRI.

Markus von Broady
  • 36,563
  • 3
  • 30
  • 99
GKCC
  • 55
  • 2
  • So you want to see HDRI background, but you want the perspective to be fixed, as if whenever you rotate the camera, it doesn't actually rotate but instead everything else rotates? – Markus von Broady Oct 23 '22 at 10:24
  • The HDRI background image is fixed in A state (so the color is also fixed), I want only that Gundam image I made to move at various angles. – GKCC Oct 23 '22 at 10:58
  • Do you mean something like this? If so, I'm sure I've seen it posted, but can't find it.... – Robin Betts Oct 23 '22 at 12:25
  • Stupid question but I don't seem to understand what you want. You want the background to be fixed while the camera is moving...? Moving to... see the object from different sides while keeping the background consistent? What about rotating the object instead of moving the camera? – Gordon Brinkmann Oct 23 '22 at 13:39
  • Every time you move the screen, the HDRI background color keeps changing. I wanted to fix it. I couldn't find a proper way. So I just change it to a simple HDRI Puport background color changes less. I decided to write this

    Thank you very much for your interest in the comments

    – GKCC Oct 23 '22 at 14:51
  • I edited the content of the question based on OP's comment on Brinkmann's answer; it seems Gordon figured out what OP meant. – Markus von Broady Oct 24 '22 at 10:16

1 Answers1

3

I hope I understand correctly what you want to achieve. If so, here is how I would do it when using an HDRI as background. Please note that this only works when using the camera view, since you cannot simply plug the "viewport view" into the Shader Editor (maybe someone else knows a way with some python scripting?):

  1. Place an Empty in the world's center at X/Y/Z = 0/0/0 and leave the rotation 0°/0°/0° as well.

add empty

  1. Add a Copy Rotation constraint to the Empty and use the Camera as Target. You can leave all settings at default.

copy rotation

  1. Go into the Shader Editor set to World. Plug a Mapping node into the Environment Texture and connect it to the Object output of a Texture Coordinate node. Choose the Empty as Object.

add mapping

  1. Now you can use the Rotation in the Mapping node to create an offset to the Camera's rotation to select the view of the HDRI you want to see. You can now move the camera around, the background will always stay the same. Just note that since the background is moving together with the camera, the lighting conditions change.

rotation offset

moving background

  1. If you want the view to change but not the lighting, you can duplicate the Environment Texture node and use it without Mapping. Use a Mix Shader with a Light Path node's Is Camera Ray output as factor. Of course both Environment Texture nodes can be mapped if you need it to get the lighting the way you want. You just can't use the Object output of the same _Texture Coordinate _ node for the one that shouldn't move, but the implicit default when not using the Vector input for the Environment Texture is Generated anyway.

mixing backgrounds

Gordon Brinkmann
  • 28,589
  • 1
  • 19
  • 49
  • Alternatively, you could just use the Texture Coordinate: Camera for the image sampling. But then your HDRI image needs to be flat. – Markus von Broady Oct 24 '22 at 09:46
  • Wow!!!! This is the need I was so looking for. I'm so happy you taught me a really cool method!!!! – GKCC Oct 24 '22 at 10:01
  • @MarkusvonBroady Right, but since HDRIs used for lighting are usually 360°, I didn't go for the simple solution here. – Gordon Brinkmann Oct 24 '22 at 10:07
  • @GordonBrinkmann oh, I mean your solution, just that the Camera Ray part could use the Camera coordinate, and another Image Texture. Perhaps you could even figure out the maths to still use the same Image Texture, I've never tried that so I don't know how hard it would be… The simplest approach seems to be to render an empty scene, and then use the resulting image. – Markus von Broady Oct 24 '22 at 10:10
  • @MarkusvonBroady My bad, of course you're right, this would work as well... just the perspective of the background would change, the equirectangular mapping doesn't work the same if you use Camera. Maybe I'll edit the answer later. – Gordon Brinkmann Oct 24 '22 at 12:34
  • Yes, the mapping, also changing output dimensions could be problematic for that idea, but of course you'd know everything about that – Markus von Broady Oct 24 '22 at 12:59