-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Feat: Ability to view resulting model layer by layer #103
Comments
My naive take would be to limit the resulting mesh to a certain height, settable through a slider. If you could give me one or two hints on where to start looking, I would try to do this :) |
Firstly you'll need to pass a new uniform variable to the voxel mesh shader called something like That leaves actually creating a UI element for a slider that sets the Hope this helps. |
Thanks :) Will check and go on an adventure :D |
OK. Making some progress, but I need a little input if possible please :) I am at a point where the model is cut off X blocks above the grid (the last blocks are cut in half and miss the closing surface, but I hope that changes when my question is answered :D). However my model does not start at y=0. How would I be able to find the lowest block's starting Y coordinate? I need that offset so I can add the number of blocks I want to show in height. I added this to the shader:
where u_sliceHeight would be a value above 0.0 in amount of blocks I want to show in height. the fragment shader discards if v_sliced > 0.5. Setting the position only to 0,0,0 will result in ugly rendering artifacts. |
The block mesh is to the renderer in chunks in Hope this helps. |
As for the other problem what you can do is subtract half of the normal from the vertex to get the actual block position instead of the vertex position. The problem is that if a block is at (0.0, 30.0, 0.0), the vertices are (-0.5, 29.5, -0.5), (0.5, 29.5, -0.5), (0.5, 29.5, 0.5), (-0.5, 29.5, 0.5), (-0.5, 30.5, -0.5), (0.5, 30.5, -0.5), (0.5, 30.5, 0.5), (-0.5, 30.5, 0.5). (That's before they're multiplied by Hope this helps. |
There will most definitely be floating-point precision issues, however, so you'll need to incorperate some nearly equals when checking the height of the normal-corrected vertex as. |
My initial take on this is at mduft@b5328d0 - however I'm unable to cope with the half-block-rendering issue xD I'm completely lost on where to correct the vertex positions, and how to deal with that in the shader. Maybe what I have so far is of use to someone... |
No problem, I can take a look and fix up the rest and get it merged in sometime soon! Thanks for getting this in a good position 😁 |
Heyaaa, that sounds incredible :D It will be easier than ever to build things in minecraft :D Thanks a ton for all the advice (even though that resulted in less lines of code than advice written by you xD), and for having a look at it. Feel free to pick the commit and/or tell me if I should open a PR with the unfinished changes. |
Opened PR #104, adding to new |
Closed with 901e83e. |
I'm building all of my models in survival, most of the time bottom up. Its super helpful in some more complex models to be able to view them layer by layer, much like mineprints.net for example supports.
The text was updated successfully, but these errors were encountered: