mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-02-01 01:52:04 -05:00
This reverts commit 0edaebe192.
The commit was actually less optimal than it was before. Shaders are
always fully unfolded and both sides of a branch are always executed.
Despite that fact, the "avoid branching" commit actually *added* two
extra unnecessary instructions with the same number of actual sample
instructions, making it arguably less optimal than before.
This was tested via the D3DDissamble function.
46 lines
880 B
Plaintext
46 lines
880 B
Plaintext
uniform float4x4 ViewProj;
|
|
uniform texture2d tex_a;
|
|
uniform texture2d tex_b;
|
|
uniform float2 tex_a_dir;
|
|
uniform float2 tex_b_dir;
|
|
|
|
|
|
sampler_state textureSampler {
|
|
Filter = Linear;
|
|
AddressU = Clamp;
|
|
AddressV = Clamp;
|
|
};
|
|
|
|
struct VertData {
|
|
float4 pos : POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
VertData VSDefault(VertData v_in)
|
|
{
|
|
VertData vert_out;
|
|
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
|
|
vert_out.uv = v_in.uv;
|
|
return vert_out;
|
|
}
|
|
|
|
float4 PSSlide(VertData v_in) : TARGET
|
|
{
|
|
float2 tex_a_uv = v_in.uv + tex_a_dir;
|
|
float2 tex_b_uv = v_in.uv - tex_b_dir;
|
|
|
|
return (tex_a_uv.x - saturate(tex_a_uv.x) != 0.0) ||
|
|
(tex_a_uv.y - saturate(tex_a_uv.y) != 0.0)
|
|
? tex_b.Sample(textureSampler, tex_b_uv)
|
|
: tex_a.Sample(textureSampler, tex_a_uv);
|
|
}
|
|
|
|
technique Slide
|
|
{
|
|
pass
|
|
{
|
|
vertex_shader = VSDefault(v_in);
|
|
pixel_shader = PSSlide(v_in);
|
|
}
|
|
}
|