Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvas Layer Environment not Showing in Spatial Editor Viewport #26533

Open
shartte opened this issue Mar 3, 2019 · 3 comments
Open

Canvas Layer Environment not Showing in Spatial Editor Viewport #26533

shartte opened this issue Mar 3, 2019 · 3 comments

Comments

@shartte
Copy link
Contributor

shartte commented Mar 3, 2019

Godot version:
3.1.0 beta9

Issue description:
A canvas layer is not drawn as the background layer in the SpatialEditor, even when using WorldEnvironment with BGMode=canvas, and "Use Environment" is true for the current viewport.
The same canvas layer is shown in the running game just fine.

Use case:
I need the editor to show the canvas environment because I am working on a game with pre-rendered 3d backgrounds (examples: Pillars of Eternity, Temple of Elemental Evil), but normal 3d scenes. In order to align any node in the editor with the pre-rendered background properly, I need to actually see the background in the editor (adjusting the camera to have the same transform as used when rendering the background is a different issue).

Steps to reproduce:

  • Create new Scene
  • Add WorldEnvironment
  • Create Environment for WorldEnvironment, set Background Mode to Canvas (and increase max. layer)
  • Add a canvas layer to the WorldEnvironment
  • Add some 2D sprite to that layer
  • Running the scene will show that 2D sprite rendered behind the 3D scene (good!)
  • But the editor will not show it (even when view environment is enabled)

Minimal reproduction project:
CanvasDemo.zip

@shartte shartte changed the title Canvas Environment not Canvas Layer Environment not Showing in Spatial Editor Viewport Mar 3, 2019
@shartte
Copy link
Contributor Author

shartte commented Mar 4, 2019

I looked into this issue a bit. Although my analysis might be off (have only been using Godot for a very short amount of time).

CanvasLayer nodes register themselves with the current node's parent viewport upon NOTIFICATION_ENTER_TREE.
A viewport will only consider it's directly registered canvas layers when drawing the environment background in canvas mode.
Since the spatial editor viewports are nested within the primary viewport, no canvas layers will be registered on them, and as such, they will not draw any background. The primary viewport's background is fully obscured by editor controls.
Following this logic, I think I can reproduce this in the normal game by simply using multiple viewports.

@shartte
Copy link
Contributor Author

shartte commented Mar 5, 2019

I managed to reproduce this outside of the editor now, by using another viewport that shares the same world/environment.
Demo is attached.
CanvasDemo2.zip
image

Expected behavior would have been that the icon shows up in the nested viewport as well, since it's sharing the same environment with bgmode=canvas.

@shartte
Copy link
Contributor Author

shartte commented Mar 12, 2019

Current workaround:
Add a tool script that fishes out the spatial editor viewport from the editor's scene tree and set that as custom_viewport on the canvas layer. This will allow the canvas layer to show up in one of the spatial viewports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants