Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
JoshuaVe's avatar
JoshuaVe
Protege
2 years ago
Solved

OVROverlay, underlays and Universal Render Pipeline (URP) doesn't work?

Has anyone gotten that combination of things to work?  Overlay works just fine with URP, so I'm assuming it's my attempts to punch out a hole that are failing.  I'm assuming Oculus' shader doesn't work with URP, as it renders pink in the preview -- but hey, maybe I'm wrong.

I've tried updating it to URP, and I've tried using a URP/Transparent shader, as I believe it's basically the same thing.  

I've tried using Render Object on the Universal Render Asset to ensure that we render at the proper time to punch a hole.  I set my Quad object to be on the Layer for the Render Object's LayerMask, and set the event to be After Rendering Opaques, and to override Depth, Write Depth, and Depth Test Greater.  That should result in it render my quad over anything that might be in the way... right?  I also tried Depth Test Always -- which should really always render my transparent thing and write it's depth.

But nothing every shows up on my Quest 2 when I'm set to Underlay.  (if I turn off rendering everything else in the scene, it works and I see it.)

  • Okay, got it working, was a foreheadslapper where I'd forgotten I'd turned off a certain Layer on my camera -- the exact layer I was rendering my punchout quad on... eyeroll.

    My final URP punchout shader is fairly simple, I can share if anyone is curious.

     

6 Replies

Replies have been turned off for this discussion
  • Okay, got it working, was a foreheadslapper where I'd forgotten I'd turned off a certain Layer on my camera -- the exact layer I was rendering my punchout quad on... eyeroll.

    My final URP punchout shader is fairly simple, I can share if anyone is curious.

     

    • lohini.messa's avatar
      lohini.messa
      Honored Guest

      Hello, Can you share your punchout shader?

      I was trying to use Oculus SDk's Underlay Impostor shader but it doesn't work with URP.

      Thank you.

      • JoshuaVe's avatar
        JoshuaVe
        Protege
        Properties {
        		_MainTex ("Albedo", 2D) = "white" {}
        	}
        
        	SubShader {
        		Tags {
        			"Queue" = "Transparent"
        			"IgnoreProjector" = "True"
        			"RenderType" = "Transparent"
        			"RenderPipeline" = "UniversalPipeline"
        		}
        
        		Blend DstColor Zero
        		Lighting Off
        		ZWrite On
        		ZTest LEqual
        
        		Pass {
        			Name "Forward"
        			Tags { "LightMode" = "UniversalForward" }
        			HLSLPROGRAM
        
        			#pragma vertex vert
        			#pragma fragment frag
        
        			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
        
        			sampler2D _MainTex;
        
        			CBUFFER_START(UnityPerMaterial)
        			float4 _MainTex_ST;
        			CBUFFER_END
        
        			struct vertexIn
        			{
        				float4 vertex : POSITION;
        				float2 texCoord : TEXCOORD0;
        				UNITY_VERTEX_INPUT_INSTANCE_ID
        			};
        
        			struct vertexOut
        			{
        				float4 vertex : SV_POSITION;
        				float2 texCoord : TEXCOORD0;
        				UNITY_VERTEX_OUTPUT_STEREO
        			};
        
        			vertexOut vert(vertexIn v)
        			{
        				vertexOut output;
        
        				UNITY_SETUP_INSTANCE_ID(v);
        				UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
        
        				VertexPositionInputs vertexInputs = GetVertexPositionInputs(v.vertex.xyz);
        				output.vertex = vertexInputs.positionCS;
        				output.texCoord = TRANSFORM_TEX(v.texCoord, _MainTex);
        				return output;
        			}
        
        
        			half4 frag(vertexOut input) : SV_Target
        			{
        				half4 outColor = tex2D(_MainTex, input.texCoord);
        				clip( outColor.a < 0.1f ? -1:1 );
        				return half4(outColor.xyz, 0);
        			}
        
        			ENDHLSL
        		}
        	}
  • It's a pretty simple shader, I adapted it from one on Unity's documentation.  If you don't need transparency in your output image, you can lose the clip.