-
Notifications
You must be signed in to change notification settings - Fork 3k
Source Filter Transition Shader
StreamFX ships with three different ways to use custom shaders in OBS Studio: Source Shader, Filter Shader and Transition Shader. Each has slightly different usage, but can mostly work with almost the same shader and allows you to easily use your own or someone elses shaders in OBS Studio. Shaders allow for quick iteration and enable some effects that were previously impossible.
Version Information
Status | Version |
---|---|
Added | 0.5 |
Unstable | N/A |
Stable | N/A |
Deprecated | N/A |
Removed | N/A |
(note: links are currently dead)
TODO
The []
denote optional things, while the ()
denote required things. They are only used to illustrate the structure itself, and must be removed.
uniform (type) (name)<
// 'true' to allow Users to see this parameters, 'false' to hide it. Enables invisible parameters which do special things with scripts.
[bool visible = true;]
// 'true' to completely disallow modification from outside. Useful for predefined parameters and values that are spread from other parameters.
[bool automatic = false;]
// Name used in the UI.
[string name = "Name";]
// Description used in the UI.
[string description = "Description";]
// DANGEROUS: Override the detected type with a specific one. Do not use unless you absolutely need it.
[string type = "bool";] // Turn this into a boolean.
[string type = "float";] // Turn this into a float.
[string type = "int";] // Turn this into an integer.
[string type = "string";] // Turn this into a string.
[string type = "texture";] // Turn this into a texture.
[string type = "sampler";] // Turn this into a sampler.
// DANGEROUS: Override the detected size with a specified one. Do not use unless you absolutely need it.
[int size = 1;]
>[ = (value)];
A value parameter is one of the following types: float, float#, float[], float#x#, int, int#, int[], int#x#, uint, uint#, uint[], uint#x#, bool, bool#, bool[], bool#x#. Some types may require type and size overrides in order to be detected correctly.
uniform (type) (name)<
// ... continued from Generic Parameters
// Changes the field type to a different one.
[string field_type = "input";] // Standard input widget with manual entry and nothing fancy.
[string field_type = "slider";] // Horizontal slider with manual entry option.
[string field_type = "enum";] // Dropdown with enumeration entries, see "Enumeration Parameters".
// Suffix for the values.
[string suffix = " my awesome suffix";]
// Minimum value that can be set.
[(type) minimum = {...};] // Defaults to the smallest possible number.
// Maximum value that can be set.
[(type) maximum = {...};] // Defaults to the largest possible number.
// The step of the value.
[(type) step = {...};] // Defaults to 1.
// The scale of the value, which is applied to everything. Can be used to greatly increase the precision of an property.
[(type) scale = {...};] // Defaults to 1.
>[ = (value)];
A subset of value parameters where the selection is limited to a defined list of values, which can be defined in the shader. This can be useful to have users select from certain behavior instead of requiring them to enter numbers manually.
Entries in the list are limited to int, float and string, the three basic types of parameters. Vector types will simply act as an array of the basic type, and show a dropdown for each vector part. A float4 for example would allow the user to pick a value for r, g, b and a (or x, y, z and w).
uniform (type) (name)<
// ... continued from Generic Parameters
// Set the field type to enumeration.
[string field_type = "enum";] // Dropdown with enumeration entries.
// Defines the #. enumeration entry of the list. # must be a continuously increasing number starting from 0.
[(base type) enum_# = (value);] // The value of the enumeration entry.
[string enum_#_name = "(name)";] // The name of the enumeration entry, optional. If not specified, defaults to "Unnamed Entry".
>[ = (value)];
Camera Projection Matrix, must be used in the Vertex Shader.
This is an automatically set option, ensure that the user does not see it by setting the annotation 'bool automatic = true;'.
The current time since the creation of the shader, in seconds.
- x: Time in seconds since the source was created. (float)
- y: Time in the current second.
- z: Time in seconds since the source was created. (rounded down to nearest integer)
- w: Reserved
This is an automatically set option, ensure that the user does not see it by setting the annotation 'bool automatic = true;'.
- x: Width
- y: Height
- z: 1. / Width
- w: 1. / Height
This is an automatically set option, ensure that the user does not see it by setting the annotation 'bool automatic = true;'.
Available only to Filters and Transitions, holds a 2D Texture of size ViewSize.xy
with the content that is to be filtered or transitioned from.
This is an automatically set option, ensure that the user does not see it by setting the annotation 'bool automatic = true;'.
Available only to Transitions, holds a 2D Texture of size ViewSize.xy
with the content that is to be transitioned to.
This is an automatically set option, ensure that the user does not see it by setting the annotation 'bool automatic = true;'.
Value from 0 to 1 that describes the current expected progress of the transition. The transition must have completed by the time this value reaches 1 or the transition is cut off.
This is an automatically set option, ensure that the user does not see it by setting the annotation 'bool automatic = true;'.
The seed value used for randomization, user controlled. Changing this automatically regenerates all random values.
This is an automatically set option, ensure that the user does not see it by setting the annotation 'bool automatic = true;'.
A matrix containing random values that are generated per-instance, per-activation and per-frame. Use it like this:
float4 perInst = float4(Random[0][0], Random[1][0], Random[2][0], Random[3][0]);
float4 perActivation = float4(Random[0][1], Random[1][1], Random[2][1], Random[3][1]);
float4 perFrame1 = float4(Random[0][2], Random[1][2], Random[2][2], Random[3][2]);
float4 perFrame2 = float4(Random[0][3], Random[1][3], Random[2][3], Random[3][3]);
This is an automatically set option, ensure that the user does not see it by setting the annotation 'bool automatic = true;'.
The baseline for the shader language libOBS uses is HLSL, for which you can find documentation here. libOBS modifies this so it works across all of its supported graphics APIs, sacrificing functionality and versatility for compatibility. As a result, some effects that would be possible with ease in GLSL or HLSL directly do not work in libOBS's shader language. For the sake of all future documentation, the langauge will be referred to as OBS-SL, since it mixes and matches many different langauge constructs into one.
Similar to HLSL, OBS-SL supports storage, transfer and modification of data.
Name | DirectX | OpenGL |
---|---|---|
bool |
bool |
bool |
float |
float |
float |
float2 |
float2 |
vec2 |
float3 |
float3 |
vec3 |
float4 |
float4 |
vec4 |
int |
int |
int |
int2 |
int2 |
ivec2 |
int3 |
int3 |
ivec3 |
int4 |
int4 |
ivec4 |
string |
string |
string |
float3x3 |
float3x3 |
mat3x3 |
float3x4 |
float3x4 |
mat3x4 |
float4x4 |
float4x4 |
mat4x4 |
texture2d |
Texture2D |
sampler2D |
texture3d |
Texture3D |
sampler3D |
texture_cube |
TextureCube |
samplerCube |
texture_rect |
N/A | sampler2DRect |
sampler_state |
SamplerState |
Metadata only |
At the time of writing this, Arrays are only supported when DirectX is being used by libOBS. The patch to make it available in OpenGL was retracted at the request of the current OBS Project team.
Storage specifiers seem to only be used by the OpenGL backend.
Name | DirectX | OpenGL | Notes |
---|---|---|---|
uniform |
uniform |
||
const |
const |
||
inout |
inout |
||
out |
out |
A limited subset of keywords are supported, other keywords may work if they match across both langauges.
Name | DirectX | OpenGL |
---|---|---|
POSITION |
SV_Position |
gl_FragCoord |
TARGET |
SV_Target |
N/A |
VERTEXID |
SV_VertexID |
uint(gl_VertexID) |
A limited subset of semantics are supported, other keywords will not work.
Name | DirectX | OpenGL | Notes |
---|---|---|---|
POSITION |
SV_Position |
Metadata only | Provided as float32[4]
|
NORMAL |
NORMAL |
Metadata only | Provided as float32[4]
|
COLOR |
COLOR |
Metadata only | Provided as uint8_unorm[4]
|
TANGENT |
TANGENT |
Metadata only | Provided as float32[4]
|
TEXCOORD |
TEXCOORD |
Metadata only | Either float32 , float32[2] or float32[4] . |
VERTEXID |
VERTEXID |
Metadata only |
This work is licensed under a Creative Commons Attribution 4.0 International License.
The wiki has been under repeated automated attacks by bots, with attempts to phish or infect unsuspecting users with malware, trojans and similar software. As a response to these attacks and GitHubs complete ineptitude at handling this situation, we have decided to write-protect the wiki for the time being. If you wish to submit changes to the wiki, please do so over Discord. Thank you for understanding!
- 🟢 3D Transform
- 🔴 Auto-Framing
- 🟠 Blur
- 🟢 Color Grading
- 🔴 Denoising
- ❌ Displacement Mapping
- 🟢 Dynamic Mask
⚠️ SDF Effects- 🔴 Shaders
- 🔴 Spout
- 🔴 Upscaling
- 🔴 Virtual Greenscreen
- 🔴 Shaders
- 🔴 Sink
⚠️ Source Mirror
- 🔴 Shaders