Comments (9)
I think we got a fix with this build:
https://github.com/exeldro/obs-shaderfilter/actions/runs/7629693620
from obs-shaderfilter.
Is this with version 2.2.1? I tried to replicate it, but no luck so far.
Do you have a link to the image used? Or maybe more extensive steps to reproduce the issue?
from obs-shaderfilter.
I'm sorry. Yes, v2.2.1 and OBS Studio v30.0.2.
With v2.1.3 works fine.
The HS logo here:
https://images.app.goo.gl/PWAojB7VGFTEkXNH9
Or with the Composite Blur logo from the resources page https://obsproject.com/forum/resources/composite-blur.1780/
(downloaded with save image as)
from obs-shaderfilter.
I am able to replicate it now and will investigate further.
from obs-shaderfilter.
This is due to the Pre-Multiplied alpha issue that was fixed before. It looks like OBS does not pre-multiply alpha on image sources, for the first filter in the filter chain (all filters after do have pre-multiplied alpha).
Here is how to test this with a few cases (and some workaround until we figure out how to fix it):
Case 1:
- Create an image source that has alpha transparency.
- Add a user defined shader. (You'll see the alpha halo bug)
- Add
#define USE_PM_ALPHA 1
at the top of the shader text, to turn off the pre-multiplied alpha correction - The halo bug goes away.
Case 2:
- Create an image source that has alpha transparency.
- Add a user defined shader. (You'll see the alpha halo bug)
- Add a color correction filter (but dont change any of the settings)
- Drag the color correction filter before the User-defined shader.
- The halo bug goes away.
Case 3:
- Create an image source that has alpha transparency.
- Add a user defined shader to the scene that contains the image source
- No halo bug.
This is a little tricky to fix, as there may be other sources that don't pre-multiply alpha to the original source, but it also depends on what order the filter is in the stack. @exeldro do you know if there is any way to determine if the source coming into the filter has pre-multiplied alpha?
@COOLIGUAY: An interim workaround for you is to either add #define USE_PM_ALPHA 1
to the top of any shader file/text you are using on your image sources, or put a dummy filter like a non-changing Color Correction
filter before you apply the user defined shader.
Quick edit to say- if you use the #define USE_PM_ALPHA 1
, make sure your user defined shader is the first filter in the chain for that source. If it is not the first, omit #define USE_PM_ALPHA 1
.
from obs-shaderfilter.
Thank you @exeldro and @FiniteSingularity !
I have tried your #define USE_PM_ALPHA 1
solution and it definitely eliminates the haloπ
However, the alpha colors looks a little different from the original.
I have used this png for the test:
https://www.cleanpng.com/png-light-halo-aperture-cool-the-aperture-325637/preview.html
Applied the shine shader adding #define USE_PM_ALPHA 1
, renamed to shineALPHA.shader.
Then, a color correction filter at the top (also works if the filter is off).
The alpha colors looks like it was overexposed compared with the original image (filters off).
To mitigate this color issue i add another shader filter with the #define USE_PM_ALPHA 1
code.
It's not perfect but it's more accurate.
Comparative:
Could be the fix introduced in v2.2.0 an option in the settings?
At least until a definitive solution is found.
from obs-shaderfilter.
Unfortunately, it is not an easy toggle off/on. I'll dig into this a bit more, but doing #define USE_PM_ALPHA 1
should be rendering in pretty much the same way as before. I don't mean to "blame upstream" but for some reason images are rendered/passed through by OBS completely different from any other source. It could be that the image isn't SRGB- so you might try just #define USE_PM_ALPHA 1
with turning off SRGB in the blending mode, and see if that does the trick?
from obs-shaderfilter.
Ok, so I've done some digging, and there is very strange behavior that goes on with image sources, and pre-multiplied alpha.
Case 1
Any source (that I've checked so far- video, media source, etc..) other than an Image Source. Color data is pre-multiplied by the source's alpha values, no matter where in the filter chain User Defined Shader
is.
Case 2
Image source, and user defined shader
is the first source in the filter chain. Color data is NOT pre-multiplied by the source's alpha.
Case 3
Image source, and user defined shader
is not the first source in the filter chain. Color data IS pre-multiplied by the source's alpha. And the weird part is- this is true even if the prior filters are all toggled off.
I've been able to replicate this behavior both with this plugin, as well as with my Advanced Mask plugin.
from obs-shaderfilter.
Thank you so much!
Solves the halo issue when only add an empty shader filter, without loading any shader.
The color issues still remains.
I tested the new build with the png from the last test:
https://www.cleanpng.com/png-light-halo-aperture-cool-the-aperture-325637/preview.html
If you add a shine shader, the alpha colors looks washed.
With #define USE_PM_ALPHA 1
added to the shine shader, the colors looks saturated (named shineALPHA.shader).
Adding another shader filter only with #define USE_PM_ALPHA 1
the png is displayed again like the v.2.1.3 of the plugin.
Tested with the HS logo and the bloom shader with and without #define USE_PM_ALPHA 1
from obs-shaderfilter.
Related Issues (20)
- Texture Sampling behaviour issues
- The shader seems to have skip sampling behavior HOT 1
- Bad types in shader crashes OBS
- Improper blending when alpha is zero but RGB values are not (0,0,0)
- User-Defined Shader not Showing HOT 6
- Linux filters only behave when actually sampling the image in an expected manner? HOT 7
- Buffer overflow in string parameters with escaped characters HOT 1
- Rounded Rectangle HOT 1
- Add 2nd source/image to page peel shader (and maybe other similar ones) HOT 1
- Blacked out camera HOT 1
- Off-scene transition video sources don't update or become visible for rendering when used HOT 4
- [feature] Source Mirror HOT 2
- No Delay Percentage on shine filter effect
- [feature] FSR or\and Anime4k upscalers as a shaders
- Adding extra pixels on left or right of image source containing a dithered image adds banding.
- Shader filter gets disabled during move transition HOT 2
- no matching function for call to `clamp(vec2, vec2, float) HOT 3
- OpenGL does not allow C style initializers. HOT 2
- unable to enter numbers larger than 1000 into uniforms HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obs-shaderfilter.