Search Unity

Question About BoxProjection in URP and supporting SRPBatcher

Discussion in 'Shaders' started by wechat_os_Qy00tzDZ4PUDCm8OdzDBV64IA, Jul 9, 2021.

  1. wechat_os_Qy00tzDZ4PUDCm8OdzDBV64IA

    wechat_os_Qy00tzDZ4PUDCm8OdzDBV64IA

    Joined:
    Mar 16, 2019
    Posts:
    3
    I am trying to use BoxProjection on URP 10.4.0 and I understand that it is not officially supported on URP.

    I've tried to do this by adding the following code

    float4 unity_SpecCube0_ProbePosition;

    float4 unity_SpecCube0_BoxMin;

    float4 unity_SpecCube0_BoxMax;

    BoxProjection rendering is successful;

    The problem is, I don't know how to support it with the SRP Batcher.

    If I place them outside of the CBuffer, it will report the error "Build property found in another CBuffer than "(unityPerDraw) (unity_speccube0_probePosition)"

    If I put them in CBuffer unityPerDraw, in UnityInput.HSL, error is "create attribute offset in CBuffer, not phase"

    Does anyone know how to solve this problem?Thank you so much!
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Box projected reflection probe support was added to URP 12, so if you update to the latest alpha version of the editor that should be available already.

    Alternatively the uniforms need to be added to the UnityPerDraw CBuffer, which is a problem because Unity already defines the UnityPerDraw CBuffer without those values in it. You'd have to make a copy of the existing UnityInput.hlsl file, add the additional values to the UnityPerDraw CBuffer in your copy, and #include that file instead of the built in one.
     
  3. wechat_os_Qy00tzDZ4PUDCm8OdzDBV64IA

    wechat_os_Qy00tzDZ4PUDCm8OdzDBV64IA

    Joined:
    Mar 16, 2019
    Posts:
    3
    Thanks for your advice, I really did as you said, I made a copy of UnityInput.HLSL file, and put it in my own ShaderLibrary, and fixed a few # including order errors, it still reports bugs like this.Anyway thanks for you help, maybe I should try to update my URP version.
    upload_2021-7-13_16-8-29.png "