28 lines
516 B
GLSL
28 lines
516 B
GLSL
#version 430 core
|
|
|
|
uniform vec3 color;
|
|
uniform vec3 background_color;
|
|
|
|
out vec4 out_color;
|
|
|
|
//zad5
|
|
float n = 0.05;
|
|
float f = 20.;
|
|
float linear_z() {
|
|
float z_around_0 = gl_FragCoord.z * 2 - 1;
|
|
float z = -2 * n * f / (z_around_0 * (n - f) + n + f);
|
|
return z / -f;
|
|
}
|
|
|
|
|
|
void main()
|
|
{
|
|
//zad4
|
|
// out_color = vec4(gl_FragCoord.z, gl_FragCoord.z, gl_FragCoord.z, 1);
|
|
//zad5
|
|
// out_color = vec4(vec3(linear_z()), 1);
|
|
//zad5*
|
|
out_color = vec4(mix(color, background_color, linear_z()), 1);
|
|
// out_color = vec4(color, 1);
|
|
}
|