Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
bb33b29
WebGLRenderer: Refactor uv shaderchunks.
mrdoob Mar 27, 2023
bb120b7
GLTFLoader: Removed uv2 workaround.
mrdoob Mar 28, 2023
c04f862
MeshGouraudMaterial: Clean up.
mrdoob Mar 28, 2023
433d660
Texture: Renamed uvChannel to uvSet.
mrdoob Mar 28, 2023
08ebb83
ShaderChunks: Refactored back vUv code.
mrdoob Mar 28, 2023
ff60a9c
WebGLProgram: Removed uvsVertexOnly flag.
mrdoob Mar 28, 2023
17c4090
WebGLRenderer: Added uvSet support for map and emmisiveMap.
mrdoob Mar 28, 2023
2ee8adb
WebGLRenderer: Added uvSet support for lightMap and aoMap.
mrdoob Mar 28, 2023
a53e9f9
Texture: Added uvSet to copy() and toJSON().
mrdoob Mar 28, 2023
bdfe368
ObjectLoader: Parse Texture uvSet.
mrdoob Mar 28, 2023
e47d5be
Examples: Fixed webgl_materials_lightmap.
mrdoob Mar 28, 2023
df778f1
Examples: Updated webgl_lines_dashed screenshot...
mrdoob Mar 28, 2023
d83626b
WebGLRenderer: Added support for multiple transforms.
mrdoob Mar 28, 2023
d1d77d1
UniformLib: Restored uvTransform.
mrdoob Mar 28, 2023
9b7c369
WebGLRenderer: Fixed Sprites uniforms.
mrdoob Mar 28, 2023
f3aae72
Merge branch 'dev' into multi_uvs
mrdoob Mar 28, 2023
8a7816f
WebGLRenderer: Added lightMap transform code.
mrdoob Mar 28, 2023
5fef053
Examples: Updated webgl_loader_gltf_sheen screenshot.
mrdoob Mar 28, 2023
ee710e6
WebGLMaterials: Added refreshTransformUniform function.
mrdoob Mar 28, 2023
dbf8cf5
WebGLProgram: Clean up.
mrdoob Mar 29, 2023
22b4fcd
OCD clean up.
mrdoob Mar 29, 2023
c48595f
WebGLMaterials: Clean up.
mrdoob Mar 29, 2023
8e9129c
WebGLPrograms: Clean up.
mrdoob Mar 29, 2023
2da76c4
Clean up.
mrdoob Mar 29, 2023
b399fa3
WebGLMaterials: Clean up.
mrdoob Mar 29, 2023
f955984
ShaderLib: Clean up.
mrdoob Mar 29, 2023
0c4a439
WebGLRenderer: Added clearcoat transforms code.
mrdoob Mar 29, 2023
8f49aa7
Merge branch 'dev' into multi_uvs
mrdoob Mar 29, 2023
f17f114
Revert "Examples: Updated webgl_lines_dashed screenshot..."
mrdoob Mar 29, 2023
929770b
WebGLRenderer: Added bumpMap transforms code.
mrdoob Mar 29, 2023
e4abb9e
More OCD clean up.
mrdoob Mar 29, 2023
9143ca4
Clean up.
mrdoob Mar 29, 2023
9e536c6
WebGLRenderer: Added alphaMap transform code.
mrdoob Mar 29, 2023
64bcc3d
Examples: Fixed webgl_materials_physical_clearcoat transform.
mrdoob Mar 29, 2023
fa4d52c
Examples: Fixed webgl_lines_dashed example.
mrdoob Mar 29, 2023
4c8c82d
ShaderChunk: Rename uvs_* to uv_* back.
mrdoob Mar 29, 2023
4e7c43c
Manual: Replaced vUv2 references.
mrdoob Mar 29, 2023
e622e8f
Examples: Updated ProgressiveLightMap code.
mrdoob Mar 29, 2023
60bf297
ShaderChunk: Removed vUv2.
mrdoob Mar 29, 2023
ab055ff
WebGLRenderer: Fixed normalMap and clearcoarNormalMap transforms.
mrdoob Mar 29, 2023
2870e78
Examples: Updated webgl_nodes_loader_gltf_sheen screenshot.
mrdoob Mar 29, 2023
e4a8cf7
WebGLRenderer: Added displacementMap transform code.
mrdoob Mar 29, 2023
68f5990
WebGLProgram: Clean up.
mrdoob Mar 29, 2023
b8f6bc7
WebGLProgram/s: Yet more clean up.
mrdoob Mar 29, 2023
e1e522b
WebGLProgram/s and ShaderChunk: More clean up.
mrdoob Mar 29, 2023
e57ae61
WebGLProgram/s: More clean up.
mrdoob Mar 29, 2023
fd4ad6c
WebGLProgram: Check that there's a UV2 before trying to use it.
mrdoob Mar 29, 2023
22242e7
WebGLPrograms: More clean up.
mrdoob Mar 29, 2023
e7d3f9e
WebGLProgram: Fixed normalmap crash.
mrdoob Mar 29, 2023
5c67747
WebGLProgram/s: More clean up.
mrdoob Mar 29, 2023
82d54ab
WebGLPrograms: Clean up.
mrdoob Mar 29, 2023
0af4ec8
WebGLProgram: Fixed depthPacking check.
mrdoob Mar 29, 2023
f0d3c49
WebGLRenderer: Added specular*Map transform code.
mrdoob Mar 29, 2023
76a9ff8
WebGLPrograms: Clean up.
mrdoob Mar 29, 2023
6b49ab8
WebGLPrograms: Clean up.
mrdoob Mar 29, 2023
fc6dfc3
WebGLProgram: Added specular*Map to cache key.
mrdoob Mar 29, 2023
cadd36f
WebGLRenderer: Added sheen*Map transform code.
mrdoob Mar 29, 2023
10a79bf
WebGLRenderer: Added iridescence*Map transforms code.
mrdoob Mar 29, 2023
31f27e2
WebGLRenderer: Added transmissionMap and thicknessMap transform code.
mrdoob Mar 29, 2023
d5ef9fc
WebGLMaterials: Use mapTransform in refreshUniformsLine.
mrdoob Mar 29, 2023
7e278a8
ShaderChunks: Removed vUv and uvTransform.
mrdoob Mar 29, 2023
f9b8c79
Examples: Updated advanced examples with USE_MAP and MAP_UV.
mrdoob Mar 29, 2023
89047d3
WebGLProgram/s: Clean up.
mrdoob Mar 29, 2023
1b67067
Docs: Added placeholder.
mrdoob Mar 29, 2023
ef9cee5
GLTFLoader: Clone texture before modifying .uvSet
donmccurdy Mar 29, 2023
ea7c726
Revert "ShaderChunks: Removed vUv and uvTransform."
mrdoob Mar 30, 2023
508425a
Revert "Examples: Updated advanced examples with USE_MAP and MAP_UV."
mrdoob Mar 30, 2023
4a3fdc7
Examples: Fixed PackedPhongMaterial.
mrdoob Mar 30, 2023
2f54dc9
ShaderChunks: Leaving vUv for backwards compatibility.
mrdoob Mar 30, 2023
8c90da1
Texture: Renamed uvSet to channel.
mrdoob Mar 30, 2023
8ddb7a5
UniformsLib: Clean up.
mrdoob Mar 30, 2023
7f433c4
Docs: Updated offset and repeat details.
mrdoob Mar 30, 2023
e4feace
Docs: Removed uv transforms call out from GLTFLoader.
mrdoob Mar 30, 2023
4d67bb1
Docs: Added basic `channel` description.
mrdoob Mar 30, 2023
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
33 changes: 6 additions & 27 deletions docs/api/en/textures/Texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ <h3>[property:number mapping]</h3>
See the [page:Textures texture constants] page for other mapping types.
</p>

