Resource icon

obs-shaderfilter 0.9-beta

NLeseul

Member
NLeseul submitted a new resource:

obs-shaderfilter - Apply custom shaders to your OBS sources

A video filter which allows you to apply your own shaders to a source. Several hopefully useful example shaders are included, including basic drop shadow, border, and rounded corner effects.

Note that this is a prerelease version at this time, and may cause OBS to crash or misbehave. Use at your own risk.

Read more about this resource...
 

GiacoAV

New Member
This actually is a really great start! There is some bug and glitches like the fact that i need to change my effect selection and switch back to the User-defined shader to have the shader options but i can get over that.

I have an idea though : Add blur filters
This could really be an awesome shader to add as for example i would use it as part of my overlay!

Keep up the good work!
 

NLeseul

Member
Here's a basic blur shader, as described here:

Code:
// Basic 9-tap Gaussian blur, applied in one direction. Apply in pairs, with blur_vertical set on every other
// instance, to get a two-dimensional blur.
// Based on: https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson5

uniform bool blur_vertical;

float4 mainImage(VertData v_in) : TARGET
{
    float4 sum = float4(0, 0, 0, 0);
  
    float hstep = !blur_vertical * uv_pixel_interval.x;
    float vstep = blur_vertical * uv_pixel_interval.y;
  
    sum += 0.0162162162 * image.Sample(textureSampler, float2(v_in.uv.x - 4 * hstep, v_in.uv.y - 4 * vstep));
    sum += 0.0540540541 * image.Sample(textureSampler, float2(v_in.uv.x - 3 * hstep, v_in.uv.y - 3 * vstep));
    sum += 0.1216216216 * image.Sample(textureSampler, float2(v_in.uv.x - 2 * hstep, v_in.uv.y - 2 * vstep));
    sum += 0.1945945946 * image.Sample(textureSampler, float2(v_in.uv.x - 1 * hstep, v_in.uv.y - 1 * vstep));
  
    sum += 0.2270270270 * image.Sample(textureSampler, v_in.uv);
  
    sum += 0.1945945946 * image.Sample(textureSampler, float2(v_in.uv.x + 1 * hstep, v_in.uv.y + 1 * vstep));
    sum += 0.1216216216 * image.Sample(textureSampler, float2(v_in.uv.x + 2 * hstep, v_in.uv.y + 2 * vstep));
    sum += 0.0540540541 * image.Sample(textureSampler, float2(v_in.uv.x + 3 * hstep, v_in.uv.y + 3 * vstep));
    sum += 0.0162162162 * image.Sample(textureSampler, float2(v_in.uv.x + 4 * hstep, v_in.uv.y + 4 * vstep));
  
    return sum;
}


You'll need to apply two of them to your source, one horizontal and one vertical.

This is a fixed-size blur with a radius of 4 pixels, so the effect isn't very strong. You should be able to apply multiple pairs to strengthen the effect, but watch your GPU usage.
 

NLeseul

Member
Hmm. I just upgraded my installation to 20.1.1, and I don't see any problems there.

What issue are you seeing in 20.1.0? Was this previously working for you in 20.0.1 and stopped working after you upgraded?
 

Paul of Tw

New Member
Hmm. I just upgraded my installation to 20.1.1, and I don't see any problems there.

What issue are you seeing in 20.1.0? Was this previously working for you in 20.0.1 and stopped working after you upgraded?

Nothing happened .... It didn't show the shaderfilter in filter menu, even though I put all required files into the correct obs file directory... I also reinstalled OBS studio to newest version 20.1.1. But the problem still goes on...

I'm using Windows 10 64-bit . I was wondering, maybe it's locale problem, because I'm using chinese language in OBS and this plug-in only have english now.

I tried to change full english in OBS, but nothing appeared.

I'm so glad and excited about this plug-in, wish this problem can be find out and fixed in the future. Thank you!!

showing.png
 

NLeseul

Member
Yeah, the locale difference shouldn't be an issue. I believe OBS will fall back on the default locale configured in the plugin (usually en-US) if it can't find your current locale. And even if that disappeared somehow, I think it would just show the unlocalized string IDs in the interface.

