[Request] Mip Map support for efficient blur and bloom shaders?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • This isn't so much a request for help with specific shader development but rather more of a feature request for [mention]Yves[/mention] et. al. Basically, if Fusion could create its D3D11 textures with mipmaps enabled, we could then use the SampleLevel() HLSL function, instead of just Sample(), to get automatic low-compute-cost blurring effects. This would allow us to make much more efficient blur and bloom shaders similar to how it's done in most other game engines.

    The issue is the current blurs and bloom either rely on individual point sampling of the full resolution image, which looks bad a high radius levels (since you can see the duplicated images; it's not a smooth blur), OR, for true gaussian blur, is extremely inefficient at higher radius values and high resolutions like 1080p.

    If we could SampleLevel() instead of Sample(), that would allow us to "pre-blur" the image for effects that would benefit from it. See some examples below, including a mockup of what this would look like.

    Plus, my understanding is that this comes at almost no compute cost, since bilinear filtering is effectively "free" on modern GPUs. But the mipmaps have to be enabled when creating the ID3D11Texture2D in Fusion's code (as defined in the "MipLevels" variable in the D3D11_TEXTURE2D_DESC). It would use a little more VRAM to store the mip textures but I don't think is is an issue for most Fusion games.

    I believe this would be a simple change to Fusion's code and would be awesome if we could specify the number of mip map levels (or set to 0 for automatic).

    Examples:

    Here is a 1080p scene. I want to apply a LARGE RADIUS bloom effect; 200 pixels or so, to get a "magical soft bloom" effect
    Please login to see this attachment.

    Here it is with Looki's bloom shader at 200px radius. You can see the repeated images. It does not look good at high radius values.
    Please login to see this attachment.

    Here is a custom shader I made, similar to Looki's, but it takes 180 point samples in randomly expanding circles, instead of 12. Looks a little better but still not a true smooth blur.
    Please login to see this attachment.

    And here it is with concentric circles instead of randomized:
    Please login to see this attachment.

    Here is is using a modified version of defisym's Gaussian Blur shader. It looks smooth but is EXTREMELY slow at high radius values. At 200 pixels it took over 10 seconds for the frame to appear:
    Please login to see this attachment.

    Finally, here is a mockup of what we could get using a combination of Mip Maps and a point sample bloom. The only part of this image I "faked" was pre-blurring the background to the equivalent of what Mip Maps would do. (I shrunk the 1080p image down to 3.125% (Mip level 5 (divide texture by 2 five times), 60x34 pixels) then scaled it back up to 1920x1080 with bilinear filtering). Then I applied my above 180-point bloom filter.
    Please login to see this attachment.

    You could probably drop the number of samples down to half or less, and still get a very nice smooth bloom effect.

    here are references to the Microsoft KB articles referencing the creation of textures with Mip Maps enabled:
    Please login to see this link.
    Please login to see this link.
    Please login to see this link.

    I believe these are the only changes that would need to be made:
    In the 1D3D11Device::CreateTexture2D call, in the D3D11_TEXTURE2D_DESC:
    --Change "MipLevels" from 1 to 0 (0 = automatically generate all mip levels)
    --Change "MiscFlags" to "D3D11_RESOURCE_MISC_GENERATE_MIPS"

    If mip maps could be enabled in Fusion's D3D textures that would be amazing! It would be a game changer for fullscreen "atmospheric" shaders, imo.

    EDIT: To clarify, I'm only asking about this for D3D 11. I don't believe this would be possible with D3D 9.

    Edited once, last by n89 (August 31, 2023 at 10:29 PM).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!