29 lines
844 B
GLSL
29 lines
844 B
GLSL
precision highp float;
|
|
precision highp int;
|
|
|
|
#include <utils>
|
|
|
|
in vec3 oldPos;
|
|
in vec3 newPos;
|
|
in vec3 ray;
|
|
|
|
out vec4 fragColor;
|
|
|
|
void main() {
|
|
/* if the triangle gets smaller, it gets brighter, and vice versa */
|
|
float oldArea = length(dFdx(oldPos)) * length(dFdy(oldPos));
|
|
float newArea = length(dFdx(newPos)) * length(dFdy(newPos));
|
|
fragColor = vec4(oldArea / newArea * 0.2, 1.0, 0.0, 0.0);
|
|
|
|
vec3 refractedLight = refract(-light, vec3(0.0, 1.0, 0.0), IOR_AIR / IOR_WATER);
|
|
|
|
/* shadow for the rim of the pool */
|
|
vec2 t = intersectCube(
|
|
newPos,
|
|
-refractedLight,
|
|
vec3(-poolHalfSize.x, -poolHeight, -poolHalfSize.y),
|
|
vec3(poolHalfSize.x, poolHeight * 2.0, poolHalfSize.y)
|
|
);
|
|
fragColor.r *= 1.0 / (1.0 + exp(-200.0 / (1.0 + 10.0 * (t.y - t.x)) * (newPos.y - refractedLight.y * t.y - poolHeight * 2.0 / 12.0)));
|
|
}
|