Skip to content

Instantly share code, notes, and snippets.

@pcwalton
pcwalton / UnityFreeformStretching.md
Last active September 27, 2025 08:13
Unity Freeform Stretching

Unity Freeform Stretching

Revision 2

This note explains how the freeform stretching and rotate with stretch features in Unity's Shuriken ("Legacy") particle system work. It may be useful for those who want to duplicate the effect on the GPU, via Unity's VFX Graph or otherwise. These formulas were obtained through experimentation and, while they seem algebraically equivalent to what Shuriken does, are not the exact operations that Unity uses.

Vector projection of $V$ onto $U$ is notated as $\mathrm{proj}_U(V) = U\frac{V \cdot U}{U \cdot U}$. The magnitude of a vector $V$ is denoted with $||V|| = \sqrt{V \cdot V}$. A normalized vector is notated with $\hat V = \frac{V}{||V||}$.

All these operations are in particle space. That is, we assume that the particle is centered at the origin $(0, 0, 0)$, with its normal facing the +Z directi

@pcwalton
pcwalton / BevyGPUDrivenReleaseNotes.md
Created April 10, 2025 04:10
Bevy GPU-driven release notes

GPU-Driven Rendering

Over the years, the trend in real-time rendering has increasingly been to move work from the CPU to the GPU. One of the latest developments in this area has been GPU-driven rendering, in which the GPU takes a representation of the scene and essentially works out what to draw on its own. While Bevy 0.15 had some support for GPU-driven rendering for meshlets only, Bevy 0.16 features comprehensive support for this technique, including for skinned meshes. This dramatically reduces the amount of CPU time that the renderer needs for larger scenes. It's automatically enabled on platforms that support it; unless your application hooks into the rendering pipeline, upgrading to Bevy 0.16 will automatically enable GPU-driven rendering for your meshes.

To explain how GPU-driven rendering operates, it's easiest to first describe how CPU-driven rendering works:

  1. The CPU determines the objects that are visible, via frustum culling and perhaps occlusion culling.

  2. For each such object:

@pcwalton
pcwalton / BevyFeatures.md
Created January 16, 2025 18:26
Bevy rendering features

Bevy Features

  • wgpu-based renderer
    • Direct3D 12
    • Vulkan
    • OpenGL
    • Metal
    • WebGPU
    • WebGL 2
  • Multithreaded rendering
diff --git a/Cargo.toml b/Cargo.toml
index 7729047..393959d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -39,7 +39,7 @@ name = "ui"
required-features = ["render"]
[dependencies]
-bevy = { version = "0.14.0", default-features = false, features = [
+bevy = { version = "0.15.0-dev", default-features = false, features = [
diff --git a/examples/tools/scene_viewer/scene_viewer_plugin.rs b/examples/tools/scene_viewer/scene_viewer_plugin.rs
index 2ff6af494..52597c1bb 100644
--- a/examples/tools/scene_viewer/scene_viewer_plugin.rs
+++ b/examples/tools/scene_viewer/scene_viewer_plugin.rs
@@ -72,6 +72,7 @@ impl Plugin for SceneViewerPlugin {
Update,
(
update_lights,
+ update_materials,
camera_tracker,
diff --git a/crates/bevy_pbr/src/extended_material.rs b/crates/bevy_pbr/src/extended_material.rs
index a5c46ea6f..39ad33faf 100644
--- a/crates/bevy_pbr/src/extended_material.rs
+++ b/crates/bevy_pbr/src/extended_material.rs
@@ -1,3 +1,5 @@
+use std::marker::PhantomData;
+
use bevy_asset::{Asset, Handle};
use bevy_reflect::{impl_type_path, Reflect};
use bevy_render::{
diff --git a/crates/bevy_pbr/src/meshlet/from_mesh.rs b/crates/bevy_pbr/src/meshlet/from_mesh.rs
index 36af9c445..c6f8c6cff 100644
--- a/crates/bevy_pbr/src/meshlet/from_mesh.rs
+++ b/crates/bevy_pbr/src/meshlet/from_mesh.rs
@@ -23,14 +23,14 @@ impl MeshletMesh {
if mesh.primitive_topology() != PrimitiveTopology::TriangleList {
return Err(MeshToMeshletMeshConversionError::WrongMeshPrimitiveTopology);
}
- let vertex_buffer_layout = &mesh.get_mesh_vertex_buffer_layout();
- if vertex_buffer_layout.attribute_ids()
diff --git a/crates/bevy_pbr/src/meshlet/material_draw_prepare.rs b/crates/bevy_pbr/src/meshlet/material_draw_prepare.rs
index 1fee72d69..fb723a0d5 100644
--- a/crates/bevy_pbr/src/meshlet/material_draw_prepare.rs
+++ b/crates/bevy_pbr/src/meshlet/material_draw_prepare.rs
@@ -9,11 +9,11 @@ use bevy_core_pipeline::{
use bevy_derive::{Deref, DerefMut};
use bevy_render::{
camera::TemporalJitter,
- mesh::{InnerMeshVertexBufferLayout, Mesh, MeshVertexBufferLayout},
+ mesh::{Mesh, MeshVertexBufferLayout, MeshVertexBufferLayoutRef, MeshVertexBufferLayouts},
diff --git a/crates/bevy_pbr/src/light_probe/environment_map.wgsl b/crates/bevy_pbr/src/light_probe/environment_map.wgsl
index 7a6d660e5..2c8390f83 100644
--- a/crates/bevy_pbr/src/light_probe/environment_map.wgsl
+++ b/crates/bevy_pbr/src/light_probe/environment_map.wgsl
@@ -30,10 +30,7 @@ fn compute_radiances(
var radiances: EnvironmentMapRadiances;
// Search for a reflection probe that contains the fragment.
- var query_result = query_light_probe(
- light_probes.reflection_probes,
commit acdae9ee7d92c7bfbbe2d560a3e00039ce5a3380
Author: Patrick Walton <[email protected]>
Date: Mon Feb 5 18:10:52 2024 -0800
wip
diff --git a/crates/bevy_transform/Cargo.toml b/crates/bevy_transform/Cargo.toml
index 8e5e93718..cde746d06 100644
--- a/crates/bevy_transform/Cargo.toml
+++ b/crates/bevy_transform/Cargo.toml