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
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -805,16 +805,6 @@ _extends DataTexture_

Helper texture uniform for encoding materials as texture data.

### .threeCompatibilityTransforms

```js
threeCompatibilityTransforms = false : Boolean
```

Three.js materials support only a single set of UV transforms in a certain fallback priority while the pathtracer supports a unique set of transforms per texture. Set this field to true in order to use the same uv transform handling as three.js materials.

See fallback order documentation [here](https://threejs.org/docs/#api/en/textures/Texture.offset).

### .setMatte

```js
Expand Down
43 changes: 2 additions & 41 deletions src/uniforms/MaterialsTexture.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export class MaterialsTexture extends DataTexture {
this.minFilter = NearestFilter;
this.magFilter = NearestFilter;
this.generateMipmaps = false;
this.threeCompatibilityTransforms = false;
this.features = new MaterialFeatures();

}
Expand Down Expand Up @@ -117,47 +116,9 @@ export class MaterialsTexture extends DataTexture {

}

function getUVTransformTexture( material ) {

// https://github.com/mrdoob/three.js/blob/f3a832e637c98a404c64dae8174625958455e038/src/renderers/webgl/WebGLMaterials.js#L204-L306
// https://threejs.org/docs/#api/en/textures/Texture.offset
// fallback order of textures to use as a common uv transform
return material.map ||
material.specularMap ||
material.displacementMap ||
material.normalMap ||
material.bumpMap ||
material.roughnessMap ||
material.metalnessMap ||
material.alphaMap ||
material.emissiveMap ||
material.clearcoatMap ||
material.clearcoatNormalMap ||
material.clearcoatRoughnessMap ||
material.iridescenceMap ||
material.iridescenceThicknessMap ||
material.specularIntensityMap ||
material.specularColorMap ||
material.transmissionMap ||
material.thicknessMap ||
material.sheenColorMap ||
material.sheenRoughnessMap ||
null;

}

function writeTextureMatrixToArray( material, textureKey, array, offset ) {

let texture;
if ( threeCompatibilityTransforms ) {

texture = getUVTransformTexture( material );

} else {

texture = material[ textureKey ] && material[ textureKey ].isTexture ? material[ textureKey ] : null;

}
const texture = material[ textureKey ] && material[ textureKey ].isTexture ? material[ textureKey ] : null;

// check if texture exists
if ( texture ) {
Expand Down Expand Up @@ -187,7 +148,7 @@ export class MaterialsTexture extends DataTexture {
let index = 0;
const pixelCount = materials.length * MATERIAL_PIXELS;
const dimension = Math.ceil( Math.sqrt( pixelCount ) ) || 1;
const { threeCompatibilityTransforms, image, features } = this;
const { image, features } = this;

// get the list of textures with unique sources
const uniqueTextures = reduceTexturesToUniqueSources( textures );
Expand Down