Explorar el Código

VideoCore: Saturate vertex colors before interpolating

During testing, it was discovered that hardware does not interpolate
colors output by the vertex shader as-is. Rather, it drops the sign and
saturates the value to 1.0. This is done before interpolation, such that
(e.g.) interpolating outputs 1.5 and -0.5 is equivalent to as if the
shader had output the values 1.0 and 0.5 instead, with the interpolated
value never crossing 0.0.

This change has been tested against hardware.
Yuri Kunde Schlesner hace 11 años
padre
commit
4e09202226
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      src/video_core/vertex_shader.cpp

+ 6 - 0
src/video_core/vertex_shader.cpp

@@ -610,6 +610,12 @@ OutputVertex RunShader(const InputVertex& input, int num_attributes, const Regs:
         }
     }
 
+    // The hardware takes the absolute and saturates vertex colors like this, *before* doing interpolation
+    for (int i = 0; i < 4; ++i) {
+        ret.color[i] = float24::FromFloat32(
+            std::fmin(std::fabs(ret.color[i].ToFloat32()), 1.0f));
+    }
+
     LOG_TRACE(Render_Software, "Output vertex: pos (%.2f, %.2f, %.2f, %.2f), col(%.2f, %.2f, %.2f, %.2f), tc0(%.2f, %.2f)",
         ret.pos.x.ToFloat32(), ret.pos.y.ToFloat32(), ret.pos.z.ToFloat32(), ret.pos.w.ToFloat32(),
         ret.color.x.ToFloat32(), ret.color.y.ToFloat32(), ret.color.z.ToFloat32(), ret.color.w.ToFloat32(),