3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Make the star the default shape of water sparkles (#2036)
Nguyen Xuan An3ce1f1cc99a0
diff --git a/changes/2036.md b/changes/2036.mdindex 5f56e622..e90a08d7 100644--- a/changes/2036.md+++ b/changes/2036.md@@ -1 +1 @@-- `material.waterGlint` adds a hard-edged sun glint and star or dot sparkles to water, off by default (#2036)+- `material.waterGlint` adds a hard-edged sun glint and star or dot sparkles to water, off by default; sparkles are four-point stars unless `shape` says `dot` (#2036)diff --git a/docs/material-maps.md b/docs/material-maps.mdindex 82a755a0..63614d0c 100644--- a/docs/material-maps.md+++ b/docs/material-maps.md@@ -167,7 +167,7 @@ glTF import maps `alphaMode` MASK and BLEND, `alphaCutoff`, `doubleSided` and `b| `sparkle` | `density` | 0 to 1 (0.35) | Share of cells that carry a sparkle. || `sparkle` | `size` | 0.02 to 2 m (0.12) | Width of a cell on the water, so how big a sparkle is. || `sparkle` | `threshold` | 0.9 to 0.9999 (0.985) | A sparkle lights when its mirror direction has at least this cosine to the sun. Higher is fewer and tighter. |-| `sparkle` | `shape` | `dot` or `star` (`dot`) | Round dot or four-point star. |+| `sparkle` | `shape` | `dot` or `star` (`star`) | Four-point star, or a round dot. || `sparkle` | `twinkle` | 0 to 8 per second (1) | How fast each facet turns; 0 keeps them still, though waves and camera still move them. || `sparkle` | `intensity` | 0 to 4 (1) | Brightness. |diff --git a/src/agent-scene-capabilities.js b/src/agent-scene-capabilities.jsindex 12b79373..f36365b7 100644--- a/src/agent-scene-capabilities.js+++ b/src/agent-scene-capabilities.js@@ -272,7 +272,7 @@ export const AGENT_SCENE_CAPABILITIES = Object.freeze({})]))),materialSubsurface: 'material.subsurface { weight, radius, scale, color } as Blender Principled BSDF Subsurface; surface tag, rasterizer only. Ranges in scene_create.',materialRetro: 'material.retro { vertexSnap [width, height] (whole numbers 16 to 4096), affineUV true }: the PS1 look. vertexSnap rounds each vertex to a width by height screen grid so vertices jitter as the camera moves; affineUV interpolates texture coordinates without perspective correction so textures swim on large triangles. Set either or both. Raster renders only; the path tracer ignores it. Shadows ignore it. A material without retro renders exactly as before.',- materialWaterGlint: 'material.waterGlint { edge { threshold 0.05 to 0.95 (0.4), intensity 0 to 4 (1) }, sparkle { density 0 to 1 (0.35), size 0.02 to 2 m (0.12), threshold 0.9 to 0.9999 (0.985), shape dot | star (dot), twinkle 0 to 8 per second (1), intensity 0 to 4 (1) } } on a water material, both parts off unless named: stylized highlights. edge replaces the soft sun glint with its lobe cut at threshold into a flat hard-edged shape that follows the waves; raise threshold for a smaller shape. sparkle cuts the water into size-metre cells and lights the share given by density whose tilted facet mirrors the sun within threshold (a cosine, higher is fewer and tighter), so sparkles twinkle with the camera, the waves and time and never show on the side away from the sun. Sparkles fade in far water where a cell is under two pixels. Raster renders only; the path tracer ignores it. Painted light streaks are not built yet.',+ materialWaterGlint: 'material.waterGlint { edge { threshold 0.05 to 0.95 (0.4), intensity 0 to 4 (1) }, sparkle { density 0 to 1 (0.35), size 0.02 to 2 m (0.12), threshold 0.9 to 0.9999 (0.985), shape dot | star (star), twinkle 0 to 8 per second (1), intensity 0 to 4 (1) } } on a water material, both parts off unless named: stylized highlights. edge replaces the soft sun glint with its lobe cut at threshold into a flat hard-edged shape that follows the waves; raise threshold for a smaller shape. sparkle cuts the water into size-metre cells and lights the share given by density whose tilted facet mirrors the sun within threshold (a cosine, higher is fewer and tighter), so sparkles twinkle with the camera, the waves and time and never show on the side away from the sun. Sparkles fade in far water where a cell is under two pixels. Raster renders only; the path tracer ignores it. Painted light streaks are not built yet.',materialWear: 'material.wear { mask, threshold 0.5, softness 0.25, metal { color, metallic 1, roughness 0.3 }, dirt { mask, threshold, softness, color, roughness 0.9 } }: the material own color, metallic and roughness are the paint; per pixel it turns to the metal layer where the vertex group mask is high, then to dirt (no metal, rougher) where the dirt group is high. Masks are vertex groups of the node mesh (vertex_group measure edge, curvature or occlusion), so a mesh with no UVs works. Rasterizer only; not with baked sky visibility.',alphaModes: RECIPE_ALPHA_MODES,materialPatterns: MATERIAL_PATTERN_TYPES, maxMaterialPatterns: MAX_MATERIAL_PATTERNS,diff --git a/src/glitter-shader.js b/src/glitter-shader.jsindex 493a9f2b..d77be323 100644--- a/src/glitter-shader.js+++ b/src/glitter-shader.js@@ -7,7 +7,7 @@ import { layerTextureSupport, registerShaderFeatureCode } from './shader-registr// sparkle: glitter on the sun path. The water is cut into cells `size` metres wide. Each cell holds a tiny facet that tilts with the// wave under it and turns over time; it lights up when its mirror direction falls within `threshold` (cosine) of the// sun, so sparkles twinkle as the camera, the waves and the clock move, and none appear on the side away from the sun.-// `density` is the share of cells that carry a facet, `shape` is a round dot or a four-point star.+// `density` is the share of cells that carry a facet, `shape` is a four-point star (the default) or a round dot.// The GLSL lives here, outside world-material-shader.js, so a scene without the field never compiles it: the renderer asks for the// `waterGlint` feature only when a part has the field, and importing this module (or loadAgentSceneModules) registers it.// The code runs in the worldFinal slot, after the water mirror and refraction have been mixed, so the light is not mixed away.@@ -147,7 +147,7 @@ function normalizeEdge(value) {function normalizeSparkle(value) {requireObject(value, 'waterGlint.sparkle', '{ density: 0.35, size: 0.12, shape: "star" }');rejectUnknownKeys(value, 'waterGlint.sparkle', SPARKLE_FIELDS);- const shape = value.shape ?? 'dot';+ const shape = value.shape ?? 'star';if (!WATER_GLINT_SHAPES.includes(shape)) {throw invalidField('waterGlint.sparkle.shape', value.shape, `one of ${WATER_GLINT_SHAPES.join(', ')}, such as "star"`);}diff --git a/tests/glitter-shader.test.js b/tests/glitter-shader.test.jsindex d8cb5195..46f8ad9c 100644--- a/tests/glitter-shader.test.js+++ b/tests/glitter-shader.test.js@@ -79,3 +79,9 @@ test('a material with waterGlint is not snapshotted, so a change to it is seen',test('the capabilities name the fields and the raster-only limit', () => {assert.match(AGENT_SCENE_CAPABILITIES.materialWaterGlint, /edge[\s\S]*sparkle[\s\S]*density[\s\S]*twinkle[\s\S]*path tracer ignores it/);});++test('sparkles are four-point stars unless the shape says dot (#2036)', () => {+ assert.equal(normalizeWaterGlint({ sparkle: {} }).sparkle.shape, 'star');+ assert.equal(normalizeWaterGlint({ sparkle: { density: 0.5 } }).sparkle.shape, 'star');+ assert.equal(normalizeWaterGlint({ sparkle: { shape: 'dot' } }).sparkle.shape, 'dot');+});