Skip to content

Instantly share code, notes, and snippets.

@Monroe88
Created February 21, 2018 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Monroe88/b4b0a0be2ae60c4321833811db987be2 to your computer and use it in GitHub Desktop.
Save Monroe88/b4b0a0be2ae60c4321833811db987be2 to your computer and use it in GitHub Desktop.
/*
Input Lag shader
*/
struct previous
{
uniform sampler2D texture;
float2 tex_coord;
};
struct input
{
float2 video_size;
float2 texture_size;
float2 output_size;
float frame_count;
float frame_direction;
float frame_rotation;
sampler2D texture : TEXUNIT0;
};
struct tex_coords
{
float2 tex;
float2 prev;
float2 prev1;
float2 prev2;
float2 prev3;
float2 prev4;
float2 prev5;
float2 prev6;
};
void main_vertex
(
float4 position : POSITION,
out float4 oPosition : POSITION,
uniform float4x4 modelViewProj,
float2 tex : TEXCOORD,
previous PREV,
previous PREV1,
previous PREV2,
previous PREV3,
previous PREV4,
previous PREV5,
previous PREV6,
out tex_coords coords
)
{
oPosition = mul(modelViewProj, position);
coords = tex_coords(tex, PREV.tex_coord,
PREV1.tex_coord,
PREV2.tex_coord,
PREV3.tex_coord,
PREV4.tex_coord,
PREV5.tex_coord,
PREV6.tex_coord);
}
struct output
{
float4 col : COLOR;
};
output main_fragment(tex_coords coords,
uniform input IN,
previous PREV,
previous PREV1,
previous PREV2,
previous PREV3,
previous PREV4,
previous PREV5,
previous PREV6
)
{
float4 color = tex2D(PREV6.texture, coords.prev6); // Add 7 frames of input lag by displaying the seventh previous frame (PREV6)
output OUT;
OUT.col = color;
return OUT;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment