1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Fix light range in voxel GI

This commit is contained in:
retrotails
2025-05-21 06:29:07 -04:00
parent 25a3c27c41
commit ba06234309
3 changed files with 16 additions and 6 deletions

View File

@@ -2943,6 +2943,10 @@ void GI::VoxelGIInstance::update(bool p_update_light_instances, const Vector<RID
}
}
// probe size relative to 1 unit in world space
Vector3 ps = gi->voxel_gi_get_octree_size(probe) / gi->voxel_gi_get_bounds(probe).size;
float cell_size = (1.0 / MAX(MAX(ps.x, ps.y), ps.z));
if (has_dynamic_object_data || p_update_light_instances || p_dynamic_objects.size()) {
// PROCESS MIPMAPS
if (mipmaps.size()) {
@@ -2961,6 +2965,7 @@ void GI::VoxelGIInstance::update(bool p_update_light_instances, const Vector<RID
push_constant.dynamic_range = gi->voxel_gi_get_dynamic_range(probe);
push_constant.light_count = light_count;
push_constant.aniso_strength = 0;
push_constant.cell_size = cell_size;
/* print_line("probe update to version " + itos(last_probe_version));
print_line("propagation " + rtos(push_constant.propagation));
@@ -3161,9 +3166,9 @@ void GI::VoxelGIInstance::update(bool p_update_light_instances, const Vector<RID
push_constant.prev_rect_size[1] = 0;
push_constant.on_mipmap = false;
push_constant.propagation = gi->voxel_gi_get_propagation(probe);
push_constant.cell_size = cell_size;
push_constant.pad[0] = 0;
push_constant.pad[1] = 0;
push_constant.pad[2] = 0;
//process lighting
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();

View File

@@ -188,7 +188,7 @@ private:
uint32_t cell_offset;
uint32_t cell_count;
float aniso_strength;
uint32_t pad;
float cell_size;
};
struct VoxelGIDynamicPushConstant {
@@ -209,7 +209,8 @@ private:
float dynamic_range;
uint32_t on_mipmap;
float propagation;
float pad[3];
float cell_size;
float pad[2];
};
VoxelGILight *voxel_gi_lights = nullptr;

View File

@@ -86,7 +86,7 @@ layout(push_constant, std430) uniform Params {
uint cell_offset;
uint cell_count;
float aniso_strength;
uint pad;
float cell_size;
}
params;
@@ -126,7 +126,8 @@ layout(push_constant, std430) uniform Params {
float dynamic_range;
bool on_mipmap;
float propagation;
float pad[3];
float cell_size;
float pad[2];
}
params;
@@ -209,7 +210,10 @@ bool compute_light_vector(uint light, vec3 pos, out float attenuation, out vec3
return false;
}
attenuation = get_omni_attenuation(distance, 1.0 / lights.data[light].radius, lights.data[light].attenuation);
attenuation = get_omni_attenuation(
distance * params.cell_size,
1.0 / (lights.data[light].radius * params.cell_size),
lights.data[light].attenuation);
if (lights.data[light].type == LIGHT_TYPE_SPOT) {
vec3 rel = normalize(pos - light_pos);