Created
February 21, 2018 02:06
-
-
Save Monroe88/b4b0a0be2ae60c4321833811db987be2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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