Kink3d / kMotion

Motion Blur for Unity's Universal Render Pipeline.
MIT License
269 stars 33 forks source link

Help needed #12

Open UserUser510 opened 1 year ago

UserUser510 commented 1 year ago

kMotion doesn't work, even after applying @EsiNikko's hotfixes, and I keep getting these warning logs:

CommandBuffer: temporary render texture _CameraColorTexture not found while executing Motion Blur (Blit source)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

and

CommandBuffer: temporary render texture _CameraColorTexture not found while executing Motion Blur (Blit destination)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Is there a way to fix this issue? (2021.3.6f1)

caogtaa commented 1 year ago

I‘m using 2021.3.6f1 and also applied @EsiNikko's hotfixes. Try following steps:

  1. In MotionBlurRenderPass.cs

    // comment out this line, and use next line
    // var colorTextureIdentifier = new RenderTargetIdentifier("_CameraColorTexture");
    var colorTextureIdentifier = renderingData.cameraData.renderer.cameraColorTarget;
  2. Note Unity 2021.3.6f1 already include source code of kMotion, with same shader name but slightly different implementation (What a surprise!). So Shader.Find() may result finding the wrong version of kMotion shader.
    Change shader name in 1st line of CameraMotionVectors.shader and ObjectMotionVectors.shader. Then In MotionVectorRenderPass.cs, change these lines:

    const string kCameraShader = "Hidden/kMotion/CameraMotionVectors";   // use new shader name
    const string kObjectShader = "Hidden/kMotion/ObjectMotionVectors";   // use new shader name
  3. In ObjectMotionVectors.shader, comment out following lines once you see redefinition warning in Editor log.

    float4x4 unity_MatrixPreviousM;
    float4 unity_MotionVectorsParams;
maxsamarin commented 1 year ago

@caogtaa You are a savior! By downloading @EsiNikko 's version (link) and following all your steps, I got object-based motion blur working with Unity 2022.1.20f1 and URP 13.1.8 🙏

UserUser510 commented 1 year ago

I‘m using 2021.3.6f1 and also applied @EsiNikko's hotfixes. Try following steps:

  1. In MotionBlurRenderPass.cs
    // comment out this line, and use next line
    // var colorTextureIdentifier = new RenderTargetIdentifier("_CameraColorTexture");
    var colorTextureIdentifier = renderingData.cameraData.renderer.cameraColorTarget;
  2. Note Unity 2021.3.6f1 already include source code of kMotion, with same shader name but slightly different implementation (What a surprise!). So Shader.Find() may result finding the wrong version of kMotion shader. Change shader name in 1st line of CameraMotionVectors.shader and ObjectMotionVectors.shader. Then In MotionVectorRenderPass.cs, change these lines:
    const string kCameraShader = "Hidden/kMotion/CameraMotionVectors";   // use new shader name
    const string kObjectShader = "Hidden/kMotion/ObjectMotionVectors";   // use new shader name
  3. In ObjectMotionVectors.shader, comment out following lines once you see redefinition warning in Editor log.
    float4x4 unity_MatrixPreviousM;
    float4 unity_MotionVectorsParams;

thanks