Home Unity

Double sided materials polygons vs shader

Hey everyone, i have come to point where i will have to create lots of props, which will require double sided texture, some even transparent double sided textures.

I know you could technically just copy and flip the polygons in 3d modelling software, or you could used script - shader in unity to make that effect. But what are the pros & cons using these techniques ? Flipping the polygon count would certainly increase the polygon count, but maybe its still better than constantly running a shader script in unity game engine.

I would like to hear possible solutions, advises and experience.:)

-Thank you

Replies

  • EarthQuake
    If you do it manually or in a shader you're rendering the polygons twice, keep that in mind. Depending on exactly what you're doing it may make more sense to just model the shape you want.
  • YoungDeveloper
    Okay, I've heard shadows and some others things are a bit of problematic for such shaders, so they are not that equal. Not saying it's not possible, there are lots of assets which can do this, but it seems its just easier to model those extra polygons, but why then such shaders are being used, if it is harder to set up ?
  • kio
    Offline / Send Message
    kio polycounter lvl 16
    well the shader works on a "global" level - you would have to use different materials to make it work. so most of the time its just more efficient to duplicate the faces you really need - and still draw everything with the same material.
  • electricsauce
    Offline / Send Message
    electricsauce polycounter lvl 11
    I think it depends on what you're rendering. If you have a large piece of cloth it wouldn't hurt to turn off backface culling in the shader. But if you modelled a dragon, which only gives backface problems with the wings, it would make sense to just model the extra faces.
  • Farfarer
    Use the doubled polys if possible, rather than turning off culling in your shader.

    Otherwise the backside won't accept shadows correctly. And it's more expensive to render all polygons with a shader as double-sided than it is to simply render them one-sided and double up only the polys that need it.

    Although if it's being simmed (cloth or such) then you'll probably need a double sided shader.
  • YoungDeveloper
    Thank you everyone for shining a light for me on this one. :)
  • electricsauce
    Offline / Send Message
    electricsauce polycounter lvl 11
    Farfarer wrote: »
    Otherwise the backside won't accept shadows correctly. And it's more expensive to render all polygons with a shader as double-sided than it is to simply render them one-sided and double up only the polys that need it.


    Can you explain what happens to the shadows on the backface that would cause them to render improperly?
  • Vailias
    Offline / Send Message
    Vailias polycounter lvl 18
    There is no backface. There is point data and a computed normal.
    When you have single sided materials the rendering routine culls all faces that face away from the camera. When rendering doublesided it doesn't. It just renders all faces in the object.
    Most shadowing algorithms rely on a face normal (The averaged vertex normal in the plane between any given 3 vertices.). They project a volume against that normal.

    In double sided rendering the face normal is pointing along the front face, so the virtual backside won't accept a shadow as you'd expect because the data isn't there to do it.
    However, if you duplicate those faces which need to be double sided, there will be 2 faces, and so 2 normals to accept shadow projection properly.
  • Farfarer
    The default shaders that cast/recieve shadows won't render backwards facing polygons, meaning they never get written to the buffer, and so you end up getting shadow information for the wrong thing. Either the shadow information of the other, forward facing, side or for whatever's rendered behind the polygon.
Sign In or Register to comment.