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.
Asked
Active
Viewed 167 times
1
1 Answers
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?):
- 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 a Copy Rotation constraint to the Empty and use the Camera as Target. You can leave all settings at default.
- 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.
- 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.
- 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.
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







Thank you very much for your interest in the comments
– GKCC Oct 23 '22 at 14:51