godotengine / godotengine/godot-cpp

Can't set material rid of inherited material class

Open
#1,883 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

### 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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.