diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-20 15:11:20 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-20 15:11:20 +0100 |
| commit | a64ce13649a01b1b793f3de3b6ef50bf30ce1717 (patch) | |
| tree | cbd86d7ff70ee39f7f8d35f1ef16cdf1cc1522c5 /workspaces/main/shaders/scene1.wgsl | |
| parent | 850388bcaabf057beed8f126002b7b663183b2d8 (diff) | |
feat(scene1): replace ad-hoc camera with CameraParams uniform
Build camera via mat4::look_at + inverse in scene1_effect.cc, upload as
CameraParams at binding 3. Shader uses getCameraRay() from camera_common.
Enable camera_common snippet registration in shaders.cc.
handoff(Claude): Scene1 camera now driven by CameraParams uniform; fov=TAU/6 (60° vFOV) matches original tan(PI/3) parameterization.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'workspaces/main/shaders/scene1.wgsl')
| -rw-r--r-- | workspaces/main/shaders/scene1.wgsl | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/workspaces/main/shaders/scene1.wgsl b/workspaces/main/shaders/scene1.wgsl index 2f1174a..ff21318 100644 --- a/workspaces/main/shaders/scene1.wgsl +++ b/workspaces/main/shaders/scene1.wgsl @@ -2,12 +2,14 @@ // Source: Saturday cubism experiment by skal #include "sequence_uniforms" +#include "camera_common" #include "math/color" #include "math/utils" #include "math/sdf_shapes" #include "render/raymarching" @group(0) @binding(2) var<uniform> uniforms: UniformsSequenceParams; +@group(0) @binding(3) var<uniform> camera: CameraParams; const PI: f32 = 3.141592654; const TAU: f32 = 6.283185307; @@ -178,18 +180,8 @@ fn render1(ro: vec3<f32>, rd: vec3<f32>) -> vec3<f32> { fn effect(p: vec2<f32>) -> vec3<f32> { g_rot0 = rot(-0.2 * uniforms.time); - - let fov = tan(TAU / 6.0); - let ro = vec3<f32>(0.0, 2.5, 5.0); - let la = vec3<f32>(0.0, 0.0, 0.0); - let up = vec3<f32>(0.1, 1.0, 0.0); - - let ww = normalize(la - ro); - let uu = normalize(cross(up, ww)); - let vv = cross(ww, uu); - let rd = normalize(-p.x * uu + p.y * vv + fov * ww); - - return render1(ro, rd); + let ray = getCameraRay(camera, p); + return render1(ray.origin, ray.direction); } #include "render/fullscreen_vs" |
