Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

beta13 - no alpha value in shaders?

Discussion in 'Unity 5 Pre-order Beta' started by chingwa, Nov 16, 2014.

  1. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    Has anyone noticed an issue with transparent shaders in Unity 5 beta13? (and now beta14 too!)

    I'm not sure if it's a bug, or a change to how Unity is handling things, but I have shaders that use multiple surface shaders that stack on top of each other and blend together using the alpha values for each surface outpu.

    this has always worked fine, but now it seems there is no "alpha" value being written for the surface shaders. :(
     
    Last edited: Nov 24, 2014
  2. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    I found this line in the beta release notes....

    Perhaps a unity tech can shed some light here? My shaders are not marked as opaque, they use the Transparent rendering queue, but unity is still overwriting the set alpha values. If this is a change, and not a bug, how do we use alpha in our surface shaders?
     
  3. jdi_knght

    jdi_knght

    Joined:
    Nov 6, 2013
    Posts:
    25
    I was wondering why my water wasn't transparent anymore! Though I started to get used to the new look, after seeing your post I did some playing. I originally had:

    Code (CSharp):
    1.     Tags {
    2.         "Queue"="Transparent"
    3.         "RenderType"="Transparent"      
    4.          }
    5.        // other junk
    6. #pragma surface surf Lambert noforwardadd
    I added "alpha" to the pragma line and got my alpha channel back.

    Code (CSharp):
    1.     Tags {
    2.         "Queue"="Transparent"
    3.         "RenderType"="Transparent"      
    4.          }
    5.        // other junk
    6. #pragma surface surf Lambert noforwardadd alpha
    Water is now transparent again (until I decide I really liked the old look, that is :p ). Anyway, maybe something similar will work for you.
     
  4. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    Interesting. Thanks for that! My shaders are modulating the alpha information in the Lighting shader though, and this still doesn't seem to work. Even after adding the "Alpha" tag as you described, it only works when I set the "o.Alpha" component in the surface shader... when I try and edit the alpha (based on light amount, or view direction etc.) in the lighting component it simply overwrites it with the original o.Alpha value. :(
     
  5. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    Bumpity bump bump!
     
  6. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    Bump again.

    Seriously is nobody but me setting alpha values in the lighting function? There has not ever been a problem in doing this since at least Unity 3.x, and I'm relying on many of my shaders to work this way.
     
  7. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    bump!
     
  8. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The whole shader system needs more docs really. The amount of trial and error I had to do to learn things for 4.x was a bit much so if any staff could spare a moment with the docs team to really explain the whole thing (particularly custom shaders as there's no built in shader editor) that would be helpful!
     
  9. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    I agree, I think I've spent the majority of my development time wrangling with shader code. and especially now, with the standard shader and the behind-the-scenes shader changes they've made in the latest beta update, we need more documentation and more communcation here.

    Whatever the latest changes were meant to do, they've completely broken my shaders across practically all my projects. And again, it's all directly related to now not being able to set the final alpha value in the lighting function.
     
  10. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    Bump! I just checked this in Beta 14 as well and it's still broken. Again, alpha can only be set in the surface function.... trying to do so in the lighting function has no effect on the final alpha output!
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    This doesn't indicate it's broken though. It indicates it's the new design for it. As I can still output alpha my end (I use vert/frag not surface) I would think you would need to either: request a feature on beta, or rewrite using cg/frag shaders.

    I use alpha channel myself as a blurred pixel buffer - it lets my post fx know which pixels are tagged to be blurred. This works in 5, so I know it's probably down to this new and deliberate change in behaviour.

    That's not broken, it's by design. Why, I have no idea and I'm hoping a greybeard will pop in with the relevant explanations :)
     
  12. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    Yes we need a grey beard here. I don't know how relevant the above line from the release notes is... because I can change alpha values in the surface shader just fine (when it's marked as alpha as shown by jdi_knght above). the problem is specifically in the lighting function and the release notes don't mention this... though, sure, they allude to it... but until proven otherwise I'm treating this as a bug.

    A bug report was submitted this morning... #650679
     
  13. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    And just to be clear, I am not talking about image effects here... I'm talking about normal geometry/texture shaders.