Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions build/three.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

const REVISION = '183';
const REVISION = '184dev';

/**
* Represents mouse buttons and interaction types in context of controls.
Expand Down Expand Up @@ -53175,6 +53175,15 @@ class AnimationAction {

const interpolant = tracks[ i ].createInterpolant( null );
interpolants[ i ] = interpolant;

// preserve interpolant settings (like tangent data from BezierInterpolant)

if ( interpolant.settings ) {

Object.assign( interpolantSettings, interpolant.settings );

}

interpolant.settings = interpolantSettings;

}
Expand Down Expand Up @@ -53981,6 +53990,7 @@ class AnimationAction {

} else {

this._loopCount = loopCount;
this.time = time;

}
Expand Down Expand Up @@ -54028,7 +54038,7 @@ class AnimationAction {

} else {

settings.endingEnd = WrapAroundEnding;
settings.endingEnd = WrapAroundEnding;

}

Expand Down Expand Up @@ -67083,7 +67093,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,

outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace ),
alphaToCoverage: !! material.alphaToCoverage,

map: HAS_MAP,
Expand Down Expand Up @@ -77528,7 +77538,7 @@ class WebGLRenderer {

const fog = scene.fog;
const environment = ( material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ) ? scene.environment : null;
const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace );
const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace );
const usePMREM = material.isMeshStandardMaterial || ( material.isMeshLambertMaterial && ! material.envMap ) || ( material.isMeshPhongMaterial && ! material.envMap );
const envMap = environments.get( material.envMap || environment, usePMREM );
const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
Expand Down
38 changes: 35 additions & 3 deletions build/three.core.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/three.core.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/three.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -7620,7 +7620,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,

outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace ),
alphaToCoverage: !! material.alphaToCoverage,

map: HAS_MAP,
Expand Down Expand Up @@ -18065,7 +18065,7 @@ class WebGLRenderer {

const fog = scene.fog;
const environment = ( material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ) ? scene.environment : null;
const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace );
const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace );
const usePMREM = material.isMeshStandardMaterial || ( material.isMeshLambertMaterial && ! material.envMap ) || ( material.isMeshPhongMaterial && ! material.envMap );
const envMap = environments.get( material.envMap || environment, usePMREM );
const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
Expand Down
2 changes: 1 addition & 1 deletion build/three.module.min.js

Large diffs are not rendered by default.

468 changes: 418 additions & 50 deletions build/three.webgpu.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/three.webgpu.min.js

Large diffs are not rendered by default.

468 changes: 418 additions & 50 deletions build/three.webgpu.nodes.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/three.webgpu.nodes.min.js

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions examples/jsm/objects/Sky.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ import {
* sky.scale.setScalar( 10000 );
* 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.material.uniforms.showSunDisc.value = false;
* // ...
* // re-enable before scene sky box rendering
* sky.material.uniforms.showSunDisc.value = true;
* ```
*
* @augments Mesh
* @three_import import { Sky } from 'three/addons/objects/Sky.js';
Expand Down Expand Up @@ -78,6 +88,7 @@ Sky.SkyShader = {
'cloudCoverage': { value: 0.4 },
'cloudDensity': { value: 0.4 },
'cloudElevation': { value: 0.5 },
'showSunDisc': { value: 1 },
'time': { value: 0.0 }
},

Expand Down Expand Up @@ -167,6 +178,7 @@ Sky.SkyShader = {
uniform float cloudCoverage;
uniform float cloudDensity;
uniform float cloudElevation;
uniform float showSunDisc;
uniform float time;

// Cloud noise functions
Expand Down Expand Up @@ -256,8 +268,8 @@ Sky.SkyShader = {
vec3 L0 = vec3( 0.1 ) * Fex;

// composition + solar disc
float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );
L0 += ( vSunE * 19000.0 * Fex ) * sundisk;
float sundisc = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta ) * showSunDisc;
L0 += ( vSunE * 19000.0 * Fex ) * sundisc;

vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );

Expand Down
29 changes: 23 additions & 6 deletions examples/jsm/objects/SkyMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
*/
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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();

Expand Down
5 changes: 4 additions & 1 deletion examples/webgl_shaders_sky.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
exposure: renderer.toneMappingExposure,
cloudCoverage: 0.4,
cloudDensity: 0.4,
cloudElevation: 0.5
cloudElevation: 0.5,
showSunDisc: true
};

function guiChanged() {
Expand All @@ -68,6 +69,7 @@
uniforms[ 'cloudCoverage' ].value = effectController.cloudCoverage;
uniforms[ 'cloudDensity' ].value = effectController.cloudDensity;
uniforms[ 'cloudElevation' ].value = effectController.cloudElevation;
uniforms[ 'showSunDisc' ].value = effectController.showSunDisc;

const phi = THREE.MathUtils.degToRad( 90 - effectController.elevation );
const theta = THREE.MathUtils.degToRad( effectController.azimuth );
Expand All @@ -89,6 +91,7 @@
gui.add( effectController, 'elevation', 0, 90, 0.1 ).onChange( guiChanged );
gui.add( effectController, 'azimuth', - 180, 180, 0.1 ).onChange( guiChanged );
gui.add( effectController, 'exposure', 0, 1, 0.0001 ).onChange( guiChanged );
gui.add( effectController, 'showSunDisc' ).onChange( guiChanged );

const folderClouds = gui.addFolder( 'Clouds' );
folderClouds.add( effectController, 'cloudCoverage', 0, 1, 0.01 ).name( 'coverage' ).onChange( guiChanged );
Expand Down
5 changes: 4 additions & 1 deletion examples/webgpu_sky.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
exposure: renderer.toneMappingExposure,
cloudCoverage: 0.4,
cloudDensity: 0.4,
cloudElevation: 0.5
cloudElevation: 0.5,
showSunDisc: true
};

