1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-21 20:35:17 +02:00

fix water settings change, fix underwater color for low water settings

This commit is contained in:
XProger
2019-01-08 04:48:36 +03:00
parent 77a335bacc
commit ac3a7dc630
2 changed files with 20 additions and 17 deletions

View File

@@ -651,16 +651,14 @@ struct MeshBuilder {
}
void roomRemoveWaterSurfaces(TR::Room &room, int &iCount, int &vCount) {
for (int i = 0; i < room.data.fCount; i++)
room.data.faces[i].water = false;
if (Core::settings.detail.water == Core::Settings::LOW) {
for (int i = 0; i < room.data.fCount; i++)
room.data.faces[i].water = false;
if (Core::settings.detail.water == Core::Settings::LOW)
return;
}
for (int i = 0; i < room.data.fCount; i++) {
TR::Face &f = room.data.faces[i];
if (f.water) continue;
short3 &a = room.data.vertices[f.vertices[0]].pos;
short3 &b = room.data.vertices[f.vertices[1]].pos;

View File

@@ -214,7 +214,7 @@ uniform vec4 uFogParams;
vec4 light = max(vec4(0.0), lum) * max(vec4(0.0), vec4(1.0) - att);
#ifdef UNDERWATER
light.x *= abs(sin(dot(coord.xyz, vec3(1.0 / 512.0)) + uParam.x)) * 1.5 + 0.5;
light.x *= 0.5 + abs(sin(dot(coord.xyz, vec3(1.0 / 1024.0)) + uParam.x)) * 0.75;
#endif
vec3 ambient;
@@ -485,7 +485,7 @@ uniform vec4 uFogParams;
color.xyz *= light;
#ifdef TYPE_ENTITY
#if defined(TYPE_ENTITY) && defined(OPT_UNDERWATER_FOG)
float specular = calcSpecular(normal, vViewVec.xyz, vLightVec, uLightColor[0], rSpecular);
#ifdef UNDERWATER
specular *= (1.0 - uwSign);
@@ -493,16 +493,21 @@ uniform vec4 uFogParams;
color.xyz += specular;
#endif
#if defined(UNDERWATER) && defined(OPT_UNDERWATER_FOG)
float dist;
if (uViewPos.y < uParam.y)
dist = abs((vCoord.y - uParam.y) / normalize(uViewPos.xyz - vCoord.xyz).y);
else
dist = length(uViewPos.xyz - vCoord.xyz);
float fog = clamp(1.0 / exp(dist * WATER_FOG_DIST * uwSign), 0.0, 1.0);
dist += vCoord.y - uParam.y;
color.xyz *= mix(vec3(1.0), UNDERWATER_COLOR, clamp(dist * WATER_COLOR_DIST * uwSign, 0.0, 2.0));
color.xyz = mix(UNDERWATER_COLOR * 0.2, color.xyz, fog);
#ifdef UNDERWATER
#ifdef OPT_UNDERWATER_FOG
float dist;
if (uViewPos.y < uParam.y)
dist = abs((vCoord.y - uParam.y) / normalize(uViewPos.xyz - vCoord.xyz).y);
else
dist = length(uViewPos.xyz - vCoord.xyz);
float fog = clamp(1.0 / exp(dist * WATER_FOG_DIST * uwSign), 0.0, 1.0);
dist += vCoord.y - uParam.y;
color.xyz *= mix(vec3(1.0), UNDERWATER_COLOR, clamp(dist * WATER_COLOR_DIST * uwSign, 0.0, 2.0));
color.xyz = mix(UNDERWATER_COLOR * 0.2, color.xyz, fog);
#else
color.xyz = mix(color.xyz, color.xyz * UNDERWATER_COLOR, uwSign);
color.xyz = mix(uFogParams.xyz, color.xyz, vNormal.w);
#endif
#else
color.xyz = mix(uFogParams.xyz, color.xyz, vNormal.w);
#endif