<h3>[property:Integer channel]</h3>
<p>
Lets you select the uv attribute to map the texture to. `0` for `uv` and `1` for `uv2`.
</p>

<h3>[property:number wrapS]</h3>
<p>
This defines how the texture is wrapped horizontally and corresponds to *U* in UV mapping.<br />
Expand Down Expand Up @@ -151,39 +156,13 @@ <h3>[property:Vector2 offset]</h3>
How much a single repetition of the texture is offset from the beginning, in each direction U and V.
Typical range is `0.0` to `1.0`.
</p>
<p>
The below texture types share the `first` uv channel in the engine. The offset (and repeat) setting is evaluated according to
the following priorities and then shared by those textures:
<ol>
<li>color map</li>
<li>specular map</li>
<li>displacement map</li>
<li>normal map</li>
<li>bump map</li>
<li>roughness map</li>
<li>metalness map</li>
<li>alpha map</li>
<li>emissive map</li>
<li>clearcoat map</li>
<li>clearcoat normal map</li>
<li>clearcoat roughnessMap map</li>
</ol>
</p>
<p>
The below texture types share the `second` uv channel in the engine. The offset (and repeat) setting is evaluated according to
the following priorities and then shared by those textures:
<ol>
<li>ao map</li>
<li>light map</li>
</ol>
</p>