I'm also on Windows 10 64-bit, so there probably isn't anything odd there either.

If you don't even see an option to add this filter, that seems like the plugin DLL isn't being found by OBS for some reason. Can you check your OBS startup log ("Help" -> "Log Files" -> "View Current Log" immediately after starting OBS) and see if there's any reference to obs-shaderfilter.dll, error or otherwise? In mine, for example, I see this:

Code:
00:29:15.701: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/chrome_elf.dll' not found, loading of module failed
00:29:15.737: [CoreAudio encoder]: Adding CoreAudio AAC encoder
00:29:15.929: [AMF] Encountered Exception during AMF initialization: Unable to load 'amfrt64.dll', error code 126.
00:29:15.929: Failed to initialize module 'enc-amf.dll'
00:29:16.215: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/gsdll64.dll' not found, loading of module failed
00:29:16.224: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/libcef.dll' not found, loading of module failed
00:29:16.225: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/libEGL.dll' not found, loading of module failed
00:29:16.226: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/libGLESv2.dll' not found, loading of module failed
00:29:16.296: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/lua53.dll' not found, loading of module failed
00:29:16.297: Failed to load 'en-US' text for module: 'obs-browser.dll'
00:29:16.297: [browser_source: 'Version: 1.29.0']
00:29:16.916: LoadLibrary failed for 'nvEncodeAPI64.dll': The specified module could not be found.
00:29:16.916:  (126)
00:29:19.265: Failed to load 'en-US' text for module: 'tsuki-studio.dll'
00:29:19.358: VLC found, VLC video source enabled
00:29:19.636: No blackmagic support
00:29:20.544: ---------------------------------
00:29:20.544:   Loaded Modules:
00:29:20.544:     win-wasapi.dll
00:29:20.544:     win-mf.dll
00:29:20.544:     win-dshow.dll
00:29:20.544:     win-decklink.dll
00:29:20.544:     win-capture.dll
00:29:20.544:     vlc-video.dll
00:29:20.544:     tsuki-studio.dll
00:29:20.544:     text-freetype2.dll
00:29:20.544:     rtmp-services.dll
00:29:20.544:     obs-x264.dll
00:29:20.544:     obs-vst.dll
00:29:20.544:     obs-transitions.dll
00:29:20.544:     obs-text.dll
00:29:20.544:     obs-shaderfilter.dll
00:29:20.544:     obs-qsv11.dll
00:29:20.544:     obs-outputs.dll
00:29:20.544:     obs-ghostscript.dll
00:29:20.544:     obs-filters.dll
00:29:20.544:     obs-ffmpeg.dll
00:29:20.544:     obs-browser.dll
00:29:20.544:     image-source.dll
00:29:20.544:     frontend-tools.dll
00:29:20.544:     enc-amf.dll
00:29:20.544:     coreaudio-encoder.dll
00:29:20.544: ---------------------------------

Basically, there's some text in there about every DLL in the folder OBS is scanning, even the ones that can't be loaded as plugins. If OBS is failing to load the plugin for some reason, you should see an error about it there. If you don't see that, then OBS is probably looking in a different place for plugins than where you put the file.
 

Paul of Tw

New Member
Thanks for your suggestion! This time I use 32-bit version, and I open the log file, it did show the error message as follows:

Required module function 'obs_module_load' in module '../../obs-plugins/32bit/chrome_elf.dll' not found, loading of module failed
[CoreAudio encoder]: CoreAudio AAC encoder not installed on the system or couldn't be loaded
[AMF] Encountered Exception during AMF initialization: Unable to load 'amfrt32.dll', error code 126.
Failed to initialize module 'enc-amf.dll'
Required module function 'obs_module_load' in module '../../obs-plugins/32bit/libcef.dll' not found, loading of module failed
Required module function 'obs_module_load' in module '../../obs-plugins/32bit/libEGL.dll' not found, loading of module failed
Required module function 'obs_module_load' in module '../../obs-plugins/32bit/libGLESv2.dll' not found, loading of module failed
Failed to load 'en-US' text for module: 'obs-browser.dll'
[browser_source: 'Version: 1.29.0']
LoadLibrary failed for 'nvEncodeAPI.dll': The specified module could not be found.
(126)

