This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hello everybody.
I'm asking for something about ShadersMaterials performances vs. SpatialMaterial...
Suppose one have to do a simple work, like apply a single diffuse texture to a mesh, doing it with a couple row shader is better (in speed terms) respect using a simple and confortable SpatialMaterial or performance are the same?
Naturally I'm speaking in "pratical situation", rather then theory...

Many thanks

Godot version 3.4
in Engine by (61 points)

1 Answer

+2 votes

Practically I wouldn't worry about it. There are usually a lot of other things that affect performance way more, like not sharing material between objects.

There is no difference between a SpatialMaterial and a ShaderMaterial if they do the same operation and produce the same material. If you right click a SpatialMaterial and convert it into a ShaderMaterial they should have more or less identical performance.

Now, if you don't need everything the SpatialMaterial does, you can write a ShaderMaterial that does less operations, and in turn will have better performance. But I'm pretty sure the difference will be negligible, unless you have hundreads of non-shared material instances.

For example, the shader below will have better performance than the default SpatialMaterial, due to making less operations.

shader_type spatial;
render_mode unshaded;

void fragment() {
    ALBEDO = vec3(1.0, 0.0, 0.0);
by (1,122 points)

Understood. Thanks

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.