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

Hackfix for clipping in Gormiti #9914

Closed

Conversation

Pokechu22
Copy link
Contributor

This should fix bug 12436.

I don't really know what I'm doing here, to be honest; I don't fully understand the clipping code.

What I do know is that the game deliberately draws a black rectangle over the entire screen (the first 3 values are the x/y/z coordinates, with the hex values first and then the decoded float values in parentheses, and the last value is the color, where alpha is 1):

Primitive GX_DRAW_TRIANGLE_STRIP (3) VAT 0

00000000 (0) 00000000 (0) 3f800000 (1)  00000001  
00000000 (0) 43f00000 (480) 3f800000 (1)  00000001  
44200000 (640) 00000000 (0) 3f800000 (1)  00000001  
44200000 (640) 43f00000 (480) 3f800000 (1)  00000001  

It also configures the alpha test and z-test to pass for these. I can only assume that this is deliberate anti-emulation code, because there doesn't seem to be any other purpose to this rectangle.

Testing using the hardware fifoplayer showed that this rectangle did not render; I assume this is because it is passing the far plane (but I'm not 100% sure whether it's the far or near plane, as I don't have a perfect understanding of this part of rendering. The z coordinate is transformed to -1 and then projected position's z-coordinate is 0, so I think it it's the far plane, though.) My guess is that this is supposed to be a >= 0 comparison for clipping instead of a > 0 comparison, which I did with the software renderer, but I did some hacky stuff in the hardware renderers instead.

This PR also applies the sonic epsilon hack for host_config.backend_depth_clamp = false to UberShaders (it was implemented for specialized shaders in #9591). I haven't tested anything for backend_depth_clamp = false.

@Pokechu22 Pokechu22 changed the title Hackfix for clipping in Gromiti Hackfix for clipping in Gormiti Jul 19, 2021
@Rumi-Larry
Copy link

Wouldn't it be better to patch the game to remove the rectangle?

@Pokechu22
Copy link
Contributor Author

Pokechu22 commented Jul 20, 2021

That would probably be better than the current fix (given the side effects of breaking a bunch of games), but if a more accurate fix is found that'd be preferable to a game patch. However, I don't own Gormiti, so I can't do a patch myself.

@Pokechu22 Pokechu22 force-pushed the gormiti-clipping-hack branch from 914297b to b2ec900 Compare July 21, 2021 02:23
@Rumi-Larry
Copy link

What would be the motivation of the devs to implement anti-emulation? Certainly it would be different than anti-piracy, right?

@Pokechu22 Pokechu22 force-pushed the gormiti-clipping-hack branch from b2ec900 to 679cab6 Compare July 25, 2021 05:20
@dolphin-emu-bot
Copy link
Contributor

FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:

  • gormiti on ogl-lin-mesa: diff
  • inverted-depth-range on ogl-lin-mesa: diff
  • jj-awae-mirrored on ogl-lin-mesa: diff
  • lego-star-wars-crane-shadow on ogl-lin-mesa: diff
  • megaman-heat on ogl-lin-mesa: diff
  • nintendo-channel on ogl-lin-mesa: diff
  • puzzle-collection on ogl-lin-mesa: diff
  • rs3-bumpmapping on ogl-lin-mesa: diff
  • rs3-skybox2 on ogl-lin-mesa: diff
  • shadow-eyes on ogl-lin-mesa: diff
  • soa-black on ogl-lin-mesa: diff
  • sw3-dt on ogl-lin-mesa: diff
  • taiko-depth on ogl-lin-mesa: diff
  • gormiti on sw-lin-mesa: diff
  • inverted-depth-range on sw-lin-mesa: diff
  • kirby-shadows on sw-lin-mesa: diff
  • lego-star-wars-crane-shadow on sw-lin-mesa: diff
  • megaman-heat on sw-lin-mesa: diff
  • puzzle-collection on sw-lin-mesa: diff
  • soa-black on sw-lin-mesa: diff
  • taiko-depth on sw-lin-mesa: diff
  • xenoblade-menu on sw-lin-mesa: diff
  • burnout2-vehicletextures on ogl-lin-radeon: diff
  • ed-updated on ogl-lin-radeon: diff
  • gormiti on ogl-lin-radeon: diff
  • inverted-depth-range on ogl-lin-radeon: diff
  • jj-awae-mirrored on ogl-lin-radeon: diff
  • lego-star-wars-crane-shadow on ogl-lin-radeon: diff
  • megaman-heat on ogl-lin-radeon: diff
  • nfsu-reflections on ogl-lin-radeon: diff
  • nintendo-channel on ogl-lin-radeon: diff
  • puzzle-collection on ogl-lin-radeon: diff
  • rs3-bumpmapping on ogl-lin-radeon: diff
  • rs3-skybox2 on ogl-lin-radeon: diff
  • sadx-ui on ogl-lin-radeon: diff
  • shadow-eyes on ogl-lin-radeon: diff
  • soa-black on ogl-lin-radeon: diff
  • sonic-riders-blur on ogl-lin-radeon: diff
  • sw3-dt on ogl-lin-radeon: diff
  • taiko-depth on ogl-lin-radeon: diff
  • burnout2-vehicletextures on uberogl-lin-radeon: diff
  • ed-updated on uberogl-lin-radeon: diff
  • gormiti on uberogl-lin-radeon: diff
  • inverted-depth-range on uberogl-lin-radeon: diff
  • jj-awae-mirrored on uberogl-lin-radeon: diff
  • lego-star-wars-crane-shadow on uberogl-lin-radeon: diff
  • megaman-heat on uberogl-lin-radeon: diff
  • nfsu-reflections on uberogl-lin-radeon: diff
  • nintendo-channel on uberogl-lin-radeon: diff
  • puzzle-collection on uberogl-lin-radeon: diff
  • rs3-bumpmapping on uberogl-lin-radeon: diff
  • rs3-skybox2 on uberogl-lin-radeon: diff
  • sadx-ui on uberogl-lin-radeon: diff
  • shadow-eyes on uberogl-lin-radeon: diff
  • soa-black on uberogl-lin-radeon: diff
  • sonic-riders-blur on uberogl-lin-radeon: diff
  • sw3-dt on uberogl-lin-radeon: diff
  • taiko-depth on uberogl-lin-radeon: diff

automated-fifoci-reporter

@Pokechu22 Pokechu22 marked this pull request as ready for review August 6, 2021 17:24
@Pokechu22 Pokechu22 marked this pull request as draft August 6, 2021 17:24
@Pokechu22
Copy link
Contributor Author

Closing this as this is not the correct fix (and breaks other games). I will probably investigate this further later on and come up with a better fix (once I understand the problem better).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants