Dolphin, the GameCube and Wii emulator - Forums

Full Version: Conditional EFB scaling to fix bloom
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7
Click here for most recent bloom fix build
It's been awhile since I started this thread. GraphicsMod should eventually fix all the bloom stuff, but right now the link above can get you the best fixes.

I would now describe bloom issues as an issue of pixel density. Higher IRs have higher pixel densities for the same area of the screen. A higher pixel density makes blending nearby pixels more accurate, which in turn makes bloom more accurate and less blurry (bloom should be blurry). The fix is either to remove the high IR for bloom or, if that causes aliasing/shimmering artifacts due to size differences, apply blurring to the bloom.  Blurring works great in most games.

***



Bloom issues are caused by the Scale EFB option upscaling small textures that shouldn't be touched.  So if we conditionally don't scale small textures, we can avoid the bloom issues. This would be generally the same method as my game hacks to fix bloom, but it'd target all efb copies instead of just bloom ones. This method would be less buggy, more accurate, and far more widely applicable than per-game hacks, as long as buggy bloom games don't have other small efb copies that may need to be scaled up.

In VideoCommon\TextureCacheBase.cpp line 1659 to 1668. It would be changed to something like:

/edit changed code a bit.

 u32 scaled_tex_w = g_renderer->EFBToScaledX(srcRect.GetWidth());
 u32 scaled_tex_h = g_renderer->EFBToScaledY(srcRect.GetHeight());

//Or use  if (width < 300)
 if (width < 600)
 {
   scaled_tex_w = width;
   scaled_tex_h = height;
 }


// Optional - not sure if needed.
// if (scaleByHalf)
// {
//  tex_w /= 2;
//  tex_h /= 2;
//  scaled_tex_w = tex_w;
// scaled_tex_h = tex_h;
// }

-- Yes I know that could be written better.  I can't figure out how to fix ScaleByHalf with game-based ASM hacks, but this code will do it and enable games like Okami and Metroid Prime 3 to be fixed.

-- I could've sworn I saw some game ScaleByHalf(?) upwards (320x src-> 640x dst), but don't know if that's dealt with here.  You'd probably want that to be EFB scaled. Or is 640 dst always width = 640 by this point in this code?

-- Some games may want scaled 320x efb copies, but there are definitely games like Okami that suffer from 320x being scaled, so only scaling >320x is a good start.

I'm not sure if there are any sizes between 320 and 640, or above 640, so I guess the code might be simply to "only scale 640x full sized EFB copies".

If this does work, I'd suggest a toggle-able hack to enable it. I'd be happy to test it, if someone could correctly code and build it.

/edit Actually metroid 3 seems to use 320 and smaller efb copies for everything, so this would be the same as disabling scaled efb.
/edit Another option may be to not scale efb copies that are being offset and combined with the previous copy, but I'm not sure what the offset factor is called in the code. It's a float like 1.05 in the game.

/edit I got it working:
It seems to fix Okami, but I only tested for a moment. Fixes Xenoblade. Fixes HOTD Overkill.

MKW Picture + Discuss:
/edit Added Slider version of fix. May have bugs.
So it won't upscale the bloom effects and Metroid Prime 3, alongside with other few games, wouldn't even run at native resolution?

But there are games that even with efb scale off has bloom issues in dolphin, this won't fix those games right, hmm how about an option to disable bloom effects without the need to create a Ar/Gecko code?

Those bloom issues is the most annoying issue atm for me, that's why I would rather turn it off.

BTW: I was thinking if custom textures can edit bloom effects too, if yeah maybe it coud turn it off there too and better yet improve the effect to work at high res.
Native resolution would be fine and this fix would have to be toggle-able like scaled efb copies.

It won't fix games that have issues with efb scale off. There's no way to determine what efb copies are for (without looking at a specific game), so there's no universal way to disable bloom for all games. The only information we have is what type of copy is being made (alpha, contrast, normal), but bloom techniques are so varied and use different types of copies, I don't see that helping.

Could try to disable all efb copies or post processing, but I think very few games would be improved by that.

Bloom is created by taking a picture of a texture, usually low res, then moving it around the source and making it transparent. The only way to turn it off from a texture would be to remove the texture, so that's a no-go. High res textures won't make bloom any better either, unfortunately. Not much to be done from the texture end.

I was going to make a video guide on how the GC/Wii does bloom, but never got around to it. Maybe I should put that back on the agenda. Right now I'm trying to learn how to build dolphin. I want to customize some debugger stuff for myself so I can use newer versions of dolphin.
I imagine if we know the specific textures, rules to apply special rules to them per game based on their hashes should be possible (I think we generate such for the texture exports anyway); and perhaps a better way to resolve other issues caused by scaling when necessary.
No, I don't see that working at all for efb copies. If it sounds like I was going in that direction, I probably over simplified the explanation.
Got it working, pic in top post.
Could you share the build for me test too?
(10-22-2018, 10:17 PM)One More Try Wrote: [ -> ]Got it working, pic in top post.

Given the issues in your example, I'd guess this would need a slider or other input to allow setting the minimum unscaled size?
What do I need to share the build, just dolphin.exe?

@Kolano I think a slider would help with testing. If people test a variety of games, it could probably be narrowed down. Maybe just <300 and <600 options will do. A list of common EFB sizes would also help to narrow down what's needed.
(10-23-2018, 05:42 PM)One More Try Wrote: [ -> ]What do I need to share the build, just dolphin.exe?

Dolphin.exe is enough to run the build if you copy it into an existing Dolphin install, but you would need some additional files if you want someone who never has had Dolphin installed before to be able to use it. See the development build .7z archives for a list of needed files.

Also, you need to upload the source code as well, otherwise you're violating Dolphin's license. Making a fork on GitHub is a good way to do that.
Pages: 1 2 3 4 5 6 7