commenting frag shader

This commit is contained in:
Evan Pratten 2021-09-22 20:31:30 -04:00
parent f7f1844adb
commit cd4c08210c

View File

@ -1,36 +1,34 @@
#version 330
// Input vertex attributes (from vertex shader)
// Fragment texture UV coordinate
in vec2 fragTexCoord;
in vec4 fragColor;
// Input uniform values
// Whole input texture
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// Viewport size
uniform vec2 viewport;
// Output fragment color
out vec4 finalColor;
// Pixel scaling
// Pixel scaling factor (pixels per pixel)
const vec2 pixelScale = vec2(1.0, 1.0);
void main()
{
void main() {
// Calculate the distance to merge pixels
float dx = pixelScale.x * (1.0 / viewport.x);
float dy = pixelScale.y * (1.0 / viewport.y);
// Calculate the distance to merge pixels
float dx = pixelScale.x * (1.0 / viewport.x);
float dy = pixelScale.y * (1.0 / viewport.y);
// Get the base UV coordinate of the pixel
vec2 baseUV = fragTexCoord;
// Get the base UV coordinate of the pixel
vec2 baseUV = fragTexCoord;
// Calculate a UV for this new blocky pixel
vec2 pixelatedUV = vec2(dx * floor(baseUV.x / dx), dy * floor(baseUV.y / dy));
// Calculate a UV for this new blocky pixel
vec2 pixelatedUV = vec2(dx * floor(baseUV.x / dx), dy * floor(baseUV.y / dy));
// Rebuild the texture with the new UVs
vec3 tc = texture(texture0, pixelatedUV).rgb;
// Rebuild the texture with the new UVs
vec3 tc = texture(texture0, pixelatedUV).rgb;
// Build the final pixel
finalColor = vec4(tc, 1.0);
// Build the final pixel
finalColor = vec4(tc, 1.0);
}