Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Alpha Transparency Issues

Discussion in 'General Graphics' started by m_truly, May 2, 2016.

  1. m_truly

    m_truly

    Joined:
    May 6, 2015
    Posts:
    14
    Unity Pro 5.3.4f1

    I have a gradient ramp that causes an object to be opaque in the center and fade out towards the edges. Problem is... the object is not 100% opaque in the center. (See attached images).

    How can I accomplish this effect?

    Thanks for any ideas!
     

    Attached Files:

  2. smd863

    smd863

    Joined:
    Jan 26, 2014
    Posts:
    292
    An alpha-blended material doesn't write into the Z-buffer even when its alpha value is 1. Since it doesn't write into the Z-buffer, the renderer can't tell what pieces of geometry are in front of others so it just renders them on top of each other in the (arbitrary) order they are submitted to the GPU.

    You need to assign two materials to your mesh. Use an opaque material where it is fully opaque, and assign the alpha-blended material only where it starts to fade. You may still run into some problems with certain geometry, but it should work for the example you posted.
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
  4. m_truly

    m_truly

    Joined:
    May 6, 2015
    Posts:
    14
    Thanks very much for the info! I will give these options a try.

    Thanks again.