Skip to content

Duplicating ShaderMaterial reverts certain shader parameters #110498

@NuclearPhoenixx

Description

@NuclearPhoenixx

Tested versions

Reproducible in v4.5.rc.double.custom_build [bfa330d]

Did not test in any other version yet.

System information

Godot v4.5.rc.double (bfa330d) - Windows 11 (build 26100) - Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 32.0.15.8129) - 12th Gen Intel(R) Core(TM) i5-12400F (12 threads) - 31.84 GiB memory

Issue description

Duplicating a ShaderMaterial with modified shader parameters that were set by code (not in the editor) will reset certain types back to the "default" (editor) values for both the original and the duplicated ShaderMaterial.

For example, if you set a shader parameter to be a certain Vector2, and then duplicate the material, the original and the duplicate materials with both now revert this Vector2 to the one that can be seen in the editor, i.e. the parameter that was just set is gone, even for the original material!

Simple example: Editor shows Vector2(0,0) for some parameter. You change it to Vector2(1, 1) in code (set_shader_parameter), and after duplicating this one material, all instances of that same material will now show Vector2(0,0) again.

I can reproduce this for Vector2 and Vector3 types, but not for float and int for example.

Steps to reproduce

Open the MRP and click play, in the console output you will see the originally set parameter and then the values after mat_a.duplicate() has been called.

The editor shows Vector2(0,0) for albedo_texture_size. Changing it to Vector2.ONE and printing the parameter is successfull. But after duplicating, the value reverts back to Vector2(0,0). The same is NOT true for the float point_size for example.

Minimal reproduction project (MRP)

min-repro-shader.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    For team assessment

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions