Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/shaders/glsl/water_high.fs
#version 110 | #version 110 | ||||
#include "common/fog.h" | #include "common/fog.h" | ||||
#if USE_SHADOWS_ON_WATER | |||||
#include "common/shadows_fragment.h" | #include "common/shadows_fragment.h" | ||||
#endif | |||||
// Environment settings | // Environment settings | ||||
uniform vec3 ambient; | uniform vec3 ambient; | ||||
uniform vec3 sunDir; | uniform vec3 sunDir; | ||||
uniform vec3 sunColor; | uniform vec3 sunColor; | ||||
uniform mat4 skyBoxRot; | uniform mat4 skyBoxRot; | ||||
uniform vec3 cameraPos; | uniform vec3 cameraPos; | ||||
▲ Show 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | #endif | ||||
// How perpendicular to the normal our view is. Used for fresnel. | // How perpendicular to the normal our view is. Used for fresnel. | ||||
float ndotv = clamp(dot(normal, eyeVec), 0.0, 1.0); | float ndotv = clamp(dot(normal, eyeVec), 0.0, 1.0); | ||||
// Fresnel for "how much reflection vs how much refraction". | // Fresnel for "how much reflection vs how much refraction". | ||||
float fresnel = clamp(((pow(1.1 - ndotv, 2.0)) * 1.5), 0.1, 0.75); // Approximation. I'm using 1.1 and not 1.0 because it causes artifacts, see #1714 | float fresnel = clamp(((pow(1.1 - ndotv, 2.0)) * 1.5), 0.1, 0.75); // Approximation. I'm using 1.1 and not 1.0 because it causes artifacts, see #1714 | ||||
vec3 specular = getSpecular(normal, eyeVec); | vec3 specular = getSpecular(normal, eyeVec); | ||||
#if USE_SHADOWS_ON_WATER && USE_SHADOW | #if USE_SHADOW | ||||
float shadow = get_shadow(); | float shadow = get_shadow(); | ||||
float fresShadow = mix(fresnel, fresnel * shadow, 0.05 + murkiness * 0.2); | float fresShadow = mix(fresnel, fresnel * shadow, 0.05 + murkiness * 0.2); | ||||
vec3 color = mix(refrColor.rgb, reflColor.rgb, fresShadow * reflColor.a); | vec3 color = mix(refrColor.rgb, reflColor.rgb, fresShadow * reflColor.a); | ||||
color += shadow * specular; | color += shadow * specular; | ||||
vec4 foam = getFoam(fancyeffects, shadow); | vec4 foam = getFoam(fancyeffects, shadow); | ||||
#else | #else | ||||
vec3 color = mix(refrColor.rgb, reflColor.rgb, fresnel * reflColor.a); | vec3 color = mix(refrColor.rgb, reflColor.rgb, fresnel * reflColor.a); | ||||
color += specular; | color += specular; | ||||
Show All 12 Lines |
Wildfire Games · Phabricator