Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

softgpu: Correct tex on fogged rectangles #16384

Merged
merged 2 commits into from
Nov 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion GPU/Software/Clipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,26 @@ void ProcessRect(const ClipVertexData &v0, const ClipVertexData &v1, BinManager
else if (outsidePos >= 2 || outsideNeg >= 2)
return;

if (v0.v.fogdepth != v1.v.fogdepth) {
bool splitFog = v0.v.fogdepth != v1.v.fogdepth;
if (splitFog) {
// If they match the same 1/255, we can consider the fog flat. Seen in Resistance.
// More efficient if we can avoid splitting.
static constexpr float foghalfstep = 0.5f / 255.0f;
if (v1.v.fogdepth - foghalfstep <= v0.v.fogdepth && v1.v.fogdepth + foghalfstep >= v0.v.fogdepth)
splitFog = false;
}
if (splitFog) {
// Rectangles seem to always use nearest along X for fog depth, but reversed.
// TODO: Check exactness of middle.
VertexData vhalf0 = v1.v;
vhalf0.screenpos.x = v0.v.screenpos.x + (v1.v.screenpos.x - v0.v.screenpos.x) / 2;
vhalf0.texturecoords.x = v0.v.texturecoords.x + (v1.v.texturecoords.x - v0.v.texturecoords.x) / 2;

VertexData vhalf1 = v1.v;
vhalf1.screenpos.x = v0.v.screenpos.x + (v1.v.screenpos.x - v0.v.screenpos.x) / 2;
vhalf1.screenpos.y = v0.v.screenpos.y;
vhalf1.texturecoords.x = v0.v.texturecoords.x + (v1.v.texturecoords.x - v0.v.texturecoords.x) / 2;
vhalf1.texturecoords.y = v0.v.texturecoords.y;

VertexData vrev1 = v1.v;
vrev1.fogdepth = v0.v.fogdepth;
Expand Down