Skip to content

fix: Use dynamic loop count for VolumetricFog and TSL soft particles#1167

Merged
braedonsaunders merged 2 commits into
mainfrom
claude/fix-fog-particles-UIIfN
Jan 31, 2026
Merged

fix: Use dynamic loop count for VolumetricFog and TSL soft particles#1167
braedonsaunders merged 2 commits into
mainfrom
claude/fix-fog-particles-UIIfN

Conversation

@braedonsaunders

Copy link
Copy Markdown
Owner

VolumetricFog.ts:

  • Replace hardcoded Loop(32) with Loop(128) + early exit based on uSteps uniform
  • Quality presets now properly control raymarch step count at runtime

AdvancedParticleSystem.ts:

  • Replace MeshBasicMaterial with TSL MeshBasicNodeMaterial
  • Implement soft particle depth-aware alpha fade
  • Add setDepthTexture(), updateCamera(), setSoftness() methods for integration
  • Particles now properly fade when approaching scene geometry

https://claude.ai/code/session_01AKCzEWNpJbJo9dZjBTcNgV

VolumetricFog.ts:
- Replace hardcoded Loop(32) with Loop(128) + early exit based on uSteps uniform
- Quality presets now properly control raymarch step count at runtime

AdvancedParticleSystem.ts:
- Replace MeshBasicMaterial with TSL MeshBasicNodeMaterial
- Implement soft particle depth-aware alpha fade
- Add setDepthTexture(), updateCamera(), setSoftness() methods for integration
- Particles now properly fade when approaching scene geometry

https://claude.ai/code/session_01AKCzEWNpJbJo9dZjBTcNgV
MeshBasicNodeMaterial doesn't accept constructor arguments like regular
materials - properties must be set individually after instantiation.

https://claude.ai/code/session_01AKCzEWNpJbJo9dZjBTcNgV

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f17cebbcd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +544 to +548
// Get screen-space coordinates for depth sampling
const screenUV = viewportCoordinate.xy;

// Sample scene depth and convert to linear
const sceneDepthSample = texture(depthTex, screenUV).r;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Sample depth with normalized viewport UVs

viewportCoordinate is defined in TSL as pixel-space coordinates (see node_modules/three/src/nodes/display/ScreenNode.js around the viewportCoordinate/viewportUV definitions). Passing pixel units directly into texture() means the depth lookup will be out of [0,1] for most fragments and clamp to edges, so the soft-fade will read a near-constant depth and won’t correctly fade near geometry. Use viewportUV (or divide by viewportSize) for normalized sampling.

Useful? React with 👍 / 👎.

Comment on lines +554 to +556
// Get particle's linear depth from gl_FragCoord.z
const particleNDC = viewportCoordinate.z.mul(2.0).sub(1.0);
const particleLinearDepth = near.mul(far).div(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid swizzling .z from viewportCoordinate

viewportCoordinate is a vec2 in TSL (pixel-space x/y), so viewportCoordinate.z is an invalid swizzle. This will emit an invalid shader expression or undefined value for the particle depth, breaking the linear-depth calculation and potentially failing material compilation. Use a depth-specific node like viewportDepth/viewportLinearDepth or another supported fragment-depth source instead.

Useful? React with 👍 / 👎.

@braedonsaunders braedonsaunders merged commit 024e5ed into main Jan 31, 2026
4 checks passed
@braedonsaunders braedonsaunders deleted the claude/fix-fog-particles-UIIfN branch January 31, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants