Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/shaders/glsl/water_high.fs
Show First 20 Lines • Show All 284 Lines • ▼ Show 20 Lines | #if USE_REFLECTION | ||||
// Distort the reflection coords based on waves. | // Distort the reflection coords based on waves. | ||||
reflCoords = (0.5*reflectionCoords.xy - 15.0 * n.zx / refVY) / reflectionCoords.z + 0.5; | reflCoords = (0.5*reflectionCoords.xy - 15.0 * n.zx / refVY) / reflectionCoords.z + 0.5; | ||||
vec4 refTex = texture2D(reflectionMap, reflCoords); | vec4 refTex = texture2D(reflectionMap, reflCoords); | ||||
reflColor = refTex.rgb; | reflColor = refTex.rgb; | ||||
if (refTex.a < 0.99) | if (refTex.a < 0.99) | ||||
{ | { | ||||
// Calculate where we intersect with the skycube. | |||||
Ray myRay = Ray(vec3(worldPos.x/4.0,worldPos.y,worldPos.z/4.0),eye); | |||||
vec3 start = vec3(-1500.0 + mapSize/2.0,-100.0,-1500.0 + mapSize/2.0); | |||||
vec3 end = vec3(1500.0 + mapSize/2.0,500.0,1500.0 + mapSize/2.0); | |||||
float tmin = IntersectBox(myRay,start,end); | |||||
vec4 newpos = vec4(-worldPos.x/4.0,worldPos.y,-worldPos.z/4.0,1.0) + vec4(eye * tmin,0.0) - vec4(-mapSize/2.0,worldPos.y,-mapSize/2.0,0.0); | |||||
newpos *= skyBoxRot; | |||||
newpos.y *= 4.0; | |||||
// Interpolate between the sky color and nearby objects. | // Interpolate between the sky color and nearby objects. | ||||
reflColor = mix(textureCube(skyCube, newpos.rgb).rgb, refTex.rgb, refTex.a); | reflColor = mix(textureCube(skyCube, (vec4(eye, 1.0) * skyBoxRot).xyz).rgb, refTex.rgb, refTex.a); | ||||
} | } | ||||
// reflMod is used to reduce the intensity of sky reflections, which otherwise are too extreme. | // reflMod is used to reduce the intensity of sky reflections, which otherwise are too extreme. | ||||
reflMod = max(refTex.a, 0.75); | reflMod = max(refTex.a, 0.75); | ||||
#else | #else | ||||
reflMod = 0.75; | reflMod = 0.75; | ||||
reflColor = vec3(0.15, 0.7, 0.82); | reflColor = vec3(0.15, 0.7, 0.82); | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator