Skip to content

Conversation

@mrdoob
Copy link
Owner

@mrdoob mrdoob commented Nov 10, 2025

Description

I was always curious to see how would it be to convert a mesh into a SDF 3D texture and then render it using MeshStandardMaterial. Finally gave it a try today.

Screen.Recording.2025-11-10.at.9.41.24.PM.mov

mrdoob and others added 9 commits November 10, 2025 05:42
…rt, function or class

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…rt, function or class

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…rt, function or class

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@mrdoob mrdoob changed the title VolumeMesh exploration MeshVolume exploration Nov 12, 2025
@mrdoob
Copy link
Owner Author

mrdoob commented Nov 12, 2025

62k tris mesh converted to a 64³ SDF and instanced 1000 times:

Screenshot 2025-11-13 at 01 34 37

Video: https://x.com/mrdoob/status/1988645523562316241

Comment on lines 127 to 151
// Check if the point is inside or outside by raycasting
// Skip expensive raycasts for points far from surface (definitely outside)
let isInside = false;

if ( dist < this.margin ) {

// If we hit a back face then we're inside
let insideCount = 0;
ray.origin.copy( point );

for ( let i = 0; i < 6; i ++ ) {

ray.direction.copy( directions[ i ] );
const hit = bvh.raycastFirst( ray, DoubleSide );
if ( hit && hit.face.normal.dot( ray.direction ) > 0.0 ) {

insideCount ++;

}

}

isInside = insideCount > 3;

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a note that checking "insidedness" can only really reliably work if the source model is water tight - has no intersecting triangles, etc. Otherwise you might get an odd pos / neg pattern.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good to know!

break;
}

float stepSize = distanceToSurface * 0.5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why halve the step to the surface?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Not sure!

Without it the render would get that near clipping artifact:
https://x.com/mrdoob/status/1987814636306198581

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.

3 participants