Search Unity

Question URP Shadergraph: Dithering Alpha Fade not working on android

Discussion in 'Shader Graph' started by melterx12, Jan 13, 2021.

  1. melterx12

    melterx12

    Joined:
    Jan 20, 2019
    Posts:
    16
    Hi, I am currently working on a project using Unity 2020.2.1f1 and URP. I have a shadergraph node setup that applies a dithering transparency effect to an opaque object using alpha clipping and I am lerping the opacity of the shader using a C# script.

    The game object smoothly fades from opaque to invisible in the editor (Vulkan), but when running an android build (also Vulkan), the gameobject simply just immediately becomes completely invisible as soon as the fading is supposed to start.

    Here is the C# coroutine that handles the fading:

    Code (CSharp):
    1. float objectOpacity = 1f;
    2.  
    3. IEnumerator LerpOpacity(float targetValue, float durationSeconds)
    4.     {  
    5.         if (objectOpacity != targetValue)
    6.         {
    7.             isFaded = true;
    8.             float time = 0f;
    9.             float startValue = objectOpacity;
    10.             while (time < durationSeconds)
    11.             {
    12.                 //Pause color lerping while flashing is occurring.
    13.                 while (isColorFlashing)
    14.                 {
    15.                     yield return null;
    16.                 }
    17.  
    18.                 objectOpacity = Mathf.Lerp(startValue, targetValue, time / durationSeconds);
    19.                 meshRenderer.material.SetFloat("Opacity", objectOpacity);
    20.                 time += Time.deltaTime;
    21.                 yield return null;
    22.             }
    23.             objectOpacity = targetValue;
    24.             meshRenderer.material.SetFloat("Opacity", targetValue);
    25.         }
    26.     }
    Anyone have any insight as to what could be causing this?
     
  2. melterx12

    melterx12

    Joined:
    Jan 20, 2019
    Posts:
    16
    nevermind I figured it out, looks like somehow two of my custom function shader nodes were causing conflicts on android but not in editor.