diff --git a/code/renderer/crp_local.h b/code/renderer/crp_local.h index 34c4b24..2bf0041 100644 --- a/code/renderer/crp_local.h +++ b/code/renderer/crp_local.h @@ -69,6 +69,14 @@ struct MotionBlurModes CameraBit = 1 << 0, ObjectBit = 1 << 1 }; + + enum Id + { + None, + CameraOnly = CameraBit, + ObjectOnly = ObjectBit, + Full = CameraOnly + ObjectOnly + }; }; struct Tessellator diff --git a/code/renderer/crp_prepass.cpp b/code/renderer/crp_prepass.cpp index 115462e..344e948 100644 --- a/code/renderer/crp_prepass.cpp +++ b/code/renderer/crp_prepass.cpp @@ -422,6 +422,20 @@ void Prepass::EndBatch() R_InvMatrix(backEnd.modelMatrix, tempMatrix); R_TransposeMatrix(tempMatrix, normalMatrix); + // select the right motion vector code path in the shader for view weapons + // we should identify view weapons directly instead of using the depth hack flag + int mblurMode = crp_mblur->integer; + float mblurScale = batchMotionScale; + if(batchDepthHack && mblurMode == MotionBlurModes::CameraOnly) + { + mblurScale = 0.0f; + mblurMode = 0; // doesn't really matter but shows intent in the root constants + } + else if(batchDepthHack && mblurMode == MotionBlurModes::ObjectOnly) + { + mblurMode = MotionBlurModes::Full; + } + memcpy(rc.modelViewMatrix, backEnd.orient.modelMatrix, sizeof(rc.modelViewMatrix)); memcpy(rc.modelMatrix, backEnd.modelMatrix, sizeof(rc.modelMatrix)); et.CompareEntity(rc.prevModelMatrix, batchEntityId, backEnd.modelMatrix); @@ -434,11 +448,11 @@ void Prepass::EndBatch() rc.normalMatrix[6] = normalMatrix[ 8]; rc.normalMatrix[7] = normalMatrix[ 9]; rc.normalMatrix[8] = normalMatrix[10]; - rc.motionBlurScale = batchMotionScale; + rc.motionBlurScale = mblurScale; rc.textureIndex = texIdx; rc.samplerIndex = sampIdx; rc.alphaTest = alphaTest; - rc.motionBlurMode = crp_mblur->integer; + rc.motionBlurMode = (uint32_t)mblurMode; CmdSetGraphicsRootConstants(0, sizeof(rc), &rc); db.DrawStage(vertexCount, indexCount);