Merge pull request #1603 from NZJenkins/texbem_stage

Bumpmap bias tweaks
This commit is contained in:
PatrickvL 2019-05-15 07:14:33 +02:00 committed by GitHub
commit 55c015c1b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -2958,7 +2958,7 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS
if (m_PSVersion >= D3DPS_VERSION(1, 4))
{
// If the bump-map texture format is X_D3DFMT_X8L8V8U8 or X_D3DFMT_L6V5U5 we need to apply a bias
// If the bump-map texture format is X_D3DFMT_X8L8V8U8 or X_D3DFMT_L6V5U5 we need to apply a bias
// This happens because these formats are an alias of unsigned texture formats.
// Fixes an issue with the JSRF boost-dash effect
// NOTE: This assumes that this shader will only ever be used for the input bumpmap texture
@ -2966,9 +2966,11 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS
// and include the texture formats in the shader hash, somehow.
extern XTL::X_D3DBaseTexture* XTL::EmuD3DActiveTexture[TEXTURE_STAGES];
extern XTL::X_D3DFORMAT GetXboxPixelContainerFormat(const XTL::X_D3DPixelContainer *pXboxPixelContainer);
auto format = GetXboxPixelContainerFormat(XTL::EmuD3DActiveTexture[0]);
auto format = GetXboxPixelContainerFormat(XTL::EmuD3DActiveTexture[inputStage]);
bool bias = false;
if (format == XTL::X_D3DFMT_X8L8V8U8 || format == XTL::X_D3DFMT_L6V5U5) {
auto biasModifier = (1 << ARGMOD_SCALE_BX2);
// TODO L6V5U5 format is converted incorrectly if not supported by the device
if (format == XTL::X_D3DFMT_X8L8V8U8 /*|| format == XTL::X_D3DFMT_L6V5U5*/) {
bias = true;
}
@ -2978,7 +2980,7 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS
Ins.Parameters[1].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + inputStage, MASK_R);
if (bias) {
Ins.Parameters[1].Modifiers = (1 << ARGMOD_BIAS);
Ins.Parameters[1].Modifiers = biasModifier;
}
Ins.Parameters[2].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + Stage, MASK_R);
@ -2988,7 +2990,7 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS
Ins.Parameters[0].SetScaleBemLumRegister(XTL::D3DTSS_BUMPENVMAT10, Stage, Recompiled);
Ins.Parameters[1].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + inputStage, MASK_G);
if (bias) {
Ins.Parameters[1].Modifiers = (1 << ARGMOD_BIAS);
Ins.Parameters[1].Modifiers = biasModifier;
}
Ins.Parameters[2].SetRegister(PARAM_R, 1, MASK_R);
InsertIns.emplace_back(Ins);
@ -2998,7 +3000,7 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS
Ins.Parameters[0].SetScaleBemLumRegister(XTL::D3DTSS_BUMPENVMAT01, Stage, Recompiled);
Ins.Parameters[1].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + inputStage, MASK_R);
if (bias) {
Ins.Parameters[1].Modifiers = (1 << ARGMOD_BIAS);
Ins.Parameters[1].Modifiers = biasModifier;
}
Ins.Parameters[2].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + Stage, MASK_G);
InsertIns.emplace_back(Ins);
@ -3007,7 +3009,7 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS
Ins.Parameters[0].SetScaleBemLumRegister(XTL::D3DTSS_BUMPENVMAT11, Stage, Recompiled);
Ins.Parameters[1].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + inputStage, MASK_G);
if (bias) {
Ins.Parameters[1].Modifiers = (1 << ARGMOD_BIAS);
Ins.Parameters[1].Modifiers = biasModifier;
}
Ins.Parameters[2].SetRegister(PARAM_R, 1, MASK_G);
InsertIns.emplace_back(Ins);