Skip to content

Commit f2cf0b5

Browse files
committed
obs-shaderfilter: Version 1.2
Add new standard parameters (loops, local time, 2 new random numbers) Update UI Update filter templates Add fire shader Add matrix effect Add Night Sky background Update Readme
1 parent c7a1525 commit f2cf0b5

8 files changed

+279
-98
lines changed

README.md

+29-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# obs-shaderfilter 1.11
1+
# obs-shaderfilter 1.2
22

33
## Introduction
44

@@ -51,7 +51,7 @@ that need to render outside the bounds of the original source.
5151

5252
Normally, all that's required for OBS purposes is a pixel shader, so the plugin will wrap your shader text with a
5353
standard template to add a basic vertex shader and other boilerplate. If you wish to customize the vertex shader
54-
or other parts of the effect for some reason, you can check the "Override entire effect" option.
54+
or other parts of the effect for some reason, you can check the "Use Effect File (.effect)" option.
5555

5656
Any parameters you add to your shader (defined as `uniform` variables) will be detected by the plugin and exposed
5757
in the properties window to have their values set. Currently, only `int`, `float`, `bool`, `string`, `texture2d`, and `float4`
@@ -77,8 +77,12 @@ handle these variables being missing, but the shader may malfunction.)
7777
* **`image`** (`texture2d`)—The image to which the filter is being applied, either the original output of
7878
the source or the output of the previous filter in the chain. (Standard for all OBS filters.)
7979
* **`elapsed_time`** (`float`)—The time in seconds which has elapsed since the filter was created. Useful for
80-
creating animations.
81-
* **`rand_f`** (`float`)— a random float between 0 and 1.
80+
creating animations.
81+
* **`local_time`** (`float`)— a random float representing the local time.(1.2)
82+
* **`loops`** (`int`)— count of how many loops times the shader has rendered a page.(1.2)
83+
* **`rand_f`** (`float`)— a random float between 0 and 1. changes per frame.
84+
* **`rand_activation_f`** (`float`)— a random float between 0 and 1. changes per activation, load or change of settings.(1.2)
85+
* **`rand_instance_f`** (`float`)— a random float between 0 and 1. changes per instance on load.(1.2)
8286
* **`uv_offset`** (`float2`)—The offset which should be applied to the UV coordinates of the vertices. This is
8387
used in the standard vertex shader to draw extra pixels on the borders of the source.
8488
* **`uv_scale`** (`float2`)—The scale which should be applied to the UV coordinates of the vertices. This is
@@ -89,8 +93,10 @@ handle these variables being missing, but the shader may malfunction.)
8993
texture, or otherwise scale UV coordinate distances into texel distances.
9094

9195
### New Options in version 1.1+
92-
* *Use Slider Inputs— Converts Integer and floating point inputs into sliders in the UI.
93-
* *Use Shader Time—Start the effect from the loadtime of the shader, not the start up time of OBS Studio.
96+
* **`Use Slider Inputs`**— Converts Integer and floating point inputs into sliders in the UI.
97+
* **`Use Shader Time`**—Start the effect from the loadtime of the shader, not the start up time of OBS Studio.
98+
* **`Override Entire Effect`** renamed **`Use Effect File (.effect)`** in UI and documentation
99+
* Textures moved from the shaders folder to the textures folder. Existing textures are not deleted so as to not disrupt you current scenes.(1.2)
94100

95101
### Example shaders
96102

@@ -102,29 +108,36 @@ loaded.
102108
I recommend *.shader* as they do not require `override_entire_effect` as pixel shaders, while *.effect* signifies vertex shaders with `override_entire_effect` required.
103109

