23 lines
676 B
GLSL
23 lines
676 B
GLSL
in vec3 TexCoords;
|
|
out vec4 FragColor;
|
|
|
|
uniform samplerCube textureSource;
|
|
uniform vec2 ScaleU;
|
|
|
|
void main()
|
|
{
|
|
vec3 sampleDir = normalize(TexCoords);
|
|
vec3 right = normalize(cross(sampleDir, vec3(0.0, 1.0, 0.0)));
|
|
vec3 up = normalize(cross(right, sampleDir));
|
|
|
|
vec3 color = vec3(0.0);
|
|
float total = 0.0;
|
|
for (float x = -4.0; x <= 4.0; x += 1.0) {
|
|
for (float y = -4.0; y <= 4.0; y += 1.0) {
|
|
vec3 offset = right * ScaleU.x * x + up * ScaleU.y * y;
|
|
color += texture(textureSource, normalize(sampleDir + offset)).rgb;
|
|
total += 1.0;
|
|
}
|
|
}
|
|
FragColor = vec4(color / total, 1.0);
|
|
} |