-
-
Notifications
You must be signed in to change notification settings - Fork 55
Dealing with normals of sharp edges #139
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
Comments
I am not very familiar with this, but I believe there are conflicting desiderata for the representation.
So it seems beneficial to support both.
How are |
I'm not suggesting that this is the representation that should end up on a GPU. Afaik you usually upload your mesh once and try to do all the transformations on the gpu, so reconstructing the flat representation from the compressed one would be a one time cost. I also think the verbose version should still be around and usable if possible .
The current process is using MeshIO/FileIO to load it into a GeometryBasics mesh and to put that on the GPU (in GLMakie). Generally an obj file represents faces as
where |
But "this" representation is what currently ends up on the GPU, right? That's the reason why |
Pretty much, yea. I'm thinking of something like this: (view this as pseudocode) normal_buffer = GLBuffer(mesh.normals[mesh.normal_indices]) where |
I think we should be able to do this with |
Fixed via FaceView |
For a smooth underlying shape, you want normals to vary smoothly as well. That way shading will restore smooth of the curvature that is lost in triangulation. If you have sharp edges though, this effect is undesired. In a cube for example, you want normals to jump when moving from face to face, even if you're looking at the same position.
One way to deal with this is to duplicate vertices (i.e. position and normal) like I did in #36 a while ago. This is the case now for some primitives, like
Rect3D
orPyramind
.(The bottom face has normals in the wrong direction here...)
Other primitives don't do this, like for example
Cylinder
.We could go through all the mesh generating functions and duplicate vertices where needed, but I don't think that a good idea. My concerns are the following:
Rect3D
generates 24 coordinates instead of 8. There are also only 6 unique normals, but we generate 24. That's a lot of extra fat...coordinates
as user. For example, in MakieTeX I needed to transform a 3D bounding box and I thought I could just domap(v -> transform * v, coordinates(bbox))
and then remembered that that is 3x more work than it should be.I think the way to deal with is detach positions, normals, etc, for example by changing faces to have one index per attribute like in obj files. Or by adding some remapping functionality that can map vertex indices (1:24 for Rect3D) to attribute indices (1:8 for positions, 1:6 for normals). Making these changes should also mean that reading obj files (and probably others?) becomes easier. (I think JuliaIO/MeshIO.jl#64 would become unnecessary and we could go back on it, for example.)
The text was updated successfully, but these errors were encountered: