-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Hacktix/crt-shader
CRT Shader
- Loading branch information
Showing
4 changed files
with
86 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#version 130 | ||
|
||
#define CRT_CASE_BORDR 0.0125 | ||
#define SCAN_LINE_MULT 1250.0 | ||
|
||
uniform float CRT_CURVE_AMNTx; // curve amount on x | ||
uniform float CRT_CURVE_AMNTy; // curve amount on y | ||
uniform sampler2D texture; | ||
|
||
in vec4 color; | ||
in vec2 texCoord; | ||
|
||
void main() { | ||
vec2 tc = texCoord.xy; | ||
|
||
// Distance from the center | ||
float dx = abs(0.5-tc.x); | ||
float dy = abs(0.5-tc.y); | ||
|
||
// Square it to smooth the edges | ||
dx *= dx; | ||
dy *= dy; | ||
|
||
tc.x -= 0.5; | ||
tc.x *= 1.0 + (dy * CRT_CURVE_AMNTx); | ||
tc.x += 0.5; | ||
|
||
tc.y -= 0.5; | ||
tc.y *= 1.0 + (dx * CRT_CURVE_AMNTy); | ||
tc.y += 0.5; | ||
|
||
// Get texel, and add in scanline if need be | ||
vec4 cta = texture2D(texture, tc); | ||
|
||
cta.rgb += sin(tc.y * SCAN_LINE_MULT) * 0.03; | ||
|
||
// Cutoff | ||
if(tc.y > 1.0 || tc.x < 0.0 || tc.x > 1.0 || tc.y < 0.0) | ||
cta = vec4(0.0); | ||
|
||
// Apply | ||
gl_FragColor = cta * color; | ||
} |