atmosphere: disable haze for rays that do not hit the Earth sphere
This commit is contained in:
1 parent
83bec11d61
commit
97c78ceca3
1 file changed
+4
-3
Vendored
+4
-3
@@ -345,12 +345,13 @@ var FRAG_SRC = [
|
||||
'float cIn = dot(oc, oc) - R * R;',
|
||||
'float discIn = b * b - cIn;',
|
||||
'float tInner = 100000.0;',
|
||||
'float hitsInner = 0.0;',
|
||||
'if (discIn > 0.0) {',
|
||||
'float sq = sqrt(discIn);',
|
||||
'float t1 = -b - sq;',
|
||||
'float t2 = -b + sq;',
|
||||
'if (t1 > 0.0) tInner = t1;',
|
||||
'else if (t2 > 0.0) tInner = t2;',
|
||||
'if (t1 > 0.0) { tInner = t1; hitsInner = 1.0; }',
|
||||
'else if (t2 > 0.0) { tInner = t2; hitsInner = 1.0; }',
|
||||
'}',
|
||||
'if (tInner < 100000.0) tEnd = min(tEnd, tInner);',
|
||||
'if (tEnd <= tStart) { gl_FragColor = vec4(0.0); return; }',
|
||||
@@ -375,7 +376,7 @@ var FRAG_SRC = [
|
||||
't += step;',
|
||||
'}',
|
||||
'float rawAlpha = clamp(1.0 - exp(-tau), 0.0, 1.0);',
|
||||
'float alpha = clamp(rawAlpha * uAtmoGain, 0.0, uAtmoMaxAlpha);',
|
||||
'float alpha = clamp(rawAlpha * uAtmoGain * hitsInner, 0.0, uAtmoMaxAlpha);',
|
||||
'vec3 col = scatter / max(rawAlpha, 1e-4);',
|
||||
'gl_FragColor = vec4(col, alpha);',
|
||||
'return;',
|
||||
|
||||
Reference in new issue
Block a user