diff options
Diffstat (limited to 'servers/rendering/renderer_rd/shaders/environment')
3 files changed, 29 insertions, 28 deletions
diff --git a/servers/rendering/renderer_rd/shaders/environment/sdfgi_direct_light.glsl b/servers/rendering/renderer_rd/shaders/environment/sdfgi_direct_light.glsl index 9f7449b8aa..06709f65d3 100644 --- a/servers/rendering/renderer_rd/shaders/environment/sdfgi_direct_light.glsl +++ b/servers/rendering/renderer_rd/shaders/environment/sdfgi_direct_light.glsl @@ -24,7 +24,7 @@ struct ProcessVoxel { uint albedo; // rgb bits 0-15 albedo, bits 16-21 are normal bits (set if geometry exists toward that side), extra 11 bits for neighbors. uint light; // rgbe8985 encoded total saved light, extra 2 bits for neighbors. uint light_aniso; // 55555 light anisotropy, extra 2 bits for neighbors. - //total neighbours: 26 + //total neighbors: 26 }; #ifdef MODE_PROCESS_STATIC @@ -443,10 +443,10 @@ void main() { imageStore(dst_aniso1, positioni, vec4(aniso1, 0.0, 0.0)); imageStore(dst_light, positioni, uvec4(light_total_rgbe)); - //also fill neighbours, so light interpolation during the indirect pass works + //also fill neighbors, so light interpolation during the indirect pass works - //recover the neighbour list from the leftover bits - uint neighbours = (voxel_albedo >> 21) | ((voxel_position >> 21) << 11) | ((process_voxels.data[voxel_index].light >> 30) << 22) | ((process_voxels.data[voxel_index].light_aniso >> 30) << 24); + //recover the neighbor list from the leftover bits + uint neighbors = (voxel_albedo >> 21) | ((voxel_position >> 21) << 11) | ((process_voxels.data[voxel_index].light >> 30) << 22) | ((process_voxels.data[voxel_index].light_aniso >> 30) << 24); const uint max_neighbours = 26; const ivec3 neighbour_positions[max_neighbours] = ivec3[]( @@ -478,7 +478,7 @@ void main() { ivec3(1, 1, 1)); for (uint i = 0; i < max_neighbours; i++) { - if (bool(neighbours & (1 << i))) { + if (bool(neighbors & (1 << i))) { ivec3 neighbour_pos = positioni + neighbour_positions[i]; imageStore(dst_light, neighbour_pos, uvec4(light_total_rgbe)); imageStore(dst_aniso0, neighbour_pos, aniso0); diff --git a/servers/rendering/renderer_rd/shaders/environment/sdfgi_preprocess.glsl b/servers/rendering/renderer_rd/shaders/environment/sdfgi_preprocess.glsl index bce98f4054..dd35ae3b73 100644 --- a/servers/rendering/renderer_rd/shaders/environment/sdfgi_preprocess.glsl +++ b/servers/rendering/renderer_rd/shaders/environment/sdfgi_preprocess.glsl @@ -102,10 +102,10 @@ dispatch_data; struct ProcessVoxel { uint position; // xyz 7 bit packed, extra 11 bits for neighbors. - uint albedo; //rgb bits 0-15 albedo, bits 16-21 are normal bits (set if geometry exists toward that side), extra 11 bits for neighbours - uint light; //rgbe8985 encoded total saved light, extra 2 bits for neighbours - uint light_aniso; //55555 light anisotropy, extra 2 bits for neighbours - //total neighbours: 26 + uint albedo; //rgb bits 0-15 albedo, bits 16-21 are normal bits (set if geometry exists toward that side), extra 11 bits for neighbors + uint light; //rgbe8985 encoded total saved light, extra 2 bits for neighbors + uint light_aniso; //55555 light anisotropy, extra 2 bits for neighbors + //total neighbors: 26 }; layout(set = 0, binding = 11, std430) restrict buffer writeonly ProcessVoxels { @@ -135,10 +135,10 @@ dispatch_data; struct ProcessVoxel { uint position; // xyz 7 bit packed, extra 11 bits for neighbors. - uint albedo; //rgb bits 0-15 albedo, bits 16-21 are normal bits (set if geometry exists toward that side), extra 11 bits for neighbours - uint light; //rgbe8985 encoded total saved light, extra 2 bits for neighbours - uint light_aniso; //55555 light anisotropy, extra 2 bits for neighbours - //total neighbours: 26 + uint albedo; //rgb bits 0-15 albedo, bits 16-21 are normal bits (set if geometry exists toward that side), extra 11 bits for neighbors + uint light; //rgbe8985 encoded total saved light, extra 2 bits for neighbors + uint light_aniso; //55555 light anisotropy, extra 2 bits for neighbors + //total neighbors: 26 }; layout(set = 0, binding = 6, std430) restrict buffer readonly ProcessVoxels { @@ -1016,14 +1016,14 @@ void main() { store_positions[index].albedo = rgb >> 1; //store as it comes (555) to avoid precision loss (and move away the alpha bit) store_positions[index].albedo |= (facing & 0x3F) << 15; // store facing in bits 15-21 - store_positions[index].albedo |= neighbour_bits << 21; //store lower 11 bits of neighbours with remaining albedo - store_positions[index].position |= (neighbour_bits >> 11) << 21; //store 11 bits more of neighbours with position + store_positions[index].albedo |= neighbour_bits << 21; //store lower 11 bits of neighbors with remaining albedo + store_positions[index].position |= (neighbour_bits >> 11) << 21; //store 11 bits more of neighbors with position store_positions[index].light = imageLoad(src_light, pos).r; store_positions[index].light_aniso = imageLoad(src_light_aniso, pos).r; - //add neighbours - store_positions[index].light |= (neighbour_bits >> 22) << 30; //store 2 bits more of neighbours with light - store_positions[index].light_aniso |= (neighbour_bits >> 24) << 30; //store 2 bits more of neighbours with aniso + //add neighbors + store_positions[index].light |= (neighbour_bits >> 22) << 30; //store 2 bits more of neighbors with light + store_positions[index].light_aniso |= (neighbour_bits >> 24) << 30; //store 2 bits more of neighbors with aniso } groupMemoryBarrier(); diff --git a/servers/rendering/renderer_rd/shaders/environment/volumetric_fog.glsl b/servers/rendering/renderer_rd/shaders/environment/volumetric_fog.glsl index 4658afd02d..8e4f5762fd 100644 --- a/servers/rendering/renderer_rd/shaders/environment/volumetric_fog.glsl +++ b/servers/rendering/renderer_rd/shaders/environment/volumetric_fog.glsl @@ -37,7 +37,7 @@ layout(push_constant, std430) uniform Params { vec3 position; float pad; - vec3 extents; + vec3 size; float pad2; ivec3 corner; @@ -184,36 +184,37 @@ void main() { vec4 local_pos = params.transform * world; local_pos.xyz /= local_pos.w; + vec3 half_size = params.size / 2.0; float sdf = -1.0; if (params.shape == 0) { // Ellipsoid // https://www.shadertoy.com/view/tdS3DG - float k0 = length(local_pos.xyz / params.extents); - float k1 = length(local_pos.xyz / (params.extents * params.extents)); + float k0 = length(local_pos.xyz / half_size); + float k1 = length(local_pos.xyz / (half_size * half_size)); sdf = k0 * (k0 - 1.0) / k1; } else if (params.shape == 1) { // Cone // https://iquilezles.org/www/articles/distfunctions/distfunctions.htm - // Compute the cone angle automatically to fit within the volume's extents. - float inv_height = 1.0 / max(0.001, params.extents.y); - float radius = 1.0 / max(0.001, (min(params.extents.x, params.extents.z) * 0.5)); + // Compute the cone angle automatically to fit within the volume's size. + float inv_height = 1.0 / max(0.001, half_size.y); + float radius = 1.0 / max(0.001, (min(half_size.x, half_size.z) * 0.5)); float hypotenuse = sqrt(radius * radius + inv_height * inv_height); float rsin = radius / hypotenuse; float rcos = inv_height / hypotenuse; vec2 c = vec2(rsin, rcos); float q = length(local_pos.xz); - sdf = max(dot(c, vec2(q, local_pos.y - params.extents.y)), -params.extents.y - local_pos.y); + sdf = max(dot(c, vec2(q, local_pos.y - half_size.y)), -half_size.y - local_pos.y); } else if (params.shape == 2) { // Cylinder // https://iquilezles.org/www/articles/distfunctions/distfunctions.htm - vec2 d = abs(vec2(length(local_pos.xz), local_pos.y)) - vec2(min(params.extents.x, params.extents.z), params.extents.y); + vec2 d = abs(vec2(length(local_pos.xz), local_pos.y)) - vec2(min(half_size.x, half_size.z), half_size.y); sdf = min(max(d.x, d.y), 0.0) + length(max(d, 0.0)); } else if (params.shape == 3) { // Box // https://iquilezles.org/www/articles/distfunctions/distfunctions.htm - vec3 q = abs(local_pos.xyz) - params.extents; + vec3 q = abs(local_pos.xyz) - half_size; sdf = length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0); } @@ -222,7 +223,7 @@ void main() { #ifndef SDF_USED cull_mask = 1.0 - smoothstep(-0.1, 0.0, sdf); #endif - uvw = clamp((local_pos.xyz + params.extents) / (2.0 * params.extents), 0.0, 1.0); + uvw = clamp((local_pos.xyz + half_size) / params.size, 0.0, 1.0); } if (cull_mask > 0.0) { |