Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shader Materials broken when created in C# (Regression from 4.4-beta2 -> 4.4-beta3) #103194

Open
Joy-less opened this issue Feb 22, 2025 · 2 comments · May be fixed by #103201
Open

Shader Materials broken when created in C# (Regression from 4.4-beta2 -> 4.4-beta3) #103194

Joy-less opened this issue Feb 22, 2025 · 2 comments · May be fixed by #103201

Comments

@Joy-less
Copy link
Contributor

Tested versions

  • The regression occurs in 4.4-beta3, 4.4-beta4, 4.4-rc1.
  • The last working version is 4.4-beta2.

System information

Godot v4.4.rc1.mono - Windows 11 (build 26100) - Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1050 Ti (NVIDIA; 32.0.15.6636) - Intel(R) Core(TM) i3-9100F CPU @ 3.60GHz (4 threads)

Issue description

ShaderMaterial is completely bugged when created with new in C# starting with Godot 4.4-beta3.

Here is the code that works in 4.4-beta2 but not in 4.4-beta3 and beyond:

[Export] Shader EyesShader;

// ...

ShaderMaterial EyesMaterial = new() {
    Shader = EyesShader,
};
FaceMesh.SetSurfaceOverrideMaterial(0, EyesMaterial);

Here is the fix:

[Export] ShaderMaterial EyesMaterial;

// ...

// Create eyes material
ShaderMaterial Material = (ShaderMaterial)EyesMaterial.Duplicate();
FaceMesh.SetSurfaceOverrideMaterial(0, Material);

This is what it looks like in 4.4-beta2:

Image

This is what it looks like in 4.4-rc1 (same as 4.4-beta3 and 4.4-beta4):

Image

The big orange eyes are created in the editor so the ShaderMaterial is not instantiated in C#. The blue eyes on the character are subject to the given C# code.

Steps to reproduce

Shader ExampleShader;
MeshInstance3D ExampleMeshInstance3D;

ExampleMeshInstance3D.SetSurfaceOverrideMaterial(0, new ShaderMaterial() {
    Shader = ExampleShader,
});

Minimal reproduction project (MRP)

shader-material-regression.zip

Godot 4.4-beta2:

Image

Godot 4.4-rc1:

Image

@akien-mga
Copy link
Member

I haven't bisected, but looking at the changelog for 4.4-beta3 and the description of the bug, #95626 sounds like it might be related.

CC @Chaosus @raulsntos

@raulsntos
Copy link
Member

I bisected it to 860a6ab

Also, here's the MRP ported to GDScript: shader-material-regression-gd.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Bad
Development

Successfully merging a pull request may close this issue.

3 participants