<h3>[property:Vector2 repeat]</h3>
<p>
How many times the texture is repeated across the surface, in each direction U and V. If repeat is set
greater than 1 in either direction, the corresponding Wrap parameter should also be set to
[page:Textures THREE.RepeatWrapping] or [page:Textures THREE.MirroredRepeatWrapping] to achieve the desired
tiling effect. Setting different repeat values for textures is restricted in the same way like [page:.offset].
tiling effect.
</p>

<h3>[property:number rotation]</h3>
Expand Down
32 changes: 5 additions & 27 deletions docs/api/it/textures/Texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ <h3>[property:number mapping]</h3>
Vedi la pagina [page:Textures texture constants] per altri tipi di mapping.
</p>

<h3>[property:Integer channel]</h3>
<p>
Lets you select the uv attribute to map the texture to. `0` for `uv` and `1` for `uv2`.
</p>

<h3>[property:number wrapS]</h3>
<p>
Questo definisce come la texture è wrappata orizzontalmente e corrisponde a *U* nel mapping UV.<br />
Expand Down Expand Up @@ -152,40 +157,13 @@ <h3>[property:Vector2 offset]</h3>
Di quanto una singola ripetizione della texture è sfalsata dall'inizio, in ciascuna direzione U e V.
L'intervallo tipico è compreso tra `0.0` e `1.0`.
</p>
<p>
I tipi di texture seguenti condividono il `primo` canale uv nel motore. L'impostazione dell'offset (e della ripetizione) viene valutata
in base alle seguenti priorità e quindi condivisa da tali texture:
<ol>
<li>color map</li>
<li>specular map</li>
<li>displacement map</li>
<li>normal map</li>
<li>bump map</li>
<li>roughness map</li>
<li>metalness map</li>
<li>alpha map</li>
<li>emissive map</li>
<li>clearcoat map</li>
<li>clearcoat normal map</li>
<li>clearcoat roughnessMap map</li>
</ol>
</p>
<p>
I tipi di texture seguenti condividono il `secondo` canale uv nel motore. L'impostazione dell'offset (e della ripetizione) viene valutata
in base alle seguenti priorità e quindi condivisa da tali texture:
<ol>
<li>ao map</li>
<li>light map</li>
</ol>
</p>

<h3>[property:Vector2 repeat]</h3>
<p>
Quante volte la texture è ripetuta sulla superficie, in ogni direzione U e V. Se la proprietà ripeat è
impostata su un valore maggiore di 1 in entrambe le direzioni, anche il parametro Wrap corrispondente
deve essere impostato su [page:Textures THREE.RepeatWrapping] o [page:Textures THREE.MirroredRepeatWrapping] per ottenere l'effetto
di piastrellatura desiderato.
L'impostazione di diversi valori di ripetizione per le texture è limitata allo stesso modo di [page:.offset].
</p>

<h3>[property:number rotation]</h3>
Expand Down
33 changes: 6 additions & 27 deletions docs/api/zh/textures/Texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ <h3>[property:number mapping]</h3>
请参阅[page:Textures texture constants](映射模式常量)来了解其他映射类型。
</p>

<h3>[property:Integer channel]</h3>
<p>
Lets you select the uv attribute to map the texture to. `0` for `uv` and `1` for `uv2`.
</p>

<h3>[property:number wrapS]</h3>
<p>
这个值定义了纹理贴图在水平方向上将如何包裹,在UV映射中对应于*U*。<br />
Expand Down Expand Up @@ -141,38 +146,12 @@ <h3>[property:Vector2 offset]</h3>
贴图单次重复中的起始偏移量,分别表示U和V。
一般范围是由`0.0`到`1.0`。
</p>
<p>
在此引擎中下列纹理共享`第一套`uv通道。
偏移量(以及重复次数)的设置项按照下列纹理进行优先级排列并共享:
<ol>
<li>color map</li>
<li>specular map</li>
<li>displacement map</li>
<li>normal map</li>
<li>bump map</li>
<li>roughness map</li>
<li>metalness map</li>
<li>alpha map</li>
<li>emissive map</li>
<li>clearcoat map</li>
<li>clearcoat normal map</li>
<li>clearcoat roughnessMap map</li>
</ol>
</p>
<p>
在此引擎中下列纹理类型共享`第二套`uv通道。
偏移量(以及重复次数)的设置项按照下列纹理进行优先级排列并共享:
<ol>
<li>ao map</li>
<li>light map</li>
</ol>
</p>

<h3>[property:Vector2 repeat]</h3>
<p>
决定纹理在表面的重复次数,两个方向分别表示U和V,如果重复次数在任何方向上设置了超过1的数值,
对应的Wrap需要设置为[page:Textures THREE.RepeatWrapping]或者[page:Textures THREE.MirroredRepeatWrapping]来
达到想要的平铺效果。此项设置有和[page:.offset]一样的限制。
达到想要的平铺效果。
</p>

<h3>[property:number rotation]</h3>
Expand Down
14 changes: 3 additions & 11 deletions docs/examples/en/loaders/GLTFLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h2>Extensions</h2>
<li>KHR_mesh_quantization</li>
<li>KHR_lights_punctual<sup>1</sup></li>
<li>KHR_texture_basisu</li>
<li>KHR_texture_transform<sup>2</sup></li>
<li>KHR_texture_transform</li>
<li>EXT_texture_webp</li>
<li>EXT_meshopt_compression</li>
<li>EXT_mesh_gpu_instancing</li>
Expand All @@ -66,24 +66,16 @@ <h2>Extensions</h2>
</p>

