Skip to content

Can't set material rid of inherited material class #1883

@tostc

Description

@tostc

Godot version

4.5.1.stable

godot-cpp version

4.5.stable

System information

All supported systems

Issue description

I'm currently developing a custom material type that inherits directly from the material class. My problem is that the get_rid and get_material methods are always returns a null RID. Even if I override _get_rid, it remains unchanged.

I investigated a bit more closely and it seems that the set_material method of the Material class is missing within the engine in the C++ bindings.

This seems to be a problem in GDScript as well.

I thought it was possible, since the documentary claims this:
Importantly, you can inherit from Material to create your own custom material type in script or in GDExtension.

Steps to reproduce

  1. Create a new C++ Class and inherit from Material
  2. Create a new material using godot::RenderingServer::get_singleton()->material_create(); and set a shader using godot::RenderingServer::get_singleton()->material_set_shader(m_MaterialRid, Shader);
  3. Overwrite godot::RID _get_rid() const and return the RID, which was created using material_create.
  4. Try to set a uniform variable godot::RenderingServer::get_singleton()->material_set_param(get_rid(), "metallic", 2.0); or godot::RenderingServer::get_singleton()->material_set_param(get_rid(), "metallic", 2.0);
  5. You will get an error message, that the RID is null.

Minimal reproduction project

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions