Code Monkey home page Code Monkey logo

Comments (4)

Xaymar avatar Xaymar commented on July 16, 2024 1

This is technically outside of the scope of the plugin. If you need a faster way, I'd recommend doing exactly what you already said to do. However there are actual optimizations that can be done for the filter.

Pass the Kernel by Value instead of Texture

Currently the plugin allocates a Kernel texture containing every kernel for 0 Width to 31 Width. This is very inefficient as Textures really don't fit well into a Fragment L1 cache. A significant speed up could already be attained through simply moving the values into an actual float array of constant size.

Use the result of linear-sampling in addition to multi-pass blurring

The filter already uses dual-pass blurring, which is the only reason that Gaussian blur doesn't absolutely kill your GPU right now. The number of texture accesses can be halved if we take linear-sampling into account and do some clever math to hide the inaccuracies resulting from that.

Unroll the loop

The D3D11 and OpenGL shader compilers currently don't know how many iterations the loop will do at most. This is inefficient and leads to expensive instructions being generated. This plus the first optimization is already a huge boost, looping code is very expensive.

Implement better Blur filters

There are many solutions that actually out-perform currently implement solutions simply by their access pattern and how they actually calculate the final value. Some however are a bit difficult to actually do without direct access to D3D11 or the OpenGL api, which OBS abstracts away.

Edit: By the way, if you need a fast way to blur things, Box Blur is the way to go. Gaussian and Bilateral Blur are computationally expensive and should be used only if you have the necessary gpu capacity to do so.

from obs-streamfx.

Xaymar avatar Xaymar commented on July 16, 2024 1

Gaussian Blur now also has the kernel array optimization, further reducing GPU usage. This is as far as I'll optimize this for now, and should make Gaussian Blur more usable.

Marking as Fixed/Completed.

from obs-streamfx.

Xaymar avatar Xaymar commented on July 16, 2024

A faster variant of Box Blur is now implemented: Box Linear. This blur reduces the total number of samples by n, allowing the blur to run even faster. If the Radius is even, the blur only takes O(2n+1) instead of O(4n+1), if the Radius is odd, the blur only takes O(2n) instead of O(4n+1).

The same type of optimization will be added for Gaussian Blur, in addition to moving to kernel array instead of texture.

from obs-streamfx.

Xaymar avatar Xaymar commented on July 16, 2024

Gaussian Linear Blur has also now been implemented, reducing the number of samples for Gaussian Blur by up to n. An even radius will now only take O(2n+2), while an odd radius will take O(2n+4) instead of O(4n+2). Further improvements can be done by switching out the kernel texture with an array of floats.

from obs-streamfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.