Search Unity

Opacity slider

Discussion in 'Shaders' started by apelleti2, Dec 3, 2010.

  1. apelleti2

    apelleti2

    Joined:
    Dec 3, 2010
    Posts:
    6
    So Im pretty new to ShaderLab and scripting in general and Ive been reading through the tutorials and the one thing I noticed is that with shaders there really isnt any sort of opacity slider or float that we can put in from 0-1 that will change the opacity of a material. Is there a way to implement this into a shader to adjust the opacity of a material?
     
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    To make semitransparent materials, you can use the built-in Transparent family of shaders. The alpha channel of the main texture is multiplied by the alpha of the main colour, and the result is used for opacity in the shader.
     
  3. apelleti2

    apelleti2

    Joined:
    Dec 3, 2010
    Posts:
    6
    thanks. But there is no way to have a slider in the inspector of the material like in the hypershader of maya?
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you can if you write an own shader that wastes performance to use a float for range then you can specify it with a number.

    normally the texture is used becuase it allows you to specify transparency per pixel and in an art program
     
  5. apelleti2

    apelleti2

    Joined:
    Dec 3, 2010
    Posts:
    6
    thanks. You guys have been a great help
     
  6. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Properties don't have a significant performance cost, but they do need to bear some relation to how the shader works. Adding a separate alpha slider when there is already a perfectly good alpha value in the main colour is inefficient.