Detect textures used in decals and light projectors as used in 3d

This commit is contained in:
Jordyfel 2024-08-02 03:36:48 +03:00
parent 3978628c6c
commit 78622ab4d3
3 changed files with 29 additions and 0 deletions

View File

@ -155,6 +155,8 @@ Error CompressedTexture2D::load(const String &p_path) {
path_to_file = p_path;
format = image->get_format();
RS::get_singleton()->texture_set_path(texture, get_path());
if (get_path().is_empty()) {
//temporarily set path if no path set for resource, helps find errors
RenderingServer::get_singleton()->texture_set_path(texture, p_path);

View File

@ -242,6 +242,12 @@ void LightStorage::light_set_projector(RID p_light, RID p_texture) {
if (light->type != RS::LIGHT_DIRECTIONAL) {
if (light->projector.is_valid()) {
#ifdef TOOLS_ENABLED
TextureStorage::Texture *tex = TextureStorage::get_singleton()->get_texture(p_texture);
if (tex->detect_3d_callback) {
tex->detect_3d_callback(tex->detect_3d_callback_ud);
}
#endif
texture_storage->texture_add_to_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI);
}
light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR);

View File

@ -2458,6 +2458,27 @@ void TextureStorage::decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID
decal->textures[p_type] = p_texture;
if (decal->textures[p_type].is_valid()) {
#ifdef TOOLS_ENABLED
Texture *tex = get_texture(p_texture);
if (tex->detect_3d_callback) {
tex->detect_3d_callback(tex->detect_3d_callback_ud);
}
if (tex->detect_normal_callback && p_type == RS::DecalTexture::DECAL_TEXTURE_NORMAL) {
tex->detect_normal_callback(tex->detect_normal_callback_ud);
}
Texture *normal_tex = nullptr;
if (decal->textures[RS::DecalTexture::DECAL_TEXTURE_NORMAL].is_valid()) {
normal_tex = get_texture(decal->textures[RS::DecalTexture::DECAL_TEXTURE_NORMAL]);
}
Texture *orm_tex = nullptr;
if (decal->textures[RS::DecalTexture::DECAL_TEXTURE_ORM].is_valid()) {
orm_tex = get_texture(decal->textures[RS::DecalTexture::DECAL_TEXTURE_ORM]);
}
if (orm_tex && orm_tex->detect_roughness_callback && normal_tex && !normal_tex->path.is_empty()) {
orm_tex->detect_roughness_callback(orm_tex->detect_roughness_callback_ud, normal_tex->path, RS::TEXTURE_DETECT_ROUGHNESS_G);
}
#endif
texture_add_to_decal_atlas(decal->textures[p_type]);
}