Skip to content

Examples: Adjust volume instances demo to write to depth #30464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 6, 2025

Conversation

gkjohnson
Copy link
Collaborator

@gkjohnson gkjohnson commented Feb 5, 2025

Related issue: "How do you integrate Signed Distance Fields (SDF) into a basic three.js scene?"

Description

This forum post was asking how to adjust the depth of a shader when rendering via something like raymarching and I noticed there were no examples showing how to do so.

This PR changes the webgl_volume_instancing example to calculate the raymarch ray in the fragment shader so gl_FragDepth can be calculated and assigned. This allows the cubes to intersect (more) correctly in the demo:

image

And with more steps:

image

And intersecting a mesh:

image

@gkjohnson gkjohnson added this to the r174 milestone Feb 5, 2025
@gkjohnson gkjohnson marked this pull request as draft February 5, 2025 14:30
@gkjohnson gkjohnson marked this pull request as ready for review February 5, 2025 15:03
@gkjohnson
Copy link
Collaborator Author

I'm not sure why the screenshot is failing 🤔 Perhaps there are just some graphics differences on my machine. I can copy the as-run "actual" screenshot from artifacts if that's okay.

@Makio64
Copy link
Contributor

Makio64 commented Feb 6, 2025

@gkjohnson not sure its related but on my other pr on compute instance particles i also coudnt generate the new screenshot on my macbook pro m3 max. It seems to happen only on certain webgpu examples for me.

@mrdoob
Copy link
Owner

mrdoob commented Feb 6, 2025

Updated the PR with whatever the CI server is generating 🤷‍♂️

@mrdoob
Copy link
Owner

mrdoob commented Feb 6, 2025

Would you like to update webgl_volume_cloud shader while you're at it? Or in a different PR?

@gkjohnson
Copy link
Collaborator Author

Would you like to update webgl_volume_cloud shader while you're at it? Or in a different PR?

The clouds example accumulates color and opacity over multiple steps so it's a bit more complicated to support depth intersection. Wed need to pass in a depth texture and perform the intersection manually. So I'll have to skip that for now.

@mrdoob
Copy link
Owner

mrdoob commented Feb 6, 2025

Updated the PR with whatever the CI server is generating 🤷‍♂️

Seems like it didn't do the trick... Grr...

@mrdoob mrdoob merged commit 4df9898 into mrdoob:dev Feb 6, 2025
11 checks passed
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