Raycasting and sdfs with webgpu

View on PC/Desktop here: https://ray-tracing-in-one-weekend.vercel.app/

2 Likes

Any chance to view it without signup/login to Vercel?

2 Likes

I believe the thing is behind access control

1 Like

Thanks for pointing that out. I’ve cleared it up. It was a mistake on my end. Please let me know, if it works on your end.

Sorry about that. Its open now. Please let me know if it works on your end


works now. Might be a good idea to explain what we’re seeing here.

I assume there are 3 analytical spheres here with a smooth union operation?

float opSmoothUnion( float d1, float d2, float k )
{
    float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 );
    return mix( d2, d1, h ) - k*h*(1.0-h);
}

Exactly!
And I’m using for(var i: i32; i < sphere_count; i++) { let t = hit_sphere(spheres[i], 0.5, ray_origin, ray_direction); if (t > 0.0) { hit_point = ray_origin + t * ray_direction; normal = normalize(hit_point - spheres[i]); return 0.5 * (normal + vec3f(1.0, 1.0, 1.0)); // Simple shading based on normal } }ray color.
t is the distance along the ray from the origin to an intersection .

Sorry about the formatting, I don’t know how to remove the whitespace.

1 Like

try three backticks, like so

You’ll get

some code goes
here
2 Likes