mirror of
https://github.com/libretro/Play-.git
synced 2024-12-04 07:20:56 +00:00
Add support for modulate and decal texture functions.
This commit is contained in:
parent
01a12a5fce
commit
22b7da30cf
@ -1061,6 +1061,8 @@ void CGSH_Direct3D9::FillShaderCapsFromTexture(SHADERCAPS& shaderCaps, const uin
|
||||
{
|
||||
shaderCaps.texSourceMode = CGsPixelFormats::IsPsmIDTEX4(tex0.nPsm) ? TEXTURE_SOURCE_MODE_IDX4 : TEXTURE_SOURCE_MODE_IDX8;
|
||||
}
|
||||
|
||||
shaderCaps.texFunction = tex0.nFunction;
|
||||
}
|
||||
|
||||
void CGSH_Direct3D9::SetRenderingContext(uint64 primReg)
|
||||
|
@ -89,7 +89,8 @@ private:
|
||||
struct SHADERCAPS : public convertible<uint32>
|
||||
{
|
||||
uint32 texSourceMode : 2;
|
||||
uint32 padding : 30;
|
||||
uint32 texFunction : 2;
|
||||
uint32 padding : 28;
|
||||
|
||||
bool isIndexedTextureSource() const { return texSourceMode == TEXTURE_SOURCE_MODE_IDX4 || texSourceMode == TEXTURE_SOURCE_MODE_IDX8; }
|
||||
};
|
||||
|
@ -130,11 +130,23 @@ Nuanceur::CShaderBuilder CGSH_Direct3D9::GeneratePixelShader(SHADERCAPS caps)
|
||||
textureColor = Sample(clutTexture, NewFloat2(colorIndex, NewFloat(b, 0)));
|
||||
}
|
||||
|
||||
switch(caps.texFunction)
|
||||
{
|
||||
case TEX0_FUNCTION_MODULATE:
|
||||
textureColor = Clamp(textureColor * inputColor * NewFloat4(b, 2, 2, 2, 2),
|
||||
NewFloat4(b, 0, 0, 0, 0), NewFloat4(b, 1, 1, 1, 1));
|
||||
break;
|
||||
case TEX0_FUNCTION_DECAL:
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
|
||||
//For proper alpha blending, alpha has to be multiplied by 2 (0x80 -> 1.0)
|
||||
//This has the side effect of not writing a proper value in the framebuffer (should write alpha "as is")
|
||||
outputColor = inputColor * textureColor;
|
||||
finalAlpha = Saturate(outputColor->w() * NewFloat(b, 2));
|
||||
outputColor = NewFloat4(outputColor->xyz(),finalAlpha);
|
||||
finalAlpha = Saturate(textureColor->w() * NewFloat(b, 2));
|
||||
outputColor = NewFloat4(textureColor->xyz(), finalAlpha);
|
||||
}
|
||||
|
||||
return b;
|
||||
|
Loading…
Reference in New Issue
Block a user