Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGLPrograms: UV attributes now depend on used channels, not geometry attributes. #27608

Merged
merged 1 commit into from
Jan 23, 2024
Merged
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: 11 additions & 7 deletions src/renderers/webgl/WebGLPrograms.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities

const _programLayers = new Layers();
const _customShaders = new WebGLShaderCache();
const _activeChannels = new Set();
const programs = [];

const IS_WEBGL2 = capabilities.isWebGL2;
Expand Down Expand Up @@ -38,6 +39,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities

function getChannel( value ) {

_activeChannels.add( value );

if ( value === 0 ) return 'uv';

return `uv${ value }`;
Expand Down Expand Up @@ -158,10 +161,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities

const HAS_EXTENSIONS = !! material.extensions;

const HAS_ATTRIBUTE_UV1 = !! geometry.attributes.uv1;
const HAS_ATTRIBUTE_UV2 = !! geometry.attributes.uv2;
const HAS_ATTRIBUTE_UV3 = !! geometry.attributes.uv3;

let toneMapping = NoToneMapping;

if ( material.toneMapped ) {
Expand Down Expand Up @@ -293,9 +292,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
vertexTangents: !! geometry.attributes.tangent && ( HAS_NORMALMAP || HAS_ANISOTROPY ),
vertexColors: material.vertexColors,
vertexAlphas: material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4,
vertexUv1s: HAS_ATTRIBUTE_UV1,
vertexUv2s: HAS_ATTRIBUTE_UV2,
vertexUv3s: HAS_ATTRIBUTE_UV3,

pointsUvs: object.isPoints === true && !! geometry.attributes.uv && ( HAS_MAP || HAS_ALPHAMAP ),

Expand Down Expand Up @@ -368,6 +364,14 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities

};

// the usage of getChannel() determines the active texture channels for this shader

parameters.vertexUv1s = _activeChannels.has( 1 );
parameters.vertexUv2s = _activeChannels.has( 2 );
parameters.vertexUv3s = _activeChannels.has( 3 );

_activeChannels.clear();

return parameters;

}
Expand Down