1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Merge pull request #89919 from BlueCube3310/bicubic-lightmap

Implement bicubic sampling for lightmaps
This commit is contained in:
Rémi Verschelde
2024-08-20 10:01:41 +02:00
30 changed files with 354 additions and 15 deletions

View File

@@ -1103,9 +1103,17 @@ void RenderForwardClustered::_setup_lightmaps(const RenderDataRD *p_render_data,
RID lightmap = light_storage->lightmap_instance_get_lightmap(p_lightmaps[i]);
// Transform (for directional lightmaps).
Basis to_lm = light_storage->lightmap_instance_get_transform(p_lightmaps[i]).basis.inverse() * p_cam_transform.basis;
to_lm = to_lm.inverse().transposed(); //will transform normals
RendererRD::MaterialStorage::store_transform_3x3(to_lm, scene_state.lightmaps[i].normal_xform);
// Light texture size.
Vector2i lightmap_size = light_storage->lightmap_get_light_texture_size(lightmap);
scene_state.lightmaps[i].texture_size[0] = lightmap_size[0];
scene_state.lightmaps[i].texture_size[1] = lightmap_size[1];
// Exposure.
scene_state.lightmaps[i].exposure_normalization = 1.0;
if (p_render_data->camera_attributes.is_valid()) {
float baked_exposure = light_storage->lightmap_get_baked_exposure_normalization(lightmap);
@@ -4242,6 +4250,11 @@ void RenderForwardClustered::_update_shader_quality_settings() {
spec_constants.push_back(sc);
sc.constant_id = SPEC_CONSTANT_USE_LIGHTMAP_BICUBIC_FILTER;
sc.bool_value = lightmap_filter_bicubic_get();
spec_constants.push_back(sc);
scene_shader.set_default_specialization_constants(spec_constants);
base_uniforms_changed(); //also need this

View File

@@ -73,6 +73,7 @@ class RenderForwardClustered : public RendererSceneRenderRD {
SPEC_CONSTANT_DECAL_FILTER = 10,
SPEC_CONSTANT_PROJECTOR_FILTER = 11,
SPEC_CONSTANT_USE_DEPTH_FOG = 12,
SPEC_CONSTANT_USE_LIGHTMAP_BICUBIC_FILTER = 13,
};
enum {
@@ -235,8 +236,9 @@ class RenderForwardClustered : public RendererSceneRenderRD {
struct LightmapData {
float normal_xform[12];
float pad[3];
float texture_size[2];
float exposure_normalization;
float pad;
};
struct LightmapCaptureData {