Skip to content

Commit

Permalink
Fix textures used in decals and light projectors not detected as used…
Browse files Browse the repository at this point in the history
… in 3D
  • Loading branch information
Jordyfel committed Feb 14, 2025
1 parent 750640c commit 0931a36
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scene/resources/compressed_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ Error CompressedTexture2D::load(const String &p_path) {
} else {
texture = RS::get_singleton()->texture_2d_create(image);
}
RS::get_singleton()->texture_set_path(texture, get_path());

if (lw || lh) {
RS::get_singleton()->texture_set_size_override(texture, lw, lh);
}
Expand Down
6 changes: 6 additions & 0 deletions servers/rendering/renderer_rd/storage_rd/light_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,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);
Expand Down
17 changes: 17 additions & 0 deletions servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2673,6 +2673,23 @@ 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 (p_type == RS::DecalTexture::DECAL_TEXTURE_NORMAL && tex->detect_normal_callback) {
tex->detect_normal_callback(tex->detect_normal_callback_ud);
}

if (p_type == RS::DecalTexture::DECAL_TEXTURE_NORMAL || p_type == RS::DecalTexture::DECAL_TEXTURE_ORM) {
Texture *normal_tex = get_texture(decal->textures[RS::DecalTexture::DECAL_TEXTURE_NORMAL]);
Texture *orm_tex = get_texture(decal->textures[RS::DecalTexture::DECAL_TEXTURE_ORM]);
if (orm_tex && normal_tex && !normal_tex->path.is_empty() && orm_tex->detect_roughness_callback) {
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]);
}

Expand Down

0 comments on commit 0931a36

Please sign in to comment.