godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.24k stars 20.23k forks source link

Document which texture types can be used in a Sprite3D #75342

Closed phunnyguy closed 8 months ago

phunnyguy commented 1 year ago

Godot version

4.0

System information

PopOS, Forward+, Nvidia 960M(525.85.05), Forward+(Vulkan)

Issue description

Using a Canvas Texture on a Sprite3D results in a white image when it should just display the sprite.

whitesprite

Steps to reproduce

Create Canvas Texture using a sprite sheet. Use that Canvas Texture with a Sprite3D

Minimal reproduction project

test-project.zip

Calinou commented 1 year ago

CanvasTexture is only meant for 2D usage, not 3D ("canvas" denotes a CanvasItem). Use the Quick Load (or Load) dropdown option to load an existing texture in a 3D material's property, or create a new material using New StandardMaterial3D.

This should be made clearer in the class reference, but we should also look into printing an error when attempting to use incompatible texture types in SpriteBase3D or BaseMaterial3D.

phunnyguy commented 1 year ago

Attempting to use StandardMaterial3D with a Sprite3D node isn't possible either because the engine does not allow it. Giving me this error. unable to use material3d on sprite3d

Calinou commented 1 year ago

Attempting to use StandardMaterial3D with a Sprite3D node isn't possible either because the engine does not allow it. Giving me this error.

StandardMaterial3D can only be used in MeshInstance3D's material properties, or Material Override/Overlay on a node that inherits from GeometryInstance3D. This includes Sprite3D, but its size must be set by also defining a texture in the Texture property when you use a material override (as Sprite3D is not "aware" of the material override).

In general, it's not recommended to use Material Override with a Sprite3D – use a MeshInstance3D with a QuadMesh if you have more advanced needs.

For basic use cases, what you need to do is use Quick Load or Load at the bottom of the resource dropdown, then choose the texture file in the file dialog:

image