render parity unit G: 40250 tiling selection + verbatim STP terrain

- PythonApplication::Create mirrors 40250 :1196-1251 (SOFTWARE_TILING cfg,
  auto tiling IsFastTNL ? HTP : STP, MinLOD on !IsFastTNL)
- RecordingDevice caps: VertexShaderVersion 1.1 + CLIPTLVERTS (fast T&L -> HTP)
- MapOutdoorRenderSTP.cpp replaced by the full 40250 source (native gate only)
- native_render XYZRHW: fix inverted screen->NDC Y, negative rhw clip,
  no texture transform on TL vertices, specular-alpha vertex fog (capture v9)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-28 13:54:11 +09:00
co-authored by Claude Opus 5.5
parent 91ce13c3cf
commit 863f3771af
10 changed files with 864 additions and 66 deletions
+14 -4
View File
@@ -7,6 +7,7 @@ layout(location = 4) in uvec4 in_joints;
layout(location = 5) in vec4 in_weights;
layout(location = 6) in vec2 in_mask_uv;
layout(location = 7) in float in_rhw;
layout(location = 8) in float in_vertex_fog;
layout(location = 0) out vec4 out_color;
layout(location = 1) out vec2 out_uv;
@@ -73,7 +74,9 @@ vec2 stage_texcoord(int stage, bool pretransformed, vec3 eye, vec3 n) {
? (length(eye) > 0.0 ? -normalize(eye) : vec3(0.0)) : vec3(0.0, 0.0, -1.0);
coord = vec4(2.0 * dot(e, n) * n - e, 1.0);
}
uint transform_flags = fixed_state.stage_alpha[stage].w;
// Pretransformed (XYZRHW) vertices bypass D3D8 T&L, texture transforms included
// (RecordingDevice's CPU texcoord path does the same).
uint transform_flags = pretransformed ? 0u : fixed_state.stage_alpha[stage].w;
uint elements = transform_flags & 0xFFu;
vec4 r = coord;
if (elements != 0u)
@@ -109,7 +112,9 @@ void main() {
// D3D row-vector matrices are uploaded row-major. GLSL reads the bytes as their transpose.
gl_Position = draw.mvp * vec4(pos, 1.0);
if (pretransformed) {
float clip_w = in_rhw > 0.0 ? 1.0 / in_rhw : 1.0;
// Vertices behind the eye carry a negative rhw (STP terrain): rebuilding clip space
// with w = 1/rhw < 0 lets the clipper drop them instead of drawing w = 1 spikes.
float clip_w = in_rhw != 0.0 ? 1.0 / in_rhw : 1.0;
gl_Position.xyz *= clip_w;
gl_Position.w = clip_w;
}
@@ -172,8 +177,13 @@ void main() {
out_mask_uv = stage_texcoord(1, pretransformed, eye, n);
out_fog = 1.0;
if (fixed_state.flags.w != 0u && !pretransformed) {
float distance_to_eye = fixed_state.fog_params.w > 0.5 ? length(eye) : abs(eye.z);
if (fixed_state.flags.w == 4u) {
// XYZRHW with FOGTABLEMODE NONE: D3D8 takes the vertex fog from the specular alpha.
out_fog = in_vertex_fog;
} else if (fixed_state.flags.w != 0u) {
// Table fog on XYZRHW vertices runs on eye depth w = 1/rhw.
float distance_to_eye = pretransformed ? gl_Position.w
: (fixed_state.fog_params.w > 0.5 ? length(eye) : abs(eye.z));
if (fixed_state.flags.w == 3u) {
float span = fixed_state.fog_params.y - fixed_state.fog_params.x;
if (span > 0.0001)