mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
examples: Remove broken effects
This commit is contained in:
parent
a9bb56c5ee
commit
624570b862
9 changed files with 15 additions and 1095 deletions
|
@ -426,6 +426,7 @@ endif()
|
||||||
## Data & Source
|
## Data & Source
|
||||||
list(APPEND PROJECT_DATA
|
list(APPEND PROJECT_DATA
|
||||||
"data/locale/en-US.ini"
|
"data/locale/en-US.ini"
|
||||||
|
"data/effects/color-conversion.effect"
|
||||||
"data/effects/mipgen.effect"
|
"data/effects/mipgen.effect"
|
||||||
"data/effects/pack-unpack.effect"
|
"data/effects/pack-unpack.effect"
|
||||||
)
|
)
|
||||||
|
@ -748,9 +749,11 @@ endif()
|
||||||
if(${PropertyPrefix}ENABLE_FILTER_SHADER)
|
if(${PropertyPrefix}ENABLE_FILTER_SHADER)
|
||||||
set(REQUIRE_SHADER_CODE ON)
|
set(REQUIRE_SHADER_CODE ON)
|
||||||
list(APPEND PROJECT_DATA
|
list(APPEND PROJECT_DATA
|
||||||
|
"data/examples/shaders/filter/crt-curvature.effect"
|
||||||
|
"data/examples/shaders/filter/crt-scanlines.effect"
|
||||||
"data/examples/shaders/filter/drunk.effect"
|
"data/examples/shaders/filter/drunk.effect"
|
||||||
"data/examples/shaders/filter/example.effect"
|
"data/examples/shaders/filter/hexagonize.effect"
|
||||||
"data/examples/shaders/filter/example_displace_by_texture.effect"
|
"data/examples/shaders/filter/semiline.effect"
|
||||||
)
|
)
|
||||||
list(APPEND PROJECT_PRIVATE_SOURCE
|
list(APPEND PROJECT_PRIVATE_SOURCE
|
||||||
"source/filters/filter-shader.hpp"
|
"source/filters/filter-shader.hpp"
|
||||||
|
@ -787,7 +790,10 @@ endif()
|
||||||
if(${PropertyPrefix}ENABLE_SOURCE_SHADER)
|
if(${PropertyPrefix}ENABLE_SOURCE_SHADER)
|
||||||
set(REQUIRE_SHADER_CODE ON)
|
set(REQUIRE_SHADER_CODE ON)
|
||||||
list(APPEND PROJECT_DATA
|
list(APPEND PROJECT_DATA
|
||||||
"data/examples/shaders/source/example.effect"
|
"data/examples/shaders/source/shadertoy-3l23Rh.effect"
|
||||||
|
"data/examples/shaders/source/shadertoy-3tlXWS.effect"
|
||||||
|
"data/examples/shaders/source/shadertoy-MslfRn.effect"
|
||||||
|
"data/examples/shaders/source/shadertoy-MslGRn.effect"
|
||||||
)
|
)
|
||||||
list(APPEND PROJECT_PRIVATE_SOURCE
|
list(APPEND PROJECT_PRIVATE_SOURCE
|
||||||
"source/sources/source-shader.hpp"
|
"source/sources/source-shader.hpp"
|
||||||
|
@ -802,6 +808,10 @@ endif()
|
||||||
if(${PropertyPrefix}ENABLE_TRANSITION_SHADER)
|
if(${PropertyPrefix}ENABLE_TRANSITION_SHADER)
|
||||||
set(REQUIRE_SHADER_CODE ON)
|
set(REQUIRE_SHADER_CODE ON)
|
||||||
list(APPEND PROJECT_DATA
|
list(APPEND PROJECT_DATA
|
||||||
|
"data/examples/shaders/transition/color-shift.effect"
|
||||||
|
"data/examples/shaders/transition/luma-burn.effect"
|
||||||
|
"data/examples/shaders/transition/pixelator.effect"
|
||||||
|
"data/examples/shaders/transition/sliding-bars.effect"
|
||||||
)
|
)
|
||||||
list(APPEND PROJECT_PRIVATE_SOURCE
|
list(APPEND PROJECT_PRIVATE_SOURCE
|
||||||
"source/transitions/transition-shader.hpp"
|
"source/transitions/transition-shader.hpp"
|
||||||
|
|
|
@ -1,209 +0,0 @@
|
||||||
// Always provided by OBS
|
|
||||||
uniform float4x4 ViewProj<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "View Projection Matrix";
|
|
||||||
>;
|
|
||||||
|
|
||||||
// Provided by Stream Effects
|
|
||||||
uniform float4 Time<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "Time Array";
|
|
||||||
string description = "A float4 value containing the total time, rendering time and the time since the last tick. The last value is a random number between 0 and 1.";
|
|
||||||
>;
|
|
||||||
uniform float4x4 Random<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "Random Array";
|
|
||||||
string description = "A float4x4 value containing random values between 0 and 1";
|
|
||||||
>;
|
|
||||||
uniform texture2d ImageSource<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "Source Texture (Filter, Transition)";
|
|
||||||
>;
|
|
||||||
uniform float2 ImageSource_Size<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "Source Texture Size (Filter, Transition)";
|
|
||||||
>;
|
|
||||||
uniform float2 ImageSource_Texel<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "Source Texture Texel Size (Filter, Transition)";
|
|
||||||
>;
|
|
||||||
|
|
||||||
// Shader Parameters
|
|
||||||
uniform float4 p_my_val<
|
|
||||||
bool visible = true;
|
|
||||||
string name = "This is a Value";
|
|
||||||
float4 minimum = {0., 0., 0., 0.};
|
|
||||||
float4 maximum = {1., 1., 1., 1.};
|
|
||||||
float4 step = {.01, .01, .01, .01};
|
|
||||||
> = {0., 0., 0., 1.};
|
|
||||||
uniform float p_hue_shift <
|
|
||||||
bool visible = true;
|
|
||||||
string name = "Hue Shift";
|
|
||||||
string mode = "slider"; // Default is input/spinbox
|
|
||||||
float minimum = -180.0;
|
|
||||||
float maximum = 180.0;
|
|
||||||
float step = 0.01;
|
|
||||||
> = 0.0;
|
|
||||||
|
|
||||||
uniform float p_flag_amplitude <
|
|
||||||
bool visible = true;
|
|
||||||
string name = "Flag Amplitude";
|
|
||||||
string mode = "slider"; // Default is input/spinbox
|
|
||||||
float minimum = 0.01;
|
|
||||||
float maximum = 100.0;
|
|
||||||
float step = 0.01;
|
|
||||||
> = 1.0;
|
|
||||||
uniform float p_flag_speed <
|
|
||||||
bool visible = true;
|
|
||||||
string name = "Flag Speed";
|
|
||||||
string mode = "slider"; // Default is input/spinbox
|
|
||||||
float minimum = 0.01;
|
|
||||||
float maximum = 100.0;
|
|
||||||
float step = 0.01;
|
|
||||||
> = 1.0;
|
|
||||||
uniform float p_flag_whatever <
|
|
||||||
bool visible = true;
|
|
||||||
string name = "Flag Repeats";
|
|
||||||
string mode = "slider"; // Default is input/spinbox
|
|
||||||
float minimum = 0.01;
|
|
||||||
float maximum = 100.0;
|
|
||||||
float step = 0.01;
|
|
||||||
> = 8.0;
|
|
||||||
|
|
||||||
|
|
||||||
// ---------- Shader Code
|
|
||||||
sampler_state def_sampler {
|
|
||||||
AddressU = Wrap;
|
|
||||||
AddressV = Wrap;
|
|
||||||
Filter = Linear;
|
|
||||||
};
|
|
||||||
sampler_state def_sampler2 {
|
|
||||||
AddressU = Border;
|
|
||||||
AddressV = Border;
|
|
||||||
Filter = Linear;
|
|
||||||
Border = 0000000000;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct VertData {
|
|
||||||
float4 pos : POSITION;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FragData {
|
|
||||||
float4 pos : POSITION;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
FragData VSDefault(VertData v_in) {
|
|
||||||
FragData vert_out;
|
|
||||||
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
|
|
||||||
vert_out.uv = v_in.uv;
|
|
||||||
return vert_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Random Color
|
|
||||||
float4 PS_Random(FragData v_in) : TARGET {
|
|
||||||
return float4(Random[0][0], Random[0][1], Random[0][2], 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Random
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(v_in);
|
|
||||||
pixel_shader = PS_Random(v_in);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Fixed Color
|
|
||||||
float4 PS_Fixed(FragData v_in) : TARGET {
|
|
||||||
return p_my_val;
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Fixed
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(v_in);
|
|
||||||
pixel_shader = PS_Fixed(v_in);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Isolate Hue
|
|
||||||
float4 RGBtoHSV(float4 RGBA) {
|
|
||||||
const float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
|
||||||
const float e = 1.0e-10;
|
|
||||||
float4 p = lerp(float4(RGBA.bg, K.wz), float4(RGBA.gb, K.xy), step(RGBA.b, RGBA.g));
|
|
||||||
float4 q = lerp(float4(p.xyw, RGBA.r), float4(RGBA.r, p.yzx), step(p.x, RGBA.r));
|
|
||||||
float d = q.x - min(q.w, q.y);
|
|
||||||
return float4(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x, RGBA.a);
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 HSVtoRGB(float4 HSVA) {
|
|
||||||
const float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
|
||||||
float4 v = float4(0,0,0,0);
|
|
||||||
v.rgb = HSVA.z * lerp(K.xxx, clamp(abs(frac(HSVA.xxx + K.xyz) * 6.0 - K.www) - K.xxx, 0.0, 1.0), HSVA.y);
|
|
||||||
v.a = HSVA.a;
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 PS_HueShift(FragData v_in) : TARGET {
|
|
||||||
float4 v = ImageSource.Sample(def_sampler, v_in.uv);
|
|
||||||
|
|
||||||
float4 hsv = RGBtoHSV(v);
|
|
||||||
hsv.r = hsv.r + p_hue_shift;
|
|
||||||
return HSVtoRGB(hsv);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique HueShift
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(v_in);
|
|
||||||
pixel_shader = PS_HueShift(v_in);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Flag
|
|
||||||
float4 PS_Flag(FragData v_in) : TARGET {
|
|
||||||
float time = Time.y * p_flag_speed + v_in.uv.x * p_flag_whatever;
|
|
||||||
float v_offset = sin(time) + cos(Time.x);
|
|
||||||
float pi = 3.141;
|
|
||||||
float v_orig = v_offset;
|
|
||||||
v_offset = lerp(v_offset, v_orig * 0.25, 0.5 + cos(time + pi / 3) * 0.5);
|
|
||||||
v_offset = lerp(v_offset, v_orig * 0.125, 0.5 + sin(time + pi / 3 * 2) * 0.5);
|
|
||||||
v_offset = lerp(v_offset, v_orig * 0.333, 0.5 + cos(time + pi) * 0.5);
|
|
||||||
v_offset = lerp(v_offset, v_orig * 0.4, 0.5 + sin(time + pi / 3 * 4) * 0.5);
|
|
||||||
v_offset = lerp(v_offset, v_orig * 0.2, 0.5 + cos(time + pi / 3 * 5) * 0.5);
|
|
||||||
v_offset *= v_in.uv.x;
|
|
||||||
|
|
||||||
float d = p_flag_amplitude * ImageSource_Texel.y * 2;
|
|
||||||
v_in.uv.x *= 1.0;
|
|
||||||
v_in.uv.y = v_in.uv.y + v_offset * d;
|
|
||||||
v_in.uv.y -= d / 2.;
|
|
||||||
v_in.uv.y *= 1.0 / (1.0 - d);
|
|
||||||
return ImageSource.Sample(def_sampler2, v_in.uv);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Flag
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(v_in);
|
|
||||||
pixel_shader = PS_Flag(v_in);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Pass Through
|
|
||||||
float4 PS_Draw(FragData v_in) : TARGET {
|
|
||||||
return ImageSource.Sample(def_sampler, v_in.uv);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Draw
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(v_in);
|
|
||||||
pixel_shader = PS_Draw(v_in);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,84 +0,0 @@
|
||||||
// Always provided by OBS
|
|
||||||
uniform float4x4 ViewProj<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "View Projection Matrix";
|
|
||||||
>;
|
|
||||||
|
|
||||||
// Provided by Stream Effects
|
|
||||||
uniform float4 Time<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "Time Array";
|
|
||||||
string description = "A float4 value containing the total time, rendering time and the time since the last tick. The last value is a random number between 0 and 1.";
|
|
||||||
>;
|
|
||||||
uniform float4x4 Random<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "Random Array";
|
|
||||||
string description = "A float4x4 value containing random values between 0 and 1";
|
|
||||||
>;
|
|
||||||
uniform texture2d ImageSource<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "Source Texture (Filter, Transition)";
|
|
||||||
>;
|
|
||||||
uniform float2 ImageSource_Size<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "Source Texture Size (Filter, Transition)";
|
|
||||||
>;
|
|
||||||
uniform float2 ImageSource_Texel<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "Source Texture Texel Size (Filter, Transition)";
|
|
||||||
>;
|
|
||||||
|
|
||||||
// Shader Parameters
|
|
||||||
uniform texture2d p_texture <
|
|
||||||
bool visible = true;
|
|
||||||
string name = "Displacement Map";
|
|
||||||
>;
|
|
||||||
uniform float p_scale <
|
|
||||||
bool visible = true;
|
|
||||||
string name = "Displacement Scale";
|
|
||||||
float minimum = 0.0;
|
|
||||||
float maximum = 100.0;
|
|
||||||
float step = 0.01;
|
|
||||||
> = 1.0;
|
|
||||||
|
|
||||||
// ---------- Shader Code
|
|
||||||
sampler_state def_sampler {
|
|
||||||
AddressU = Wrap;
|
|
||||||
AddressV = Wrap;
|
|
||||||
Filter = Linear;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct VertData {
|
|
||||||
float4 pos : POSITION;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FragData {
|
|
||||||
float4 pos : POSITION;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
FragData VSDefault(VertData v_in) {
|
|
||||||
FragData vert_out;
|
|
||||||
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
|
|
||||||
vert_out.uv = v_in.uv;
|
|
||||||
return vert_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Pass Through
|
|
||||||
float4 PS_Draw(FragData v_in) : TARGET {
|
|
||||||
float4 disp = p_texture.Sample(def_sampler, v_in.uv);
|
|
||||||
|
|
||||||
float2 uv_off = (disp.xy - 0.5) * p_scale;
|
|
||||||
|
|
||||||
return ImageSource.Sample(def_sampler, v_in.uv + uv_off);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Draw
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(v_in);
|
|
||||||
pixel_shader = PS_Draw(v_in);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
// This file is used to test features.
|
|
||||||
|
|
||||||
uniform float4x4 ViewProj<
|
|
||||||
bool automatic = true;
|
|
||||||
>;
|
|
||||||
uniform float4 Time<
|
|
||||||
bool automatic = true;
|
|
||||||
>;
|
|
||||||
uniform texture2d InputA<
|
|
||||||
bool automatic = true;
|
|
||||||
>;
|
|
||||||
|
|
||||||
struct VertexData {
|
|
||||||
float4 pos : POSITION;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
sampler_state def_sampler {
|
|
||||||
AddressU = Wrap;
|
|
||||||
AddressV = Wrap;
|
|
||||||
Filter = Linear;
|
|
||||||
};
|
|
||||||
|
|
||||||
VertexData VSDefault(VertexData vtx) {
|
|
||||||
vtx.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj);
|
|
||||||
return vtx;
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 PSSolid(VertexData vtx) : TARGET {
|
|
||||||
return InputA.Sample(def_sampler, vtx.uv) * float4(cos(Time.y * 3.141 * 2.) * .5 + .5, cos(sin(Time.y * 3.141 * 2.) * 3.141), sin(Time.y * 3.141 * 2.) * .5 + .5, 1.);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Solid
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(vtx);
|
|
||||||
pixel_shader = PSSolid(vtx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 PSTranslucent(VertexData vtx) : TARGET {
|
|
||||||
return InputA.Sample(def_sampler, vtx.uv) * float4(1., 1., 1., sin(Time.y * 3.141 * 2.) * .5 + .5);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Translucent
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(vtx);
|
|
||||||
pixel_shader = PSTranslucent(vtx);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,372 +0,0 @@
|
||||||
uniform float4x4 ViewProj<
|
|
||||||
bool automatic = true;
|
|
||||||
>;
|
|
||||||
uniform float4 ViewSize<
|
|
||||||
bool automatic = true;
|
|
||||||
>;
|
|
||||||
uniform float4 Time<
|
|
||||||
bool automatic = true;
|
|
||||||
>;
|
|
||||||
|
|
||||||
// Camera Parameters
|
|
||||||
uniform float3 CameraPosition<
|
|
||||||
string name = "Camera Position";
|
|
||||||
string field_type = "slider";
|
|
||||||
float3 minimum = {-10.0, -10.0, -10.0};
|
|
||||||
float3 maximum = {10.0, 10.0, 10.0};
|
|
||||||
> = {0., 0., 0.};
|
|
||||||
|
|
||||||
uniform float3 CameraRotation<
|
|
||||||
string name = "Camera Rotation";
|
|
||||||
string suffix = " °Deg";
|
|
||||||
string field_type = "slider";
|
|
||||||
float3 minimum = {-180.0, -90.0, -180.0};
|
|
||||||
float3 maximum = {180.0, 90.0, 180.0};
|
|
||||||
float3 scale = {0.01745329251994329576923690768489, 0.01745329251994329576923690768489, 0.01745329251994329576923690768489};
|
|
||||||
> = {0., 0., 0.};
|
|
||||||
|
|
||||||
uniform float CameraFieldOfView<
|
|
||||||
string name = "Camera Field Of View";
|
|
||||||
string suffix = " °Deg";
|
|
||||||
string field_type = "slider";
|
|
||||||
float minimum = 1.0;
|
|
||||||
float maximum = 180.0;
|
|
||||||
float scale = 0.00872664625997164788461845384244;
|
|
||||||
> = 90.0;
|
|
||||||
|
|
||||||
uniform float2 CameraRange<
|
|
||||||
string name = "Camera Range";
|
|
||||||
string field_type = "slider";
|
|
||||||
float2 minimum = {0.0, 1.00};
|
|
||||||
float2 maximum = {10000.0, 10000.0};
|
|
||||||
float2 scale = {0.01, 0.01};
|
|
||||||
> = {0.1, 256.0};
|
|
||||||
|
|
||||||
uniform int RayMarchAccuracy<
|
|
||||||
string name = "Ray March Steps";
|
|
||||||
string field_type = "slider";
|
|
||||||
int minimum = 32;
|
|
||||||
int maximum = 1024;
|
|
||||||
> = 256;
|
|
||||||
|
|
||||||
//----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
|
|
||||||
// Configuration
|
|
||||||
#define MAX_ACCURACY 1024
|
|
||||||
|
|
||||||
// Camera Type
|
|
||||||
//#define CAMERA_ORTHOGRAPHIC // Orthographic projection
|
|
||||||
|
|
||||||
//----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
|
|
||||||
#define INFINITY 1.#INF
|
|
||||||
|
|
||||||
//----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
|
|
||||||
float4x4 make_rotation_matrix(float3 axis, float angle)
|
|
||||||
{
|
|
||||||
axis = normalize(axis);
|
|
||||||
float s = sin(angle);
|
|
||||||
float c = cos(angle);
|
|
||||||
float oc = 1.0 - c;
|
|
||||||
|
|
||||||
float x_x = axis.x * axis.x;
|
|
||||||
float x_y = axis.x * axis.y;
|
|
||||||
float x_z = axis.x * axis.z;
|
|
||||||
float y_x = x_y;
|
|
||||||
float y_y = axis.y * axis.y;
|
|
||||||
float y_z = axis.y * axis.z;
|
|
||||||
float z_x = x_z;
|
|
||||||
float z_y = y_z;
|
|
||||||
float z_z = axis.z * axis.z;
|
|
||||||
|
|
||||||
return float4x4(oc * x_x + c, oc * x_y - axis.z * s, oc * z_x + axis.y * s, 0.0,
|
|
||||||
oc * x_y + axis.z * s, oc * y_y + c, oc * z_y - axis.x * s, 0.0,
|
|
||||||
oc * x_z - axis.y * s, oc * y_z + axis.x * s, oc * z_z + c, 0.0,
|
|
||||||
0.0, 0.0, 0.0, 1.0);
|
|
||||||
};
|
|
||||||
|
|
||||||
float3 rotate_float3(float3 v, float3 rotation)
|
|
||||||
{
|
|
||||||
float4x4 rz = make_rotation_matrix(float3(0., 0., 1.), rotation.z);
|
|
||||||
float4x4 ry = make_rotation_matrix(float3(0., 1., 0.), rotation.y);
|
|
||||||
float4x4 rx = make_rotation_matrix(float3(1., 0., 0.), rotation.x);
|
|
||||||
|
|
||||||
float4 p = float4(v, 1.);
|
|
||||||
float4 rtd = mul(mul(mul(p, rz), rx), ry);
|
|
||||||
|
|
||||||
return rtd.xyz;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool solve_quadratic(float a, float b, float c, out float x0, out float x1)
|
|
||||||
{
|
|
||||||
float discr = b * b - 4. * a * c;
|
|
||||||
if (discr < 0.) {
|
|
||||||
return false;
|
|
||||||
} else if (discr == 0.) {
|
|
||||||
x0 = x1 = - 0.5 * b / a;
|
|
||||||
} else {
|
|
||||||
float q = (b > 0.) ?
|
|
||||||
-0.5 * (b + sqrt(discr)) :
|
|
||||||
-0.5 * (b - sqrt(discr));
|
|
||||||
x0 = q / a;
|
|
||||||
x1 = c / q;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x0 > x1) {
|
|
||||||
float tmp = x1;
|
|
||||||
x1 = x0;
|
|
||||||
x0 = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool collide_point_aabb(float3 pos, float3 aabb, float3 size) {
|
|
||||||
float3 aabb_min = aabb - size;
|
|
||||||
float3 aabb_max = aabb + size;
|
|
||||||
return (pos.x >= aabb_min.x)
|
|
||||||
&& (pos.y >= aabb_min.y)
|
|
||||||
&& (pos.z >= aabb_min.z)
|
|
||||||
&& (pos.x <= aabb_max.x)
|
|
||||||
&& (pos.y <= aabb_max.y)
|
|
||||||
&& (pos.z <= aabb_max.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool collide_aabb_aabb(float3 pos1, float3 size1, float3 pos2, float3 size2) {
|
|
||||||
float3 min1 = pos1 - size1;
|
|
||||||
float3 max1 = pos1 + size1;
|
|
||||||
float3 min2 = pos2 - size2;
|
|
||||||
float3 max2 = pos2 + size2;
|
|
||||||
|
|
||||||
return (min1.x <= max2.x && max1.x >= min2.x) &&
|
|
||||||
(min1.y <= max2.y && max1.y >= min2.y) &&
|
|
||||||
(min1.z <= max2.z && max1.z >= min2.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool intersect_box(float3 pos, float3 size, float3 ray_pos, float3 ray_dir, out float t) {
|
|
||||||
float3 aabb_size = float3(max(size.x, max(size.y, size.z)), 0., 0.);
|
|
||||||
if (!collide_aabb_aabb(ray_pos, ray_dir, pos, aabb_size.xxx))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
t = 0.;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool intersect_sphere(float3 center, float radius, float3 orig, float3 dir, out float t)
|
|
||||||
{
|
|
||||||
if (!collide_aabb_aabb(orig, dir, center, float3(radius, radius, radius)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
float t0, t1; // solutions for t if the ray intersects
|
|
||||||
float radius2 = radius * radius;
|
|
||||||
|
|
||||||
// analytic solution
|
|
||||||
float3 L = orig - center;
|
|
||||||
float a = dot(dir, dir);
|
|
||||||
float b = 2. * dot(dir, L);
|
|
||||||
float c = dot(L, L) - radius2;
|
|
||||||
|
|
||||||
if (!solve_quadratic(a, b, c, t0, t1)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t0 > t1) {
|
|
||||||
float tmp = t0;
|
|
||||||
t0 = t1;
|
|
||||||
t1 = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t0 < 0.) {
|
|
||||||
t0 = t1; // if t0 is negative, let's use t1 instead
|
|
||||||
if (t0 < 0.) {
|
|
||||||
return false; // both t0 and t1 are negative
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
t = t0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
|
|
||||||
struct default_data {
|
|
||||||
float4 pos : POSITION;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
default_data default_vs(default_data data) {
|
|
||||||
data.pos = mul(float4(data.pos.xyz, 1.0), ViewProj);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
|
|
||||||
struct material_data {
|
|
||||||
float4 color;
|
|
||||||
float metallic;
|
|
||||||
float specular;
|
|
||||||
float roughness;
|
|
||||||
float4 emissive_color;
|
|
||||||
float3 normal;
|
|
||||||
float index_of_refraction;
|
|
||||||
};
|
|
||||||
|
|
||||||
void material_data_constructor(out material_data material)
|
|
||||||
{
|
|
||||||
material.color = float4(0., 0., 0., 0.);
|
|
||||||
material.metallic = 0.;
|
|
||||||
material.specular = .5;
|
|
||||||
material.roughness = 1.;
|
|
||||||
material.emissive_color = float4(0., 0., 0., 0.);
|
|
||||||
material.normal = float3(0., 0., 0.);
|
|
||||||
material.index_of_refraction = 1.;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ray_data {
|
|
||||||
// Status
|
|
||||||
float3 position; // Current position.
|
|
||||||
float3 direction; // Direction of the ray.
|
|
||||||
int depth; // Ray Calculation Depth, limited by ACCURACY define.
|
|
||||||
|
|
||||||
// Hit
|
|
||||||
bool hit; // Did we hit anything?
|
|
||||||
float3 hit_position; // If so, where?
|
|
||||||
float4 hit_color; // What color does it have?
|
|
||||||
float3 hit_normal; // And what is the normal for that hit?
|
|
||||||
float hit_depth;
|
|
||||||
};
|
|
||||||
|
|
||||||
void ray_data_constructor(out ray_data ray)
|
|
||||||
{
|
|
||||||
ray.position = float3(0., 0., 0.);
|
|
||||||
ray.direction = float3(0., 0., 0.);
|
|
||||||
ray.depth = 0;
|
|
||||||
|
|
||||||
ray.hit = false;
|
|
||||||
ray.hit_position = float3(0., 0., 0.);
|
|
||||||
ray.hit_color = float4(0., 0., 0., 0.);
|
|
||||||
ray.hit_normal = float3(0., 0., 0.);
|
|
||||||
ray.hit_depth = 0.;
|
|
||||||
}
|
|
||||||
|
|
||||||
float get_view_aspect_ratio() {
|
|
||||||
return ViewSize.x / ViewSize.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
float get_raymarch_step_length() {
|
|
||||||
return CameraRange.y / float(RayMarchAccuracy);
|
|
||||||
}
|
|
||||||
|
|
||||||
ray_data initialize_camera_ray(float2 uv) {
|
|
||||||
ray_data ray;
|
|
||||||
ray_data_constructor(ray);
|
|
||||||
|
|
||||||
uv -= .5;
|
|
||||||
//uv *= 2.;
|
|
||||||
|
|
||||||
float aspect = get_view_aspect_ratio();
|
|
||||||
|
|
||||||
#ifdef CAMERA_ORTHOGRAPHIC
|
|
||||||
ray.direction = rotate_float3(float3(0., 0., 1.), CameraRotation);
|
|
||||||
ray.position = CameraPosition + float3(uv.x * ViewSize.x, uv.y * ViewSize.y, CameraRange.x);
|
|
||||||
#else
|
|
||||||
ray.direction = rotate_float3(rotate_float3(float3(0., 0., 1.), CameraRotation), float3(
|
|
||||||
uv.y * CameraFieldOfView / aspect,
|
|
||||||
uv.x * CameraFieldOfView,
|
|
||||||
0.));
|
|
||||||
ray.position = CameraPosition + float3(-uv.x, uv.y / aspect, CameraRange.x);
|
|
||||||
#endif
|
|
||||||
ray.direction *= get_raymarch_step_length();
|
|
||||||
|
|
||||||
return ray;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool raymarch_box(inout ray_data ray, float3 pos, float3 rotation, float3 size, material_data material) {
|
|
||||||
float step = 0.;
|
|
||||||
if (!intersect_box(pos, size, ray.position, ray.direction, step))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// if (step > 1.)
|
|
||||||
// return false;
|
|
||||||
|
|
||||||
float depth = (step + float(ray.depth));
|
|
||||||
// if (ray.hit && (ray.hit_depth <= depth))
|
|
||||||
// return false;
|
|
||||||
|
|
||||||
ray.hit = true;
|
|
||||||
ray.hit_position = ray.position + ray.direction * step;
|
|
||||||
ray.hit_depth = depth;
|
|
||||||
ray.hit_color = material.color;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool raymarch_sphere(inout ray_data ray, float3 pos, float3 rotation, float radius, material_data material) {
|
|
||||||
float step = 0.;
|
|
||||||
if (!intersect_sphere(pos, radius, ray.position, ray.direction, step))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (step > 1.) // Ray start to end actually did not hit.
|
|
||||||
return false;
|
|
||||||
|
|
||||||
float depth = (step + float(ray.depth));
|
|
||||||
if (ray.hit && (ray.hit_depth <= depth))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ray.hit = true;
|
|
||||||
ray.hit_position = ray.position + ray.direction * step;
|
|
||||||
ray.hit_depth = depth;
|
|
||||||
ray.hit_color = material.color;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool scene(inout ray_data ray) {
|
|
||||||
material_data box1;
|
|
||||||
material_data_constructor(box1);
|
|
||||||
box1.color = float4(0., 0., 0., 1.);
|
|
||||||
raymarch_box(ray, float3(0., -1., 2.), float3(0., 0., 0.), float3(1., 1., 1.), box1);
|
|
||||||
|
|
||||||
material_data sphere1;
|
|
||||||
material_data_constructor(sphere1);
|
|
||||||
sphere1.color = float4(1., 0., 0., 1.);
|
|
||||||
raymarch_sphere(ray, float3(-1., 0., 1.), float3(0., 0., 0.), 0.5, sphere1);
|
|
||||||
|
|
||||||
material_data sphere2;
|
|
||||||
material_data_constructor(sphere2);
|
|
||||||
sphere2.color = float4(0., 0., 1., 1.);
|
|
||||||
raymarch_sphere(ray, float3(1., 0., 1.), float3(0., 0., 0.), 0.5, sphere2);
|
|
||||||
|
|
||||||
return ray.hit;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool raymarch(inout ray_data ray) {
|
|
||||||
// Simulate hitting a sphere.
|
|
||||||
if (ray.depth >= RayMarchAccuracy) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (; (ray.depth < MAX_ACCURACY) && (ray.depth < RayMarchAccuracy); ray.depth++) {
|
|
||||||
if (scene(ray))
|
|
||||||
break;
|
|
||||||
|
|
||||||
ray.position = ray.position + ray.direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ray.hit;
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 pass1_ps(default_data data) : TARGET {
|
|
||||||
// Set up camera.
|
|
||||||
ray_data ray = initialize_camera_ray(data.uv);
|
|
||||||
// Raymarch
|
|
||||||
raymarch(ray);
|
|
||||||
// Finally just return the color
|
|
||||||
//return float4(ray.hit_depth / float(CameraRange.y), float(ray.depth) / float(RayMarchAccuracy), 0., 1.);
|
|
||||||
return ray.hit_color;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
|
|
||||||
technique Draw {
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = default_vs(data);
|
|
||||||
pixel_shader = pass1_ps(data);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,178 +0,0 @@
|
||||||
// Source Shader Example
|
|
||||||
//
|
|
||||||
// Check back here on new plugin versions for new features.
|
|
||||||
//
|
|
||||||
// This example explains the necessary basics to get started with custom shaders,
|
|
||||||
// however it does not teach you HLSL. You will have to learn that yourself, and
|
|
||||||
// no support is given for HLSL issues - either pay an artist, or learn it your-
|
|
||||||
// self.
|
|
||||||
//
|
|
||||||
// Some uniform variables are automatically provided by StreamFX, these are:
|
|
||||||
// * float4x4 ViewProj: View Projection Matrix
|
|
||||||
// * float4 Time:
|
|
||||||
// [0] is current time,
|
|
||||||
// [1] is frame time,
|
|
||||||
// [2] is 24 hour system time,
|
|
||||||
// [3] is a random value that changes each frame.
|
|
||||||
// * matrix4x4 Random: 16 random values that change each frame.
|
|
||||||
// * float4 ViewSize:
|
|
||||||
// [0..1] View Size (1 / VS = 1 pixel move)
|
|
||||||
// [2..3] Inverse View Size (1 * IVS = 1 pixel move)
|
|
||||||
// * texture2d ImageA: (First) input image for filters and transitions.
|
|
||||||
// * texture2D ImageB: Second input image for transitions.
|
|
||||||
//
|
|
||||||
// Custom Shaders make heavy use of annotations, which can be used to essentially
|
|
||||||
// describe a complete shader with just its own file, requiring no outside input.
|
|
||||||
// There are various annotations that StreamFX reads from, and some are situational,
|
|
||||||
// so it is best if I show some examples.
|
|
||||||
//
|
|
||||||
// ---------- Basic Uniform Example ----------
|
|
||||||
// uniform bool UniqueParameterName<
|
|
||||||
// This defines a parameter of type float with the unique key "UniqueParameterName",
|
|
||||||
// which is used to access it in a script as "Shader.Parameters.UniqueParameterName".
|
|
||||||
//
|
|
||||||
// bool visible = false;
|
|
||||||
// [OPTIONAL] The boolean annotation 'visible' allows hiding a parameter from the user,
|
|
||||||
// but still allowing scripts to change it. Limits are ignored, but scale is not.
|
|
||||||
//
|
|
||||||
// bool automatic = true;
|
|
||||||
// [OPTIONAL] Prevents parameters from being shown as well as being modified by scripts,
|
|
||||||
// and overrides visible if set to true. For seeded or given-by-default parameters this
|
|
||||||
// must be set to true or their state is not guaranteed and may be nonsense.
|
|
||||||
//
|
|
||||||
// string name = "Hello World";
|
|
||||||
// [OPTIONAL] Overrides the visible name of a parameter with your own better string.
|
|
||||||
// The maximum length is 256 characters, but you really should keep it shorter than 40.
|
|
||||||
//
|
|
||||||
// string description = "This is an example";
|
|
||||||
// [OPTIONAL] Sets the description of a parameter that shows up when hovering over it.
|
|
||||||
//
|
|
||||||
// string type = "float";
|
|
||||||
// [OPTIONAL] Overrides the detected type with a specified one, which is useful for some
|
|
||||||
// functionality trickery and even array types. Must not differ in byte-size from the
|
|
||||||
// intended type. Best left out unless you absolutely need it. Valid types are:
|
|
||||||
// "bool", "float", "int", "string", "texture", "sampler"
|
|
||||||
//
|
|
||||||
// int size = 1;
|
|
||||||
// [OPTIONAL/REQUIRED] Optional on detected types, required on arrays or unknown types.
|
|
||||||
// Overrides the detected size with your own, which may at most be 32 elements (4x8 matrix).
|
|
||||||
// >;
|
|
||||||
//
|
|
||||||
// ---------- Float/Int Uniform Example ----------
|
|
||||||
// uniform float UniqueParameterName<
|
|
||||||
// In addition to the basic parameters, Floats and Ints have additional annotations that are being read.
|
|
||||||
//
|
|
||||||
// string field_type = "input";
|
|
||||||
// [OPTIONAL] Changes the visible type of the field to be something else.
|
|
||||||
// Possible values:
|
|
||||||
// * "input": The default input method, a simple field with limits and stepping.
|
|
||||||
// * "slider": A slider, also with limits and stepping.
|
|
||||||
// * "enum": Enumeration that holds only selected data.
|
|
||||||
//
|
|
||||||
// string suffix = "";
|
|
||||||
// [OPTIONAL] Suffix to attach to the value in the UI, for example " px" for
|
|
||||||
// pixels. Does not work with enumerations.
|
|
||||||
//
|
|
||||||
// float minimum = 0.0;
|
|
||||||
// [OPTIONAL] Minimum possible value, must always be the same type as the uniform.
|
|
||||||
//
|
|
||||||
// float maximum = 1.0;
|
|
||||||
// [OPTIONAL] Maximum possible value, must always be the same type as the uniform.
|
|
||||||
//
|
|
||||||
// float step = 0.01;
|
|
||||||
// [OPTIONAL] Step value for each increase/decrease. Values lower than 0.01 may
|
|
||||||
// not be supported.
|
|
||||||
//
|
|
||||||
// float scale = 1.0;
|
|
||||||
// [OPTIONAL] Defines the scaling used when assigning the value to the shader.
|
|
||||||
// For example a UI value of 100.0 can be scaled to 1.0 this way.
|
|
||||||
//
|
|
||||||
// int values<
|
|
||||||
// [REQUIRED if "enum"] Contains the values for an enumeration and holds the
|
|
||||||
// number of enumeration entries actually available.
|
|
||||||
//
|
|
||||||
// string _0<
|
|
||||||
// float value = 1.0;
|
|
||||||
// > = "Entry 1";
|
|
||||||
// Defines the first enumeration entry with the visible name "Entry 1" and the value 1.0.
|
|
||||||
//
|
|
||||||
// string _1<
|
|
||||||
// float value = 0.0;
|
|
||||||
// > = "Entry 2";
|
|
||||||
// Defines the second enumeration entry with the visible name "Entry 2" and the value 0.0.
|
|
||||||
//
|
|
||||||
// > = 2;
|
|
||||||
// [REQUIRED if "enum"] The value of this annotation must be the number of enumeration entries.
|
|
||||||
//
|
|
||||||
// >;
|
|
||||||
//
|
|
||||||
// ---------- Float4/Int4 Uniform Example ----------
|
|
||||||
// uniform float4 UniqueParameterName<
|
|
||||||
// There aren't many difference to the standard float/int parameter, but you can
|
|
||||||
// specify limits, stepping and scale per element. Enumerations also are per
|
|
||||||
// element so their type must be the base type (float for float#, int for int#).
|
|
||||||
//
|
|
||||||
// float4 minimum = {0.0, 1.0, 0.5, -0.5};
|
|
||||||
// Each element now has different minimum values which ...
|
|
||||||
//
|
|
||||||
// float4 maximum = {1.0, 0.0, 0.6, 0.0};
|
|
||||||
// ... also works for maximum, ...
|
|
||||||
//
|
|
||||||
// float4 step = {0.01, 0.01, 0.1, 0.5};
|
|
||||||
// ... stepping and ...
|
|
||||||
//
|
|
||||||
// float4 scale = {100.0, 0.01, 3.14, 1283828.0};
|
|
||||||
// ... scaling values.
|
|
||||||
//
|
|
||||||
// >;
|
|
||||||
|
|
||||||
// Always provided by OBS
|
|
||||||
uniform float4x4 ViewProj<
|
|
||||||
bool automatic = true;
|
|
||||||
>;
|
|
||||||
|
|
||||||
// Provided by StreamFX
|
|
||||||
uniform float4 Time<
|
|
||||||
bool automatic = true;
|
|
||||||
>;
|
|
||||||
|
|
||||||
// ---------- Shader Code
|
|
||||||
sampler_state def_sampler {
|
|
||||||
AddressU = Wrap;
|
|
||||||
AddressV = Wrap;
|
|
||||||
Filter = Linear;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct VertData {
|
|
||||||
float4 pos : POSITION;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FragData {
|
|
||||||
float4 pos : POSITION;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
FragData VSDefault(VertData v_in) {
|
|
||||||
FragData vert_out;
|
|
||||||
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
|
|
||||||
vert_out.uv = v_in.uv;
|
|
||||||
return vert_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 PSTime(FragData v_in) : TARGET {
|
|
||||||
return float4(
|
|
||||||
cos(Time[0] * 5.) * 0.5 + 0.5,
|
|
||||||
cos(Time[0] * 0.) * 0.5 + 0.5,
|
|
||||||
cos(Time[0] * 0.) * 0.5 + 0.5,
|
|
||||||
1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Draw
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(v_in);
|
|
||||||
pixel_shader = PSTime(v_in);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,150 +0,0 @@
|
||||||
// Always provided by OBS
|
|
||||||
uniform float4x4 ViewProj<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "View Projection Matrix";
|
|
||||||
>;
|
|
||||||
|
|
||||||
// Provided by Stream Effects
|
|
||||||
uniform float4 Time<
|
|
||||||
bool visible = false;
|
|
||||||
string name = "Time Array";
|
|
||||||
string description = "A float array of length 4, with the indexes being:\n[0] Time Visible in Seconds\n[1] Last Render Time\n[2] Current System Time (24h looping)\n[3] Random value between 0 and 1.";
|
|
||||||
>;
|
|
||||||
|
|
||||||
// Params
|
|
||||||
uniform float PlasmaUVScale <
|
|
||||||
bool visible = true;
|
|
||||||
int order = 0;
|
|
||||||
string name = "UV Scaling";
|
|
||||||
string suffix = " %";
|
|
||||||
string type = "slider";
|
|
||||||
float minimum = 1.0;
|
|
||||||
float maximum = 10000.0;
|
|
||||||
float step = 0.01;
|
|
||||||
float scale = 0.01;
|
|
||||||
> = 100.0;
|
|
||||||
|
|
||||||
uniform float PlasmaTwists <
|
|
||||||
bool visible = true;
|
|
||||||
int order = 1;
|
|
||||||
string name = "Twists";
|
|
||||||
string type = "slider";
|
|
||||||
float minimum = 0.01;
|
|
||||||
float maximum = 100.0;
|
|
||||||
float step = 0.01;
|
|
||||||
float scale = 3.1415926535897932384626433832795;
|
|
||||||
> = 1.0;
|
|
||||||
|
|
||||||
uniform float4 PlasmaLowColor <
|
|
||||||
bool visible = true;
|
|
||||||
int order = 2;
|
|
||||||
string name = "Color 1";
|
|
||||||
string type = "slider";
|
|
||||||
float minimum = -1000.0;
|
|
||||||
float maximum = 1000.0;
|
|
||||||
float step = 0.01;
|
|
||||||
float scale = 0.01;
|
|
||||||
> = {100.0, 0.0, 0.0, 100.0};
|
|
||||||
|
|
||||||
uniform float4 PlasmaMiddleColor <
|
|
||||||
bool visible = true;
|
|
||||||
int order = 3;
|
|
||||||
string name = "Color 2";
|
|
||||||
string type = "slider";
|
|
||||||
float minimum = -1000.0;
|
|
||||||
float maximum = 1000.0;
|
|
||||||
float step = 0.01;
|
|
||||||
float scale = 0.01;
|
|
||||||
> = {0.0, 100.0, 0.0, 100.0};
|
|
||||||
|
|
||||||
uniform float4 PlasmaHighColor <
|
|
||||||
bool visible = true;
|
|
||||||
int order = 4;
|
|
||||||
string name = "Color 3";
|
|
||||||
string type = "slider";
|
|
||||||
float minimum = -1000.0;
|
|
||||||
float maximum = 1000.0;
|
|
||||||
float step = 0.01;
|
|
||||||
float scale = 0.01;
|
|
||||||
> = {0.0, 0.0, 100.0, 100.0};;
|
|
||||||
|
|
||||||
struct StageData {
|
|
||||||
float4 pos : POSITION;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
StageData VSDefault(StageData data) {
|
|
||||||
data.pos = mul(float4(data.pos.xyz, 1.0), ViewProj);
|
|
||||||
data.uv += 0.5;
|
|
||||||
data.uv *= PlasmaUVScale;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Plasma1(float2 uv, float t) {
|
|
||||||
return sin(uv.x * 10 + t);
|
|
||||||
}
|
|
||||||
|
|
||||||
float Plasma2(float2 uv, float t) {
|
|
||||||
return sin(10 * (uv.x*sin(t/2)+uv.y*cos(t/3))+t);
|
|
||||||
}
|
|
||||||
|
|
||||||
float Plasma3(float2 uv, float t) {
|
|
||||||
float cx = uv.x + .5*sin(t/5);
|
|
||||||
float cy = uv.y + .5*cos(t/3);
|
|
||||||
return sin(sqrt(100*(cx*cx+cy*cy)+1)+t);
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 BasicPlasma(StageData data) : TARGET {
|
|
||||||
return float4(Plasma1(data.uv, Time[0]), Plasma2(data.uv, Time[0]), Plasma3(data.uv, Time[0]), 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Basic
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(data);
|
|
||||||
pixel_shader = BasicPlasma(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 Plasma(StageData data) : TARGET {
|
|
||||||
float a = Plasma1(data.uv, Time[0]);
|
|
||||||
float b = Plasma2(data.uv, Time[0]);
|
|
||||||
float c = Plasma3(data.uv, Time[0]);
|
|
||||||
|
|
||||||
float v = abs(sin((a + b + c) * (PlasmaTwists / 100.0)));
|
|
||||||
|
|
||||||
return float4(v,v,v, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Draw
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(data);
|
|
||||||
pixel_shader = Plasma(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 ColoredPlasma(StageData data) : TARGET {
|
|
||||||
float a = Plasma1(data.uv, Time[0]);
|
|
||||||
float b = Plasma2(data.uv, Time[0]);
|
|
||||||
float c = Plasma3(data.uv, Time[0]);
|
|
||||||
|
|
||||||
float v = abs(sin((a + b + c) * (PlasmaTwists / 100.0)));
|
|
||||||
|
|
||||||
float v1 = clamp(v * 2.0, 0., 1.);
|
|
||||||
float v2 = clamp((v - 0.5) * 2.0, 0., 1.);
|
|
||||||
float4 col = lerp(lerp(PlasmaLowColor, PlasmaMiddleColor, v1), PlasmaHighColor, v2);
|
|
||||||
|
|
||||||
return clamp(col, 0., 1.);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Colored
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(data);
|
|
||||||
pixel_shader = ColoredPlasma(data);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
// This file is used to test features.
|
|
||||||
|
|
||||||
uniform float4x4 ViewProj<
|
|
||||||
bool automatic = true;
|
|
||||||
>;
|
|
||||||
uniform float4 Time<
|
|
||||||
bool automatic = true;
|
|
||||||
>;
|
|
||||||
|
|
||||||
struct VertexData {
|
|
||||||
float4 pos : POSITION;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
VertexData VSDefault(VertexData vtx) {
|
|
||||||
vtx.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj);
|
|
||||||
return vtx;
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 PSSolid(VertexData vtx) : TARGET {
|
|
||||||
return float4(cos(Time.y * 3.141 * 2.) * .5 + .5, cos(sin(Time.y * 3.141 * 2.) * 3.141), sin(Time.y * 3.141 * 2.) * .5 + .5, 1.);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Solid
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(vtx);
|
|
||||||
pixel_shader = PSSolid(vtx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 PSTranslucent(VertexData vtx) : TARGET {
|
|
||||||
return float4(1., 1., 1., sin(Time.y * 3.141 * 2.) * .5 + .5);
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Translucent
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(vtx);
|
|
||||||
pixel_shader = PSTranslucent(vtx);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -136,10 +136,10 @@ float4 PSDefault(VertData vtx) : TARGET {
|
||||||
float bar_offset = 0.;
|
float bar_offset = 0.;
|
||||||
float bar_direction = 0.;
|
float bar_direction = 0.;
|
||||||
if (TransitionTime < .5 || !_49_FadeToColor) {
|
if (TransitionTime < .5 || !_49_FadeToColor) {
|
||||||
bar_offset = noised(float2(bar_id, 0.)).x * bar_offset_max;
|
bar_offset = -abs(noised(float2(bar_id, 0.)).x * bar_offset_max);
|
||||||
bar_direction = step(noised(float2(bar_id, 1.)).x, .5);
|
bar_direction = step(noised(float2(bar_id, 1.)).x, .5);
|
||||||
} else {
|
} else {
|
||||||
bar_offset = noised(float2(bar_id, 1.)).x * bar_offset_max;
|
bar_offset = -abs(noised(float2(bar_id, 1.)).x * bar_offset_max);
|
||||||
bar_direction = step(noised(float2(bar_id, 0.)).x, .5);
|
bar_direction = step(noised(float2(bar_id, 0.)).x, .5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue