Skip to content

OBS Shading Language

Xaymar edited this page Nov 7, 2021 · 21 revisions

OBS Shading Language (OBS-SL)

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.

Data

Similar to HLSL, OBS-SL supports storage, transfer and modification of data.

Storage Specifiers

Storage specifiers seem to only be used by the OpenGL backend.

Name DirectX OpenGL Notes
uniform uniform
const const
inout inout
out out

Types

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

Arrays

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.

Keywords

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)

Input/Output Semantics

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
Clone this wiki locally