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
22 changes: 4 additions & 18 deletions examples/jsm/loaders/EXRLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3343,6 +3343,10 @@ class EXRLoader extends DataTextureLoader {
format: EXRDecoder.format,
colorSpace: EXRDecoder.colorSpace,
type: this.type,
minFilter: LinearFilter,
magFilter: LinearFilter,
generateMipmaps: false,
flipY: false,
};

}
Expand Down Expand Up @@ -3386,24 +3390,6 @@ class EXRLoader extends DataTextureLoader {

}

load( url, onLoad, onProgress, onError ) {

function onLoadCallback( texture, texData ) {

texture.colorSpace = texData.colorSpace;
texture.minFilter = LinearFilter;
texture.magFilter = LinearFilter;
texture.generateMipmaps = false;
texture.flipY = false;

if ( onLoad ) onLoad( texture, texData );

}

return super.load( url, onLoadCallback, onProgress, onError );

}

}

export { EXRLoader };
34 changes: 6 additions & 28 deletions examples/jsm/loaders/HDRLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,12 @@ class HDRLoader extends DataTextureLoader {
header: rgbe_header_info.string,
gamma: rgbe_header_info.gamma,
exposure: rgbe_header_info.exposure,
type: type
type: type,
colorSpace: LinearSRGBColorSpace,
minFilter: LinearFilter,
magFilter: LinearFilter,
generateMipmaps: false,
flipY: true
};

}
Expand All @@ -451,33 +456,6 @@ class HDRLoader extends DataTextureLoader {

}

load( url, onLoad, onProgress, onError ) {

function onLoadCallback( texture, texData ) {

switch ( texture.type ) {

case FloatType:
case HalfFloatType:

texture.colorSpace = LinearSRGBColorSpace;
texture.minFilter = LinearFilter;
texture.magFilter = LinearFilter;
texture.generateMipmaps = false;
texture.flipY = true;

break;

}

if ( onLoad ) onLoad( texture, texData );

}

return super.load( url, onLoadCallback, onProgress, onError );

}

}

export { HDRLoader };
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/lighting/ClusteredLightsNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ClusteredLightsNode extends LightsNode {

customCacheKey() {

return this._compute.getCacheKey() + super.customCacheKey();
return ( this._compute ? this._compute.getCacheKey() : 0 ) + super.customCacheKey();

}

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/lighting/DynamicLightsNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class DynamicLightsNode extends LightsNode {

}

this._lightNodes = lightNodes;
return lightNodes;

}

Expand Down
21 changes: 1 addition & 20 deletions examples/webgl_materials_matcap.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,27 +190,8 @@

function handleEXR( event ) {

const contents = event.target.result;

const loader = new EXRLoader();

loader.setDataType( THREE.HalfFloatType );

const texData = loader.parse( contents );

const texture = new THREE.DataTexture();

texture.image.width = texData.width;
texture.image.height = texData.height;
texture.image.data = texData.data;

texture.format = texData.format;
texture.type = texData.type;
texture.colorSpace = THREE.LinearSRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
texture.generateMipmaps = false;
texture.flipY = false;
const texture = loader.createDataTexture( event.target.result );

updateMatcap( texture );

Expand Down
21 changes: 1 addition & 20 deletions examples/webgpu_materials_matcap.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,8 @@

function handleEXR( event ) {

const contents = event.target.result;

const loader = new EXRLoader();

loader.setDataType( THREE.HalfFloatType );

const texData = loader.parse( contents );

const texture = new THREE.DataTexture();

texture.image.width = texData.width;
texture.image.height = texData.height;
texture.image.data = texData.data;

texture.format = texData.format;
texture.type = texData.type;
texture.colorSpace = THREE.LinearSRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
texture.generateMipmaps = false;
texture.flipY = false;
const texture = loader.createDataTexture( event.target.result );

updateMatcap( texture );

Expand Down
107 changes: 69 additions & 38 deletions src/loaders/DataTextureLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,77 +74,108 @@ class DataTextureLoader extends Loader {

}

if ( texData.image !== undefined ) {
scope._applyTexData( texture, texData );

texture.image = texData.image;
if ( onLoad ) onLoad( texture, texData );

} else if ( texData.data !== undefined ) {
}, onProgress, onError );

texture.image.width = texData.width;
texture.image.height = texData.height;
texture.image.data = texData.data;

}
return texture;

texture.wrapS = texData.wrapS !== undefined ? texData.wrapS : ClampToEdgeWrapping;
texture.wrapT = texData.wrapT !== undefined ? texData.wrapT : ClampToEdgeWrapping;
}

texture.magFilter = texData.magFilter !== undefined ? texData.magFilter : LinearFilter;
texture.minFilter = texData.minFilter !== undefined ? texData.minFilter : LinearFilter;
/**
* Parses the given buffer and returns a configured data texture. Use this method
* for parsing texture data that is already in memory (e.g. drag and drop or data
* loaded from a server) without going through {@link DataTextureLoader#load}.
*
* @param {ArrayBuffer} buffer - The raw texture data.
* @return {DataTexture} The data texture.
*/
createDataTexture( buffer ) {

texture.anisotropy = texData.anisotropy !== undefined ? texData.anisotropy : 1;
const texture = new DataTexture();

if ( texData.colorSpace !== undefined ) {
this._applyTexData( texture, this.parse( buffer ) );

texture.colorSpace = texData.colorSpace;
return texture;

}
}

if ( texData.flipY !== undefined ) {
/**
* Applies the given parsed texture data to the given data texture.
*
* @private
* @param {DataTexture} texture - The data texture.
* @param {DataTextureLoader~TexData} texData - The parsed texture data.
*/
_applyTexData( texture, texData ) {

texture.flipY = texData.flipY;
if ( texData.image !== undefined ) {

}
texture.image = texData.image;

if ( texData.format !== undefined ) {
} else if ( texData.data !== undefined ) {

texture.format = texData.format;
texture.image.width = texData.width;
texture.image.height = texData.height;
texture.image.data = texData.data;

}
}

if ( texData.type !== undefined ) {
texture.wrapS = texData.wrapS !== undefined ? texData.wrapS : ClampToEdgeWrapping;
texture.wrapT = texData.wrapT !== undefined ? texData.wrapT : ClampToEdgeWrapping;

texture.type = texData.type;
texture.magFilter = texData.magFilter !== undefined ? texData.magFilter : LinearFilter;
texture.minFilter = texData.minFilter !== undefined ? texData.minFilter : LinearFilter;

}
texture.anisotropy = texData.anisotropy !== undefined ? texData.anisotropy : 1;

if ( texData.mipmaps !== undefined ) {
if ( texData.colorSpace !== undefined ) {

texture.mipmaps = texData.mipmaps;
texture.minFilter = LinearMipmapLinearFilter; // presumably...
texture.colorSpace = texData.colorSpace;

}
}

if ( texData.mipmapCount === 1 ) {
if ( texData.flipY !== undefined ) {

texture.minFilter = LinearFilter;
texture.flipY = texData.flipY;

}
}

if ( texData.generateMipmaps !== undefined ) {
if ( texData.format !== undefined ) {

texture.generateMipmaps = texData.generateMipmaps;
texture.format = texData.format;

}
}

texture.needsUpdate = true;
if ( texData.type !== undefined ) {

if ( onLoad ) onLoad( texture, texData );
texture.type = texData.type;

}, onProgress, onError );
}

if ( texData.mipmaps !== undefined ) {

return texture;
texture.mipmaps = texData.mipmaps;
texture.minFilter = LinearMipmapLinearFilter; // presumably...

}

if ( texData.mipmapCount === 1 ) {

texture.minFilter = LinearFilter;

}

if ( texData.generateMipmaps !== undefined ) {

texture.generateMipmaps = texData.generateMipmaps;

}

texture.needsUpdate = true;

}

Expand Down
2 changes: 0 additions & 2 deletions src/materials/nodes/Line2NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,6 @@ class Line2NodeMaterial extends NodeMaterial {
*/
get lineColorNode() {

warnOnce( 'Line2NodeMaterial: "lineColorNode" has been deprecated. Use "colorNode" instead.' ); // @deprecated r185

return this.colorNode;

}
Expand Down
21 changes: 7 additions & 14 deletions src/materials/nodes/NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -985,9 +985,9 @@ class NodeMaterial extends Material {
* Setups the lights node based on the scene, environment and material.
*
* @param {NodeBuilder} builder - The current node builder.
* @return {LightsNode} The lights node.
* @return {LightingNode<Array>} The lights node.
*/
setupLights( builder ) {
setupMaterialLightings( builder ) {

const materialLightsNode = [];

Expand Down Expand Up @@ -1029,15 +1029,7 @@ class NodeMaterial extends Material {

}

let lightsN = this.lightsNode || builder.lightsNode;

if ( materialLightsNode.length > 0 ) {

lightsN = builder.renderer.lighting.createNode( [ ...lightsN.getLights(), ...materialLightsNode ] );

}

return lightsN;
return materialLightsNode;

}

Expand Down Expand Up @@ -1070,15 +1062,16 @@ class NodeMaterial extends Material {

const lights = this.lights === true || this.lightsNode !== null;

const lightsNode = lights ? this.setupLights( builder ) : null;
const materialLightings = this.lights === true ? this.setupMaterialLightings( builder ) : [];
const lightsNode = lights ? ( this.lightsNode || builder.lightsNode ) : null;

let outgoingLightNode = this.setupOutgoingLight( builder );

if ( lightsNode && lightsNode.getScope().hasLights ) {
if ( lightsNode && ( materialLightings.length > 0 || lightsNode.getScope().hasLights ) ) {

const lightingModel = this.setupLightingModel( builder ) || null;

outgoingLightNode = lightingContext( lightsNode, lightingModel, backdropNode, backdropAlphaNode );
outgoingLightNode = lightingContext( lightsNode, lightingModel, materialLightings, backdropNode, backdropAlphaNode );

} else if ( backdropNode !== null ) {

Expand Down
14 changes: 12 additions & 2 deletions src/nodes/core/VaryingNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,18 @@ class VaryingNode extends Node {
const type = this.getNodeType( builder );
const propertyName = builder.getPropertyName( varying, NodeShaderStage.VERTEX );

// force node run in vertex stage
builder.flowNodeFromShaderStage( NodeShaderStage.VERTEX, properties.node, type, propertyName );
if ( builder.shaderStage === NodeShaderStage.VERTEX ) {

const snippet = properties.node.build( builder, type );

builder.addLineFlowCode( `${ propertyName } = ${ snippet }`, this );

} else {

// force node run in vertex stage
builder.flowNodeFromShaderStage( NodeShaderStage.VERTEX, properties.node, type, propertyName );

}

properties[ propertyKey ] = propertyName;

Expand Down
Loading
Loading