2D_in_3D.gd 436 B

123456789101112131415
  1. extends Spatial
  2. func _ready():
  3. # Get the viewport and clear it
  4. var viewport = get_node("Viewport")
  5. viewport.set_clear_mode(Viewport.CLEAR_MODE_ONLY_NEXT_FRAME)
  6. # Let two frames pass to make sure the vieport's is captured
  7. yield(get_tree(), "idle_frame")
  8. yield(get_tree(), "idle_frame")
  9. # Retrieve the texture and set it to the viewport quad
  10. get_node("Viewport_quad").material_override.albedo_texture = viewport.get_texture()