Skip to content
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

Chamfer modifier rework #1116

Open
brnkhy opened this issue Oct 30, 2018 · 3 comments
Open

Chamfer modifier rework #1116

brnkhy opened this issue Oct 30, 2018 · 3 comments
Assignees

Comments

@brnkhy
Copy link
Contributor

brnkhy commented Oct 30, 2018

First of all what's chamfer modifier?
Hard to describe in words for me but it's basically this;
chamfer
It adds an extra quad on sharp edges and the shading of this quad (mostly) smoothens the overall look of the mesh.
This is an old shot using current chamfer modifier, you'll probably notice how smooth it looks compared to regular sharp cornered boxes.
dcdvu_xxuaq92zm
I think it looks beautiful and should definitely be used when performance tradeoff is acceptable.

Ok so what's wrong with it? Why the rework?
Leaving possible performance improvements aside, the biggest issue with it is compatibility with other modifiers, especially the building texture modifier. Current chamfer modifier is pretty dominant and works as if it'll be the one and only mesh modifier in the stack. It's like a polygon+height modifier and of course it doesn't work with side wall decorations/texturing as it cretes the side walls itself as well.
Too late I realized that was a huge overkill and I don't need to create side walls to achieve this effect at all. All I had to do is chamfer the corner edges and then let any side wall modifier to do its own thing using old&new wall segmets together.
unity_2018-10-30_14-05-46

So now what's the plan?
As seen in the image above, we only need to change original polygon a little to achieve it so what I'm planning to do is, add this chamfer as a parameter in the polygon modifier. If the value is 0, I'll leave original polygon as is but for any value higher, I'll add the corner vertex smoothing. This will also work with building side wall texturing stuff almost right away.
Almost?
Only problem I found so far is the normal calculation for side wall corners. Chamfer and corner smoothing is a strategy of its own and side wall modifier will have no idea about it so it'll just create sharp corner normals yielding something like this;
dqmpdocw4ae_cgk
Notice how top edges looks smooth and rounded while side edges are sharp? That's because polygon modifier who's aware of the situation creates round normals while side wall modifier has no idea and creates sharp normals by default.
I haven't implemented the solution yet but it shouldn't be too hard really. Polygon mesh modifier already creates normals for the top vertices so we'll cache those and use them as reference in side wall modifier.

It looks like this, before the side edge normal fix at the moment.
Without chamfer;
dqmlunwwkaazmho

With chamfer;
dqmlvb4woaabwuw

Texture bleeding on edges kinda ruins it at the moment but we'll get to that soon as well.

@atripathi-mb @greglemonmapbox @jordy-isaac

@brnkhy brnkhy self-assigned this Oct 30, 2018
@brnkhy
Copy link
Contributor Author

brnkhy commented Oct 30, 2018

It also looks pretty cute on attached buildings;
unity_2018-10-30_15-17-37

@cccprobot
Copy link

Hey all, working on a project with more stylized buildings and we're trying to take advantage of the chamfer (in a situation where textures are not being used). I don't see this available as a parameter and when we apply the modifier to Buildings, it just stops all buildings from extruding at all. Are we missing something or has this not been released into the current SDK?

@brnkhy
Copy link
Contributor Author

brnkhy commented Apr 17, 2019

Hey @cccprobot !
Original chamfer modifier is in the sdk at the moment and I think you can find instructions on it in this ticket; #878
It's a little unintuitive at the moment I'm afraid.

This new version I described above is not live yet as far as I can remember but old one should be rather good as well. Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants