diff options
author | Sebastian Park <SebPark03@gmail.com> | 2024-05-09 22:02:12 -0400 |
---|---|---|
committer | Sebastian Park <SebPark03@gmail.com> | 2024-05-09 22:02:12 -0400 |
commit | 481e582be02385271f87524bfe46d6c41654e23c (patch) | |
tree | ddb9a0b98de7e5b40aeea55464deb75cc753a15d /resources/shaders/caustics.frag | |
parent | f1230ea24dc87a3bb5c9c709d4571e3298d7d07f (diff) |
"raytraced" caustics.
Diffstat (limited to 'resources/shaders/caustics.frag')
-rw-r--r-- | resources/shaders/caustics.frag | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/resources/shaders/caustics.frag b/resources/shaders/caustics.frag new file mode 100644 index 0000000..f746896 --- /dev/null +++ b/resources/shaders/caustics.frag @@ -0,0 +1,20 @@ +#version 410 core +out vec4 fragColor; + +in vec3 normal_worldSpace; +in vec3 pos; +in vec3 newPos; +in vec4 col; +in float refractProb; + +uniform sampler2D normSamp; + +void main() { +// fragColor = vec4(vec3((pos[0] + 1) / 2, (pos[1] + 1) / 2, 0.f), 1.f); + float oldArea = length(dFdx(vec3(pos[0], pos[2], pos[1]))) * length(dFdy(vec3(pos[0], pos[2], pos[1]))); + float newArea = length(dFdx(vec3(newPos[0], newPos[2], newPos[1]))) * length(dFdy(vec3(newPos[0], newPos[2], newPos[1]))); + float areaRatio = oldArea / newArea; + float intensity = pow(areaRatio * .3f, 1.5f); + fragColor = vec4(0.98, 1, .78, intensity * refractProb); +// fragColor = col; +} |