function guiChanged() {
Expand All @@ -79,6 +80,7 @@
sky.cloudCoverage.value = effectController.cloudCoverage;
sky.cloudDensity.value = effectController.cloudDensity;
sky.cloudElevation.value = effectController.cloudElevation;
sky.showSunDisc.value = effectController.showSunDisc;

const phi = THREE.MathUtils.degToRad( 90 - effectController.elevation );
const theta = THREE.MathUtils.degToRad( effectController.azimuth );
Expand All @@ -100,6 +102,7 @@
gui.add( effectController, 'elevation', 0, 90, 0.1 ).onChange( guiChanged );
gui.add( effectController, 'azimuth', - 180, 180, 0.1 ).onChange( guiChanged );
gui.add( effectController, 'exposure', 0, 1, 0.0001 ).onChange( guiChanged );
gui.add( effectController, 'showSunDisc' ).onChange( guiChanged );

const folderClouds = gui.addFolder( 'Clouds' );
folderClouds.add( effectController, 'cloudCoverage', 0, 1, 0.01 ).name( 'coverage' ).onChange( guiChanged );
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const REVISION = '183';
export const REVISION = '184dev';

/**
* Represents mouse buttons and interaction types in context of controls.
Expand Down
20 changes: 16 additions & 4 deletions src/nodes/accessors/TextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { nodeProxy, vec3, nodeObject, int, Fn } from '../tsl/TSLBase.js';
import { step } from '../math/MathNode.js';
import { NodeUpdateType } from '../core/constants.js';

import { Compatibility, IntType, LessCompare, NearestFilter, UnsignedIntType } from '../../constants.js';
import { Compatibility, GreaterCompare, GreaterEqualCompare, IntType, LessCompare, LessEqualCompare, NearestFilter, UnsignedIntType } from '../../constants.js';

import { Texture } from '../../textures/Texture.js';
import { warn, warnOnce } from '../../utils.js';
Expand Down Expand Up @@ -405,15 +405,17 @@ class TextureNode extends UniformNode {

} else {

if ( this.value.compareFunction === null || this.value.compareFunction === LessCompare ) {
const compareFunction = texture.compareFunction;

if ( compareFunction === null || compareFunction === LessCompare || compareFunction === LessEqualCompare || compareFunction === GreaterCompare || compareFunction === GreaterEqualCompare ) {

compareStepNode = this.compareNode;

} else {

compareNode = this.compareNode;

warnOnce( 'TSL: Only "LessCompare" is supported for depth texture comparison fallback.' );
warnOnce( 'TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.' );

}

Expand Down Expand Up @@ -559,7 +561,17 @@ class TextureNode extends UniformNode {

if ( compareStepSnippet !== null ) {

snippet = step( expression( compareStepSnippet, 'float' ), expression( snippet, nodeType ) ).build( builder, nodeType );
const compareFunction = texture.compareFunction;

if ( compareFunction === GreaterCompare || compareFunction === GreaterEqualCompare ) {

snippet = step( expression( snippet, nodeType ), expression( compareStepSnippet, 'float' ) ).build( builder, nodeType );

} else {

snippet = step( expression( compareStepSnippet, 'float' ), expression( snippet, nodeType ) ).build( builder, nodeType );

}

}

Expand Down
5 changes: 3 additions & 2 deletions src/nodes/lighting/ShadowNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
import QuadMesh from '../../renderers/common/QuadMesh.js';
import { Loop } from '../utils/LoopNode.js';
import { screenCoordinate } from '../display/ScreenNode.js';
import { GreaterEqualCompare, HalfFloatType, LessEqualCompare, LinearFilter, NearestFilter, PCFShadowMap, PCFSoftShadowMap, RGFormat, VSMShadowMap } from '../../constants.js';
import { Compatibility, GreaterEqualCompare, HalfFloatType, LessEqualCompare, LinearFilter, NearestFilter, PCFShadowMap, PCFSoftShadowMap, RGFormat, VSMShadowMap } from '../../constants.js';
import { renderGroup } from '../core/UniformGroupNode.js';
import { viewZToLogarithmicDepth } from '../display/ViewportDepthNode.js';
import { lightShadowMatrix } from '../accessors/Lights.js';
Expand Down Expand Up @@ -420,8 +420,9 @@ class ShadowNode extends ShadowBaseNode {
const { depthTexture, shadowMap } = this.setupRenderTarget( shadow, builder );

const shadowMapType = renderer.shadowMap.type;
const hasTextureCompare = renderer.hasCompatibility( Compatibility.TEXTURE_COMPARE );

if ( shadowMapType === PCFShadowMap || shadowMapType === PCFSoftShadowMap ) {
if ( ( shadowMapType === PCFShadowMap || shadowMapType === PCFSoftShadowMap ) && hasTextureCompare ) {

depthTexture.minFilter = LinearFilter;
depthTexture.magFilter = LinearFilter;
Expand Down
Loading