Skip to content

Commit

Permalink
Small DDGI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tippesi committed Jan 3, 2025
1 parent 4fdb1e5 commit f6f830e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
9 changes: 4 additions & 5 deletions data/shader/ddgi/ddgi.hsh
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ layout(std140, set = 2, binding = 27) uniform DDGIBuffer {

struct RayHit {
#ifndef AE_HALF_FLOAT
vec3 direction;
vec3 radiance;
float hitDistance;
vec4 direction;
vec4 radiance;
#else
AeF16x4 direction;
AeF16x4 radiance;
Expand All @@ -92,7 +91,7 @@ RayHit UnpackRayHit(PackedRayHit compressed) {
hit.direction.z = comn.x;
hit.radiance.z = comn.y;

hit.hitDistance = compressed.data.w;
hit.radiance.w = compressed.data.w;
#else
hit.direction = compressed.direction;
hit.radiance = compressed.radiance;
Expand All @@ -111,7 +110,7 @@ PackedRayHit PackRayHit(RayHit hit) {
compressed.data.x = uintBitsToFloat(packHalf2x16(hit.direction.xy));
compressed.data.y = uintBitsToFloat(packHalf2x16(hit.radiance.xy));
compressed.data.z = uintBitsToFloat(packHalf2x16(comn));
compressed.data.w = hit.hitDistance;
compressed.data.w = hit.radiance.a;
#else
compressed.direction = hit.direction;
compressed.radiance = hit.radiance;
Expand Down
18 changes: 9 additions & 9 deletions data/shader/ddgi/probeUpdate.csh
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ void main() {
for (uint j = 0; j < loadRayCount; j++) {
#if defined(IRRADIANCE)
AeF16 weight = max(0.0hf, dot(N, rayData[j].direction.rgb));
AeF16 weight = max(AeF16(0.0), dot(N, rayData[j].direction.rgb));
if (weight >= 0.00001hf) {
if (weight >= AeF16(0.00001)) {
AeF16x3 radiance = AeF16x3(rayData[j].radiance);
result += AeF16x4(radiance, 1.0hf) * weight;
result += AeF16x4(radiance, AeF16(1.0)) * weight;
}
const float probeOffsetDistance = max(ddgiData.cascades[cascadeIndex].cellSize.w * 0.05, 0.5);
Expand All @@ -224,21 +224,21 @@ void main() {
}
}
#elif defined(RADIANCE)
AeF16 weight = max(0.0hf, dot(N, rayData[j].direction.rgb));
weight = pow(weight, 256.0hf);
AeF16 weight = max(AeF16(0.0), dot(N, rayData[j].direction.rgb));
weight = pow(weight, AeF16(256.0));
AeF16x3 radiance = rayData[j].radiance.xyz;
if (weight > 0.15)
result += AeF16x4(radiance, 1.0hf) * weight;
result += AeF16x4(radiance, AeF16(1.0)) * weight;
#else
AeF16 weight = max(0.0hf, dot(N, rayData[j].direction.xyz));
AeF16 weight = max(AeF16(0.0), dot(N, rayData[j].direction.xyz));
AeF16 hitDistance = rayData[j].direction.w;
weight = pow(weight, depthSharpness);
if (weight >= 0.00000001hf) {
result += AeF16x4(hitDistance, sqr(hitDistance), 0.0hf, 1.0hf) * weight;
if (weight >= AeF16(0.00000001)) {
result += AeF16x4(hitDistance, sqr(hitDistance), AeF16(0.0), AeF16(1.0)) * weight;
}
#endif
}
Expand Down
6 changes: 3 additions & 3 deletions data/shader/ddgi/rayHit.csh
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ void main() {

RayHit hit;
#ifndef AE_HALF_FLOAT
hit.radiance = radiance;
hit.direction = ray.direction;
hit.hitDistance = ray.hitDistance;
hit.radiance.rgb = radiance;
hit.direction.xyz = ray.direction;
hit.radiance.a = ray.hitDistance;
#else
hit.radiance = AeF16x4(radiance, ray.hitDistance);
hit.direction = AeF16x4(ray.direction, 1.0);
Expand Down

0 comments on commit f6f830e

Please # to comment.