104110
* *animated_texture.effect*— Animates a texture with polar sizing and color options
111+
* *ascii.shader*— a little example of ascii art
105112
* *background_removal.effect*— simple implementation of background removal. Optional color space corrections
106113
* *blink.shader*—A shader that fades the opacity of the output in and out over time, with a configurable speed
107114
multiplier. Demonstrates the user of the `elapsed_time` parameter.
108115
* *bloom.shader / glow.shader*— simple shaders to add glow or bloom effects, the glow shader has some additional options for animation
109-
* *cartoon.effect* (Overrides entire effect)— Simple Cartooning based on hue and steps of detail value.
116+
* *cartoon.effect* (Use Effect File (.effect))— Simple Cartooning based on hue and steps of detail value.
110117
* *border.shader*—A shader that adds a solid border to all extra pixels outside the bounds of the input.
111118
* *drop_shadow.shader*—A shader that adds a basic drop shadow to the input. Note that this is done with a simple
112119
uniform blur, so it won't look quite as good as a proper Gaussian blur. This is also an O(N²) blur on the size
113120
of the blur, so be very conscious of your GPU usage with a large blur size.
114121
* *edge_detection.shader*—A shader that detects edges of color. Includes support for alpha channels.
115-
* *filter_template.effect* (Overrides entire effect)—A copy of the default effect used by the plugin, which simply
122+
* *filter_template.effect* (Use Effect File (.effect))—A copy of the default effect used by the plugin, which simply
116123
renders the input directly to the output after scaling UVs to reflect any extra border pixels. This is useful as a starting
117124
point for developing new effects, especially those that might need a custom vertex shader. (Note that modifying this file will
118125
not affect the internal effect template used by the plugin.)
126+
* *filter_template.shader* —A copy of the default shader used by the plugin, which simply
127+
renders the input directly to the output after scaling UVs to reflect any extra border pixels. This is useful as a starting
128+
point for developing new pixel shaders. (Note that modifying this file will not affect the internal effect template used by the plugin.)
129+
* *fire.shader*— A fire example converted from shadertoy
119130
* *gradient.shader*— This shader has a little brother *simple_gradient.shader*, but lets you choose three colors and animate gradients.
120131
* *glitch_analog.shader*—A shader that creates glitch effects similar to analog signal issues. Includes support for alpha channel.
121132
* *hexagon.shader*—A shader that creates a grid of hexagons with several options for you to set. This is an example of making shapes.
122133
* *luminance.shader*—A shader that adds an alpha layer based on brightness instead of color. Extremely useful for making live
123134
video special effects, like replacing backgrounds or foregrounds.
135+
* *matrix.effect*— The cat is a glitch conversion from shadertoy. Updated with several configurable options.(1.2)
124136
* *multiply.shader*—A shader that multiplies the input by another image specified in the parameters. Demonstrates the use
125137
of user-defined `texture2d` parameters.
126-
* *perlin_noise.effect* (Overrides entire effect)—An effect generates perlin_noise, used to make water, clouds and glitch effects.
127-
* *pulse.effect* (Overrides entire effect)—An effect that varies the size of the output over time. This demonstrates
138+
* *night_sky.shader*— Animated moon, clouds, stars background(1.2)
139+
* *perlin_noise.effect* (Use Effect File (.effect))—An effect generates perlin_noise, used to make water, clouds and glitch effects.
140+
* *pulse.effect* (Use Effect File (.effect))—An effect that varies the size of the output over time. This demonstrates
128141
a custom vertex shader that manipulates the position of the rendered vertices based on user data. Note that moving the vertices
129142
in the vertex shader will not affect the logical size of the source in OBS, and this may mean that pixels outside the source's
130143
bounds will get cut off by later filters in the filter chain.
@@ -134,14 +147,14 @@ I recommend *.shader* as they do not require `override_entire_effect` as pixel s
134147
Pixels inside the bounds of the input are treated as solid; pixels outside are treated as opaque. The complexity of the blur
135148
does not increase with its size, so you should be able to make your blur size as large as you like wtihout affecting
136149
GPU load.
137-
* *repeat.effect* (Overrides entire effect)—Duplicates the input video as many times as you like and organizes on the screen.
150+
* *repeat.effect* (Use Effect File (.effect))—Duplicates the input video as many times as you like and organizes on the screen.
138151
* *rgb_color_wheel.shader—A rotatable RGB color wheel!
139-
* *rotatoe.effect* (Overrides entire effect)—A test rotation effect
152+
* *rotatoe.effect* (Use Effect File (.effect))—A test rotation effect
140153
* *rounded_rect.shader*—A shader that rounds the corners of the input, optionally adding a border outside the rounded
141154
edges.
142155
* *scan_line.shader*—An effect that creates old style tv scan lines, for glitch style effects.
143156
* *selective_color.shader*—Create black and white effects with some colorization. (defaults: .4,.03,.25,.25, 5.0, true,true, true, true. cuttoff higher = less color, 0 = all 1 = none)
144-
* *shake.effect* (Overrides entire effect)—creates random screen glitch style shake. Keep the random_scale low for small (0.2-1) for small
157+
* *shake.effect* (Use Effect File (.effect))—creates random screen glitch style shake. Keep the random_scale low for small (0.2-1) for small
145158
jerky movements and larger for less often big jumps.
146159
* *spotlight.shader*—Creates a stationary or animated spotlight effect with color options, speed of animation and glitch
147160
* *shine.shader*—Add shine / glow to any element, use the transition luma wipes (obs-studio\plugins\obs-transitions\data\luma_wipes *SOME NEW WIPES INCLUDED IN THIS RELEASE ZIP*) or create your own,
@@ -151,7 +164,7 @@ I recommend *.shader* as they do not require `override_entire_effect` as pixel s
151164
suggested default settings is opacity 0.5, innerRadius = 0.5, outerRadius = 1.2
152165
* *zoom_blur.shader*—A shader that creates a zoom with blur effect based on a number of samples and magnitude of each sample. It also includes
153166
an animation with or without easing and a glitch option. Set speed to zero to not use animation. Suggested values are 15 samples and 30-50 magnitude.
154-
* *other*— I have far too many shaders to list. Please check [Examples folder](https://github.com/Oncorporation/obs-shaderfilter/tree/master/data/examples)
167+
* *other*— We have far too many shaders to list. Please check [Examples folder](https://github.com/Oncorporation/obs-shaderfilter/tree/master/data/examples)
155168
or find me on discord, as I have many additional filters for fixing input problems.
156169

157170
## Building
@@ -180,5 +193,5 @@ mess to deal with and I don't like it.
180193

181194
## Donations
182195

183-
I appreciate donations on twitch.tv/surn , [Bitcoin](bitcoin:3HAN6eVxv81URgj51wxeCd9eMhg3tvriro) or [LiteCoin](litecoin:MQFVTFCZUtcucZJzQCyiSDTirrWGqTyCjM).
184-
Why Crypto? You do not have free speech when you live in fear of everything being taken away on an authoritarian whim, a criminal plot or by a outraged mob.
196+
I appreciate donations/follows/subs on twitch.tv/surn , [Bitcoin](bitcoin:3HAN6eVxv81URgj51wxeCd9eMhg3tvriro) or [LiteCoin](litecoin:MQFVTFCZUtcucZJzQCyiSDTirrWGqTyCjM).
197+
Why Crypto? We do not have free speech when we live in fear of everything being taken away on an authoritarian whim, a criminal plot or an outraged mob?

data/examples/filter_template.effect

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1+
//My effect modified to by Me for use with obs-shaderfilter month/year v.01
12
uniform float4x4 ViewProj;
23
uniform texture2d image;
34

5+
//Section to converting GLSL to HLSL - can delete
6+
#define vec2 float2
7+
#define vec3 float3
8+
#define vec4 float4
9+
#define ivec2 int2
10+
#define ivec3 int3
11+
#define ivec4 int4
12+
#define mat2 float2x2
13+
#define mat3 float3x3
14+
#define mat4 float4x4
15+
#define fract frac
16+
#define mix lerp
17+
#define iTime float
18+
419
uniform float elapsed_time;
520
uniform float2 uv_offset;
621
uniform float2 uv_scale;
722
uniform float2 uv_pixel_interval;
8-
uniform float rand_f;
923
uniform float2 uv_size;
10-
uniform string notes;
24+
uniform float rand_f;
25+
uniform float rand_instance_f;
26+
uniform float rand_activation_f;
27+
uniform int loops;
28+
uniform float local_time;
29+
uniform string notes = "add notes here";
1130

1231
sampler_state textureSampler {
1332
Filter = Linear;

data/examples/filter_template.shader

+31-20
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,49 @@
1+
//My shader modified to by Me for use with obs-shaderfilter month/year v.01
2+
3+
//Section to converting GLSL to HLSL - can delete
4+
#define vec2 float2
5+
#define vec3 float3
6+
#define vec4 float4
7+
#define ivec2 int2
8+
#define ivec3 int3
9+
#define ivec4 int4
10+
#define mat2 float2x2
11+
#define mat3 float3x3
12+
#define mat4 float4x4
13+
#define fract frac
14+
#define mix lerp
15+
#define iTime float
16+
17+
/*
18+
**Shaders have these variables pre loaded by the plugin**
19+
**this section can be deleted**
20+
121
uniform float4x4 ViewProj;
222
uniform texture2d image;
323
424
uniform float elapsed_time;
525
uniform float2 uv_offset;
626
uniform float2 uv_scale;
727
uniform float2 uv_pixel_interval;
8-
uniform float rand_f;
928
uniform float2 uv_size;
29+
uniform float rand_f;
30+
uniform float rand_instance_f;
31+
uniform float rand_activation_f;
32+
uniform int loops;
33+
uniform float local_time;
34+
*/
1035
uniform string notes = "add notes here";
1136

12-
sampler_state textureSampler {
13-
Filter = Linear;
14-
AddressU = Border;
15-
AddressV = Border;
16-
BorderColor = 00000000;
17-
};
18-
19-
struct VertData {
20-
float4 pos : POSITION;
21-
float2 uv : TEXCOORD0;
22-
};
23-
24-
VertData mainTransform(VertData v_in)
25-
{
26-
VertData vert_out;
27-
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
28-
vert_out.uv = v_in.uv * uv_scale + uv_offset;
29-
return vert_out;
30-
}
3137

3238
float4 mainImage(VertData v_in) : TARGET
3339
{
3440
return image.Sample(textureSampler, v_in.uv);
3541
}
3642

43+
/*
44+
**Shaders use the built in Draw technique**
45+
**this section can be deleted**
46+
3747
technique Draw
3848
{
3949
pass
@@ -42,3 +52,4 @@ technique Draw
4252
pixel_shader = mainImage(v_in);
4353
}
4454
}
55+
*/

data/examples/fire.shader

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
//fire shader modified by Charles Fettinger for use with obs-shaderfilter 07/20 v.01
2+
// https://github.com/Oncorporation/obs-shaderfilter plugin
3+
// https://www.shadertoy.com/view/MtcGD7 original version
4+
5+
//Section to converting GLSL to HLSL - can delete
6+
#define vec2 float2
7+
#define vec3 float3
8+
#define vec4 float4
9+
#define ivec2 int2
10+
#define ivec3 int3
11+
#define ivec4 int4
12+
#define mat2 float2x2
13+
#define mat3 float3x3
14+
#define mat4 float4x4
15+
#define fract frac
16+
#define mix lerp
17+
//#define iTime float
18+
19+
/*
20+
**Shaders have these variables pre loaded by the plugin**
21+
**this section can be deleted**
22+
23+
uniform float4x4 ViewProj;
24+
uniform texture2d image;
25+
26+
uniform float elapsed_time;
27+
uniform float2 uv_offset;
28+
uniform float2 uv_scale;
29+
uniform float2 uv_pixel_interval;
30+
uniform float2 uv_size;
31+
uniform float rand_f;
32+
uniform float rand_instance_f;
33+
uniform float rand_activation_f;
34+
uniform int loops;
35+
uniform float local_time;
36+
*/
37+
uniform string notes = "add notes here";
38+
39+
uniform bool Invert_Direction <
40+
string name = "Invert Direction";
41+
> = true;
42+
43+
vec3 rgb2hsv(vec3 c)
44+
{
45+
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
46+
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
47+
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
48+
49+
float d = q.x - min(q.w, q.y);
50+
float e = 1.0e-10;
51+
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
52+
}
53+
54+
vec3 hsv2rgb(vec3 c)
55+
{
56+
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
57+
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
58+
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
59+
}
60+
61+
float rand(vec2 n)
62+
{
63+
return fract(sin(cos(dot(n, vec2(12.9898, 12.1414)))) * 83758.5453);
64+
//return rand_f;
65+
}
66+
67+
float noise(vec2 n)
68+
{
69+
const vec2 d = vec2(0.0, 1.0);
70+
vec2 b = floor(n), f = smoothstep(vec2(0.0, 0.0), vec2(1.0, 1.0), fract(n));
71+
return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
72+
}
73+
74+
float fbm(vec2 n)
75+
{
76+
float total = 0.0, amplitude = 1.0;
77+
for (int i = 0; i < 5; i++)
78+
{
79+
total += noise(n) * amplitude;
80+
n += n * 1.7;
81+
amplitude *= 0.47;
82+
}
83+
return total;
84+
}
85+
86+
float4 mainImage(VertData v_in) : TARGET
87+
{
88+
//float4 rgba = image.Sample(textureSampler, v_in.uv);
89+
float2 iResolution = 1 - v_in.uv + float2( .99, 1.15);
90+
float iTime = elapsed_time;
91+
92+
const vec3 c1 = vec3(0.5, 0.0, 0.1);
93+
const vec3 c2 = vec3(0.9, 0.1, 0.0);
94+
const vec3 c3 = vec3(0.2, 0.1, 0.7);
95+
const vec3 c4 = vec3(1.0, 0.9, 0.1);
96+
const vec3 c5 = vec3(0.1, 0.1, 0.1);
97+
const vec3 c6 = vec3(0.9, 0.9, 0.9);
98+
99+
vec2 speed = vec2(1.2, 0.1);
100+
float shift = 1.327 - sin(iTime * 2.0) / 2.4;
101+
float alpha = 1.0;
102+
103+
//change the constant term for all kinds of cool distance versions,
104+
//make plus/minus to switch between
105+
//ground fire and fire rain!
106+
float dist = 3.5 - sin(iTime * 0.4) / 1.89;
107+
108+
vec2 p = v_in.uv.xy * dist / iResolution.xx;
109+
p.x -= iTime / 1.1;
110+
float q = fbm(p - iTime * 0.01 + 1.0 * sin(iTime) / 10.0);
111+
float qb = fbm(p - iTime * 0.002 + 0.1 * cos(iTime) / 5.0);
112+
float q2 = fbm(p - iTime * 0.44 - 5.0 * cos(iTime) / 7.0) -6.0;
113+
float q3 = fbm(p - iTime * 0.9 - 10.0 * cos(iTime) / 30.0) -4.0;
114+
float q4 = fbm(p - iTime * 2.0 - 20.0 * sin(iTime) / 20.0) +2.0;
115+
q = (q + qb - .4 * q2 - 2.0 * q3 + .6 * q4) / 3.8;
116+
vec2 r = vec2(fbm(p + q / 2.0 - iTime* speed.x - p.x - p.y),
117+
fbm(p - q - iTime* speed.y));
118+
vec3 c = mix(c1, c2, fbm(p + r)) + mix(c3, c4, r.x) - mix(c5, c6, r.y);
119+
vec3 color = vec3(c * cos(shift * 1 - v_in.uv.y / iResolution.y));
120+
color += .05;
121+
color.r *= .8;
122+
vec3 hsv = rgb2hsv(color);
123+
hsv.y *= hsv.z * 1.1;
124+
hsv.z *= hsv.y * 1.13;
125+
hsv.y = (2.2 - hsv.z * .9) * 1.20;
126+
color = hsv2rgb(hsv);
127+
128+
return vec4(color.x, color.y, color.z, alpha);
129+
}
130+
131+
132+

data/examples/matrix.effect

+16-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ uniform float2 uv_scale;
2424
uniform float2 uv_size;
2525
uniform float2 uv_pixel_interval;
2626
uniform float rand_f;
27+
uniform float rand_instance_f;
28+
uniform float rand_activation_f;
29+
uniform int loops;
30+
uniform float local_time;
31+
2732

2833
uniform float2 mouse<
2934
string name = "Virtual Mouse Coordinates";
@@ -66,12 +71,21 @@ uniform bool Apply_To_Alpha_Layer = true;
6671
float vorocloud(float2 p){
6772
float f = 0.0;
6873
float flow = 1.0;
74+
float time = elapsed_time;
6975
if(Invert_Direction){
7076
flow *= -1;
7177
}
78+
/*
79+
//periodically stop
80+
if (loops % 16 >= 8.0)
81+
{
82+
time = local_time - elapsed_time;
83+
}
84+
*/
85+
7286
float r = clamp(Ratio,-50,50);
73-
float2 pp = cos(float2(p.x * 14.0, (16.0 * p.y + cos(floor(p.x * 30.0)) + flow * elapsed_time * PI2)) );
74-
p = cos(p * 12.1 + pp * r + sin(elapsed_time/PI)*(r/PI) + 0.5 * cos(pp.x * r + sin(elapsed_time/PI)*(r/PI)));
87+
float2 pp = cos(float2(p.x * 14.0, (16.0 * p.y + cos(floor(p.x * 30.0)) + flow * time * PI2)) );
88+
p = cos(p * 12.1 + pp * r + sin(time/PI)*(r/PI) + 0.5 * cos(pp.x * r + sin(time/PI)*(r/PI)));
7589

7690
float2 pts[4];
7791

0 commit comments

Comments
 (0)