After spending half an evening trying to wrap my head around the ocean
problem, here's what I found out:

Just to be sure, I moved the geometry back into the fragment part - this
indeed seems to work more accurately. Then I switched ground layer effects
off and computed just with distance attenuation (as the default shader
does).

Basically, I think the geometry works just fine, i.e. the code is correct
but there's something else going on which is funny.

First, note that the water vertices are fogged correctly, it's just the
lines between them which don't check out. Whoever based the default shader
on a distance measure

    fogCoord = abs(ecPosition.z / ecPosition.w);

instead of the true distance to the vertex obviously knew this: While this
screws up the fog at the periphery (it computes the projection of the
distance to the current view axis, so if it's in the center of the screen
this is the distance, but if it's at the edge the fog is (for 120 deg FOV
vastly) underestimated).

Now, contrary to my first impression, in a pure distance fading picture
this largely compensates for the error on the line between faraway ocean
vertices, i.e. it is pretty good in removing most of the ocean problem
(without the ground haze layer - with it it screws the whole trigonometry
because all the altitudes compute wrong if you insert something which
isn't the distance as a distance, so I can't use it anyway), but it
introduces wide-angle artefacts over terrain. So, I think that function
has been used here intentionally - if the person putting it there could
please comment? Thus, I think we're dealing with a known problem, and for
all I can see it really has to do with vertex spacing.

However, artefacts  aren't limited to vertex spacing. Using Emilian's test
setup, I proceeded to render very dense, thin ground fog layers.

Here's an area above KINS:

http://www.phy.duke.edu/~trenk/pics/shadertest4.jpg

Note on the left part that even for large distances, the fog is able to
trace fine features of the terrain. This would be completely impossible if
we had any real problems with the geometry or the distance measure.

But now focus on the lower right - there's a very ugly wedge which doesn't
really belong there. To me this seems like a fault in the terrain mesh
which is picked up by the shader which gets a wrong distance. If you make
the fog layer thicker, it gets swamped eventually.

To test that conjecture, I've moved to an area where I know a terrain mesh
faultline (north of Grenoble with France custom scenery).

Same exercise:

http://www.phy.duke.edu/~trenk/pics/shadertest5.jpg


To the left, you can see that the shader gets even very fine terrain
features right out to large distances. To the right is the terrain fault
line (there's even a blackish line which corresponds to a real gap in the
terrain overlap) - and lo and behold, the shader gets completely thrown by
the terrain mesh fault line.

So I believe at least part of the problem is that it gets drawn to
problems in the terrain mesh. Maybe there's also something funny with the
ocean mesh - apparently it doesn't need to be a visible problem to be
picked up by the shader.

> Hmm, that's not what I'm experiencing here. What I see is insufficienlty
> fogged
> tiles at the edge of visibility, where I would expect them to be fully
> fogged (either by the haze layer or by the "fog").

Haven't seen those, but:

Switch ground haze off (set altitude to zero). Then you're left with
standard fog based on distance. Ramp up the fog function to the degree
that everything fades out properly. Then switch ground haze back on - this
adds fog, so whatever was faded properly before should now be faded as
well.

Whatever else you see is coloring mismatch, nt incomplete fogging.

I have a slight residual color mismatch whenever there are thin layers and
finite terrain elevation. That comes from the fact that the actual color
seen depends on how deep into the layer you look, and that depends on
terrain (if the layer is 1000 m deep, but the terrain is 990 m, you can
only go 10 m deep). However, the skydome can't know how high the terrain
is where it is not loaded, so it makes the default assumption that the
terrain has zero elevation - which might overestimate the darkening of the
fog, and thus we get a mismatch. There is no solution to this one, I'm
afraid, except to load terrain farther out.


Going to do something else now - I'll dream of fog otherwise...

Cheers,

* Thorsten


------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to