Point sprite fixes
* Implement Min and Max * Account for upscaling
This commit is contained in:
parent
5441dbff1c
commit
24b38ae3b3
|
@ -6394,15 +6394,21 @@ void UpdateFixedFunctionVertexShaderState()
|
|||
|
||||
// Point sprites
|
||||
auto pointSize = XboxRenderStates.GetXboxRenderState(X_D3DRS_POINTSIZE);
|
||||
auto pointSizeMin = XboxRenderStates.GetXboxRenderState(X_D3DRS_POINTSIZE_MIN);
|
||||
auto pointSizeMax = XboxRenderStates.GetXboxRenderState(X_D3DRS_POINTSIZE_MAX);
|
||||
ffShaderState.PointSprite.PointSize = *reinterpret_cast<float*>(&pointSize);
|
||||
bool PointScaleEnable = XboxRenderStates.GetXboxRenderState(X_D3DRS_POINTSCALEENABLE) != FALSE;
|
||||
ffShaderState.PointSprite.RenderTargetHeight = PointScaleEnable ? (float)GetPixelContainerHeight(g_pXbox_RenderTarget) : 1.0f;
|
||||
ffShaderState.PointSprite.PointSizeMin = *reinterpret_cast<float*>(&pointSizeMin);
|
||||
ffShaderState.PointSprite.PointSizeMax = *reinterpret_cast<float*>(&pointSizeMax);
|
||||
|
||||
bool PointScaleEnable = XboxRenderStates.GetXboxRenderState(X_D3DRS_POINTSCALEENABLE);
|
||||
auto scaleA = XboxRenderStates.GetXboxRenderState(X_D3DRS_POINTSCALE_A);
|
||||
ffShaderState.PointSprite.ScaleA = PointScaleEnable ? *reinterpret_cast<float*>(&scaleA) : 1.0f;
|
||||
auto scaleB = XboxRenderStates.GetXboxRenderState(X_D3DRS_POINTSCALE_B);
|
||||
ffShaderState.PointSprite.ScaleB = PointScaleEnable ? *reinterpret_cast<float*>(&scaleB) : 0.0f;
|
||||
auto scaleC = XboxRenderStates.GetXboxRenderState(X_D3DRS_POINTSCALE_C);
|
||||
ffShaderState.PointSprite.ScaleC = PointScaleEnable ? *reinterpret_cast<float*>(&scaleC) : 0.0f;
|
||||
ffShaderState.PointSprite.ScaleABC.x = PointScaleEnable ? *reinterpret_cast<float*>(&scaleA) : 1.0f;
|
||||
ffShaderState.PointSprite.ScaleABC.y = PointScaleEnable ? *reinterpret_cast<float*>(&scaleB) : 0.0f;
|
||||
ffShaderState.PointSprite.ScaleABC.z = PointScaleEnable ? *reinterpret_cast<float*>(&scaleC) : 0.0f;
|
||||
ffShaderState.PointSprite.XboxRenderTargetHeight = PointScaleEnable ? (float)GetPixelContainerHeight(g_pXbox_RenderTarget) : 1.0f;
|
||||
ffShaderState.PointSprite.RenderUpscaleFactor = g_RenderUpscaleFactor;
|
||||
|
||||
// Fog
|
||||
// Determine how fog depth is calculated
|
||||
|
|
|
@ -390,16 +390,19 @@ float DoPointSpriteSize()
|
|||
{
|
||||
const PointSprite ps = state.PointSprite;
|
||||
float pointSize = ps.PointSize;
|
||||
float A = ps.ScaleABC.x;
|
||||
float B = ps.ScaleABC.y;
|
||||
float C = ps.ScaleABC.z;
|
||||
|
||||
// Note : if (ps.PointScaleEnable) not required because when disabled, CPU sets RenderTargetHeight and ScaleA to 1, and ScaleB and ScaleC to 0
|
||||
{
|
||||
const float eyeDistance = length(View.Position);
|
||||
const float factor = ps.ScaleA + ps.ScaleB * eyeDistance + ps.ScaleC * (eyeDistance * eyeDistance);
|
||||
const float factor = A + (B * eyeDistance) + (C * (eyeDistance * eyeDistance));
|
||||
|
||||
pointSize *= ps.RenderTargetHeight * sqrt(1 / factor);
|
||||
pointSize *= ps.XboxRenderTargetHeight * sqrt(1 / factor);
|
||||
}
|
||||
|
||||
return pointSize;
|
||||
return clamp(pointSize, ps.PointSizeMin, ps.PointSizeMax) * ps.RenderUpscaleFactor;
|
||||
}
|
||||
|
||||
VS_INPUT InitializeInputRegisters(const VS_INPUT xInput)
|
||||
|
|
|
@ -105,11 +105,12 @@ struct Modes {
|
|||
|
||||
struct PointSprite {
|
||||
alignas(16) float PointSize;
|
||||
alignas(16) float PointSizeMin;
|
||||
alignas(16) float PointSizeMax;
|
||||
// alignas(16) float PointScaleEnable;
|
||||
alignas(16) float RenderTargetHeight;
|
||||
alignas(16) float ScaleA;
|
||||
alignas(16) float ScaleB;
|
||||
alignas(16) float ScaleC;
|
||||
alignas(16) float XboxRenderTargetHeight;
|
||||
alignas(16) float3 ScaleABC;
|
||||
alignas(16) float RenderUpscaleFactor;
|
||||
};
|
||||
|
||||
struct TextureState {
|
||||
|
|
Loading…
Reference in New Issue