The native runtime for three.js: three.js, down to the metal. 45× smaller than Electron, on a Sony PS3, and path-traced at 60 fps on ray-tracing GPUs.
Rust electron-alternativegame-engineglobal-illuminationgraphicsjavascript-runtimemetalpath-tracingray-tracingreal-time-renderingrenderingrustthreejstypescriptvoxelvulkanwebgpuwgpu
Comments: the object stride with instance colours (#86)
Yujiaa6d4fcc77dbd
diff --git a/renderer/shaders/gpu_particles.wgsl b/renderer/shaders/gpu_particles.wgslindex eb094f3..e30ee48 100644--- a/renderer/shaders/gpu_particles.wgsl+++ b/renderer/shaders/gpu_particles.wgsl@@ -73,7 +73,7 @@ struct TriAttr { n0: vec4<f32>, n1: vec4<f32>, n2: vec4<f32>, uv: vec4<f32>, t:@group(0) @binding(9) var<storage, read> spawns: array<vec4<f32>>;@group(0) @binding(10) var<storage, read> grid: array<u32>;-const OBJECT_STRIDE: u32 = 3u; // scene.rs OBJECT_STRIDE (particles' objects; no instance colours with them)+const OBJECT_STRIDE: u32 = 3u; // scene.rs `object_stride`: gpu.rs writes 4 here in a scene with instance coloursfn pcg(v: u32) -> u32 {let s = v * 747796405u + 2891336453u;diff --git a/renderer/shaders/particles.wgsl b/renderer/shaders/particles.wgslindex c2e431e..8c2e10d 100644--- a/renderer/shaders/particles.wgsl+++ b/renderer/shaders/particles.wgsl@@ -60,7 +60,7 @@ struct System { a: vec4<u32>, b: vec4<u32>, c: vec4<f32>, p: array<vec4<f32>, 8>// The translucent particles' BLAS input (gpu.rs `Translucent`).@group(0) @binding(8) var<storage, read_write> tblas: array<f32>;-const OBJECT_STRIDE: u32 = 3u; // scene.rs OBJECT_STRIDE+const OBJECT_STRIDE: u32 = 3u; // scene.rs `object_stride`: gpu.rs writes 4 here in a scene with instance coloursfn pcg(v: u32) -> u32 {let s = v * 747796405u + 2891336453u;diff --git a/renderer/src/scene.rs b/renderer/src/scene.rsindex 11b0862..71e2cec 100644--- a/renderer/src/scene.rs+++ b/renderer/src/scene.rs@@ -1101,7 +1101,7 @@ pub fn build(w: &World, assets: &Path, presets_dir: &Path, overrides: Option<&se// Instanced objects' shared meshes by (geometry, GPU material); their flattened instances' triangle ranges.let mut inst_mesh_of: HashMap<(u32, u32), u32> = HashMap::new();let mut tri_instances: Vec<(u32, u32, u32)> = vec![];- // Instance colours anywhere: object entries of 4 vec4s, and the kernel's F_TINT (gpu.rs `tinted_source`).+ // Instance colours anywhere: object entries of 4 vec4s, and the kernel's F_TINT.let tinted = w.instanced.iter().any(|(id, t)| t.colors.is_some() && w.shown(*id) && matches!(w.objects.get(id).map(|o| &o.kind), Some(Kind::Instanced { .. })));let stride = object_stride(tinted);for id in &order {