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

nv2a: add NV_PGRAPH_CONTROL_3_TEXTURE_PERSPECTIVE_ENABLE, fix W_param tests and see through #1826

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

polymetal0
Copy link

@polymetal0 polymetal0 commented Dec 31, 2024

Happy new year everyone!

I was holding this PR until Vulkan rendering was ready. So here it is, for both Vulkan and OpenGL.

The fix is quite simple; passing clipRange variable as a uniform and performing perspective divide in fragment shader for z_perspective = true solves the see through issue that affects many games.

Edit: Removing vtx_inv_w and vtx_inv_w_flat and using the flag texture_enable fixes or shows progress in some pgraph tests

Passing clipRange variable as a uniform and performing perspective divide in fragment shader for z_perspective = true solves the see through issue that affects many games.

Shader code for z_perspective = false is virtually unaltered.
@polymetal0 polymetal0 changed the title See through fix nv2a: perspective divide (see through fix) Dec 31, 2024
@polymetal0 polymetal0 changed the title nv2a: perspective divide (see through fix) nv2a: perspective divide in frag shader (see through fix) Dec 31, 2024
@mborgerson
Copy link
Member

Hi again. I think this is the 4th PR now opened for this. As much as I'd like to see Halo 2 and other games fixed, I still have yet to see the test cases that I've asked for that demonstrate this actually matches hardware behavior. Will you please create the test cases?

@polymetal0
Copy link
Author

Hi. Yes sure, I'm having a look at the nxdk but I need some guidance. How could I build a scene that replicates this unwanted see through effect? could someone give me some specs? With perspective enabled, I'd put two or more 3D objects in a way that one occludes the other(s), but I assume they'd have to be in a specific position and orientation.

Also, I wanted to test the titles in #1016 that are known to suffer from this @Triticum0

And finally, the latest release of nxdk_pgraph_tests has no .xiso image attached, and there's a ZMinMaxControl test that might be helpful for this PR that is not included in the previous release @abaire

@Fabxx
Copy link
Contributor

Fabxx commented Jan 3, 2025

Dunno if i've mentioned in previous issues but just in case, the pr does fix clipping but breaks shadows and lights in splinter cell.

@abaire
Copy link
Contributor

abaire commented Jan 3, 2025

And finally, the latest release of nxdk_pgraph_tests has no .xiso image attached, and there's a ZMinMaxControl test that might be helpful for this PR that is not included in the previous release @abaire

Thanks for the heads up, the workflow should be fixed now and the latest release has an iso artifact.

@polymetal0
Copy link
Author

Dunno if i've mentioned in previous issues but just in case, the pr does fix clipping but breaks shadows and lights in splinter cell.

How so? I haven't tried any Splinter Cell yet. Anyway, this pr is slightly different bc the code was reorganized when Vulkan was implemented. Try it if you like :)

@Triticum0
Copy link

some send my an app image forgot how to build from source.

@polymetal0
Copy link
Author

some send my an app image forgot how to build from source.

There you go
xemu-pr1826.zip

@Fabxx
Copy link
Contributor

Fabxx commented Jan 3, 2025

Dunno if i've mentioned in previous issues but just in case, the pr does fix clipping but breaks shadows and lights in splinter cell.

How so? I haven't tried any Splinter Cell yet. Anyway, this pr is slightly different bc the code was reorganized when Vulkan was implemented. Try it if you like :)

there is like shadow/light clipping and you can see them behave like a vertex explosion. There might be still a depth conflict.

@Triticum0
Copy link

yeah think I got same issue on splinter cell as well thought comparing both images to xbox might be unrelated as seem dynamic light no even rendered on master build.

Xemu v8.2
xemu-2025-01-03-21-41-18

pr
xemu-2025-01-03-21-41-17

xbox
Screenshot_20250103_214906

Reference: https://www.youtube.com/watch?v=tA26hB0vbGk

@polymetal0
Copy link
Author

polymetal0 commented Jan 3, 2025

yeah think I got same issue on splinter cell as well thought comparing both images to xbox might be unrelated as seem dynamic light no even rendered on master build.

Xemu v8.2 xemu-2025-01-03-21-41-18

pr xemu-2025-01-03-21-41-17

xbox Screenshot_20250103_214906

Reference: https://www.youtube.com/watch?v=tA26hB0vbGk

Now that you mention it, this PR may also fix many of the missing shadows in #577, I could test it on Wallace & Gromit, Conker and Halo CE. It also fixes some clipping issues in Halo 2 cutscenes.

@Triticum0
Copy link

Triticum0 commented Jan 3, 2025

Done some more testing seems to have fixed most of the z-ordering issues. in most of game I tested.

007: Nightfire

Masters
xemu-2025-01-06-01-30-39

Pr
xemu-2025-01-06-01-30-38

Battlefield 2: Modern Combat
Masters
xemu-2025-01-06-01-26-59

