Search Unity

LWRP and Video Player with Alpha

Discussion in 'Universal Render Pipeline' started by Netfarm, Jan 29, 2020.

  1. Netfarm

    Netfarm

    Joined:
    Oct 20, 2017
    Posts:
    1
    I'm using this shader to manage a video with alpha in my video player on Unity:

    Code (JavaScript):
    1. Shader "Custom/VideoAlphShader" {
    2.      Properties {
    3.          _Color ("Color", Color) = (1,1,1,1)
    4.          _MainTex ("Albedo (RGB)", 2D) = "white" {}
    5.          _Glossiness ("Smoothness", Range(0,1)) = 0.5
    6.          _Metallic ("Metallic", Range(0,1)) = 0.0
    7.          _Num("Num",float) = 0.5
    8.         _Alpha("Alpha",float) = 1
    9.  
    10.     }
    11.  
    12.     SubShader {
    13.          Tags { "Queue"="Transparent"  "RenderType"="Transparent"  "RenderPipeline" = "LightweightPipeline"}
    14.          LOD 200
    15.  
    16.         CGPROGRAM
    17.      #pragma surface surf NoLighting alpha:auto
    18.  
    19.      fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten)
    20.          {
    21.              fixed4 c;
    22.              c.rgb = s.Albedo;
    23.              c.a = s.Alpha;
    24.              return c;
    25.          }
    26.      float _Num;
    27.      float _Alpha;
    28.  
    29.         sampler2D _MainTex;
    30.  
    31.         struct Input {
    32.              float2 uv_MainTex;
    33.          };
    34.  
    35.         half _Glossiness;
    36.          half _Metallic;
    37.          fixed4 _Color;
    38.          UNITY_INSTANCING_BUFFER_START(Props)
    39.          UNITY_INSTANCING_BUFFER_END(Props)
    40.      void surf (Input IN, inout SurfaceOutput o)
    41.          {
    42.              o.Emission = tex2D(_MainTex, IN.uv_MainTex).rgb;          
    43.            
    44.             if (_Alpha == 1) {
    45.                 if (IN.uv_MainTex.x >= 0.5)
    46.                 {
    47.                     o.Alpha = 0;
    48.                 }
    49.                 else
    50.                 {
    51.                     o.Alpha = tex2D(_MainTex, float2(IN.uv_MainTex.x + 0.5, IN.uv_MainTex.y)).rgb;
    52.                 }
    53.             }
    54.             else {
    55.                 o.Alpha = 0;
    56.             }
    57.         }
    58.          ENDCG
    59.      }
    60.      FallBack "Diffuse"
    61. }
    I want to use LWRP on Unity but if I enable the LWRP this shader doesn't work.
    Is it possible or not? Can I update in some way my shader to work with LWRP?
    Thanks for the help.