grk_5sem_labs/cw 4/shaders/shader_4_1.frag

28 lines
516 B
GLSL
Raw Normal View History

2023-11-18 02:25:43 +01:00
#version 430 core
2023-11-24 02:48:39 +01:00
uniform vec3 color;
uniform vec3 background_color;
2023-11-18 02:25:43 +01:00
out vec4 out_color;
2023-11-24 02:48:39 +01:00
//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;
}
2023-11-18 02:25:43 +01:00
void main()
{
2023-11-24 02:48:39 +01:00
//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);
2023-11-18 02:25:43 +01:00
}