Godot Weird Problem:Viewport Texture Error with Model
Posted by SysL, on January 23, 2025. [Link]
In Godot, if you set a ViewPort Texture directly on a Material Albedo you will receive a warning when running your game from the editor. This error appears to be harmless in game but it is annoying.
To work around it, you can set it in code:
- Grab a reference to the mesh
- Grab a reference to the viewport/subviewport
- In the _ready() callback, set the texture.
@onready var mesh_instance_3d: MeshInstance3D = $MeshInstance3D
@onready var sub_viewport: SubViewport = $SubViewport
func _ready() -> void:
mesh_instance_3d.get_surface_override_material(0).albedo_texture = sub_viewport.get_texture()
This is not likely to be fixed anytime soon, it's been open since 2022...
Information from MamaDespik (Reddit, April 29, 2024)