Skip to content
Draft
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
50139b2
Make basic raytracing work. Barebones proto
TheBlek Oct 16, 2025
c761e9a
Remove unused temp geometry, cleanup
TheBlek Oct 16, 2025
132139e
Pass basic material information to compute shader
TheBlek Oct 16, 2025
3fbb983
Add randomness, accumulate color over multiple bounces, lambert brdf
TheBlek Oct 18, 2025
ebf4b1d
Get working basic version of accumulation
TheBlek Oct 21, 2025
394d17e
Fix cosine sampling pdf value
TheBlek Oct 21, 2025
a4df761
Fix getVertexAttribute missing from dependencies. Add console.log wit…
Oct 22, 2025
7bf3fc4
Written basic scaffolding for wavefront pathtracer. Added a little me…
TheBlek Oct 24, 2025
de42afc
Use a buffer to store intermediate state for pathtracing instead of a…
TheBlek Oct 24, 2025
c0b3a08
Display total sample count in the bottom
TheBlek Oct 24, 2025
577df8e
Create a rough outline for wavefront workflow
TheBlek Oct 25, 2025
2a5a756
Move to 0.9.2; write all the needed kernels. tsl is broken for now.
Oct 27, 2025
401a6a0
Fix all compilation error except for the buffer size.
TheBlek Oct 29, 2025
bdd9dfd
Pack HitResult to fit into 128mb buffer
Nov 11, 2025
f0401be
Fix wavefront demo. It works now. No cleanup
TheBlek Nov 14, 2025
aef28fe
Create new computeKernel nodes on geometry change.
TheBlek Nov 15, 2025
5b15ae7
Cleanup.
TheBlek Nov 15, 2025
4a50400
Restore PhysicalPathTracingMaterial
TheBlek Nov 15, 2025
cd71365
Merge remote-tracking branch 'origin/main' into webgpuPrototype
gkjohnson Nov 16, 2025
7774d04
Move webgpu shaders into separate files.
TheBlek Nov 17, 2025
0bb6557
Use three.js's compute indirect feature. Add more comments.
TheBlek Nov 17, 2025
f1c51bc
Make rng state global.
TheBlek Nov 29, 2025
7422510
Rename reset node.
TheBlek Nov 29, 2025
e34c73a
Fix rng generator state in wavefront case.
TheBlek Nov 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions example/webgpu_primitives.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<html>
<head>
<title>Basic Primitives Path Tracing Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

<style>
html, body {
margin: 0;
padding: 0;
background-color: #eee;
}

#info {
position: absolute;
bottom: 0;
left: 0;
font-family: 'Courier New', Courier, monospace;
color: white;
pointer-events: none;
}

#samples, #credits {

opacity: 0.5;
background-color: rgba( 0.0, 0.0, 0.0, 0.5 );
padding: 5px;
display: inline-block;

}
</style>

</head>
<body>
<div id="info">
<div>
<div id="samples">--</div>
</div>
</div>
<script src="./webgpu_primitives.js" type="module"></script>
</body>
</html>
111 changes: 111 additions & 0 deletions example/webgpu_primitives.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { Scene, SphereGeometry, MeshStandardMaterial, Mesh, BoxGeometry, PerspectiveCamera, ACESFilmicToneMapping, WebGPURenderer } from 'three/webgpu';
import { WebGPUPathTracer, GradientEquirectTexture } from '../src/index.js';
import { getScaledSettings } from './utils/getScaledSettings.js';
import GUI from 'three/examples/jsm/libs/lil-gui.module.min.js';

const options = {
useMegakernel: true,
};

// init scene, renderer, camera, controls, etc
const scene = new Scene();
const sphereGeom = new SphereGeometry( 0.49, 64, 32 );
const ball1 = new Mesh(
sphereGeom,
new MeshStandardMaterial( {
color: '#e91e63',
roughness: 0.25,
metalness: 1,
} )
);
const ball2 = new Mesh(
sphereGeom,
new MeshStandardMaterial( {
color: '#ff9800',
roughness: 0.1,
metalness: 1,
} )
);
const ball3 = new Mesh(
sphereGeom,
new MeshStandardMaterial( {
color: '#2196f3',
roughness: 0.2,
metalness: 1,
} )
);
const ground = new Mesh(
new BoxGeometry( 3.5, 0.1, 1.5 ),
new MeshStandardMaterial( { color: '#f0f0f0' } ),
);

ball1.position.x = - 1;
ball3.position.x = 1;
ground.position.y = - 0.54;
scene.add( ball1, ball2, ball3, ground );

// set the environment map
const texture = new GradientEquirectTexture();
texture.bottomColor.set( 0xffffff );
texture.bottomColor.set( 0x666666 );
texture.update();
scene.environment = texture;
scene.background = texture;

const camera = new PerspectiveCamera();
camera.position.set( 0, 1, - 5 );
camera.lookAt( 0, 0, 0 );

const renderer = new WebGPURenderer( { antialias: true } );
renderer.toneMapping = ACESFilmicToneMapping;
document.body.appendChild( renderer.domElement );
renderer.setDrawingBufferSize( 1920, 1080, 1 );

const settings = getScaledSettings();
const pathTracer = new WebGPUPathTracer( renderer );
pathTracer.renderScale = settings.renderScale;
pathTracer.tiles.setScalar( settings.tiles );
pathTracer.setScene( scene, camera );

const gui = new GUI();

gui.add( options, 'useMegakernel' ).onChange( () => {

pathTracer.useMegakernel( options.useMegakernel );

} );


onResize();

animate();

window.addEventListener( 'resize', onResize );

function animate() {

// if the camera position changes call "ptRenderer.reset()"
requestAnimationFrame( animate );

// update the camera and render one sample
pathTracer.renderSample();

}

function onResize() {

return;
// update rendering resolution
const w = window.innerWidth;
const h = window.innerHeight;

renderer.setSize( w, h );
renderer.setPixelRatio( window.devicePixelRatio );

const aspect = w / h;
camera.aspect = aspect;
camera.updateProjectionMatrix();

pathTracer.setScene( scene, camera );

}
19 changes: 10 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"rollup": "^2.70.0",
"simple-git": "^3.10.0",
"three": "^0.181.1",
"three-mesh-bvh": "^0.7.4",
"three-mesh-bvh": "^0.9.2",
"typescript": "^5.9.2",
"vite": "^6.2.2",
"yargs": "^17.5.1"
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ export * from './materials/surface/FogVolumeMaterial.js';
// deprecated
export * from './materials/pathtracing/PhysicalPathTracingMaterial.js';
export * from './core/PathTracingRenderer.js';

// webgpu
export * from './webgpu/WebGPUPathTracer.js';
Loading