Search Unity

2 sided material - Backface culling

Discussion in 'Editor & General Support' started by lucaderiu, May 11, 2009.

  1. lucaderiu

    lucaderiu

    Joined:
    May 5, 2009
    Posts:
    4
    Hi, This is my first post here. I noticed there are tons of requests about 2-side material. In effect it's strange there is no a flag to enable/disable this option.
    I noticed lot of artists, here being disappointed about effective modeling 2-side in 3D models, I agree with them.

    Unity is a great engine and optimize by default some things, in this case the back side of the normals.
    The only thing you have to do is simple, you have to disable this optimization. How? Simply add this in your shader's code:

    Cull off

    I suggest you to start reading this page
    http://unity3d.com/support/documentation/Components/SL-Reference.html

    Hope this helps!






    [/code]
     
    iraklisan likes this.
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, but the lighting is wrong on the back side if you do that. Sometimes that's not a problem, but other times modeling two sides is the correct answer.

    --Eric
     
  3. yosh

    yosh

    Joined:
    Mar 13, 2009
    Posts:
    142
    Hi,
    i want to add the "Cull Off" to the Reflective/Specular-BuiltinShader.

    If i add it, i get a syntax-error.
    I´m unexperienced at shader-programming.
    I´ve already tested with it, but no way.

    Can somebody explain it where to put it in?
    Code (csharp):
    1. Shader "Reflective/SpecularBackface" {
    2.     Properties {
    3.         _Color ("Main Color", Color) = (1,1,1,1)
    4.         _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
    5.         _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
    6.         _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
    7.         _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
    8.         _Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect }
    9.  
    10.  
    11.     }
    12.     SubShader {
    13.         UsePass "Reflective/VertexLit/BASE"
    14.         UsePass "Specular/PPL"
    15.         Cull Off
    16.        
    17.     }
    18.     FallBack "Reflective/VertexLit", 1
    19.    
    20.  
    21. }
     
  4. Joe-Robins

    Joe-Robins

    Unity Technologies

    Joined:
    Apr 21, 2008
    Posts:
    430
    Cull Off

    Cull off

    Notice any differences? :)
    My guess is that is what is up
     
  5. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    No, you have to set culling before you do your passes. Just move "Cull off" so that it's the first thing in the SubShader block. With the exception of identifiers and the contents of Cg programs, Shaderlab is case-insensitive.

    I'd like to reiterate that simply turning culling off is not going to work in a lot of cases. It will mess up lighting and shadows. Sometimes you might not notice, but if you need any lighting, it's much better practice to make double-sided models.
     
  6. yosh

    yosh

    Joined:
    Mar 13, 2009
    Posts:
    142
    Thanks for your fast reply.
    I´ve already tested it with "Cull Off and Cull off".
    I think its in the wrong statement of the code, isnt it?

    Although getting the error the inside plane gets red...
     
  7. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    I think you might have missed my reply above.
     
  8. treepixels

    treepixels

    Joined:
    Apr 14, 2012
    Posts:
    3
    How do I access the diffuse shader for editing? or do I create a second blank shader that just renders the opposite side of the mesh? Does this get applied to all objects in game or to a specific one?

    Note: I have a character imported into unity and her jacket hood is single sided, causing it to be see through from the inside. Its already skinned so i cant go back and edit it due to time constraints. I don't mind if the inside is not rendered properly since you rarely see it but i would like it to at least not be invisible.
     
  9. SpaceManDan

    SpaceManDan

    Joined:
    Aug 3, 2013
    Posts:
    15
    Man, thats a lot of work when you can just export a *.dae format and it will just work...
     
  10. A_never_kill

    A_never_kill

    Joined:
    Jan 7, 2014
    Posts:
    81
    from where i can enable and disable backface culling.?
     
    Ebonicus likes this.