// Target with smoothstep by possum // https://www.shadertoy.com/view/Xsl3RX // License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License // Contact the author for other licensing options // type conversion #define vec2 float2 #define vec3 float3 #define vec4 float4 #define ivec2 int2 #define ivec3 int3 #define ivec4 int4 #define mat2 float2x2 #define mat3 float3x3 #define mat4 float4x4 #define fract frac #define mix lerp #define iTime Time.x #define iResolution ViewSize // Always provided by OBS uniform float4x4 ViewProj< bool automatic = true; >; // Provided by Stream Effects uniform float4 Time< bool automatic = true; >; uniform float4 ViewSize< bool automatic = true; >; uniform texture2d InputA< bool automatic = true; >; uniform float4x4 Random< bool automatic = true; >; // Shader Parameters uniform float pRings< string name = "Rings"; string field_type = "slider"; float minimum = 1.0; float maximum = 50.0; float step = 0.01; float scale = 1.; > = 5.0; uniform float pVelocity< string name = "Ring Velocity"; string field_type = "slider"; float minimum = 0.1; float maximum = 10.0; float step = 0.01; float scale = 1.; > = 1.0; uniform float pBorder< string name = "Border Size"; string field_type = "slider"; float minimum = 0.1; float maximum = 100.0; float step = 0.1; float scale = 0.001; > = 1.; // convenience values #define PI 3.1415926f #define TAU 6.2831853f #define TwoPI 6.2831853f #define HalfPI 1.5707963f #define deg30 0.20943951 float mod(float x, float y) { return x - y * floor(x / y); } // ---------- Shader Code sampler_state def_sampler { Filter = Linear; AddressU = Clamp; AddressV = Clamp; }; sampler_state imageSampler { Filter = Point; AddressU = Clamp; AddressV = Clamp; }; struct VertFragData { float4 pos : POSITION; float2 uv : TEXCOORD0; }; VertFragData VSDefault(VertFragData vtx) { vtx.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj); return vtx; } void mainImage( out vec4 fragColor, in vec2 fragCoord ) { float2 position = fragCoord.xy / ViewSize.xy; float aspect = ViewSize.x / ViewSize.y; position.x *= aspect; float dist = distance(position, float2( aspect * 0.5, 0.5)); float offset = Time.x * pVelocity; float conv = pRings * 1.; float v = dist * conv - offset; float ringr = floor(v); float ringv = abs( dist - (ringr + float( frac(v) > 0.5) + offset) / conv); float color = smoothstep( -pBorder, pBorder, ringv); if ( mod(ringr, 2.) == 1.) color = 1. - color; fragColor = vec4(color, color, color, 1.); } float4 PSDefault(VertFragData vtx) : TARGET { float4 col = float4(1., 1., 1., 1.); mainImage(col, vtx.uv * ViewSize.xy); return col; } technique Draw { pass { vertex_shader = VSDefault(vtx); pixel_shader = PSDefault(vtx); } }