fixed the view weapon motion vectors

This commit is contained in:
myT 2024-07-27 02:25:35 +02:00
parent 75466f3be0
commit 9712ffb17d
2 changed files with 24 additions and 2 deletions

View file

@ -69,6 +69,14 @@ struct MotionBlurModes
CameraBit = 1 << 0,
ObjectBit = 1 << 1
};
enum Id
{
None,
CameraOnly = CameraBit,
ObjectOnly = ObjectBit,
Full = CameraOnly + ObjectOnly
};
};
struct Tessellator

View file

@ -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);