hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/geodesic.glsl
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2025-08-22 12:24:05 +0200
committerhachem <im@hachem.wtf>2025-08-22 12:24:05 +0200
commit2c8002d30f291cba832a5750212009d48238c308 (patch)
tree4aafc468441b3e32c267040830b8e0b5af859faf /assets/shaders/geodesic.glsl
parentb9de06951631d9969c52c6ed95de17a6d8aad121 (diff)
feat: add HDRI
Diffstat (limited to 'assets/shaders/geodesic.glsl')
-rw-r--r--assets/shaders/geodesic.glsl12
1 files changed, 11 insertions, 1 deletions
diff --git a/assets/shaders/geodesic.glsl b/assets/shaders/geodesic.glsl
index 70e41ef..2e69c72 100644
--- a/assets/shaders/geodesic.glsl
+++ b/assets/shaders/geodesic.glsl
@@ -2,6 +2,7 @@
layout(local_size_x = 16, local_size_y = 16) in;
layout(binding = 0, rgba8) writeonly uniform image2D outImage;
+layout(binding = 5) uniform samplerCube u_HDRIEnvironment;
layout(std140, binding = 1) uniform Camera
{
vec3 camPos; float _pad0;
@@ -55,6 +56,11 @@ vec4 objectColor = vec4(0.0);
vec3 hitCenter = vec3(0.0);
float hitRadius = 0.0;
+vec3 SampleHDRI(vec3 direction)
+{
+ return texture(u_HDRIEnvironment, direction).rgb;
+}
+
float hash(float p)
{
p = fract(p * 0.1031);
@@ -471,7 +477,11 @@ void main()
color = vec4(shaded, objectColor.a);
color = mix(accumulatedColor, color, color.a);
} else
- color = accumulatedColor;
+ {
+ vec3 rayDirection = normalize(vec3(ray.x, ray.y, ray.z) - cam.camPos);
+ vec3 hdriColor = SampleHDRI(rayDirection);
+ color = vec4(mix(accumulatedColor.rgb, hdriColor, 1.0 - accumulatedColor.a), 1.0);
+ }
imageStore(outImage, pix, color);
}