mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
5a3954ae0e
Fixes several files incorrectly stated a different license from the actual project, as well as the copyright headers included in all files. This change has no effect on the licensing terms, it should clear up a bit of confusion by contributors. Plus the files get a bit smaller, and we have less duplicated information across the entire project. Overall the project is GPLv2 if not built with Qt, and GPLv3 if it is built with Qt. There are no parts licensed under a different license, all have been adapted from other compatible licenses into GPLv2 or GPLv3.
142 lines
5.1 KiB
Text
142 lines
5.1 KiB
Text
// AUTOGENERATED COPYRIGHT HEADER START
|
|
// Copyright (C) 2020-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
|
|
|
uniform float4x4 ViewProj;
|
|
uniform texture2d image;
|
|
uniform int size;
|
|
|
|
sampler_state pixelSampler {
|
|
Filter = Point;
|
|
AddressU = Clamp;
|
|
AddressV = Clamp;
|
|
};
|
|
|
|
struct VertData {
|
|
float4 pos : POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
VertData vertex_program(VertData vd)
|
|
{
|
|
vd.pos = mul(float4(vd.pos.xyz, 1.0), ViewProj);
|
|
return vd;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------- //
|
|
// Helpers
|
|
// -------------------------------------------------------------------------------- //
|
|
uint get_selector(VertData vd, int components) {
|
|
return uint(vd.uv.x * size * components) % components;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------- //
|
|
// Pack/Unpack RG/GR
|
|
// -------------------------------------------------------------------------------- //
|
|
float4 _PackRG(VertData vd) : TARGET {
|
|
if (get_selector(vd, 2) == 0) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).r, 0., 0., 1.);
|
|
} else {
|
|
return float4(image.Sample(pixelSampler, vd.uv).g, 0., 0., 1.);
|
|
}
|
|
}
|
|
technique PackRG { pass { vertex_shader = vertex_program(vd); pixel_shader = _PackRG(vd); } }
|
|
|
|
float4 _PackGR(VertData vd) : TARGET {
|
|
if (get_selector(vd, 2) == 0) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).g, 0., 0., 1.);
|
|
} else {
|
|
return float4(image.Sample(pixelSampler, vd.uv).r, 0., 0., 1.);
|
|
}
|
|
}
|
|
technique PackGR { pass { vertex_shader = vertex_program(vd); pixel_shader = _PackGR(vd); } }
|
|
|
|
// -------------------------------------------------------------------------------- //
|
|
// Pack/Unpack RGB/BGR
|
|
// -------------------------------------------------------------------------------- //
|
|
float4 _PackRGB(VertData vd) : TARGET {
|
|
uint select = get_selector(vd, 3);
|
|
if (select == 0) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).r, 0., 0., 1.);
|
|
} else if (select == 1) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).g, 0., 0., 1.);
|
|
} else {
|
|
return float4(image.Sample(pixelSampler, vd.uv).b, 0., 0., 1.);
|
|
}
|
|
}
|
|
technique PackRGB { pass { vertex_shader = vertex_program(vd); pixel_shader = _PackRGB(vd); } }
|
|
|
|
float4 _PackBGR(VertData vd) : TARGET {
|
|
uint select = get_selector(vd, 3);
|
|
if (select == 0) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).b, 0., 0., 1.);
|
|
} else if (select == 1) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).g, 0., 0., 1.);
|
|
} else {
|
|
return float4(image.Sample(pixelSampler, vd.uv).r, 0., 0., 1.);
|
|
}
|
|
return float4(0., 0., 0., 0.);
|
|
}
|
|
technique PackBGR { pass { vertex_shader = vertex_program(vd); pixel_shader = _PackBGR(vd); } }
|
|
|
|
// -------------------------------------------------------------------------------- //
|
|
// Pack/Unpack RGBA/ABGR
|
|
// -------------------------------------------------------------------------------- //
|
|
float4 _PackRGBA(VertData vd) : TARGET {
|
|
uint select = get_selector(vd, 4);
|
|
if (select == 0) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).r, 0., 0., 1.);
|
|
} else if (select == 1) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).g, 0., 0., 1.);
|
|
} else if (select == 2) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).b, 0., 0., 1.);
|
|
} else {
|
|
return float4(image.Sample(pixelSampler, vd.uv).a, 0., 0., 1.);
|
|
}
|
|
}
|
|
technique PackRGBA { pass { vertex_shader = vertex_program(vd); pixel_shader = _PackRGBA(vd); } }
|
|
|
|
float4 _PackABGR(VertData vd) : TARGET {
|
|
uint select = get_selector(vd, 4);
|
|
if (select == 0) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).a, 0., 0., 1.);
|
|
} else if (select == 1) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).b, 0., 0., 1.);
|
|
} else if (select == 1) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).g, 0., 0., 1.);
|
|
} else {
|
|
return float4(image.Sample(pixelSampler, vd.uv).r, 0., 0., 1.);
|
|
}
|
|
}
|
|
technique PackABGR { pass { vertex_shader = vertex_program(vd); pixel_shader = _PackABGR(vd); } }
|
|
|
|
// -------------------------------------------------------------------------------- //
|
|
// Pack/Unpack ARGB/BGRA
|
|
// -------------------------------------------------------------------------------- //
|
|
float4 _PackARGB(VertData vd) : TARGET {
|
|
uint select = get_selector(vd, 4);
|
|
if (select == 0) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).a, 0., 0., 1.);
|
|
} else if (select == 1) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).r, 0., 0., 1.);
|
|
} else if (select == 2) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).g, 0., 0., 1.);
|
|
} else {
|
|
return float4(image.Sample(pixelSampler, vd.uv).b, 0., 0., 1.);
|
|
}
|
|
}
|
|
technique PackARGB { pass { vertex_shader = vertex_program(vd); pixel_shader = _PackARGB(vd); } }
|
|
|
|
float4 _PackBGRA(VertData vd) : TARGET {
|
|
uint select = get_selector(vd, 4);
|
|
if (select == 0) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).b, 0., 0., 1.);
|
|
} else if (select == 1) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).g, 0., 0., 1.);
|
|
} else if (select == 1) {
|
|
return float4(image.Sample(pixelSampler, vd.uv).r, 0., 0., 1.);
|
|
} else {
|
|
return float4(image.Sample(pixelSampler, vd.uv).a, 0., 0., 1.);
|
|
}
|
|
}
|
|
technique PackBGRA { pass { vertex_shader = vertex_program(vd); pixel_shader = _PackBGRA(vd); } }
|