> Plus, if you neglect the curvature effect in every relevant vector, the  
> rendering artefacts at the tile boundaries must go away, because the  
> differences in rendering geometry between tiles go away, and they're the  
> only thing which can introduce the artefacts in the first place.

Turns out I was wrong here - found and eliminated the tile boundary bug.

The problematic thing seems to be refTex in the following code block of the 
water_sine fragment shader:

//load reflection
        vec4 tmp = vec4(lightdir, 0.0);
        vec4 refTex = texture2D(water_reflection, vec2(tmp)) ;
        vec4 refTexGrey = texture2D(water_reflection_grey, vec2(tmp)) ;
        vec4 refl ;

        if(cover >= 1.5){
                refl= normalize(refTex);
                }
        else
                {
                refl = normalize(refTexGrey);
                refl.r *= (0.75 + 0.15 * cover);
                refl.g *= (0.80 + 0.15 * cover);
                refl.b *= (0.875 + 0.125 * cover);
                refl.a  *= 1.0;
                }

If refTex is replaced by refTexGrey, the problem goes away (but the sea becomes 
grey even in sunshine), so there's something odd with the texture (?). But the 
whole block is actually obsolete. It basically loads a 128x128 homogeneous grey 
and a 128x128 homogeneous white texture, samples both, since both textures are 
homogeneous it finds the same color every time no matter where it is sampled, 
then chooses one of the textures and discards the other one to determine an 
(rgb) vector to be modified for cloud cover. 

Apparently we have the GPU power and texture memory by the bucketful so that we 
can use that procedure to determine a color vector. On the way, I also 
eliminated a few normalize(some_vector); statements of vectors which were 
already normalized before passing them, so the whole shader has other obsolete 
steps as well.

Not that I would be an expert in shader design, but about the same output 
(without tiling artefacts) can be achieved in a two-liner:

// basic water color
vec4 refl = vec4 (0.148, 0.27, 0.3, 1.0);

// de-saturate for reduced light
refl.rgb = mix(refl.rgb,  vec3 (0.248, 0.248, 0.248), 1.0 - smoothstep(0.4, 
1.0, scattering)); 

That has the neat side effect that we could even pass the basic color as a 
uniform from outside the shader and change the water color smoothly from the 
shore to deep ocean and dependent on latitude (the weather system happens to 
know if there's terrain in the vicinity or not). 

Feel free to do whatever you want with the information provided, after all it's 
open source...Oh, and why do I read so often that coding in Nasal is a problem 
for the performance actually?

* Thorsten
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to