OpenGL applying light from ViewportTexture to main Camera3D with different visibility layers
Tested versions
Reproducible in: 4.4.1 Stable
System information
Godot v4.4.1.stable - Windows 10 (build 19045) - Single-window, 2 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 4070 Ti SUPER (NVIDIA; 32.0.15.6603) - Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz (12 threads)
Issue description
- Main Camera with Cull Mask layer 1
- Any light at layer 2
- SubViewport's Camera with default Cull Mask all layers active
Main Camera applying lights from ViewportTexture if it rendered on screen. It works in editor too when you in Preview mode of Main Camera selecting SubViewport to see the texture in properties tab, or when making visible on screen Sprite3D or some shader with this VirtualTexture.
Steps to reproduce
Setup:
- Use/Make project in Compability or Mobile mode
- Make Node3D scene
- Add any MeshInstance3D for visualisation of light
- Add Camera3D, move it to see mesh, set Cull Mask only layer 1 active
- Add SubViewport
- Create ViewportTexture resource and assign it to SubViewport
- Add Camera3D to SubViewport, move it to see mesh too (may be different transform)
- Add OmniLight3D, move it outside mesh to light it, set VisualInstance3D/Layers to only 2 layer active
- Add Sprite3D, assing VirtualTexture to it, move it outside of mesh but not outside Main Camera range
- Hide Sprite3D for now, it will be useful for Check 2
Check 1:
- Select Main Camera and activate Preview mode at viewport of editor
- Select SubViewport in NodeTree of Scene Inspector tab showing ViewportTexture to you and applying it's light to main scene. If you have small editor widnow or expand some big property group like Rendering and scroll down, light will not be applied to main view due not rendering ViewportTexture.
Check 2:
- Select Main Camera and activate Preview mode at viewport of editor
- Show Sprite3D with VirtualTexture When VirtualTexture rendered on screen, it's light applying to main view. You can also change Position or Rotation of Viewport Camera (for example drag X position with mouse) to see how light changing it's location
Thoughts In my game project I could decide that I made something wrong with subviewport or camera settings, but if it applying not visible light from other camera only by just selecting SubViewport in editor, it really something very strange. Also, I came to the conclusion that light comes from ViewportTexture at Check 2, when not wanted light showing on mesh, I tried to move Camera inside SubViewport, and light on mesh changed too. Changing Culling Mask for two cameras not really helping.
Minimal reproduction project (MRP)
Source: godotengine/godot