Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice

Unity 3.5 glass shader?

Discussion in 'Shaders' started by flapyfox, Mar 12, 2012.

  1. flapyfox

    flapyfox

    Joined:
    Sep 9, 2008
    Posts:
    407
    is there any glass shader in Unity 3.5, a shader that combines transparency and reflection like real glass?
     
  2. 3dDude

    3dDude

    Joined:
    Jul 4, 2010
    Posts:
    1,067
    Look on the reference, I think there is a glass shader there.
     
  3. flapyfox

    flapyfox

    Joined:
    Sep 9, 2008
    Posts:
    407
    doubble checked, no glass shader.
    only FX/refractive witch doesn't do reflections (just transparency+bump)
     
  4. 3dDude

    3dDude

    Joined:
    Jul 4, 2010
    Posts:
    1,067
  5. flapyfox

    flapyfox

    Joined:
    Sep 9, 2008
    Posts:
    407
    tried the "simple glass" shader, it has neither transparent neither reflective propreties?
     
  6. 3dDude

    3dDude

    Joined:
    Jul 4, 2010
    Posts:
    1,067
    really?? I gave it a try and it worked fine.. Are you sure it was the right shader?

    Shader "Simple Glass" {
    Properties {
    _Color ("Main Color", Color) = (1,1,1,0)
    _SpecColor ("Spec Color", Color) = (1,1,1,1)
    _Emission ("Emmisive Color", Color) = (0,0,0,0)
    _Shininess ("Shininess", Range (0.01, 1)) = 0.7
    _MainTex ("Base (RGB)", 2D) = "white" { }
    }

    SubShader {
    // We use the material in many passes by defining them in the subshader.
    // Anything defined here becomes default values for all contained passes.
    Material {
    Diffuse [_Color]
    Ambient [_Color]
    Shininess [_Shininess]
    Specular [_SpecColor]
    Emission [_Emission]
    }
    Lighting On
    SeparateSpecular On

    // Set up alpha blending
    Blend SrcAlpha OneMinusSrcAlpha

    // Render the back facing parts of the object.
    // If the object is convex, these will always be further away
    // than the front-faces.
    Pass {
    Cull Front
    SetTexture [_MainTex] {
    Combine Primary * Texture
    }
    }
    // Render the parts of the object facing us.
    // If the object is convex, these will be closer than the
    // back-faces.
    Pass {
    Cull Back
    SetTexture [_MainTex] {
    Combine Primary * Texture
    }
    }
    }
    }
     
  7. flapyfox

    flapyfox

    Joined:
    Sep 9, 2008
    Posts:
    407
    yes, the exact same shader, here is what i did:
    -i opened the "glass-stained-bumpdistort.SHADER" in my project standard assets folder.
    -made a copy, changed the name and copied the "simple glass" shader text.
    -drag and drop it in my unity explorer window.
    -drag it to a default material witch turned into a glass shader.

    I am a CG artist, not much of a shader writer and i know there is a minimum technical level one should have, it would be great if you can clarify the right steps for importing a new shader in Unity (used to doing this in maya witch is a bit different).
     
  8. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,810
    Use the search, ive posted atleast 3-4 different glass shaders and some other people posted nearly as many.
     
  9. MADmarine

    MADmarine

    Joined:
    Aug 31, 2010
    Posts:
    627
    It really confuses me as to why Unity hasn't included a transparent reflective shader by default. There's certainly a high demand for it, I swear we've had around 20-30 threads on this by now.
     
  10. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    I've also been searching for a glass shader with dynamic reflections. I eventually managed to make one, by modifying the MirrorReflective shader/script to include transparency, a base texture, and tinting.

    I made a page for it on the Wiki: http://wiki.unity3d.com/index.php/SurfaceReflection

    It requires Unity Pro, though.
     
    Last edited: Mar 7, 2013
  11. archaismic

    archaismic

    Joined:
    Mar 30, 2011
    Posts:
    10
  12. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,356
unityunity