Search Unity

transparent meshes

Discussion in 'Shaders' started by Dazzid, Jul 16, 2015.

  1. Dazzid

    Dazzid

    Joined:
    Apr 15, 2014
    Posts:
    61
    Hi All,
    I have some closed meshes of lobes of the brain. I need to make them transparent to see some information generated inside those lobes.
    I've been playing with shaders for a while but always having troubles with depth on rotations, sometimes meshes disappear or they just change the color.
    What shader do you recommend me to use?
    I'm playing with something like this:
    Code (CSharp):
    1. Shader "Simple Glass" {
    2.     Properties {
    3.         _Color ("Main Color", Color) = (1,1,1,1)
    4.         _SpecColor ("Spec Color", Color) = (1,1,1,1)
    5.         _Emission ("Emmisive Color", Color) = (1,1,0,0)
    6.         _Shininess ("Shininess", Range (0.01, 1)) = 0.21
    7.         _MainTex ("Base", 2D) = "white" { }
    8.     }
    9.  
    10.     SubShader {
    11.         // We use the material in many passes by defining them in the subshader.
    12.         // Anything defined here becomes default values for all contained passes.
    13.         Material {
    14.             Diffuse [_Color]
    15.             Ambient [_Color]
    16.             Shininess [_Shininess]
    17.             Specular [_SpecColor]
    18.             Emission [_Emission]
    19.         }
    20.         Lighting On
    21.         SeparateSpecular On
    22.  
    23.         // Set up alpha blending
    24.      
    25.  
    26.         // Render the back facing parts of the object.
    27.         // If the object is convex, these will always be further away
    28.         // than the front-faces.
    29.         Pass {
    30.         Blend SrcAlpha OneMinusSrcAlpha
    31.          Material {
    32.                 Diffuse (0.1,0.1,0.1,1.0)
    33.             }
    34.             Cull Front
    35.             SetTexture [_MainTex] {
    36.                 Combine Primary * Texture
    37.             }
    38.      
    39.         }
    40.         // Render the parts of the object facing us.
    41.         // If the object is convex, these will be closer than the
    42.         // back-faces.
    43.         Pass {
    44.  
    45.             Cull Back
    46.             Blend SrcAlpha OneMinusSrcAlpha
    47.             SetTexture [_MainTex] {
    48.                 Combine Primary * Texture
    49.             }
    50.         }
    51.     }
    52. }

    Actually the shader i like the most is just "Standard" shader, but I have this problem too. One of the meshes disappear while rotating:

     
    Last edited: Jul 16, 2015