Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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:
    13,291
    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
     
    funkyCoty, 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,085
    Thanks for the solution!

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

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,291
    Any hints on the changed positionOS ?

    What are we going to use instead ?

    Thanks
     
  6. ImproxGames

    ImproxGames

    Joined:
    Apr 3, 2017
    Posts:
    20
    Also having the issue with positionOS here after upgrading from URP 13.1.8 to URP 14.0.8 (Unity 2022.1 to 2022.3). Can't figure it out, have tried numerous variants of the positionOS spelling such as as position, Position, PositionOS, vertex but nothing works so far

    Meanwhile, does anyone know any alternatives for URP Motion Blur relative to the camera?
     
  7. michael_unity145

    michael_unity145

    Joined:
    Mar 8, 2022
    Posts:
    21
    Upgraded Unity from 2021 to 2022.3.2f1 and URP 14.0.8 and my shaders broke. Syntax error in Shadows.hlsl line 262, any idea what is going on?
     
  8. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,291
    Hi,
    What is the full error ?
     
  9. michael_unity145

    michael_unity145

    Joined:
    Mar 8, 2022
    Posts:
    21
    Invalid conditional expression. at .../Library/PackageCache/com.unity.render-pipelines.universal@14.0.8/ShaderLibrary/Shadows.hlsl(262)
     
  10. csc14ml

    csc14ml

    Joined:
    Mar 10, 2022
    Posts:
    2
    We're seeing the message invalid subscript 'positionOS' as well on a custom shader.
     
  11. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,291
    Hi, try to define the vertex input structure that uses this above the vertex shader, as seems the internal one has the position entry renamed and use the custom defined one instead.