<ul>
<li>[link:https://github.com/takahirox/three-gltf-extensions KHR_materials_variants]<sup>3</sup></li>
<li>[link:https://github.com/takahirox/three-gltf-extensions KHR_materials_variants]<sup>2</sup></li>
<li>[link:https://github.com/takahirox/three-gltf-extensions MSFT_texture_dds]</li>
</ul>

<p><i>
<sup>1</sup>Requires [link:https://threejs.org/docs/#api/en/renderers/WebGLRenderer.physicallyCorrectLights physicallyCorrectLights] to be enabled.
</i></p>
<p><i>
<sup>2</sup>UV transforms are supported, with several key limitations. Transforms applied to
a texture using the first UV slot (all textures except aoMap and lightMap) must share the same
transform, or no transform at all. The aoMap and lightMap textures cannot be transformed. No
more than one transform may be used per material. See
#[link:https://github.com/mrdoob/three.js/pull/13831 13831] and
#[link:https://github.com/mrdoob/three.js/issues/12788 12788].
</i></p>

<p><i>
<sup>3</sup>You can also manually process the extension after loading in your application. See [link:https://threejs.org/examples/#webgl_loader_gltf_variants Three.js glTF materials variants example].
<sup>2</sup>You can also manually process the extension after loading in your application. See [link:https://threejs.org/examples/#webgl_loader_gltf_variants Three.js glTF materials variants example].
</i></p>

<h2>Code Example</h2>
Expand Down
32 changes: 13 additions & 19 deletions examples/jsm/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1812,13 +1812,10 @@ class GLTFTextureTransformExtension {

extendTexture( texture, transform ) {

if ( transform.texCoord !== undefined ) {

console.warn( 'THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.' );

}

if ( transform.offset === undefined && transform.rotation === undefined && transform.scale === undefined ) {
if ( ( transform.texCoord === undefined || transform.texCoord === texture.channel )
&& transform.offset === undefined
&& transform.rotation === undefined
&& transform.scale === undefined ) {

// See https://github.com/mrdoob/three.js/issues/21819.
return texture;
Expand All @@ -1827,6 +1824,12 @@ class GLTFTextureTransformExtension {

texture = texture.clone();

if ( transform.texCoord !== undefined ) {

texture.channel = transform.texCoord;

}

if ( transform.offset !== undefined ) {

texture.offset.fromArray( transform.offset );
Expand Down Expand Up @@ -3122,11 +3125,10 @@ class GLTFParser {

if ( ! texture ) return null;

// Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured
// However, we will copy UV set 0 to UV set 1 on demand for aoMap
if ( mapDef.texCoord !== undefined && mapDef.texCoord != 0 && ! ( mapName === 'aoMap' && mapDef.texCoord == 1 ) ) {
if ( mapDef.texCoord !== undefined && mapDef.texCoord > 0 ) {

console.warn( 'THREE.GLTFLoader: Custom UV set ' + mapDef.texCoord + ' for texture ' + mapName + ' not yet supported.' );
texture = texture.clone();
texture.channel = mapDef.texCoord;

}

Expand Down Expand Up @@ -3252,14 +3254,6 @@ class GLTFParser {

}

// workarounds for mesh and geometry

if ( material.aoMap && geometry.attributes.uv2 === undefined && geometry.attributes.uv !== undefined ) {

geometry.setAttribute( 'uv2', geometry.attributes.uv );

}

mesh.material = material;

}
Expand Down
3 changes: 0 additions & 3 deletions examples/jsm/materials/MeshGouraudMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const GouraudShader = {

#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <bsdfs>
#include <lights_pars_begin>
Expand All @@ -52,7 +51,6 @@ const GouraudShader = {
void main() {

#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#include <morphcolor_vertex>

Expand Down Expand Up @@ -221,7 +219,6 @@ const GouraudShader = {
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
Expand Down
8 changes: 5 additions & 3 deletions examples/jsm/misc/ProgressiveLightMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ProgressiveLightMap {
const format = /(Android|iPad|iPhone|iPod)/g.test( navigator.userAgent ) ? THREE.HalfFloatType : THREE.FloatType;
this.progressiveLightMap1 = new THREE.WebGLRenderTarget( this.res, this.res, { type: format } );
this.progressiveLightMap2 = new THREE.WebGLRenderTarget( this.res, this.res, { type: format } );
this.progressiveLightMap2.texture.channel = 1;

// Inject some spicy new logic into a standard phong material
this.uvMat = new THREE.MeshPhongMaterial();
Expand All @@ -45,17 +46,18 @@ class ProgressiveLightMap {
// Vertex Shader: Set Vertex Positions to the Unwrapped UV Positions
shader.vertexShader =
'#define USE_LIGHTMAP\n' +
'#define LIGHTMAP_UV uv2\n' +
shader.vertexShader.slice( 0, - 1 ) +
' gl_Position = vec4((uv2 - 0.5) * 2.0, 1.0, 1.0); }';
' gl_Position = vec4((LIGHTMAP_UV - 0.5) * 2.0, 1.0, 1.0); }';

// Fragment Shader: Set Pixels to average in the Previous frame's Shadows
const bodyStart = shader.fragmentShader.indexOf( 'void main() {' );
shader.fragmentShader =
'varying vec2 vUv2;\n' +
'#define USE_LIGHTMAP\n' +
shader.fragmentShader.slice( 0, bodyStart ) +
' uniform sampler2D previousShadowMap;\n uniform float averagingWindow;\n' +
shader.fragmentShader.slice( bodyStart - 1, - 1 ) +
`\nvec3 texelOld = texture2D(previousShadowMap, vUv2).rgb;
`\nvec3 texelOld = texture2D(previousShadowMap, vLightMapUv).rgb;
gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/averagingWindow);
}`;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/shaders/VelocityShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const VelocityShader = {
vertexShader: /* glsl */`
#define NORMAL

#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )

varying vec3 vViewPosition;

Expand Down
6 changes: 2 additions & 4 deletions examples/jsm/utils/PackedPhongMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class PackedPhongMaterial extends MeshPhongMaterial {

ShaderChunk.common,
ShaderChunk.uv_pars_vertex,
ShaderChunk.uv2_pars_vertex,
ShaderChunk.displacementmap_pars_vertex,
ShaderChunk.envmap_pars_vertex,
ShaderChunk.color_pars_vertex,
Expand Down Expand Up @@ -116,13 +115,12 @@ class PackedPhongMaterial extends MeshPhongMaterial {

ShaderChunk.uv_vertex,

`#ifdef USE_UV
`#ifdef USE_MAP
#ifdef USE_PACKED_UV
vUv = decodeUV(vUv);
vMapUv = decodeUV(vMapUv);
#endif
#endif`,

ShaderChunk.uv2_vertex,
ShaderChunk.color_vertex,
ShaderChunk.morphcolor_vertex,

Expand Down
Loading