- Home /
Procedurally generated mesh half "see through"
Okay, so I am procedurally generating meshes in code. In this case, I have a 255x255 mesh that gets a procedural texture applied to it and the heights are defined by real geo data I am importing. Everything is working great except for some visual artifacts that I am getting when viewing the mesh from one side.
As you can see in the picture, when looking at the mesh from one side I can see through it all the way to the far off peaks. As I rotate around the mesh, this corrects itself along this weird jagged line that I captured in the image. The right side of the image is "correct" and the left side is "see through".
I am guessing that this has something to do with the winding order of my mesh generation or perhaps the normals? Has anyone built their own meshes in code and has an idea? One thing to note, I am texturing the mesh from both sides (top and bottom) as I want to be able to go "below" the terrain and look at it from the bottom.
Answer by Owen-Reynolds · Jun 09, 2013 at 02:41 PM
Most shaders assume you want only a 1-sided mesh. To get 2-sided viewing, change it to Cull Off
. Download the Unity Default shaders, grab whichever you're using and add/change the line.
Winding does tell the shader front vs. back face, and that probably is causing the problem. But if you need 2-sided, that won't matter anyway, so no point fixing it.
I was already using Particles/Alpha Blended which has Cull Off in the shader. That is how I got 2 sided viewing working as is.
The particle shaders I$$anonymous$$HO, have a lot extra going on. A hidden "lifetime" color gradient, which is probably adding the transparency, and messing up the color. I'm thinking they also ignore normals. Then transparency always has depth issues.
If it was me, I'd want to test with the most boring Diffuse shader, then again with cull off.
Got it working. I switched over to using a transparent cutout shader (I needed some fully transparent sections) and then turned culling off. Also, I had my winding backwards so I fixed that for the heck of it even though I am not culling.
Thanks for the help!
Your answer
Follow this Question
Related Questions
Voxel Mesh has Lines Between the Voxels 1 Answer
Do i have to use shared vertices if i want my proceduraly generated mesh to look smooth? 1 Answer
Artifacts / Stretch Marks in Mesh Manipulation 0 Answers
Generating spherical terrain from a spherical heightmap 1 Answer
Procedural mesh with texture atlas, how to get rid of material artifacts? 0 Answers