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

[decomp] sky/time of day #883

Merged
merged 15 commits into from
Oct 11, 2021
Merged

[decomp] sky/time of day #883

merged 15 commits into from
Oct 11, 2021

Conversation

water111
Copy link
Collaborator

@water111 water111 commented Oct 5, 2021

Still not quite working. Stars/suns are working correctly using the sparticle/sprite system but the sky isn't quite right.

The "sky" is a pyramid drawn with "sky tri"s. The "clouds" are draw with quads and I think are just a plane with some interesting scaling as it goes to the horizon.

The rendering code is all on the EE, but it's awful and doesn't obey calling conventions.

The rendering process is:

  • texture blending
  • setup vf registers
  • draw tri/draw quad call
  • draw large polygon call
  • clipping
  • generation of gif packet

Currently the clouds are all messed up. The textures are not aligned properly, and there is a strange effect when rotating the camera. I've probably spent ~5 hours on this so far without getting anywhere, so it's time to take a step back and get organized. Possible causes:

  • the texture blending step currently isn't really handled properly. Maybe there is some texture distortion done in this step that I need to add. I didn't see anything like this at first but it's worth another check.
  • vf registers are setup up from the math camera, which may be bad. It works correctly for sparticle (stars/sun) and the random actor vis boxes, so I think it's right.
  • somehow there is a bug in the register setup or we are not preserving a register properly
  • floating point error in clipping. The result of using the isometric matrix (not used in sky, only menu) was off by 1 bit from the original game. Nothing in this code seems sensitive to single bit errors
  • clipping is not implemented properly. I am pretty sure the full reject test is right, but less sure about the actual clipping. The clip function is named clip-against-positive-hyperplane and I believe it clips the polygons against some 3d planes. To me it looks like this doesn't work, but I looked at a wireframe view in PCSX2 and the mesh looks pretty similar? One piece of evidence is that I checked a few seams that looked wrong and their texture coordinates matched. So we have a properly connected mesh that's distorted. And the distortion happens on one side, possibly indicating that one of the two clip-against-[positive,negative]-hyperplane might be working and the other isn't? (see https://www.geometrictools.com/Documentation/ClipConvexPolygonByHyperplane.pdf for the algorithm I think they are using)
  • input tex coords/vertices are wrong. Always a possibility, but the code that generates these is pretty simple and they look correct by inspection.
  • misunderstanding of texture perspective correction. While this may be true, these errors seem much bigger than that.
  • Error in direct renderer handling of primitives. For example, maybe we don't terminate a triangle fan at the right time.
  • Error in direct renderer handling of data. Maybe there is an overflow issues.
  • mips2c bug
  • compiler bug

After going through this I think the mesh is close-but-not-quite. Not sure if it's in the EE code or the direct renderer though.

@coveralls
Copy link

coveralls commented Oct 9, 2021

Pull Request Test Coverage Report for Build 1326939501

  • 45 of 1639 (2.75%) changed or added relevant lines in 27 files are covered.
  • 23 unchanged lines in 12 files lost coverage.
  • Overall coverage decreased (-1.3%) to 58.615%

Changes Missing Coverage Covered Lines Changed/Added Lines %
game/graphics/opengl_renderer/BucketRenderer.cpp 0 1 0.0%
game/graphics/opengl_renderer/TextureUploadHandler.cpp 0 1 0.0%
goalc/compiler/Env.cpp 1 2 50.0%
common/util/BitUtils.h 0 2 0.0%
game/graphics/dma/gs.cpp 0 2 0.0%
game/graphics/opengl_renderer/Shader.cpp 0 2 0.0%
decompiler/util/data_decompile.cpp 2 6 33.33%
game/graphics/opengl_renderer/debug_gui.cpp 0 5 0.0%
decompiler/IR2/FormExpressionAnalysis.cpp 1 7 14.29%
game/graphics/opengl_renderer/debug_gui.h 0 7 0.0%
Files with Coverage Reduction New Missed Lines %
common/math/Vector.h 1 40.28%
decompiler/util/data_decompile.cpp 1 52.2%
game/graphics/dma/gs.h 1 0%
game/graphics/opengl_renderer/debug_gui.cpp 1 0%
game/graphics/opengl_renderer/Shader.cpp 1 0%
game/graphics/opengl_renderer/TextureUploadHandler.cpp 1 0%
game/mips2c/mips2c_private.h 1 9.04%
game/graphics/opengl_renderer/OpenGLRenderer.cpp 2 0%
game/graphics/pipelines/opengl.cpp 2 0%
game/graphics/opengl_renderer/SpriteRenderer.cpp 3 0%
Totals Coverage Status
Change from base Build 1326932087: -1.3%
Covered Lines: 40308
Relevant Lines: 68767

💛 - Coveralls

#else
u32 result;
return _BitScanReverse(&result, in);
return result;
Copy link
Member

Choose a reason for hiding this comment

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

is this first return intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no! (and the type is wrong so it doesn't compile anyway)

@water111 water111 marked this pull request as ready for review October 10, 2021 23:56
@water111 water111 merged commit b205201 into master Oct 11, 2021
@water111 water111 deleted the w/time-of-day branch October 11, 2021 00:07
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.

3 participants