stk-code_catmod/data/shaders/sky.frag

37 lines
790 B
GLSL

#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
uniform samplerCube tex;
#if __VERSION__ >= 130
out vec4 FragColor;
#else
#define FragColor gl_FragColor
#endif
void main(void)
{
vec3 eyedir = gl_FragCoord.xyz / vec3(screen, 1.);
eyedir = 2.0 * eyedir - 1.0;
vec4 tmp = (InverseViewMatrix * InverseProjectionMatrix * vec4(eyedir, 1.));
eyedir = tmp.xyz / tmp.w;
vec4 color = texture(tex, eyedir);
FragColor = vec4(color.xyz, 1.);
}