All right, I think I nailed the redcut for good. It was quite subtle. Let me try to explain with a few pictures, and 2 lines change in planet-high.frag
Let me recap what I see with current stock FG (no tweaking).
normalmap enabled (planet-high.frag in use)
normalmap disabled (planet.frag in use)
Now the fix I proposed earlier, i.e., removing this line
- Code: Select all
nmap.rgb = normalize(nmap.rgb);
Compared to the previous image (no normalmap), it is quasi-identical, so, indeed, normalizing(rgb) created spurious normal effects.
Now, look at that,
without normal mapping, I am pushing the sun quite low and a very small redcut appears, difficult to spot because the luminosity of the reddish light is low.
This drove me mad, but this tiny cut comes from this conditional in
planet.frag- Code: Select all
if (NdotL > 0.0)
The fix is to relax the strictly positive!!!! It looks like the graphic drivers, at least both nouveau and nvidia, are really happy to truncate a strictly positive to a value which is quite far from zero
Ok, let's see how the two issues interfere? Here I am testing the normalmap enabled, with the relaxed conditional, i.e., in planet-high.frag I have
- Code: Select all
if (NdotL >= 0.0)
and I
keep- Code: Select all
nmap.rgb = normalize(nmap.rgb);
We get:
The cut is gone. But, the reddish color is very bright, and very red, much redder than what we have with no normalmap (see 2nd picture). This is not expected on the oceans, normalmap, no normalmap should give the same behaviour. So, yes, there is not one but 2 issues at work, and one issue was actually put in evidence by the other.
In conclusion, the fixes are:
1) In both planet.frag
and planet-high.frag, we should relax the conditional, i.e., replace
- Code: Select all
if (NdotL > 0.0)
by
- Code: Select all
if (NdotL >= 0.0)
2) In planet-high.frag, remove
- Code: Select all
nmap.rgb = normalize(nmap.rgb);
And here how it is after the fixes (no differences at all between normalmap enabled or not), I post only one picture for this reason:
I can propose a merge request if you want Thorsten, I do not see the shadow of a cut anymore and the normals become very smooth once the rdb normalization is removed. I've even tested changing the 0.6 factor you put on nx, ny to 1 and I do not see any change on cost lines. Mountains look a bit sharper though.
Cheers,
Chris.