Search Unity

Trying to write BlendMode PropertyDrawer - Blend [BlendMode.y] [BlendMode.z]

Discussion in 'Shaders' started by pnyx, Jul 13, 2018.

  1. pnyx

    pnyx

    Joined:
    Apr 13, 2014
    Posts:
    8
    Hi folks,

    I'm in the process of writing some custom particle shaders and I wanted to make a propertydrawer to control the BlendMode.

    Using two different Variables for the two blend factors isn't really Artist friendly so I thought I could combine it into one variable and set the rest in my property drawer.

    I wanted to avoid writing a whole custom editor so I thought I'd wrap it in a Vector3 and use a PropertyDrawer instead.
    I ran into the problem that [BlendMode.y] always seems to return 0.

    Code (CSharp):
    1. [BlendModePropertyDrawer]
    2. _BlendMode("superblend",Vector ) = (1,1,1)
    3.  
    4. [...]
    5.  
    6. Pass
    7. {
    8.    Blend [_BlendMode.y] [_BlendMode.z]
    9. [...]
    10. }
    This happens even if I set the vector directly without my PropertyDrawer.
    Does anyone have an idea how to access the components of a Vector for such a case? Could not find any examples or documentation on that specific case.

    Cheers
    Simon
     
  2. brownboot67

    brownboot67

    Joined:
    Jan 5, 2013
    Posts:
    375
    I know setting the blend ops with two floats works... I've done that combined with a custom material inspector to do something similar to what you're after.

    You might try initializing the whole vector 4 with some values you know produce something predictable.
     
  3. pnyx

    pnyx

    Joined:
    Apr 13, 2014
    Posts:
    8
    yea, it works with two floats for sure.
    I think the issue is that using this [***.x] syntax the values are not read properly. I tried setting the values in the Vector using the normal inspector but that didn't work either.
    I did find other reasons to write a full custom inspector though, so I'm circumventing the problem now.