LoadLibrary failed for '../../obs-plugins/32bit/obs-shaderfilter.dll': The specified module could not be found.
(126)
Module '../../obs-plugins/32bit/obs-shaderfilter.dll' not found

---------------------------------
Loaded Modules:
win-wasapi.dll
win-mf.dll
win-dshow.dll
win-decklink.dll
win-capture.dll
vlc-video.dll
text-freetype2.dll
rtmp-services.dll
obs-x264.dll
obs-vst.dll
obs-transitions.dll
obs-text.dll
obs-qsv11.dll
obs-outputs.dll
obs-filters.dll
obs-ffmpeg.dll
obs-browser.dll
image-source.dll
frontend-tools.dll
enc-amf.dll
coreaudio-encoder.dll
-----------------------------------------------
I re-checked again. Strangely I put all the needed files into correct position... Somehow OBS can't find it...

螢幕快照 2017-11-04 上午11.02.07.png
 

NLeseul

Member
LoadLibrary failed for '../../obs-plugins/32bit/obs-shaderfilter.dll': The specified module could not be found.
(126)
Module '../../obs-plugins/32bit/obs-shaderfilter.dll' not found

Thanks for checking that. That probably means Windows couldn't load the DLL due to a missing dependency. I checked the dependencies of the DLLs using the Dependency Walker (an excellent tool), and it looks like they are depending on some libraries from the latest Visual C++ Redistributable. I'd rather not rely on that, since none of the other DLLs in OBS Studio seem to, so I changed my build settings to prevent that dependency. Can you try installing from the attached archive and seeing if that resolve your problem? If so, I'll probably update the release on GitHub with this build, just in case anyone else is being affected by this.
 

Attachments

  • obs-shaderfilter-win-test.zip
    97.8 KB · Views: 323

Paul of Tw

New Member
It works !!! Thanks a lot !!!
螢幕快照 2017-11-05 上午7.40.18.png



Another suggestion, would that be possible to create a filter just like the "text outline"
(or can be described like border around texts ??)
Just like this example picture:
螢幕快照 2017-11-05 下午3.14.17.png


Although it's built in text source, but I want to insert outer source to make this effect. (using other application. After filtering, I can overlay dynamic texts in OBS )

 

NLeseul

Member

NLeseul

Member
No problem. Thanks for reporting the issue.

I think outline effects should be possible with a pixel shader, but it's not something I've tried myself. This article suggests one approach to doing it, if you want to experiment. "Step 4" in that article is all you'd need for a purposes of filtering a texture in OBS Studio, I think. Note that their code is written in Cg, not HLSL, so it wouldn't directly work in OBS Studio.
 

Paul of Tw

New Member
No problem. Thanks for reporting the issue.

I think outline effects should be possible with a pixel shader, but it's not something I've tried myself. This article suggests one approach to doing it, if you want to experiment. "Step 4" in that article is all you'd need for a purposes of filtering a texture in OBS Studio, I think. Note that their code is written in Cg, not HLSL, so it wouldn't directly work in OBS Studio.

Got it. Thank you so such !
 

NLeseul

Member
Excuse me, this filter can realize HQ2x ?

I don't know of any reason why it couldn't, as long as the HQ2x algorithm or any of the others can be implemented in an HLSL shader. Someone will have to write or adapt the shader code for them, though.

This project on GitHub seems to offer HLSL/Cg implementations of several of those algorithms that you or someone else might be able to use as a starting point.
 

Matyugovich

New Member
It would be awesome if someone could adapt motion blur shader to this. My skills in coding is pretty low, the best that i can do is basic HTML. Could actually donate some bucks $ to the person who does this for me.
 
Last edited:

NLeseul

Member
As far as I can tell from here and here, generalized motion blur isn't particularly easy and would pretty much need to be built into your game engine rather than applied after the fact.

Are you hoping to apply motion blur to the contents of a game capture, or do you just want there to be motion blur on a graphic that is moving around in OBS Studio's workspace?
 

regidark

New Member
Hello! I downloaded your plugin but when i unzip i don´t see the same folders as in your youtube video. Did you change anything? Is there any other place where i can download the full version?
Thanks a lot in advance
 
Top