11import { convertRgbToY } from '@typegpu/color' ;
22import { accessViewportSize } from '@typegpu/common' ;
3- import { DefaultGenerator , rand } from '@typegpu/noise' ;
3+ import { randf } from '@typegpu/noise' ;
44import { atom } from 'jotai' ;
55import {
66 Camera ,
@@ -50,8 +50,12 @@ export const accumulatedLayersAtom = atom(0);
5050 * @param mat_roughness
5151 */
5252const reflect = tgpu [ '~unstable' ]
53- . fn ( [ d . vec3f , d . vec3f , d . f32 , d . ptrFn ( d . f32 ) ] )
54- . does ( `(ray_dir: vec3f, normal: vec3f, mat_roughness: f32, out_roughness: ptr<function, f32>) -> vec3f {
53+ . fn ( [
54+ d . vec3f ,
55+ d . vec3f ,
56+ d . f32 ,
57+ d . ptrFn ( d . f32 ) ,
58+ ] ) ( `(ray_dir: vec3f, normal: vec3f, mat_roughness: f32, out_roughness: ptr<function, f32>) -> vec3f {
5559 let slope = dot(ray_dir, normal);
5660 let dn2 = 2. * slope;
5761 let refl_dir = ray_dir - dn2 * normal;
@@ -64,7 +68,7 @@ const reflect = tgpu['~unstable']
6468 new_ray_dir = mix(refl_dir, new_ray_dir, roughness);
6569 return normalize(new_ray_dir);
6670 }` )
67- . $uses ( { randOnHemisphere : rand . onHemisphere } )
71+ . $uses ( { randOnHemisphere : randf . onHemisphere } )
6872 . $name ( 'reflect' ) ;
6973
7074const renderSubPixel = tgpu [ '~unstable' ]
@@ -185,12 +189,11 @@ const mainComputeFn = tgpu['~unstable']
185189 . computeFn ( {
186190 workgroupSize : [ BlockSize , BlockSize ] ,
187191 in : { gid : d . builtin . globalInvocationId } ,
188- } )
189- . does ( /* wgsl */ `(input: Input) {
190- setupRandomSeed(vec2f(input.gid.xy) * ${ Math . random ( ) } + getRandomSeedPrimer * ${ Math . random ( ) } );
192+ } ) ( /* wgsl */ `{
193+ setupRandomSeed(vec2f(in.gid.xy) * ${ Math . random ( ) } + getRandomSeedPrimer * ${ Math . random ( ) } );
191194
192195 let prev_layers = getAccumulatedLayers;
193- let prev_render = textureLoad(previousRender, input .gid.xy, 0);
196+ let prev_render = textureLoad(previousRender, in .gid.xy, 0);
194197
195198 var acc = vec3f(0., 0., 0.);
196199 for (var sx = 0u; sx < SUPER_SAMPLES; sx++) {
@@ -200,7 +203,7 @@ const mainComputeFn = tgpu['~unstable']
200203 (f32(sy) + 0.5) * ONE_OVER_SUPER_SAMPLES,
201204 );
202205
203- acc += renderSubPixel(vec2f(input .gid.xy) + offset);
206+ acc += renderSubPixel(vec2f(in .gid.xy) + offset);
204207 }
205208 }
206209
@@ -215,14 +218,14 @@ const mainComputeFn = tgpu['~unstable']
215218 new_render = (prev_render * prev_layers + vec4(acc, 1.0)) / (prev_layers + 1);
216219 }
217220
218- textureStore(mainOutput, input .gid.xy, new_render);
221+ textureStore(mainOutput, in .gid.xy, new_render);
219222 }` )
220223 . $uses ( {
221224 SUPER_SAMPLES ,
222225 ONE_OVER_SUPER_SAMPLES ,
223226 previousRender : mainLayout . bound . previousRender ,
224227 mainOutput : mainLayout . bound . mainOutput ,
225- setupRandomSeed : DefaultGenerator . seed ,
228+ setupRandomSeed : randf . seed2 ,
226229 renderSubPixel,
227230 getRandomSeedPrimer,
228231 getAccumulatedLayers,
@@ -238,8 +241,7 @@ const auxComputeFn = tgpu['~unstable']
238241 . computeFn ( {
239242 workgroupSize : [ BlockSize , BlockSize ] ,
240243 in : { gid : d . builtin . globalInvocationId } ,
241- } )
242- . does ( /* wgsl */ `(input: Input) {
244+ } ) ( /* wgsl */ `{
243245 let offset = vec2f(
244246 0.5,
245247 0.5,
@@ -249,7 +251,7 @@ const auxComputeFn = tgpu['~unstable']
249251 var shape_ctx: ShapeContext;
250252 shape_ctx.rayPos = constructRayPos();
251253 shape_ctx.rayDir = constructRayDir(
252- vec2f(input .gid.xy) + offset
254+ vec2f(in .gid.xy) + offset
253255 );
254256 shape_ctx.rayDistance = 0.;
255257
@@ -288,7 +290,7 @@ const auxComputeFn = tgpu['~unstable']
288290
289291 // TODO: maybe apply gamma correction to the albedo luminance parameter??
290292
291- textureStore(auxOutput, input .gid.xy, aux);
293+ textureStore(auxOutput, in .gid.xy, aux);
292294 }` )
293295 . $uses ( {
294296 MAX_STEPS : MarchParams . maxSteps ,
0 commit comments