Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Question Massive breaking changes in URP 14.0.6 in Unity 2022.2.11

Discussion in 'Universal Render Pipeline' started by nasos_333, Mar 18, 2023.

  1. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    12,200
    Hi,

    I have two major issues in the latest Unity 2022.2.11 with URP 14.0.6

    I get an error about positionOS

    Shader error in 'Hidden/kMotion/MotionBlur': invalid subscript 'positionOS' at line 44 (on d3d11)

    Code (csharp):
    1.  
    2. Shader "Hidden/kMotion/MotionBlur"
    3. {
    4.     Properties
    5.     {
    6.         _MainTex("Source", 2D) = "white" {}
    7.     }
    8.     HLSLINCLUDE
    9.     // -------------------------------------
    10.     // Includes
    11.     #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
    12.     #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Random.hlsl"
    13.     #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
    14.     #include "Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/Common.hlsl"
    15.     // -------------------------------------
    16.     // Inputs
    17.     TEXTURE2D_X(_MainTex);
    18.     //TEXTURE2D(_MotionVectorTexture);       SAMPLER(sampler_MotionVectorTexture);
    19.     TEXTURE2D_FLOAT(_MotionVectorTexture); SAMPLER(sampler_MotionVectorTexture);
    20.     float _Intensity;
    21.     float4 _MainTex_TexelSize;
    22.     // -------------------------------------
    23.     // Structs
    24.     struct VaryingsMB
    25.     {
    26.         float4 positionCS    : SV_POSITION;
    27.         float4 uv            : TEXCOORD0;
    28.         UNITY_VERTEX_OUTPUT_STEREO
    29.     };
    30.  
    31.     // -------------------------------------
    32.     // Vertex
    33.     VaryingsMB VertMB(Attributes input)
    34.     {
    35.         VaryingsMB output;
    36.         UNITY_SETUP_INSTANCE_ID(input);
    37.         UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
    38.         output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
    39.         float4 projPos = output.positionCS * 0.5;
    40.         projPos.xy = projPos.xy + projPos.w;
    41.         output.uv.xy = input.uv;
    42.         output.uv.zw = projPos.xy;
    43.         return output;
    44.     }
    45.  
    and also an error about sampler_MainLightShadowmapTexture

    "Shader error in 'Unlit/VolumeFogSRP_FORWARD_URP': undeclared identifier 'sampler_MainLightShadowmapTexture' at line 500 (on d3d11)"

    This was declared in Shadows.hlsl in previous versions.

    I checked the URP Shadows.hlsl file and instead declares "sampler_LinearClampCompare".
    Replaceing in my shader the "sampler_MainLightShadowmapTexture" with the declared "sampler_LinearClampCompare" solves the issue.

    Those are massive breaking changes, is it correct to be like this, or is some bug in the new version ?

    Also the latest Graphics github does not have those massively breaking changes

    Thanks in advance for any help on this matter
     
    ROBYER1 and MaxPirat like this.
  2. Ronso007

    Ronso007

    Joined:
    Apr 21, 2019
    Posts:
    8
    I also have the exact same problem.
    It seems that sampler_LinearClampCompare does solve the issue but what happend to sampler_MainLightShadowmapTexture?
     
  3. SyminOmega

    SyminOmega

    Joined:
    Dec 2, 2018
    Posts:
    1
    I just replace my shadow sampler with the "MainLightRealtimeShadow" func which is provided in shadows.hlsl, and it works fine for my project.
     
  4. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,081
    Thanks for the solution!

    Really weird what Unity is doing. It also broke their water system in Boat Attack sample.