@@ -181,7 +181,7 @@ void getSurfaceEffect(in vec4 stencil, inout vec4 reflectionColor, inout vec4 wa
181181
182182 reflectionColor.rgb += clamp ((str * col), 0.0 , 3.0 );
183183 }
184- reflectionColor /= 6 ;
184+ reflectionColor /= 6.0 ;
185185 }
186186
187187 color = vec4 (color.rgb, 1.0 ) + vec4 (reflectionColor.rgb, 1.0 );
@@ -201,8 +201,8 @@ vec4 computeFinalWaterColor(vec4 stencil, vec4 color, float fadeAmount, bool gla
201201 in_water = 0.0 ;
202202
203203 // combine reflection and scene at water surfaces
204- float reflection_strength = 0.30 * (stencil.r- 0.1 );
205- float disable_refl = stencil.r- 0.1 ;
204+ float reflection_strength = 0.30 * (stencil.r - 0.1 );
205+ float disable_refl = stencil.r - 0.1 ;
206206
207207 if (disable_refl <= 0.0 ) disable_refl = 0.0 ; // no reflection
208208
@@ -212,9 +212,9 @@ vec4 computeFinalWaterColor(vec4 stencil, vec4 color, float fadeAmount, bool gla
212212
213213 // more color in darker water in relation to the reflection
214214 // color darkened
215- float difference = (reflection_color.r+ reflection_color.g+ reflection_color.b)/ 3.0 - (color.r + color.g + color.b)/ 5.5 ;
215+ float difference = (reflection_color.r + reflection_color.g + reflection_color.b) / 3.0 - (color.r + color.g + color.b) / 5.5 ;
216216 if (difference < 0.0 ) difference = 0.0 ;
217- vec3 regular_color = color.rgb * (1.0 - in_water* reflection_strength) + (in_water * (difference * getWaterColor().rgb));
217+ vec3 regular_color = color.rgb * (1.0 - in_water * reflection_strength) + (in_water * (difference * getWaterColor().rgb));
218218
219219 color = vec4 (regular_color, 1.0 );
220220 reflectionColor = vec4 (reflection_color, 1.0 );
@@ -224,9 +224,8 @@ vec4 computeFinalWaterColor(vec4 stencil, vec4 color, float fadeAmount, bool gla
224224
225225 // Superbomb17 effect on water surface
226226 #if STYLE == 2
227- if (! glass && isEyeInWater == 0 ) {
227+ if (! glass && isEyeInWater == 0 )
228228 getSurfaceEffect(stencil, reflectionColor, waterRawColor, fadeAmount);
229- }
230229 #endif
231230
232231 // Blending reflection factor (how much of reflection color in final fragment)
@@ -243,38 +242,44 @@ void main() {
243242
244243 vec4 waterMask = getWaterMask(texcoord);
245244 vec4 glassMask = getGlassMask(texcoord);
245+ vec4 cloudMask = getCloudMask(texcoord);
246246 vec4 iceMask = getIceMask(texcoord);
247247 vec4 stencil = getStencil(texcoord);
248248
249+ vec4 waterModelPos = getWaterModelPos(texcoord);
249250 vec3 waterNormal = getWaterNormal(texcoord);
250251 vec4 waterRawColor = getWaterRawColor(texcoord);
251252
252253 bool water = isWater(waterMask);
253254 bool glass = isGlass(glassMask);
254255 bool ice = isIce(iceMask);
256+ bool cloud = isCloud(cloudMask);
255257
256258 float glassAlpha = getGlassTransparency(glassMask);
257259 float fadeAmount = getTransitionAmount(waterMask);
258260 float waterLength = getWaterDistance(waterMask);
259261 float glassLength = getGlassDistance(glassMask);
262+ float cloudLength = getCloudLength(cloudMask);
260263
261- if (isLookingAtStillWaterThroughTransluscent(glass, ice, water, waterLength, glassLength, waterNormal)) {
262- // Mare sure you can see water reflection through glass and ice when placed in water on solid block
263- fadeAmount = 1.0 ;
264- }
264+ if (! cloud && cloudLength < waterLength) {
265+ // Make sure clouds hide water like the rest of terrain, if no clouds in front then do water stuff
265266
266- if ((water || glass) && ! ice ) {
267- // Compute reflections, refractions, and wawing water into color
268- color = computeFinalWaterColor(stencil, color, fadeAmount, glass, glassAlpha, waterRawColor) ;
269- }
267+ if (isLookingAtStillWaterThroughTransluscent(glass, ice, water, waterLength, glassLength, waterNormal) ) {
268+ // Mare sure you can see water reflection through glass and ice when placed in water on solid block
269+ fadeAmount = 1.0 ;
270+ }
270271
271- if (water && isEyeInWater == 0 ) {
272- // Blend flowing water to scene when outside water
273- float divisor = (glassLength < waterLength) ? 2.0 : 8.0 ;
274- float factor = max (0.0 , waterBlendFactor - glassAlpha / divisor);
275- color = blendWaterInScene(color, waterRawColor, factor, fadeAmount);
276- }
272+ if ((water || glass) && ! ice) {
273+ // Compute reflections, refractions, and wawing water into color
274+ color = computeFinalWaterColor(stencil, color, fadeAmount, glass, glassAlpha, waterRawColor);
275+ }
277276
278- // Debug
279- // color.rgb = texture(colortex11, texcoord).rgb;
277+ if (water && isEyeInWater == 0 ) {
278+ // Blend flowing water to scene when outside water
279+ float divisor = (glassLength < waterLength) ? 2.0 : 8.0 ;
280+ float factor = max (0.0 , waterBlendFactor - glassAlpha / divisor);
281+ color = blendWaterInScene(color, waterRawColor, factor, fadeAmount);
282+ color = applyFogOnWater(color, waterModelPos);
283+ }
284+ }
280285}
0 commit comments