Search Unity

Feedback LWRP Lit shader - _BaseColor.alpha with Opaque or Transparent surf type sometimes fades, others not

Discussion in 'Universal Render Pipeline' started by Tarrag, May 26, 2019.

  1. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    215
    I'm trying to fade on runtime the LWRP Lit material - unaltered that comes with the build at install.

    When reducing alpha on albedo color (_BaseColor) for Opaque/Transparent Surface type on the Editor, object does not fade. Then after changing back and forth a few times between Transparent & Opaque Surface type and its alpha level on editor, sometimes pressing play in between, object will fade on Opaque and Transparent.

    Is the object supposed to fade via alpha for lwrp on _BaseColor on Opaque and Transparent or not? Ultimately I'm trying to fade via alpha on runtime.

    After playing on the Editor on runtime and make it work on Transparent surface type, the script will change the color. But the script fails if I don't play on the editor to make fading work first. So, in the case of switching materials at runtime, transparency doesn't work because I didn't switch back and forth first.

    Bug?

    short vid to show this: https://drive.google.com/open?id=1rIK9YXoadEQ-0l8uZp1UKn2Upe_InCdJ

    Cheers,
    Tested on Unity 2019.1.0f2, lwrp 5.7.2, 5.6.1
     
    Last edited: May 27, 2019
  2. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    Hi, could you submit a bug for this. We will take alook at it soon.
     
  3. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    215
    No worries @phil_lira after some tweating got it working :)
     
  4. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    What did you end up doing?
     
  5. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    215
    Hey @phil_lira I played with it for quite a while to get it to work, it's been a few weeks since, sorry I can't remember exactly what made it work but I no longer change the Lit material between opaque and transparent at runtime and it works. I keep it transparent at runtime and change the alpha accordingly.

    at coroutine:
    fadedColor = new Color(fadedColor.r, fadedColor.g, fadedColor.b, fadedColor.a - (Time.deltaTime / t));
    SpecificCurrUISubObjMaterials.SetColor("_BaseColor", fadedColor);
     
  6. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    215
    Hey @phil_lira , I found the sample project in case there was a bug, sorry took quite a bit of digging but was buried in my drive :)
    possible bug sample: https://github.com/sergiosolorzano/LWRPCantChangeAlpha.git

    raised bug case 1164370

    you'd need to play with the cube's material between opaque and transparent and its alpha to see the problem and how it resolves itself.

    Cheers, Sergio