Skip to content

Commit

Permalink
Merge branch 'mrdoob:dev' into add-more-exports
Browse files Browse the repository at this point in the history
  • Loading branch information
LeviPesin authored Apr 26, 2022
2 parents 1a01303 + 814b0b2 commit 6417825
Show file tree
Hide file tree
Showing 21 changed files with 874 additions and 451 deletions.
84 changes: 24 additions & 60 deletions build/three.cjs

Large diffs are not rendered by default.

84 changes: 24 additions & 60 deletions build/three.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

95 changes: 23 additions & 72 deletions build/three.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -12124,7 +12124,6 @@ class CubeCamera extends Object3D {

const currentRenderTarget = renderer.getRenderTarget();

const currentOutputEncoding = renderer.outputEncoding;
const currentToneMapping = renderer.toneMapping;
const currentXrEnabled = renderer.xr.enabled;

Expand Down Expand Up @@ -12157,7 +12156,6 @@ class CubeCamera extends Object3D {

renderer.setRenderTarget( currentRenderTarget );

renderer.outputEncoding = currentOutputEncoding;
renderer.toneMapping = currentToneMapping;
renderer.xr.enabled = currentXrEnabled;

Expand Down Expand Up @@ -13189,7 +13187,7 @@ var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n

var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";

var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif";
var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif";

var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif";

Expand Down Expand Up @@ -18630,7 +18628,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {

parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '',

'#define MAX_BONES ' + parameters.maxBones,
( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',
( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',

Expand Down Expand Up @@ -18675,7 +18672,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
parameters.flatShading ? '#define FLAT_SHADED' : '',

parameters.skinning ? '#define USE_SKINNING' : '',
parameters.useVertexTexture ? '#define BONE_TEXTURE' : '',

parameters.morphTargets ? '#define USE_MORPHTARGETS' : '',
parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',
Expand Down Expand Up @@ -19195,8 +19191,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities

const isWebGL2 = capabilities.isWebGL2;
const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
const floatVertexTextures = capabilities.floatVertexTextures;
const maxVertexUniforms = capabilities.maxVertexUniforms;
const vertexTextures = capabilities.vertexTextures;
let precision = capabilities.precision;

Expand All @@ -19218,42 +19212,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
SpriteMaterial: 'sprite'
};

function getMaxBones( object ) {

const skeleton = object.skeleton;
const bones = skeleton.bones;

if ( floatVertexTextures ) {

return 1024;

} else {

// default for when object is not specified
// ( for example when prebuilding shader to be used with multiple objects )
//
// - leave some extra space for other uniforms
// - limit here is ANGLE's 254 max uniform vectors
// (up to 54 should be safe)

const nVertexUniforms = maxVertexUniforms;
const nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 );

const maxBones = Math.min( nVertexMatrices, bones.length );

if ( maxBones < bones.length ) {

console.warn( 'THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + maxBones + '.' );
return 0;

}

return maxBones;

}

}

function getParameters( material, lights, shadows, scene, object ) {

const fog = scene.fog;
Expand All @@ -19268,8 +19226,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
// heuristics to create shader parameters according to lights in the scene
// (not to blow over maxLights budget)

const maxBones = object.isSkinnedMesh ? getMaxBones( object ) : 0;

if ( material.precision !== null ) {

precision = capabilities.getMaxPrecision( material.precision );
Expand Down Expand Up @@ -19405,9 +19361,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
sizeAttenuation: material.sizeAttenuation,
logarithmicDepthBuffer: logarithmicDepthBuffer,

skinning: object.isSkinnedMesh === true && maxBones > 0,
maxBones: maxBones,
useVertexTexture: floatVertexTextures,
skinning: object.isSkinnedMesh === true,

morphTargets: geometry.morphAttributes.position !== undefined,
morphNormals: geometry.morphAttributes.normal !== undefined,
Expand Down Expand Up @@ -19513,7 +19467,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
array.push( parameters.vertexUvs );
array.push( parameters.fogExp2 );
array.push( parameters.sizeAttenuation );
array.push( parameters.maxBones );
array.push( parameters.morphTargetsCount );
array.push( parameters.morphAttributeCount );
array.push( parameters.numDirLights );
Expand Down Expand Up @@ -19610,48 +19563,46 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
_programLayers.enable( 2 );
if ( parameters.skinning )
_programLayers.enable( 3 );
if ( parameters.useVertexTexture )
_programLayers.enable( 4 );
if ( parameters.morphTargets )
_programLayers.enable( 5 );
_programLayers.enable( 4 );
if ( parameters.morphNormals )
_programLayers.enable( 6 );
_programLayers.enable( 5 );
if ( parameters.morphColors )
_programLayers.enable( 7 );
_programLayers.enable( 6 );
if ( parameters.premultipliedAlpha )
_programLayers.enable( 8 );
_programLayers.enable( 7 );
if ( parameters.shadowMapEnabled )
_programLayers.enable( 9 );
_programLayers.enable( 8 );
if ( parameters.physicallyCorrectLights )
_programLayers.enable( 10 );
_programLayers.enable( 9 );
if ( parameters.doubleSided )
_programLayers.enable( 11 );
_programLayers.enable( 10 );
if ( parameters.flipSided )
_programLayers.enable( 12 );
_programLayers.enable( 11 );
if ( parameters.useDepthPacking )
_programLayers.enable( 13 );
_programLayers.enable( 12 );
if ( parameters.dithering )
_programLayers.enable( 14 );
_programLayers.enable( 13 );
if ( parameters.specularIntensityMap )
_programLayers.enable( 15 );
_programLayers.enable( 14 );
if ( parameters.specularColorMap )
_programLayers.enable( 16 );
_programLayers.enable( 15 );
if ( parameters.transmission )
_programLayers.enable( 17 );
_programLayers.enable( 16 );
if ( parameters.transmissionMap )
_programLayers.enable( 18 );
_programLayers.enable( 17 );
if ( parameters.thicknessMap )
_programLayers.enable( 19 );
_programLayers.enable( 18 );
if ( parameters.sheen )
_programLayers.enable( 20 );
_programLayers.enable( 19 );
if ( parameters.sheenColorMap )
_programLayers.enable( 21 );
_programLayers.enable( 20 );
if ( parameters.sheenRoughnessMap )
_programLayers.enable( 22 );
_programLayers.enable( 21 );
if ( parameters.decodeVideoTexture )
_programLayers.enable( 23 );
_programLayers.enable( 22 );
if ( parameters.opaque )
_programLayers.enable( 24 );
_programLayers.enable( 23 );

array.push( _programLayers.mask );

Expand Down Expand Up @@ -27752,7 +27703,7 @@ function WebGLRenderer( parameters = {} ) {

} else {

p_uniforms.setOptional( _gl, skeleton, 'boneMatrices' );
console.warn( 'THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.' );

}

Expand Down
4 changes: 3 additions & 1 deletion docs/api/en/objects/SkinnedMesh.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<h1>[name]</h1>

<p class="desc">
A mesh that has a [page:Skeleton] with [page:Bone bones] that can then be used to animate the vertices of the geometry.
A mesh that has a [page:Skeleton] with [page:Bone bones] that can then be used to animate the vertices of the geometry.<br /><br />

[name] can only be used with WebGL 2. With WebGL 1 *OES_texture_float* and vertex textures support is required.
</p>

<iframe id="scene" src="scenes/bones-browser.html"></iframe>
Expand Down
4 changes: 3 additions & 1 deletion docs/api/zh/objects/SkinnedMesh.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<h1>蒙皮网格([name])</h1>

<p class="desc">
具有[page:Skeleton](骨架)和[page:Bone bones](骨骼)的网格,可用于给几何体上的顶点添加动画。
具有[page:Skeleton](骨架)和[page:Bone bones](骨骼)的网格,可用于给几何体上的顶点添加动画。<br /><br />

[name] can only be used with WebGL 2. With WebGL 1 *OES_texture_float* and vertex textures support is required.
</p>

<iframe id="scene" src="scenes/bones-browser.html"></iframe>
Expand Down
24 changes: 20 additions & 4 deletions examples/jsm/nodes/gpgpu/ComputeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,32 @@ import { NodeUpdateType } from '../core/constants.js';

class ComputeNode extends Node {

constructor( dispatchCount, workgroupSize = [ 64 ] ) {
constructor( computeNode, count, workgroupSize = [ 64 ] ) {

super( 'void' );

this.updateType = NodeUpdateType.Object;
this.computeNode = computeNode;

this.dispatchCount = dispatchCount;
this.count = count;
this.workgroupSize = workgroupSize;
this.dispatchCount = 0;

this.updateType = NodeUpdateType.Object;

this.updateDispatchCount();

}

updateDispatchCount() {

const { count, workgroupSize } = this;

let size = workgroupSize[ 0 ];

for ( let i = 1; i < workgroupSize.length; i ++ )
size *= workgroupSize[ i ];

this.computeNode = null;
this.dispatchCount = Math.ceil( count / size );

}

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/nodes/materials/NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class NodeMaterial extends ShaderMaterial {

if ( this.positionNode !== null ) {

vertex = bypass( vertex, assign( vertex, this.positionNode ) );
vertex = bypass( vertex, assign( positionLocal, this.positionNode ) );

}

if ( object.isInstancedMesh === true && builder.isAvailable( 'instance' ) === true ) {
if ( object.instanceMatrix?.isInstancedBufferAttribute === true && builder.isAvailable( 'instance' ) === true ) {

vertex = bypass( vertex, instance( object ) );

Expand Down
8 changes: 4 additions & 4 deletions examples/jsm/renderers/webgpu/WebGPUAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ class WebGPUAttributes {
const size = array.byteLength + ( ( 4 - ( array.byteLength % 4 ) ) % 4 ); // ensure 4 byte alignment, see #20441

const buffer = this.device.createBuffer( {
size: size,
size,
usage: usage | GPUBufferUsage.COPY_DST,
mappedAtCreation: true,
mappedAtCreation: true
} );

new array.constructor( buffer.getMappedRange() ).set( array );
Expand All @@ -86,8 +86,8 @@ class WebGPUAttributes {

return {
version: attribute.version,
buffer: buffer,
usage: usage
buffer,
usage
};

}
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/renderers/webgpu/WebGPUBindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class WebGPUBindings {

binding.bufferGPU = this.device.createBuffer( {
size: byteLength,
usage: binding.usage,
usage: binding.usage
} );

}
Expand Down
8 changes: 4 additions & 4 deletions examples/jsm/renderers/webgpu/WebGPUTextureUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct VarysStruct {
@stage( vertex )
fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {
var Varys: VarysStruct;
var Varys : VarysStruct;
var pos = array< vec2<f32>, 4 >(
vec2<f32>( -1.0, 1.0 ),
Expand All @@ -62,7 +62,7 @@ fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {
`;

const mipmapFragmentSource = `
@group( 0 ) @binding( 0 )
@group( 0 ) @binding( 0 )
var imgSampler : sampler;
@group( 0 ) @binding( 1 )
Expand Down Expand Up @@ -100,12 +100,12 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
pipeline = this.device.createRenderPipeline( {
vertex: {
module: this.mipmapVertexShaderModule,
entryPoint: 'main',
entryPoint: 'main'
},
fragment: {
module: this.mipmapFragmentShaderModule,
entryPoint: 'main',
targets: [ { format } ],
targets: [ { format } ]
},
primitive: {
topology: GPUPrimitiveTopology.TriangleStrip,
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ ${shaderData.codes}
fn main( ${shaderData.attributes} ) {
// system
instanceIndex = id.x * 3u;
instanceIndex = id.x;
// vars
${shaderData.vars}
Expand Down
Loading

0 comments on commit 6417825

Please sign in to comment.