This repository has been archived on 2022-04-04. You can view files and clone it, but cannot push or open issues or pull requests.
ludum-dare-50/game/dist/shaders/texture_render.fs
2022-03-22 12:45:28 -04:00

36 lines
862 B
GLSL

#version 330
// TODO: for now this is just a scanline shader for testing
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
in vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables
// NOTE: Render size values must be passed from code
const float renderWidth = 800;
const float renderHeight = 450;
float offset = 0.0;
uniform float time;
void main()
{
float frequency = renderHeight/3.0;
// Scanlines method 2
float globalPos = (fragTexCoord.y + offset) * frequency;
float wavePos = cos((fract(globalPos) - 0.5)*3.14);
// Texel color fetching from texture sampler
vec4 texelColor = texture(texture0, fragTexCoord);
finalColor = mix(vec4(0.0, 0.3, 0.0, 0.0), texelColor, wavePos);
}