summaryrefslogtreecommitdiffhomepage
path: root/shaders/test.fs
blob: 16cf7c333c581ae932a35563aef6afdd01eec8b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#version 330


// 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
uniform float renderWidth;
uniform float renderHeight;
vec2 textureResolution = vec2(renderWidth, renderHeight);
uniform float grid_size;
//vec2 onePixel = vec2(1.0, 1.0) / textureResolution;
vec2 pixelCoor = fragTexCoord * textureResolution;

void main()
{
	vec4 texelColor = vec4(0.0, 0.0, 0.0, 0.0);
    // Texel color fetching from texture sampler
	if ((mod(floor(pixelCoor.x), grid_size + 1.0) == grid_size) || (mod(floor(pixelCoor.y), grid_size + 1.0) == grid_size))
	{
		texelColor = vec4(0.0, 0.0, 0.0, 1.0);
	}
	else {
	pixelCoor.y = -pixelCoor.y;
	pixelCoor = pixelCoor / (grid_size + 1.0);
		texelColor = texture(texture0, (pixelCoor /textureResolution));
	}
//if ((pix % 3) == 2)
//black pixel
//else
//get color of floor(pix / 3)
//end

    // NOTE: Implement here your fragment shader code

    finalColor = texelColor*colDiffuse;
}