1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-22 21:03:19 +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) { 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) { if (Core::settings.detail.water == Core::Settings::LOW)
for (int i = 0; i < room.data.fCount; i++)
room.data.faces[i].water = false;
return; return;
}
for (int i = 0; i < room.data.fCount; i++) { for (int i = 0; i < room.data.fCount; i++) {
TR::Face &f = room.data.faces[i]; TR::Face &f = room.data.faces[i];
if (f.water) continue;
short3 &a = room.data.vertices[f.vertices[0]].pos; short3 &a = room.data.vertices[f.vertices[0]].pos;
short3 &b = room.data.vertices[f.vertices[1]].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); vec4 light = max(vec4(0.0), lum) * max(vec4(0.0), vec4(1.0) - att);
#ifdef UNDERWATER #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 #endif
vec3 ambient; vec3 ambient;
@@ -485,7 +485,7 @@ uniform vec4 uFogParams;
color.xyz *= light; color.xyz *= light;
#ifdef TYPE_ENTITY #if defined(TYPE_ENTITY) && defined(OPT_UNDERWATER_FOG)
float specular = calcSpecular(normal, vViewVec.xyz, vLightVec, uLightColor[0], rSpecular); float specular = calcSpecular(normal, vViewVec.xyz, vLightVec, uLightColor[0], rSpecular);
#ifdef UNDERWATER #ifdef UNDERWATER
specular *= (1.0 - uwSign); specular *= (1.0 - uwSign);
@@ -493,16 +493,21 @@ uniform vec4 uFogParams;
color.xyz += specular; color.xyz += specular;
#endif #endif
#if defined(UNDERWATER) && defined(OPT_UNDERWATER_FOG) #ifdef UNDERWATER
float dist; #ifdef OPT_UNDERWATER_FOG
if (uViewPos.y < uParam.y) float dist;
dist = abs((vCoord.y - uParam.y) / normalize(uViewPos.xyz - vCoord.xyz).y); if (uViewPos.y < uParam.y)
else dist = abs((vCoord.y - uParam.y) / normalize(uViewPos.xyz - vCoord.xyz).y);
dist = length(uViewPos.xyz - vCoord.xyz); else
float fog = clamp(1.0 / exp(dist * WATER_FOG_DIST * uwSign), 0.0, 1.0); dist = length(uViewPos.xyz - vCoord.xyz);
dist += vCoord.y - uParam.y; float fog = clamp(1.0 / exp(dist * WATER_FOG_DIST * uwSign), 0.0, 1.0);
color.xyz *= mix(vec3(1.0), UNDERWATER_COLOR, clamp(dist * WATER_COLOR_DIST * uwSign, 0.0, 2.0)); dist += vCoord.y - uParam.y;
color.xyz = mix(UNDERWATER_COLOR * 0.2, color.xyz, fog); 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 #else
color.xyz = mix(uFogParams.xyz, color.xyz, vNormal.w); color.xyz = mix(uFogParams.xyz, color.xyz, vNormal.w);
#endif #endif