Search code examples
unity-game-engineshaderurp

Convert custom shader to URP in Unity


I'm working on a VR project in Unity that involves rendering 360 videos inside a sphere GameObject. Originally, the setup worked well using a custom shader that allowed the material to render inside the GameObject, preventing it from going transparent when the camera moved inside it.

After converting the project to the Universal Render Pipeline (URP) and updating all materials accordingly, everything transitioned smoothly except for the material used to display the 360 videos. This specific material is now causing rendering issues, and I'm encountering the following error:

360Material material was not upgraded. There's no upgrader to convert Custom/InsideOut Shader shader to selected pipeline

Here is the code for the shader as well:

Shader "Custom/InsideOut Shader" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
    }
    SubShader {

        Tags { "RenderType" = "Opaque" }

        Cull Off

        CGPROGRAM

        #pragma surface surf Lambert vertex:vert
        sampler2D _MainTex;

        struct Input {
            float2 uv_MainTex;
            float4 color : COLOR;
        };

        void vert(inout appdata_full v) {
            v.normal.xyz = v.normal * -1;
        }

        void surf (Input IN, inout SurfaceOutput o) {
             fixed3 result = tex2D(_MainTex, IN.uv_MainTex);
             o.Albedo = result.rgb;
             o.Alpha = 1;
        }

        ENDCG

    }

      Fallback "Diffuse"
}

Steps taken so far:

  • Converted all materials to URP standards.
  • Attempted to adapt the custom shader for URP compatibility, but with limited success.

I suspect the issue lies in the shader's compatibility with URP, but I'm not certain how to resolve this. Any insights or suggestions on how to adapt the shader for URP or alternative approaches to render 360 videos inside a sphere GameObject in URP would be greatly appreciated!


Solution

  • You have a few options:

    • Create a sphere mesh in blender with the normals reversed.
    • Create a material with the shader set to Univeral Render Pipeline / Unlit and set "Render Face" to "Back". You will then need to update any code that references _MainTex on this material to _BaseMap.
    • Recreate the shader using an unlit shader graph.