|
|
@@ -26,6 +26,16 @@ import { Fn, float, vec2, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix,
|
|
|
* scene.add( sky );
|
|
|
* ```
|
|
|
*
|
|
|
+ * It can be useful to hide the sun disc when generating an environment map to avoid artifacts
|
|
|
+ *
|
|
|
+ * ```js
|
|
|
+ * // disable before rendering environment map
|
|
|
+ * sky.showSunDisc.value = false;
|
|
|
+ * // ...
|
|
|
+ * // re-enable before scene sky box rendering
|
|
|
+ * sky.showSunDisc.value = true;
|
|
|
+ * ```
|
|
|
+ *
|
|
|
* @augments Mesh
|
|
|
* @three_import import { SkyMesh } from 'three/addons/objects/SkyMesh.js';
|
|
|
*/
|
|
|
@@ -117,6 +127,13 @@ class SkyMesh extends Mesh {
|
|
|
*/
|
|
|
this.cloudElevation = uniform( 0.5 );
|
|
|
|
|
|
+ /**
|
|
|
+ * Whether to render the solar disc.
|
|
|
+ *
|
|
|
+ * @type {UniformNode<float>}
|
|
|
+ */
|
|
|
+ this.showSunDisc = uniform( 1 );
|
|
|
+
|
|
|
/**
|
|
|
* This flag can be used for type testing.
|
|
|
*
|
|
|
@@ -146,8 +163,8 @@ class SkyMesh extends Mesh {
|
|
|
const vertexNode = /*@__PURE__*/ Fn( () => {
|
|
|
|
|
|
// constants for atmospheric scattering
|
|
|
- const e = float( 2.71828182845904523536028747135266249775724709369995957 );
|
|
|
- // const pi = float( 3.141592653589793238462643383279502884197169 );
|
|
|
+ const e = float( 2.718281828459045 );
|
|
|
+ // const pi = float( 3.141592653589793 );
|
|
|
|
|
|
// wavelength of used primaries, according to preetham
|
|
|
// const lambda = vec3( 680E-9, 550E-9, 450E-9 );
|
|
|
@@ -211,13 +228,13 @@ class SkyMesh extends Mesh {
|
|
|
const colorNode = /*@__PURE__*/ Fn( () => {
|
|
|
|
|
|
// constants for atmospheric scattering
|
|
|
- const pi = float( 3.141592653589793238462643383279502884197169 );
|
|
|
+ const pi = float( 3.141592653589793 );
|
|
|
|
|
|
// optical length at zenith for molecules
|
|
|
const rayleighZenithLength = float( 8.4E3 );
|
|
|
const mieZenithLength = float( 1.25E3 );
|
|
|
// 66 arc seconds -> degrees, and the cosine of that
|
|
|
- const sunAngularDiameterCos = float( 0.999956676946448443553574619906976478926848692873900859324 );
|
|
|
+ const sunAngularDiameterCos = float( 0.9999566769464484 );
|
|
|
|
|
|
// 3.0 / ( 16.0 * pi )
|
|
|
const THREE_OVER_SIXTEENPI = float( 0.05968310365946075 );
|
|
|
@@ -262,8 +279,8 @@ class SkyMesh extends Mesh {
|
|
|
const L0 = vec3( 0.1 ).mul( Fex );
|
|
|
|
|
|
// composition + solar disc
|
|
|
- const sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos.add( 0.00002 ), cosTheta );
|
|
|
- L0.addAssign( vSunE.mul( 19000.0 ).mul( Fex ).mul( sundisk ) );
|
|
|
+ const sundisc = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos.add( 0.00002 ), cosTheta ).mul( this.showSunDisc );
|
|
|
+ L0.addAssign( vSunE.mul( 19000.0 ).mul( Fex ).mul( sundisc ) );
|
|
|
|
|
|
const texColor = add( Lin, L0 ).mul( 0.04 ).add( vec3( 0.0, 0.0003, 0.00075 ) ).toVar();
|
|
|
|