Unity 2022.2.16 URP 14.0.7 I make a custom scriptable renderer pass to render a showmap, then on shader i get shadow via SAMPLE_TEXTURE2D_SHADOW, is work OK in Editor and PC,but when i build to a Android run on mobile, the sample result is all black. I check the shadowmap renderTexture on the Frame Debuger and it is correct rendering on mobile, so just sample incorrect i guess. it maybe something wrong in other space. shadowmap on framer debuger,it look ok half GetHardShadow(float4 shadowCoord){ float3 uv = shadowCoord.xyz / shadowCoord.w; uv.xy = uv.xy * 0.5 + 0.5; if(uv.x<0 || uv.x>1 || uv.y<0 || uv.y>1) return 1.0f; //SAMPLE_TEXTURE2D_X can sample correct,but not the way i need // float atten = SAMPLE_TEXTURE2D_X(_MainLightShadowmapTexture, sampler_MainLightShadowmapTexture, uv); half atten = SAMPLE_TEXTURE2D_SHADOW(_MainLightShadowmapTexture, sampler_LinearClampCompare, uv ).r; return atten; //this alway return 0 on Android mobile,but correct value on PC atten = LerpWhiteTo(atten, _shadowStrength); return atten; } [ATTACH=full]1250218[/ATTACH] Code (CSharp): var format = UnityEngine.Experimental.Rendering.GraphicsFormatUtility.GetDepthStencilFormat(16, 0); rtd = new RenderTextureDescriptor(mainLightShadowResolution, mainLightShadowResolution, UnityEngine.Experimental.Rendering.GraphicsFormat.None, format); rtd.shadowSamplingMode =(RenderingUtils.SupportsRenderTextureFormat(RenderTextureFormat.Shadowmap)&& (SystemInfo.graphicsDeviceType != GraphicsDeviceType.OpenGLES2)) ?ShadowSamplingMode.RawDepth : ShadowSamplingMode.None; cmd.SetRenderTarget(ri_main_ID, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store); cmd.ClearRenderTarget(true, true, Color.clear);
and i got another truble on build to mobile,is my shadowcaster pass shader variants may all strip on build. i got a log like: STRIPPING: Universal Render Pipeline/CustomPBRLit (CustomShadowCaster pass) (Vertex) - Remaining shader variants = 0/2 = 0% - Total = 1175/79756 = 1.473243% TimeMs=0.2085 it means all the shadowcaster pass variants striped, it's no variants genetate!
i test with a new Phone (xiaomi k20 api:Vulkan) today and it's run OK now. i'm confuse if it the last phone's(nexus 6p api:OpenGl) problem, the different of Graphic API ?