diff options
Diffstat (limited to 'workspaces/main/shaders')
| -rw-r--r-- | workspaces/main/shaders/scene1.wgsl | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/workspaces/main/shaders/scene1.wgsl b/workspaces/main/shaders/scene1.wgsl index a47413b..f6a6c38 100644 --- a/workspaces/main/shaders/scene1.wgsl +++ b/workspaces/main/shaders/scene1.wgsl @@ -6,6 +6,7 @@ #include "math/color" #include "math/utils" #include "math/sdf_shapes" +#include "math/common_utils" #include "render/raymarching" @group(0) @binding(2) var<uniform> uniforms: UniformsSequenceParams; @@ -136,7 +137,7 @@ fn render1(ray: Ray) -> vec3<f32> { let result = rayMarchWithID(ray.origin, ray.direction, init); if (result.distance < MAX_RAY_LENGTH) { - let nsp = reconstructPosition(ray.origin, ray.direction, result); + let nsp = reconstructPosition(ray, result); let nnor = normalWithID(nsp); let nref = reflect(ray.direction, nnor); @@ -149,7 +150,7 @@ fn render1(ray: Ray) -> vec3<f32> { var nrcol = render0(rRay); if (nrt_result.distance < MAX_RAY_LENGTH) { - let nrsp = reconstructPosition(nsp, nref, nrt_result); + let nrsp = reconstructPosition(Ray(nsp, nref), nrt_result); let nrnor = normalWithID(nrsp); let nrref = reflect(nref, nrnor); nrcol = boxCol(nrcol, nrsp, nref, nrnor, render0(Ray(nrsp, nrref)), 1.0, 1.0); @@ -166,19 +167,12 @@ fn render1(ray: Ray) -> vec3<f32> { return col; } -fn effect(p: vec2<f32>) -> vec3<f32> { -// g_rot0 = rot(-0.2 * uniforms.time); - let ray = getCameraRay(camera, p); - return render1(ray); -} - #include "render/fullscreen_vs" @fragment fn fs_main(@builtin(position) p: vec4<f32>) -> @location(0) vec4<f32> { - let q = p.xy / uniforms.resolution; - var coord = -1.0 + 2.0 * q; - coord.x *= uniforms.resolution.x / uniforms.resolution.y; - var col = effect(coord); + let coord = getScreenCoord(p, uniforms.resolution); + let ray = getCameraRay(camera, coord); + var col = render1(ray); col = aces_approx(col); col = sRGB(col); return vec4<f32>(col, 1.0); |