Pr
xemu-2025-01-06-01-27-04

Breakdown

Masters
xemu-2025-01-03-21-11-50

Pr
xemu-2025-01-03-21-11-48

Catwoman
Masters
xemu-2025-01-03-21-06-50

Pr
xemu-2025-01-03-21-06-48

Far Cry Instincts
Masters
xemu-2025-01-03-21-16-28

Pr
xemu-2025-01-03-21-16-26

Juiced
Masters
xemu-2025-01-03-21-26-34

Pr
xemu-2025-01-03-21-26-33

Marvel Nemesis: Rise of the Imperfects
Masters
xemu-2025-01-03-22-29-12

Pr
xemu-2025-01-03-22-29-16

Midtown Madness 3 Fixeds the shadows as well
Masters
xemu-2025-01-03-21-37-40

Pr
xemu-2025-01-03-21-38-18

Project Gotham Racing Shadows are broken
Masters
xemu-2025-01-03-23-08-31

Pr
xemu-2025-01-03-23-10-09

Quantum Redshift
Masters
xemu-2025-01-03-21-59-54
Pr
xemu-2025-01-03-22-00-04

V-Rally 3
Masters
xemu-2025-01-03-21-56-10

Pr
xemu-2025-01-03-21-56-06

Games unaffected
007: From Russia with Love
Aggressive Inline
Beyond Good & Evil
Peter Jackson's King Kong: The Official Game of the Movie
Syberia
Terminator 3: The Redemption

Games Untested.
Knight's Apprentice: Memorick's Adventures AMD Only
Splinter Cell Pandora Tomorrow
Tom Clancy's Rainbow Six 3 Black Arrow
Tom Clancy's Rainbow Six 3
Tom Clancy's Ghost Recon: Advanced Warfighter
Games in #1020

will not test any more game on-till a test case has been written.

@polymetal0
Copy link
Author

polymetal0 commented Jan 4, 2025

yeah think I got same issue on splinter cell as well thought comparing both images to xbox might be unrelated as seem dynamic light no even rendered on master build.

Xemu v8.2 xemu-2025-01-03-21-41-18

pr xemu-2025-01-03-21-41-17

xbox Screenshot_20250103_214906

Reference: https://www.youtube.com/watch?v=tA26hB0vbGk

Edit: this one is trickier than expected, probably unrelated. It changes on different scales
3x
xemu-2025-01-04-02-07-18
1x
xemu-2025-01-04-02-37-15

@Triticum0
Copy link

Fixes robots, bionic ingame clipping and ice age 2

@BiatuAutMiahn
Copy link

BiatuAutMiahn commented Jan 7, 2025

Partially fixes Halo 2

master: 956ef0b
image

pr:
image

@BiatuAutMiahn
Copy link

BiatuAutMiahn commented Jan 7, 2025

Halo 2 CoOp
Vulkan X2
image

Vulkan X1
image

OGL X1
image

OGL X2
image

@BiatuAutMiahn
Copy link

Dynamic lights too? (Effect is at any scale)
xemu-2025-01-08-00-51-55
xemu-2025-01-08-00-51-38
xemu-2025-01-08-00-51-13
xemu-2025-01-08-00-37-11

@BiatuAutMiahn
Copy link

Vulkan and oGL, any scale:
xemu-2025-01-08-10-23-20

They are still there, but unused
- z_perspective refactor to PixelShader and texture_perspective var added
- vtx_inv_w and vtx_inv_w_flat vars totally removed
- Fixes warping of textures from previous commit w/o breaking tests
- Also fixes dashboard menu background regression
Copy link
Author

@polymetal0 polymetal0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@polymetal0 polymetal0 changed the title nv2a: perspective divide in frag shader (see through fix) nv2a: add NV_PGRAPH_CONTROL_3_TEXTURE_PERSPECTIVE_ENABLE, fix W_param tests and see through Jan 11, 2025
- Regression of some fixed missing shadows from xemu-project#577, identified the source of the problem
@polymetal0
Copy link
Author

Some clipping fixes:
v0.8.8
xemu-2025-01-12-17-13-01
xemu-2025-01-12-17-11-43
PR
xemu-2025-01-12-17-12-14
xemu-2025-01-12-17-12-42

Restores shadows for many games in xemu-project#577 w/o removing the Xbox dashboard background
Copy link
Contributor

@dracc dracc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some stylistic nitpicks.
I don't know graphics programming nearly good enough to make a comment on the "actual" code.

hw/xbox/nv2a/pgraph/gl/shaders.c Outdated Show resolved Hide resolved
hw/xbox/nv2a/pgraph/glsl/vsh-prog.c Outdated Show resolved Hide resolved
hw/xbox/nv2a/pgraph/glsl/vsh-prog.c Outdated Show resolved Hide resolved
hw/xbox/nv2a/pgraph/vk/shaders.c Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants