Commit Graph
181 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 333035df03 Lighting: Compute the GE's pow from the float's bits
Read as an integer, a float's bits are its log2 with the mantissa a
straight line between powers of two, scaled by 2^23, and writing an
integer back is the matching exp2. That's exactly the GE's
approximation, without log2/exp2/floor. pspPow now also returns 1 for
e <= 0 itself, so the callers drop their checks. Shader languages
without integers fall back to a true pow.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-09-30 15:47:16 -06:00
Henrik RydgårdandClaude Opus 5.5 a6849661ba Shade mapping: Use the light vector as lighting sees it
Environment map S and T are (N.L + 1) / 2 with L the light's vector as
lighting uses it: from the vertex to the light for point and spot lights,
a zero vector staying zero, and the half vector for a light that does
specular. Whether lighting or the light is enabled still doesn't matter
(gpu/lighting/shademap).

The vertex shader ID now carries the type and computation of the shade
mapping lights (the ubershader reads them from u_lightControl), so both
shader caches get a new version.

Fixes the hair shine in iDOLM@STER SP (#12376).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-09-30 15:47:16 -06:00
Henrik RydgårdandClaude Opus 5.5 6f6d3e2a81 Lighting: Take the specular viewer direction from the view matrix
The viewer is at infinity along view space +z, so in world space, where
lighting happens, it's the view matrix's third column rather than
(0,0,1): turning the camera moves the highlights (gpu/lighting/specular).
The shaders read it from u_view.

In a Need for Speed Carbon frame replayed on a PSP, this and the pow
bring the error of the cars from MSE 957 to 120 (Vulkan).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-09-30 15:47:16 -06:00
Henrik RydgårdandClaude Opus 5.5 d7a96875fb Lighting: Use the GE's approximate pow for specular, diffuse and spot
The GE computes these powers as exp2(e * log2(x)), with log2 and exp2
each a straight line between powers of two (Mitchell's approximation),
and only uses the top 4 bits of the specular coefficient's mantissa.
Through a highlight's falloff a true pow is 10-30 steps of 255 brighter
at the exponents games use. Measured in gpu/lighting/specular.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-09-30 15:47:16 -06:00
Henrik Rydgård 013fc094de Remove NeedsZWHack old Mali workaround in vertex shaders. The new transform math seems to have fixed it some other way. 2026-07-15 12:14:33 +02:00
Henrik Rydgård c4889b3a2a Some more simplification of expressions in the vertex shader generator 2026-07-15 12:03:16 +02:00
Henrik Rydgård 8721e11694 Simplify expressions 2026-07-14 20:31:39 +02:00
Henrik Rydgård 61e1ef8f7a Remove the "Software skinning" option. Now always on. 2026-07-14 17:02:57 +02:00
Henrik Rydgård 04571a15e3 Don't forget to specify highp on u_zw in OpenGL. Necessary for older Mali.
Fixes #21914
2026-07-13 19:59:53 +02:00
Henrik Rydgård 3de35305cd Simplify color clamping in vertex shader generator 2026-07-13 12:42:46 +02:00
Henrik Rydgård 38b0b0b126 Eliminate two divisions and multiplication from all vertex shaders 2026-07-13 12:11:31 +02:00
Henrik Rydgård 35010391a7 Correct framebuffer offset, after the refactor.
Fixes #21915
2026-07-13 11:43:30 +02:00
Henrik Rydgård db712016bb Comment improvements, rename a dirty-flag 2026-07-13 11:10:31 +02:00
Henrik Rydgård a207a46fba VertexShaderGenerator: The hasColor bit is only relevant in hw transform. 2026-07-10 12:49:57 +02:00
Henrik Rydgård 9e687c3282 Make Description a member function of VShaderID / FShaderID. Assorted cleanup 2026-07-09 17:46:07 +02:00
Henrik Rydgård e78a46407b Add new relay "Jeddah", minor update 2026-07-07 20:16:32 +02:00
Henrik Rydgård 623545bd24 Delete the "Hardware tessellation" feature.
Very hard to maintain and debug, not worth it.
2026-06-16 16:17:14 +02:00
Henrik Rydgård cd0802b9c8 Remove redundant flag from vertex shader IDs 2026-06-10 10:46:05 +02:00
Henrik Rydgård a7f62d763a Make the MaxZ test a bit more lenient to fix Taiko no Tatsujin. Debugger improvement
Fixes #21797
2026-06-07 13:47:42 +02:00
Henrik Rydgård b84afa8a5b Fixes menus in NBA2K12.
Not sure if we can find a better way, I suppose
we could clamp vertex coordinates that are in this range instead, if it
turns out that this somehow breaks something.
2026-06-05 18:23:31 +02:00
Henrik Rydgård d59cdcad61 GTA sprite fix: Detect sprites, clip them slightly to avoid filtering artifacts 2026-06-05 11:48:46 +02:00
Henrik Rydgård 9ce5270e80 With our compatibility flag for depth rounding, truncate to 15 bits.
This matches some earlier test results by Unknown where we could see
that only every second value was used, and is the only explanation I can
come up with for the Afterburner problem, having now traced all the
depth math properly.

Fixes #21785 - and hopefully doesn't break anything else.
2026-06-05 00:50:30 +02:00
Henrik Rydgård 50e5f9c23a Small simplification and fix in VertexShaderGenerator 2026-06-04 12:45:20 +02:00
Henrik Rydgård 078197d790 Remove unnecessary scaling and then un-scaling of through-mode Z coordinates 2026-06-03 20:31:05 +02:00
Henrik Rydgård 2ea8a9ac1f Revert "Remove unnecessary scaling and then un-scaling of through-mode Z coordinates"
Didn't mean to commit this, it was supposed to go in a PR.

This reverts commit 6d4c70c67d.
2026-06-03 17:18:10 +02:00
Henrik Rydgård 6d4c70c67d Remove unnecessary scaling and then un-scaling of through-mode Z coordinates 2026-06-03 16:00:40 +02:00
Henrik Rydgård 86212f5384 Correct minor shader generator bug for depthclamp case. 2026-06-02 15:58:47 +02:00
Henrik Rydgård 8113cb9147 Misc cleanup and renaming 2026-06-02 11:39:33 +02:00
Henrik Rydgård e75d9f8a5f Unify the bounding depth checks, correct them if minmax clip is needed 2026-05-30 19:07:59 +02:00
Henrik Rydgård 0eede05f5f Implement fragment shader depth clamp and min/max discard. Slow on some hardware, but it's a fallback. 2026-05-30 19:07:59 +02:00
Henrik Rydgård de266c3d6c Add the appropriate epsilons to cull distance. Fixes the NBA issue.
It's a bit odd that this draw doesn't go through software transform
though.
2026-05-30 19:07:59 +02:00
Henrik Rydgård 5ad24adc93 Cleanup, increase the max cull count. Flatout water works now. 2026-05-30 19:07:59 +02:00
Henrik Rydgård 3599c4002b Through mode draws should not be min/max tested 2026-05-30 19:07:59 +02:00
Henrik Rydgård 9979d5544d Round off Z for the min/max tests. Gets both Test Drive map and Wipeout Pure shadows working at the same time.. 2026-05-30 19:07:59 +02:00
Henrik Rydgård eaacbbc226 D3D and OpenGL shader buildfixes 2026-05-30 19:07:59 +02:00
Henrik Rydgård 058b1af285 Revert to software on out-of-bounds projected depth 2026-05-30 19:07:59 +02:00
Henrik Rydgård b9ef43f4de VertexShaderGenerator work 2026-05-30 19:07:59 +02:00
Henrik Rydgård 36f5664c5e Re-enable cull distance in vertex shader, fix some test errors 2026-05-30 19:07:58 +02:00
Henrik Rydgård f55adcc3a1 Apply a small depth bias to simulate rounding of Z. Fix min/max clip plane math 2026-05-30 19:07:58 +02:00
Henrik Rydgård f0d715feaa During culling, evaluate minZ,maxZ,minW,maxW, and use them to cull some things. Also, assorted vshader work. 2026-05-30 19:07:58 +02:00
Henrik Rydgård 5808afef10 Implement minZ/maxZ through user clip planes 2026-05-30 19:07:58 +02:00
Henrik Rydgård 2f73bea7f0 Correct Z in through mode, add another check to range culling 2026-05-30 19:07:58 +02:00
Henrik Rydgård 490469c4e6 Re-implement range culling 2026-05-30 19:07:58 +02:00
Henrik Rydgård ae98055cec Delete a lot of legacy depth and viewport code, fix OpenGL 2026-05-30 19:07:58 +02:00
Henrik Rydgård 62d8cf22de Move the viewport transform to software in SW transform mode
transform fix
2026-05-30 19:07:58 +02:00
Henrik Rydgård 5aedd2f1e3 Hardware transform seems to work, software transform still has issues 2026-05-30 19:07:58 +02:00
Henrik Rydgård 69c7c75124 Replace u_proj_through with a simple scale/offset
First reasonable output appears.
2026-05-30 19:07:58 +02:00
Henrik Rydgård 4a55fc6724 Prepare TestBoundingBoxFast for optimization 2026-05-25 13:37:27 +02:00
Henrik Rydgård 736d054b8f Remove the u_proj_though matrix from the uniform buffer 2026-05-19 16:33:45 +02:00
Henrik Rydgård e108828bcc Unify Z handling between the backends 2026-05-19 15:17:44 +02:00