30 lines
737 B
GLSL
30 lines
737 B
GLSL
#version 450
|
|
|
|
layout(binding = 0) uniform UniformBufferObject {
|
|
vec4 balls[8];
|
|
} ubo;
|
|
|
|
layout(location = 0) in vec3 fragColor;
|
|
|
|
layout(location = 0) out vec4 outColor;
|
|
|
|
float calculateIntensity(vec4 fragCoord, int i) {
|
|
return (ubo.balls[i].z) / (sqrt(pow(fragCoord.x - ((0.5 + ubo.balls[i].x) * 800), 2) + pow(fragCoord.y - ((0.5 + ubo.balls[i].y) * 600), 2)));
|
|
}
|
|
|
|
void main() {
|
|
float intensity = 0;
|
|
|
|
for (int i = 0; i < ubo.balls.length(); i++) {
|
|
intensity += calculateIntensity(gl_FragCoord, i);
|
|
}
|
|
|
|
intensity *= 24;
|
|
|
|
if (intensity >= 0.8) {
|
|
outColor = vec4(intensity, intensity, intensity, 1.0);
|
|
} else if (intensity <= -0.8) {
|
|
outColor = vec4(-intensity, 0, 0, 1.0);
|
|
}
|
|
}
|