-
Notifications
You must be signed in to change notification settings - Fork 11
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
Voxels and SDF #152
Voxels and SDF #152
Conversation
Used for making voxel textures
Currently has NaN values in the seeding
Thought I'd post an update to show how it is currently working. Currently
Not yet
Changes to CoreHere are some of the changes to core that I added to get everything working
Video(Jerkiness is mostly due to how I am capturing the video) voxel_sdf.mp4 |
I can not compile it with latest rust:
|
Hmm I thought this was now in stable with the merge of this rust-lang/rust#90521 Perhaps I misunderstood. I can probably do it with a three way swap instead but it's not as pretty |
Destructuring assignments were stabalized on 15 Dec 2021 so perhaps we should bump up our version of stable rust |
Just to confirm I updated my rust with rustup to current stable |
Yeah, I had a default setting to 1.57. But now It panics on linux with Intel Iris XE card.
|
Interesting it is panicing in |
crate::BinaryOperator::Add => match *left_ty_inner {
crate::TypeInner::Scalar { kind, .. }
| crate::TypeInner::Vector { kind, .. } => match kind {
crate::ScalarKind::Float => spirv::Op::FAdd,
_ => spirv::Op::IAdd,
},
_ => unimplemented!(),
} Apparently one of the add operations in the shader is not supported, perhaps something is more relaxed on metal when not converting to spv. Do you know which shader file this is? I can try and run naga-cli to cross-compile to spv and trace it down that way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for long response. Too many things happens around...
If we want to merge it, it should be rebased. There were many changes in rendering part already.
I still don't have full understanding of the algorithm, but I like the simplicity of use.
examples/voxel_sdf/main.rs
Outdated
.collect(); | ||
|
||
grid = grid.with_values(values); | ||
world.spawn(vec![(grid, VoxelJumpFlood::default(), TexSdf::default())]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question]
Will it react on change of the grid in runtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet but it should not be hard to implement. All we need to do is delete the sdf texture and seed texture when changes occur.
It is setup to recalculate them when they are missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Live reload is now working checkout the randomize button in the demo
Yeah I understand I really want to work on this more too but I haven't the time either. The algorithm at its core is:
Additional algorithms:Shadows
Ambient occlusions
|
Make sdf update without a texture rebind
…urn identity Matrix fails inversion when scale is zero. In this case it has no size so we can safely use identity as it is a render no-op
Here is it with materials now :) material_voxel.mp4 |
So cool! Have you though about how this functionality can be used for terrain spitted into chunks with loading/unloading? |
Yes I'm going to optimise this as best I can. (Will probably use that render to texture to render shadows and ao in a different pass) Then I'll doing some terrain with it. There are some bigger hurdles with terrains as the render speed decreases the more rays need to be marched and terrain takes up the whole screen. When that's working I plan to take on dynamic clouds you can do some great looking clouds with volumetric rendering techniques. |
WIP Voxels
This is my in progress voxel implementation.
Design
grid
andvoxel
.rs
hold the generic design of the voxel, it is kept separate from its potential usessdf/*
holds components to compute the SDF of the voxel and render that SDFFuture Additions
marching_cubes/*
to compute the marching cubes representation