SpiderPig Posted March 11, 2023 Share Posted March 11, 2023 Getting some mixed results with this. There are no double vertices in the mesh any more (99.9% sure ) and this is with model->UpdateNormals(). This is the result. I've outlined the wireframe with red. It seems that if the triangles are really small it gives sharp results. 1 1 Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 11, 2023 Author Share Posted March 11, 2023 I've decided I will write a method that saves a voxel terrains component as a mesh so I can do some more testing on it in a separate program. I'll upload some results and hopefully find what I'm doing wrong. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 11, 2023 Author Share Posted March 11, 2023 Love the Model::Save() method. In blender I confirmed there is no double up on verts, all triangles are sharing what they should be. These are the exported normals. Using blender to recalculate smooth shading gave no visual difference. I thought they should look better than this? Maybe this is another pitfall of marching cubes. Too many small thin triangles! Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 11, 2023 Author Share Posted March 11, 2023 Found this. The normals here don't look too amazing. I think they're smooth shading, kind of looks like it. https://www.youtube.com/watch?v=pI61q7q-2HE Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 11, 2023 Author Share Posted March 11, 2023 I'll admit, once there are textures applied its not too bad. I still think it could be better though. 4 Quote Link to comment Share on other sites More sharing options...
Genebris Posted March 11, 2023 Share Posted March 11, 2023 Yeah, this is not good topology. It's also bad for GPU performance. Can you merge vertices that are too close? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 11, 2023 Author Share Posted March 11, 2023 I agree, its a bit messy. I could merge vertices in a 2nd pass but I think it'll be a bit slow - or maybe it could be done in one pass as I create the vertices... but Surface Nets should make better geometry because the vertices should be relative evenly spaced, and there will be less triangles too. I'm working on it now so should have some results soon. Quote Link to comment Share on other sites More sharing options...
havenphillip Posted March 12, 2023 Share Posted March 12, 2023 A shot in the dark but one thing you could try is multiplying the vertex_position * entitymatrix rather than the vertex_normal * entitymatrix; 1 Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 12, 2023 Author Share Posted March 12, 2023 Thanks I'll try it! Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 13, 2023 Author Share Posted March 13, 2023 I saw here I might need to do a better job at averaging the normals of shared vertices. It says to use the angle to determine the weight that each face's normal will effect the vertex. I tried with the dot product and seemed to get slightly better results but I'm unsure on exactly what the value of "Angle" in this answers code should be. Degrees maybe? or just 0 to 1? Is there a "proper" method of average normals for shared vertices? Usually I just add all the faces normals up that share the vertex and divided by total number of faces that share it. Might be half my problem. Quote Link to comment Share on other sites More sharing options...
Josh Posted March 13, 2023 Share Posted March 13, 2023 If you are doing marching cubes, maybe it is possible to calculate the normals from the underlying volumetric geometry instead of trying to calculate them from the mesh? I mean you lose information when you go from volumetric to mesh, so maybe before losing that information it is possible to calculate normals that should be applied to the mesh? 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted March 13, 2023 Author Share Posted March 13, 2023 Yeah that's a good idea. I briefly looked at getting normals from an SDF in a shader. I think it's just a few extra samples in some known directions... I will try this. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 13, 2023 Author Share Posted March 13, 2023 This is just perplexing. The one on the left was made in blender, the right was exported from marching cubes. Both have flat shading. The left has a few more faces and vertices on the bevel, but, why the odd shading around the triangles on the right? TestCube.zip VoxelTerrain.zip Quote Link to comment Share on other sites More sharing options...
Genebris Posted March 13, 2023 Share Posted March 13, 2023 If I just delete any edge and recreate it the same way, it fixes shading. Can they be connected incorrectly somehow? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 13, 2023 Author Share Posted March 13, 2023 I deleted a few faces and remade them but still the same result. There are no double vertices and they appear to be correctly connected. Quote Link to comment Share on other sites More sharing options...
Genebris Posted March 13, 2023 Share Posted March 13, 2023 Blender shows there are 2 different normals here. If I dissolve the edge and create it, there's now 1 normal vector here and shading is fixed on this edge. I would guess vertices aren't getting split like you would expect. 1 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.