TkAstral3D/packages/sdk/public/resource/shaders/water/cylinder_caustics/fragment.glsl
2026-04-08 15:34:43 +08:00

23 lines
678 B
GLSL

precision highp float;
precision highp int;
#include <utils>
#include <cylinder_utils>
in vec3 oldPos;
in vec3 newPos;
in vec3 ray;
out vec4 fragColor;
void main() {
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);
vec2 t = intersectCylinder(newPos, -refractedLight, poolRadius, -poolHeight, poolHeight * 2.0);
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)));
}