To use an image file as the static background for a 3D scene, I'm assuming the best way to do this is to create a CanvasLayer and place the image on it. Thing is, when I do this, the canvas renders on top of the 3D world, even if I set it's Layer property (presumably it's z-order) to -1. Am I doing this wrong? Is there a more appropriate way?
Using an Image as the 3D Background
I haven't tried this so not sure if it will work but try changing the WorldEnvironemnt background mode to canvas?
I tried that already. ;-) Both as a WorldEnvironment node and as a Camera Environment property.
Bear in mind, I'm seeing my background canvas rendered, only no 3D.
These settings work for me (in my test project at least :smile: ):
Here is how you do it:
Set the world enviroment background to canvas
. Make a Control
base node in your scene, not parented to a CanvasLayer
, but rather just somewhere in the scene (in my example the Control
node is a child of the Spatial that is the scene's root). Place whatever you want as the background in that Control
node.
If you want to make GUI that draws on top of the entire scene (like the GUI normally acts), then create a CanvasLayer
node and attach whatever you want as your GUI to that (assuming it has a layer value of 1
or greater).
Awesome! And all of this stuff sits on the 2D canvas - fully separate from the 3D world. Nice.
I'm curious, if I wanted live/rich text on the GUI layer, what type of node would I create as a child of the CanvasLayer to host the text?
I would recommend using a RichTextLabel
node, unless you are talking about which node to parent the label to, in which case I would suggest just using a Control
node.
It looks like Godot supports dynamic fonts now but it also looks like the only way to change the size of a font (such as one I'm using in a RichTextLabel) is in code, such as:
get_node("path_your_label_node").get("custom_fonts/font").set_size(100)
Is this correct - you can't change RichTextLabel font size in the editor?
You can change it in the editor, but it's a little confusing.
You need to make a new Dynamic Font
(either as a font override or in your GUI theme). Click it to inspect it in the inspector. Then you can change the size through the Settings
tab. You can also change whether or not to use mipmaps and/or filtering.
In the Font
tab under Font Data
is where you can load the font file (*.ttf
, *.otf
, etc)
Wow. Thanks!