Fix: Reflection Probe Memory Alignment
Introduced in recent commit (#110194) where the reflection probes are used as ubos. Ubos have different memory requirements, but the struct wasn't adjusted, resulting in incorrect renderings. Pull Request: https://projects.blender.org/blender/blender/pulls/110202
This commit is contained in:
@@ -21,7 +21,7 @@ void ReflectionProbeModule::init()
|
||||
world_probe_data.layer = 0;
|
||||
world_probe_data.layer_subdivision = 0;
|
||||
world_probe_data.area_index = 0;
|
||||
world_probe_data.pos = float3(0.0f);
|
||||
world_probe_data.pos = float4(0.0f);
|
||||
data_buf_[0] = world_probe_data;
|
||||
|
||||
ReflectionProbe world_probe;
|
||||
@@ -125,7 +125,7 @@ void ReflectionProbeModule::sync_object(Object *ob, ObjectHandle &ob_handle)
|
||||
probe_data.area_index = new_probe_data.area_index;
|
||||
}
|
||||
|
||||
probe_data.pos = float3(float4x4(ob->object_to_world) * float4(0.0, 0.0, 0.0, 1.0));
|
||||
probe_data.pos = float4x4(ob->object_to_world) * float4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
ReflectionProbe &ReflectionProbeModule::find_or_insert(ObjectHandle &ob_handle,
|
||||
@@ -458,7 +458,7 @@ std::optional<ReflectionProbeUpdateInfo> ReflectionProbeModule::update_info_pop(
|
||||
info.object_key = item.key;
|
||||
info.resolution = 1 << (max_shift - probe_data.layer_subdivision - 1);
|
||||
info.clipping_distances = item.value.clipping_distances;
|
||||
info.probe_pos = probe_data.pos;
|
||||
info.probe_pos = float3(probe_data.pos);
|
||||
|
||||
if (cubemap_tx_.ensure_cube(GPU_RGBA16F,
|
||||
info.resolution,
|
||||
|
||||
@@ -1033,8 +1033,10 @@ struct ReflectionProbeData {
|
||||
/**
|
||||
* Position of the light probe in world space.
|
||||
* World probe uses origin.
|
||||
*
|
||||
* 4th component is not used.
|
||||
*/
|
||||
packed_float3 pos;
|
||||
float4 pos;
|
||||
|
||||
/** On which layer of the texture array is this reflection probe stored. */
|
||||
int layer;
|
||||
@@ -1056,8 +1058,6 @@ struct ReflectionProbeData {
|
||||
* LOD factor for mipmap selection.
|
||||
*/
|
||||
float lod_factor;
|
||||
|
||||
int _pad[1];
|
||||
};
|
||||
BLI_STATIC_ASSERT_ALIGN(ReflectionProbeData, 16)
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ int reflection_probes_find_closest(vec3 P)
|
||||
for (int index = 1; reflection_probe_buf[index].layer != -1 && index < REFLECTION_PROBES_MAX;
|
||||
index++)
|
||||
{
|
||||
float dist = distance(P, reflection_probe_buf[index].pos);
|
||||
float dist = distance(P, reflection_probe_buf[index].pos.xyz);
|
||||
if (dist < closest_distance) {
|
||||
closest_distance = dist;
|
||||
closest_index = index;
|
||||
|
||||
Reference in New Issue
Block a user