Comments (13)
That results currently in something like this (for sliceHeight=3):
The +/- buttons I added are currently simply incrementing, decrementing sliceHeight on the shader. That would need to change obviously :D
from objtoschematic.
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...
from objtoschematic.
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 😁
from objtoschematic.
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 :)
from objtoschematic.
Firstly you'll need to pass a new uniform variable to the voxel mesh shader called something like u_sliceHeight
, this would be in Renderer._drawBlockMesh
. Then you'll need to modify the vertex shader file block_vertex.vert
to check if the vertex position height is above u_sliceHeight
and if so discard the vertex (or set it's position to (0, 0, 0)).
That leaves actually creating a UI element for a slider that sets the u_sliceHeight
, there's already a SliderUIElement
that could be tweaked and placed on the viewpoint toolbar somewhere.
Hope this helps.
from objtoschematic.
Thanks :) Will check and go on an adventure :D
from objtoschematic.
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:
if(u_sliceHeight > 0.0 && (position.y + u_gridOffset.y) > u_sliceHeight)
{
v_sliced = 1.0;
} else {
v_sliced = 0.0;
}
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.
from objtoschematic.
How would I be able to find the lowest block's starting Y coordinate?
The block mesh is to the renderer in chunks in Renderer.useBlockMeshChunk
, it's passed a RenderNextBlockMeshChunkParams.Output
parameter which contains a dimensions
member variable which is the dimensions of the whole mesh. You can then cache this value somewhere and use it where you need to. An important thing to note is that if dimensions.y
is 35, for example, it means the block mesh is 36 blocks tall.
Hope this helps.
from objtoschematic.
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 u_voxelSize
). So if your u_sliceHeight
is 30, then the bottom vertices will be drawn but the top vertices will be discarded. When you subtract half of each vertex's normal from its position the vertices become (0.0, 30.0, 0.0), (0.0, 30.0, 0.0), (0.0, 30.0, 0.0), (0.0, 30.0, 0.0), (0.0, 30.0, 0.0), (0.0, 30.0, 0.0). Which should then allow you to treat all vertices of the same block in the same manner.
Hope this helps.
from objtoschematic.
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.
from objtoschematic.
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.
from objtoschematic.
Opened PR #104, adding to new /0.8-slice-viewer
branch.
from objtoschematic.
Closed with 901e83e.
from objtoschematic.
Related Issues (20)
- Exported litematic crashes game
- Add override to exceed 380 height limit
- Add chunked exporting to the structure blocks exporter HOT 2
- Unable to export a schem with exceeding approximately 300 Height HOT 1
- problem with TGA images. HOT 1
- Material textures in the Materials section are not correctly disabled HOT 1
- Repeat texture coordinates are somewhat broken
- Some parts of the model do not render unless the camera is moved
- Refactor texture handling, allow .png, .jpg, .bmp, .gif, .webp HOT 1
- Voxel overlap does not work as intended
- Various disabled states for material components are missing styles
- .Vox exporter for voxel meshes
- Collection of objects imported with GLB ignore world positions
- npm package/API HOT 4
- Adding modded blocks
- No human-readable error when assigning blocks with empty block palette
- Error when exporting a block mesh to .litematic that uses a single block
- No tooltips for block palette buttons
- Freeze when click 'Load Mesh' with no mesh selected
- After recoloring the mesh an option to donwload the new recolored model.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objtoschematic.