- Home /
how to render double sided faces
I would like to render both sides of faces, it seems the value in savings on rendering overhead are obvious, so I expected to find a simple way to render two sided.
Alas, it has eluded me, any help?
Duplicate : http://answers.unity3d.com/questions/36609/how-do-i-make-my-game-render-both-sides-of-a-mesh.html
TL;DR : In your shader put "Cull Off"
Answer by Bunny83 · Apr 22, 2015 at 04:58 PM
There is almost no saving of "rendering overhead" when you disable backface culling instead of modelling both sides manually.
Only if you don't need any lighting. That means no shading, no specular highlight, ... just a solid color. In this case you can turn off backface culling in the shader so both sides are rendered the same way.
If you need shading / lighting you either have to:
model the other side as seperate face. (This is the normal, most simplest, most versatile and most used approach).
use a two-pass-shader where pass one renders the front side (so it does backface culling) and pass two renders just the back side (with frontface culling). The second pass would use the inverted normal vector.
Both of those two approaches have some advantages and disadvantages:
Seperate backface Two pass shader
-------------------------------------------------------------------
+ You can adjust all aspects of the face | - Both sides have to use the same
manually. You can use different uv-coords, | Vertex properties. That means
normal and vertex colors for each face | textures would be mirrored on
| the backside.
- If you have a lot double-sides faces you | + If you only have double sided
need a vertex / index buffer with about | faces you can store more faces
double the size. | in a single mesh
* In both cases the computational overhead is almost the same, since the seperate
backface requires an additional face to be rendered and the two pass shader will
render the same face twice which results in the same overhead.
That's why in general it's more convenient to have the backface as seperate face since it allows you to use custom UV coordinates, normals, vertex colors, ... for each face.
The GPU has a rendering pipeline. It's optimised for doing the same operations on huge amount of data. So the saved amount of data when using a two-pass shader is only a marginal gain over the disadvantages that comes with that approach.
In case you don't need any lighting (and in case you use textures it's fine that the backside is mirrored) you can simply turn off backface culling in your shader like mentioned by @watermy above.
Thanks for your very thorough answer, I assumed that one object was preferable to two, but I guess you are right, it would need to render basically the same number of faces either way-
@Teadaddy: Be careful! I never said two objects (which would mean two seperate draw calls). This would be a bad idea, although Unity might batch those two objects into one draw call.
What i meant was to have a mesh that has geometry for both sides.
For example a normal single quad mesh has 4 vertices and 6 indices (2 x 3). A double sided quad that actually has two seperate faces is simply a mesh with 8 vertices and 12 indices (4 vertices for each side and 2 triangles per side == 2 sides 2 triangles 3 indices == 12).
As mentioned above the GPU is a beast. It makes almost no difference if you render a mesh with one triangle or a mesh with 100 triangles.