mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-16 01:54:38 +02:00
#23 fix underwater fog
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
#define SHADOW_TEX_SIZE 1024
|
#define SHADOW_TEX_SIZE 1024
|
||||||
|
|
||||||
#define FOG_DIST (18 * 1024)
|
#define FOG_DIST (18 * 1024)
|
||||||
#define WATER_FOG_DIST (8 * 1024)
|
#define WATER_FOG_DIST (6 * 1024)
|
||||||
//#define WATER_USE_GRID
|
//#define WATER_USE_GRID
|
||||||
#define UNDERWATER_COLOR "#define UNDERWATER_COLOR vec3(0.6, 0.9, 0.9)\n"
|
#define UNDERWATER_COLOR "#define UNDERWATER_COLOR vec3(0.6, 0.9, 0.9)\n"
|
||||||
|
|
||||||
|
@@ -119,14 +119,17 @@ varying vec4 vTexCoord; // xy - atlas coords, zw - caustics coords
|
|||||||
|
|
||||||
float fog;
|
float fog;
|
||||||
#ifdef UNDERWATER
|
#ifdef UNDERWATER
|
||||||
float d = abs((vViewVec.w - max(uViewPos.y, uParam.y)) / normalize(vViewVec.xyz).y);
|
float d;
|
||||||
d *= step(0.0, vViewVec.w - uParam.y);
|
if (uViewPos.y < uParam.y)
|
||||||
|
d = abs((coord.y - uParam.y) / normalize(vViewVec.xyz).y);
|
||||||
|
else
|
||||||
|
d = length(uViewPos - coord.xyz);
|
||||||
fog = d * WATER_FOG_DIST;
|
fog = d * WATER_FOG_DIST;
|
||||||
#else
|
#else
|
||||||
fog = length(vViewVec.xyz);
|
fog = length(vViewVec.xyz);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vNormal.w = 1.0 - clamp(1.0 / exp(fog), 0.0, 1.0);
|
vNormal.w = clamp(1.0 / exp(fog), 0.0, 1.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return coord;
|
return coord;
|
||||||
@@ -457,9 +460,9 @@ varying vec4 vTexCoord; // xy - atlas coords, zw - caustics coords
|
|||||||
|
|
||||||
#if defined(PASS_COMPOSE) && !defined(TYPE_FLASH)
|
#if defined(PASS_COMPOSE) && !defined(TYPE_FLASH)
|
||||||
#ifdef UNDERWATER
|
#ifdef UNDERWATER
|
||||||
color.xyz = mix(color.xyz, UNDERWATER_COLOR * 0.2, vNormal.w);
|
color.xyz = mix(UNDERWATER_COLOR * 0.2, color.xyz, vNormal.w);
|
||||||
#else
|
#else
|
||||||
color.xyz = mix(color.xyz, vec3(0.0), vNormal.w);
|
color.xyz = mix(vec3(0.0), color.xyz, vNormal.w);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user