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

Debug question about Disabling Fog/ Increasing & Lowering Draw Distance; Beetle Adventure Racing, Turok, Etc. #2874

Open
KMFDManic opened this issue Sep 25, 2024 · 4 comments

Comments

@KMFDManic
Copy link

@gonetz I thoroughly enjoyed your posts about how framebuffer emulation and auxiliary buffers work, N64 emulation wise. I've paid close attention to your work for many years now. N64 emulation has always intrigued me, as far back as even it becoming a deciding factor on whether I should get a Radeon or Nvidia Video Card, to best handle Golden Eye on Project 64!

In any case, I have been doing fix ups of Cores, such as MAME and N64, etc, for usage on lower spec platforms, such as the NES/MD/SNES Classics. The caveats are that image textures and depth buffer rendering do not work properly, which causes issues...of course, with games like Pokemon Snap "detection", and "proper display of FOG" in Beetle Adventure Racing.

One big issue these lower spec platforms has is a "memory leak", which causes the RAM to essentially run out of memory pretty fast, depending on the game. Metro Madness track in BAR, in particular, is a memory hog!

So, then, the subject of this particular issue, is directly related to me and me doing Debug testing with Beetle Adventure Racing. There is a Debug Menu you can unlock in BAR, which gives you access to many key components of what the Developers originally used when optimizing the final product. What I quickly noticed was how "disabling" fog completely in the Debug Menu ALSO alleviated overall RAM usage. And, there was also an option to increase or lower draw distance, which was uniquely cool, too.

I have seen this sort of perimeter used to great effect in the Mario 64 port, where fog was completely removed and draw distance increased!

I thank you so much for reading this far. What would be greatly appreciated, so very much, is your input on "disabling" fog within the Core coding, itself, as well as "altering draw (clipping?) distance", for debug testing purposes. I'd mostly like to use Turok and Beetle Adventure Racing as case test scenarios, to see how effectively RAM usage increases/lowers with these changes!

Thanks so much!

P.S.: I am testing on GLES, which does not allow me to utilize Parallel RDP, etc. I am strictly using GlideN64 Plugin, with Cores such as Mupen64Plus and Mupen Plus NX! Thanks again!

@gonetz
Copy link
Owner

gonetz commented Oct 19, 2024

HI @KMFDManic !

What would be greatly appreciated, so very much, is your input on "disabling" fog within the Core coding, itself, as well as "altering draw (clipping?) distance", for debug testing purposes.

Do you need a way to disable fog emulation?
Sorry, English is not my native language, so I may misunderstand request expressed in such an ornate manner.

If you can build from sources, fog in Beetle Adventure Racing can be disabled very easily.
You need to edit
bool texturedRectShadowMap(const GraphicsDrawer::TexturedRectParams &)
located in src\GraphicsDrawer.cpp
It should be like that:

static bool texturedRectShadowMap(const GraphicsDrawer::TexturedRectParams &)
{
	FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
	if (pCurrentBuffer != nullptr) {
		if (gDP.textureImage.size == 2 && gDP.textureImage.address >= gDP.depthImageAddress &&
			gDP.textureImage.address < (gDP.depthImageAddress + gDP.colorImage.width*gDP.colorImage.width * 6 / 4)) {
				return true;
		}
	}
	return false;
}

This way drawing of fog-related graphics will be skipped.

Note, that fog in BAR is special. It uses depth buffer as texture.
N64 hardware can do it naturally, but OpenGL requires additional screen-size texture for that.
So, disabling fog reduces video memory consumption in that game.

Turok uses standard fog method, that is blending vertex and fog color using vertex alpha as blending factor.
Disabling fog there will give you nothing in terms of performance or video memory consumption.

Regarding "altering draw (clipping?) distance".
I'm not sure that it can be done easily.
You may try to force set
gSP.viewport.vscale[2] and gSP.viewport.vtrans[2] to 0.499 in void gSPViewport( u32 v )
and check if it helps.

@KMFDManic
Copy link
Author

KMFDManic commented Oct 20, 2024

@gonetz Thank You for your response:) And, your English is absolutely fine:) Testing Beetle Adventure Racing, there is nearly a 50 MB difference in RAM usage with FOG drawing removed, as well as a few other changes I have made. The game no longer runs out of memory, nor crashes, either!

As for Turok, Spider-Man?, and other similar games that use "standard fog method", what would be the best method of disabling that? I would definitely like to play around more with Turok, especially, and see what I may be able to do with draw distance, with "fog" disabled.

Some of the platforms I have been testing on only have 256 MB of RAM, so some of these changes are quite nice for a custom N64 build there to eliminate unnecessary slowdowns/crashing!

Most of what I have wanted to get done, I already have. It is mainly "fog" disabling and "draw distance" stuff, as well as possibly trying to fix arm32 Donald Duck collision detection issues with "collecting" stars, for now:) But, thank you so very much for your help on FOG! If there are any other things that would potentially help with memory usage, id also love to know!

Thanks again for your time!

@gonetz
Copy link
Owner

gonetz commented Nov 10, 2024

As for Turok, Spider-Man?, and other similar games that use "standard fog method", what would be the best method of disabling that?

The simplest way is to open src/gDP.cpp, find gDPSetFogColor function and change it like this:
void gDPSetFogColor( u32 r, u32 g, u32 b, u32 a )
{
gDP.fogColor.r = gDP.fogColor.g = gDP.fogColor.b = gDP.fogColor.a = 0.0f;
gDP.changed |= CHANGED_FOGCOLOR;
}

This way fog color will not affect color of vertices.

@KMFDManic
Copy link
Author

@gonetz thanks so much for your help on this. It seemed to disable the fog for turok as I can see pop in much more present than before the change:)

That pretty much all that can be done with fog elimination?

Thanks again, by the way!

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

No branches or pull requests

2 participants