Created
December 9, 2018 03:08
-
-
Save mlfarrell/c4015e671ade86300071de54e07f9106 to your computer and use it in GitHub Desktop.
Retro handheld style post processing shader
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
// | |
// Pass-through post-processing shader template | |
// Verto Studio 3D | |
// Created by Mike Farrell | |
// | |
// Please read the shader section of the user-guide | |
// for more information on shader programming | |
// within Verto Studio | |
precision mediump float; | |
in mediump vec2 textureCoordinates; | |
out vec4 fragColor; | |
uniform sampler2D passInputTexture0; | |
const float pixelSize = 4.0; | |
void main() | |
{ | |
vec4 color; | |
color = texture(passInputTexture0, textureCoordinates); | |
//uncomment for an example of a simple sepia-tone | |
//post processing effect | |
float grey = dot(color.rgb, vec3(0.299, 0.587,0.114)); | |
vec4 colors = vec4( | |
0.2, | |
0.4, | |
0.6, | |
0.8 | |
); | |
if(grey < 0.2) | |
grey = colors[0]; | |
else if(grey < 0.4) | |
grey = colors[1]; | |
else if(grey < 0.7) | |
grey = colors[2]; | |
else | |
grey = colors[3]; | |
//pixel grid lines | |
if(mod(gl_FragCoord.x, pixelSize) < 1.0) | |
grey = 1.0; | |
if(mod(gl_FragCoord.y, pixelSize) < 1.0) | |
grey = 1.0; | |
color = vec4(grey * vec3(1.2, 1.0, 0.8), 1.0); | |
fragColor = color; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment