- Home /
How to change type of shading?
I am generating a mesh procedurally, but I am facing the following problem with shading: When I split a flat parallelogram (highlighted in the figure 3) into triangles, the light reflection doesn't look realistically (figure 1). Is there any way how to change shading from gouraud (if I am right and this is currently set) to flat or phong? Or is the problem somewhere else?
Answer by Kiloblargh · Jan 03, 2014 at 05:45 PM
The shading just interpolates from one vertex to the other. When an imported model has hard edges, what that really means is it has two sets of overlapping vertices in the same place on that edge- one set that goes with one side of the edge, and another set that goes with the other side.
I think the only thing that is going to fix this to your satisfaction is creating a bevel. So instead of a single edge, you have two edges close together. That way the entire light-to-dark gradation will be confined to the small area between the two edges and not "leak" across the entire front face.
I don't envy you having to figure out a procedural edge-beveling algorithm but if you're already procedurally generating architecture, I'm sure you can do it and if this were my project, that's what I'd get started working on now.
Is there any way how to use polygons ins$$anonymous$$d of triangles? This would also solve the problem
No. "Using polygons ins$$anonymous$$d of triangles" is just a way of saying "hiding the fact that you're using triangles" because everything has to become triangles by the time it is fed to the GPU.
@$$anonymous$$iloblargh The problem with your solution is that I would have to create more unnecessary polygons, and this is way I want to avoid.
is it possible to define hard edges? or can there be a problem with normals? (I've used RecalculateNormals()) or smoothing angle?
Hard edges do create extra vertices, because a vertex can only have one normal. A smooth edged cube has 8 verts. A hard edged cube has 24 verts.
This appears to be background geometry. Could you get away with using an unlit, vertex colored shader with pre-baked lighting in the vertex colors? That might give you better control over the shading so you can hide the triangle artifacts and be enough faster than real-time lighting that you can afford more polys.
Your answer
Follow this Question
Related Questions
Custom shader light blending 0 Answers
Generated mesh loses lighting at certain angles 2 Answers
MODEL TURNS BLACK AFTER APPLYING TEXTURE PLS HELP 3 Answers
What are normals? 1 Answer