super-three 0.157.1 → 0.158.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/build/three.cjs +1013 -790
- package/build/three.js +1013 -790
- package/build/three.min.js +1 -1
- package/build/three.module.js +1008 -791
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +290 -0
- package/examples/jsm/controls/FlyControls.js +26 -0
- package/examples/jsm/controls/OrbitControls.js +12 -1
- package/examples/jsm/controls/TransformControls.js +27 -11
- package/examples/jsm/csm/CSMShader.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +72 -2
- package/examples/jsm/geometries/InstancedPointsGeometry.js +174 -0
- package/examples/jsm/geometries/SDFGeometryGenerator.js +144 -0
- package/examples/jsm/libs/lottie_canvas.module.js +6 -1
- package/examples/jsm/libs/opentype.module.js +13 -75
- package/examples/jsm/libs/surfaceNet.js +201 -0
- package/examples/jsm/loaders/GLTFLoader.js +12 -3
- package/examples/jsm/loaders/LUTImageLoader.js +162 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +89 -93
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/math/Capsule.js +0 -55
- package/examples/jsm/math/Octree.js +70 -3
- package/examples/jsm/modifiers/SimplifyModifier.js +103 -11
- package/examples/jsm/modifiers/TessellateModifier.js +3 -3
- package/examples/jsm/nodes/Nodes.js +6 -6
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +3 -3
- package/examples/jsm/nodes/accessors/InstanceNode.js +3 -3
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +68 -31
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -2
- package/examples/jsm/nodes/accessors/MorphNode.js +5 -5
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +13 -3
- package/examples/jsm/nodes/accessors/TextureNode.js +3 -3
- package/examples/jsm/nodes/code/FunctionNode.js +1 -1
- package/examples/jsm/nodes/core/AssignNode.js +72 -0
- package/examples/jsm/nodes/core/LightingModel.js +3 -1
- package/examples/jsm/nodes/core/Node.js +7 -12
- package/examples/jsm/nodes/core/NodeBuilder.js +126 -16
- package/examples/jsm/nodes/core/NodeUtils.js +4 -2
- package/examples/jsm/nodes/core/OutputStructNode.js +1 -1
- package/examples/jsm/nodes/core/ParameterNode.js +33 -0
- package/examples/jsm/nodes/core/PropertyNode.js +4 -10
- package/examples/jsm/nodes/core/StackNode.js +7 -17
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/VarNode.js +6 -35
- package/examples/jsm/nodes/core/VaryingNode.js +2 -0
- package/examples/jsm/nodes/display/BumpMapNode.js +35 -13
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -1
- package/examples/jsm/nodes/display/ViewportNode.js +14 -4
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +20 -6
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +8 -3
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +8 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +8 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +93 -43
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +19 -5
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -6
- package/examples/jsm/nodes/lighting/LightingContextNode.js +21 -57
- package/examples/jsm/nodes/lighting/LightsNode.js +62 -4
- package/examples/jsm/nodes/lighting/PointLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +1 -1
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +162 -0
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +70 -71
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +5 -5
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +47 -20
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/NodeMaterial.js +17 -20
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +5 -5
- package/examples/jsm/nodes/math/OperatorNode.js +5 -21
- package/examples/jsm/nodes/shadernode/ShaderNode.js +128 -9
- package/examples/jsm/nodes/utils/ArrayElementNode.js +2 -0
- package/examples/jsm/nodes/utils/DiscardNode.js +3 -2
- package/examples/jsm/nodes/utils/JoinNode.js +11 -1
- package/examples/jsm/nodes/utils/LoopNode.js +36 -24
- package/examples/jsm/nodes/utils/SplitNode.js +2 -0
- package/examples/jsm/objects/BatchedMesh.js +586 -0
- package/examples/jsm/objects/InstancedPoints.js +21 -0
- package/examples/jsm/objects/Lensflare.js +20 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -0
- package/examples/jsm/objects/Refractor.js +3 -0
- package/examples/jsm/objects/Sky.js +5 -3
- package/examples/jsm/objects/Water.js +5 -2
- package/examples/jsm/objects/Water2.js +3 -0
- package/examples/jsm/physics/AmmoPhysics.js +21 -0
- package/examples/jsm/physics/RapierPhysics.js +21 -0
- package/examples/jsm/postprocessing/BokehPass.js +3 -2
- package/examples/jsm/postprocessing/LUTPass.js +2 -1
- package/examples/jsm/postprocessing/OutputPass.js +1 -0
- package/examples/jsm/postprocessing/Pass.js +14 -3
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SMAAPass.js +0 -2
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +3 -9
- package/examples/jsm/renderers/SVGRenderer.js +9 -6
- package/examples/jsm/renderers/common/Bindings.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +8 -1
- package/examples/jsm/renderers/common/RenderObjects.js +1 -1
- package/examples/jsm/renderers/common/Textures.js +4 -36
- package/examples/jsm/renderers/common/nodes/Nodes.js +53 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +291 -50
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +88 -12
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +40 -5
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +14 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +2 -0
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +36 -4
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +2 -0
- package/examples/jsm/shaders/AfterimageShader.js +2 -0
- package/examples/jsm/shaders/BasicShader.js +2 -0
- package/examples/jsm/shaders/BlendShader.js +2 -0
- package/examples/jsm/shaders/BokehShader.js +2 -0
- package/examples/jsm/shaders/BokehShader2.js +4 -0
- package/examples/jsm/shaders/BrightnessContrastShader.js +2 -0
- package/examples/jsm/shaders/ColorCorrectionShader.js +2 -0
- package/examples/jsm/shaders/DOFMipMapShader.js +2 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +5 -0
- package/examples/jsm/shaders/FXAAShader.js +2 -0
- package/examples/jsm/shaders/FilmShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +2 -0
- package/examples/jsm/shaders/FreiChenShader.js +2 -0
- package/examples/jsm/shaders/GodRaysShader.js +8 -0
- package/examples/jsm/shaders/HalftoneShader.js +2 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/HueSaturationShader.js +2 -0
- package/examples/jsm/shaders/KaleidoShader.js +2 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.js +2 -0
- package/examples/jsm/shaders/LuminosityShader.js +2 -0
- package/examples/jsm/shaders/MMDToonShader.js +2 -0
- package/examples/jsm/shaders/MirrorShader.js +2 -0
- package/examples/jsm/shaders/NormalMapShader.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +4 -5
- package/examples/jsm/shaders/SAOShader.js +5 -0
- package/examples/jsm/shaders/SMAAShader.js +6 -0
- package/examples/jsm/shaders/SSAOShader.js +6 -0
- package/examples/jsm/shaders/SSRShader.js +6 -0
- package/examples/jsm/shaders/SobelOperatorShader.js +2 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +2 -0
- package/examples/jsm/shaders/TechnicolorShader.js +2 -0
- package/examples/jsm/shaders/TriangleBlurShader.js +2 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -0
- package/examples/jsm/shaders/VelocityShader.js +2 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +2 -0
- package/examples/jsm/transpiler/AST.js +231 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +899 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -0
- package/examples/jsm/transpiler/TSLEncoder.js +611 -0
- package/examples/jsm/transpiler/Transpiler.js +18 -0
- package/examples/jsm/webxr/VRButton.js +1 -1
- package/examples/jsm/webxr/XRButton.js +7 -5
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +4 -1
- package/src/constants.js +7 -1
- package/src/extras/PMREMGenerator.js +7 -1
- package/src/loaders/MaterialLoader.js +10 -2
- package/src/materials/Material.js +27 -13
- package/src/math/Box3.js +35 -18
- package/src/math/Vector3.js +11 -12
- package/src/objects/SkinnedMesh.js +6 -7
- package/src/renderers/WebGLRenderer.js +142 -25
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +8 -6
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +80 -50
- package/src/renderers/webgl/WebGLPrograms.js +3 -0
- package/src/renderers/webgl/WebGLState.js +25 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -76
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +0 -29
|
@@ -49,8 +49,10 @@ struct PhysicalMaterial {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
// temporary
|
|
52
|
-
vec3
|
|
53
|
-
vec3
|
|
52
|
+
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
|
53
|
+
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
|
54
|
+
vec3 sheenSpecularDirect = vec3( 0.0 );
|
|
55
|
+
vec3 sheenSpecularIndirect = vec3(0.0 );
|
|
54
56
|
|
|
55
57
|
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
|
56
58
|
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
|
@@ -485,13 +487,13 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geome
|
|
|
485
487
|
|
|
486
488
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
487
489
|
|
|
488
|
-
|
|
490
|
+
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|
489
491
|
|
|
490
492
|
#endif
|
|
491
493
|
|
|
492
494
|
#ifdef USE_SHEEN
|
|
493
495
|
|
|
494
|
-
|
|
496
|
+
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|
495
497
|
|
|
496
498
|
#endif
|
|
497
499
|
|
|
@@ -510,13 +512,13 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
510
512
|
|
|
511
513
|
#ifdef USE_CLEARCOAT
|
|
512
514
|
|
|
513
|
-
|
|
515
|
+
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
514
516
|
|
|
515
517
|
#endif
|
|
516
518
|
|
|
517
519
|
#ifdef USE_SHEEN
|
|
518
520
|
|
|
519
|
-
|
|
521
|
+
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
520
522
|
|
|
521
523
|
#endif
|
|
522
524
|
|
|
@@ -197,7 +197,7 @@ void main() {
|
|
|
197
197
|
// https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
|
|
198
198
|
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
199
199
|
|
|
200
|
-
outgoingLight = outgoingLight * sheenEnergyComp +
|
|
200
|
+
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
|
|
201
201
|
|
|
202
202
|
#endif
|
|
203
203
|
|
|
@@ -207,7 +207,7 @@ void main() {
|
|
|
207
207
|
|
|
208
208
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
209
209
|
|
|
210
|
-
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) +
|
|
210
|
+
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
211
211
|
|
|
212
212
|
#endif
|
|
213
213
|
|
|
@@ -4,6 +4,9 @@ import { ShaderChunk } from '../shaders/ShaderChunk.js';
|
|
|
4
4
|
import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, ACESFilmicToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3, LinearSRGBColorSpace, SRGBColorSpace, LinearDisplayP3ColorSpace, DisplayP3ColorSpace, P3Primaries, Rec709Primaries } from '../../constants.js';
|
|
5
5
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
6
6
|
|
|
7
|
+
// From https://www.khronos.org/registry/webgl/extensions/KHR_parallel_shader_compile/
|
|
8
|
+
const COMPLETION_STATUS_KHR = 0x91B1;
|
|
9
|
+
|
|
7
10
|
let programIdCount = 0;
|
|
8
11
|
|
|
9
12
|
function handleSource( string, errorLine ) {
|
|
@@ -848,6 +851,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
848
851
|
].join( '\n' ) + '\n' + prefixVertex;
|
|
849
852
|
|
|
850
853
|
prefixFragment = [
|
|
854
|
+
'precision mediump sampler2DArray;',
|
|
851
855
|
'#define varying in',
|
|
852
856
|
( parameters.glslVersion === GLSL3 ) ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;',
|
|
853
857
|
( parameters.glslVersion === GLSL3 ) ? '' : '#define gl_FragColor pc_fragColor',
|
|
@@ -939,87 +943,94 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
939
943
|
|
|
940
944
|
gl.linkProgram( program );
|
|
941
945
|
|
|
942
|
-
|
|
943
|
-
if ( renderer.debug.checkShaderErrors ) {
|
|
946
|
+
function onFirstUse( self ) {
|
|
944
947
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
const fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();
|
|
948
|
+
// check for link errors
|
|
949
|
+
if ( renderer.debug.checkShaderErrors ) {
|
|
948
950
|
|
|
949
|
-
|
|
950
|
-
|
|
951
|
+
const programLog = gl.getProgramInfoLog( program ).trim();
|
|
952
|
+
const vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();
|
|
953
|
+
const fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();
|
|
951
954
|
|
|
952
|
-
|
|
955
|
+
let runnable = true;
|
|
956
|
+
let haveDiagnostics = true;
|
|
953
957
|
|
|
954
|
-
|
|
958
|
+
if ( gl.getProgramParameter( program, gl.LINK_STATUS ) === false ) {
|
|
955
959
|
|
|
956
|
-
|
|
960
|
+
runnable = false;
|
|
957
961
|
|
|
958
|
-
renderer.debug.onShaderError
|
|
962
|
+
if ( typeof renderer.debug.onShaderError === 'function' ) {
|
|
959
963
|
|
|
960
|
-
|
|
964
|
+
renderer.debug.onShaderError( gl, program, glVertexShader, glFragmentShader );
|
|
961
965
|
|
|
962
|
-
|
|
966
|
+
} else {
|
|
963
967
|
|
|
964
|
-
|
|
965
|
-
const fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );
|
|
968
|
+
// default error reporting
|
|
966
969
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
'VALIDATE_STATUS ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ) + '\n\n' +
|
|
970
|
-
'Program Info Log: ' + programLog + '\n' +
|
|
971
|
-
vertexErrors + '\n' +
|
|
972
|
-
fragmentErrors
|
|
973
|
-
);
|
|
970
|
+
const vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' );
|
|
971
|
+
const fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );
|
|
974
972
|
|
|
975
|
-
|
|
973
|
+
console.error(
|
|
974
|
+
'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' +
|
|
975
|
+
'VALIDATE_STATUS ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ) + '\n\n' +
|
|
976
|
+
'Program Info Log: ' + programLog + '\n' +
|
|
977
|
+
vertexErrors + '\n' +
|
|
978
|
+
fragmentErrors
|
|
979
|
+
);
|
|
976
980
|
|
|
977
|
-
|
|
981
|
+
}
|
|
978
982
|
|
|
979
|
-
|
|
983
|
+
} else if ( programLog !== '' ) {
|
|
980
984
|
|
|
981
|
-
|
|
985
|
+
console.warn( 'THREE.WebGLProgram: Program Info Log:', programLog );
|
|
982
986
|
|
|
983
|
-
|
|
987
|
+
} else if ( vertexLog === '' || fragmentLog === '' ) {
|
|
984
988
|
|
|
985
|
-
|
|
989
|
+
haveDiagnostics = false;
|
|
990
|
+
|
|
991
|
+
}
|
|
986
992
|
|
|
987
|
-
|
|
993
|
+
if ( haveDiagnostics ) {
|
|
988
994
|
|
|
989
|
-
|
|
995
|
+
self.diagnostics = {
|
|
990
996
|
|
|
991
|
-
|
|
997
|
+
runnable: runnable,
|
|
992
998
|
|
|
993
|
-
|
|
999
|
+
programLog: programLog,
|
|
994
1000
|
|
|
995
|
-
|
|
1001
|
+
vertexShader: {
|
|
996
1002
|
|
|
997
|
-
|
|
998
|
-
|
|
1003
|
+
log: vertexLog,
|
|
1004
|
+
prefix: prefixVertex
|
|
999
1005
|
|
|
1000
|
-
|
|
1006
|
+
},
|
|
1001
1007
|
|
|
1002
|
-
|
|
1008
|
+
fragmentShader: {
|
|
1003
1009
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1010
|
+
log: fragmentLog,
|
|
1011
|
+
prefix: prefixFragment
|
|
1006
1012
|
|
|
1007
|
-
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
};
|
|
1008
1016
|
|
|
1009
|
-
}
|
|
1017
|
+
}
|
|
1010
1018
|
|
|
1011
1019
|
}
|
|
1012
1020
|
|
|
1013
|
-
|
|
1021
|
+
// Clean up
|
|
1014
1022
|
|
|
1015
|
-
|
|
1023
|
+
// Crashes in iOS9 and iOS10. #18402
|
|
1024
|
+
// gl.detachShader( program, glVertexShader );
|
|
1025
|
+
// gl.detachShader( program, glFragmentShader );
|
|
1016
1026
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
// gl.detachShader( program, glFragmentShader );
|
|
1027
|
+
gl.deleteShader( glVertexShader );
|
|
1028
|
+
gl.deleteShader( glFragmentShader );
|
|
1020
1029
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1030
|
+
cachedUniforms = new WebGLUniforms( gl, program );
|
|
1031
|
+
cachedAttributes = fetchAttributeLocations( gl, program );
|
|
1032
|
+
|
|
1033
|
+
}
|
|
1023
1034
|
|
|
1024
1035
|
// set up caching for uniform locations
|
|
1025
1036
|
|
|
@@ -1029,7 +1040,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
1029
1040
|
|
|
1030
1041
|
if ( cachedUniforms === undefined ) {
|
|
1031
1042
|
|
|
1032
|
-
|
|
1043
|
+
// Populates cachedUniforms and cachedAttributes
|
|
1044
|
+
onFirstUse( this );
|
|
1033
1045
|
|
|
1034
1046
|
}
|
|
1035
1047
|
|
|
@@ -1045,7 +1057,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
1045
1057
|
|
|
1046
1058
|
if ( cachedAttributes === undefined ) {
|
|
1047
1059
|
|
|
1048
|
-
|
|
1060
|
+
// Populates cachedAttributes and cachedUniforms
|
|
1061
|
+
onFirstUse( this );
|
|
1049
1062
|
|
|
1050
1063
|
}
|
|
1051
1064
|
|
|
@@ -1053,6 +1066,23 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
1053
1066
|
|
|
1054
1067
|
};
|
|
1055
1068
|
|
|
1069
|
+
// indicate when the program is ready to be used. if the KHR_parallel_shader_compile extension isn't supported,
|
|
1070
|
+
// flag the program as ready immediately. It may cause a stall when it's first used.
|
|
1071
|
+
|
|
1072
|
+
let programReady = ( parameters.rendererExtensionParallelShaderCompile === false );
|
|
1073
|
+
|
|
1074
|
+
this.isReady = function () {
|
|
1075
|
+
|
|
1076
|
+
if ( programReady === false ) {
|
|
1077
|
+
|
|
1078
|
+
programReady = gl.getProgramParameter( program, COMPLETION_STATUS_KHR );
|
|
1079
|
+
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
return programReady;
|
|
1083
|
+
|
|
1084
|
+
};
|
|
1085
|
+
|
|
1056
1086
|
// free resource
|
|
1057
1087
|
|
|
1058
1088
|
this.destroy = function () {
|
|
@@ -361,6 +361,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
361
361
|
rendererExtensionFragDepth: IS_WEBGL2 || extensions.has( 'EXT_frag_depth' ),
|
|
362
362
|
rendererExtensionDrawBuffers: IS_WEBGL2 || extensions.has( 'WEBGL_draw_buffers' ),
|
|
363
363
|
rendererExtensionShaderTextureLod: IS_WEBGL2 || extensions.has( 'EXT_shader_texture_lod' ),
|
|
364
|
+
rendererExtensionParallelShaderCompile: extensions.has( 'KHR_parallel_shader_compile' ),
|
|
364
365
|
|
|
365
366
|
customProgramCacheKey: material.customProgramCacheKey()
|
|
366
367
|
|
|
@@ -503,6 +504,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
503
504
|
_programLayers.enable( 16 );
|
|
504
505
|
if ( parameters.anisotropy )
|
|
505
506
|
_programLayers.enable( 17 );
|
|
507
|
+
if ( parameters.alphaHash )
|
|
508
|
+
_programLayers.enable( 18 );
|
|
506
509
|
|
|
507
510
|
array.push( _programLayers.mask );
|
|
508
511
|
_programLayers.disableAll();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor } from '../../constants.js';
|
|
1
|
+
import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor, ConstantColorFactor, OneMinusConstantColorFactor, ConstantAlphaFactor, OneMinusConstantAlphaFactor } from '../../constants.js';
|
|
2
|
+
import { Color } from '../../math/Color.js';
|
|
2
3
|
import { Vector4 } from '../../math/Vector4.js';
|
|
3
4
|
|
|
4
5
|
function WebGLState( gl, extensions, capabilities ) {
|
|
@@ -325,6 +326,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
325
326
|
let currentBlendEquationAlpha = null;
|
|
326
327
|
let currentBlendSrcAlpha = null;
|
|
327
328
|
let currentBlendDstAlpha = null;
|
|
329
|
+
let currentBlendColor = new Color( 0, 0, 0 );
|
|
330
|
+
let currentBlendAlpha = 0;
|
|
328
331
|
let currentPremultipledAlpha = false;
|
|
329
332
|
|
|
330
333
|
let currentFlipSided = null;
|
|
@@ -600,10 +603,14 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
600
603
|
[ OneMinusSrcColorFactor ]: gl.ONE_MINUS_SRC_COLOR,
|
|
601
604
|
[ OneMinusSrcAlphaFactor ]: gl.ONE_MINUS_SRC_ALPHA,
|
|
602
605
|
[ OneMinusDstColorFactor ]: gl.ONE_MINUS_DST_COLOR,
|
|
603
|
-
[ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA
|
|
606
|
+
[ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA,
|
|
607
|
+
[ ConstantColorFactor ]: gl.CONSTANT_COLOR,
|
|
608
|
+
[ OneMinusConstantColorFactor ]: gl.ONE_MINUS_CONSTANT_COLOR,
|
|
609
|
+
[ ConstantAlphaFactor ]: gl.CONSTANT_ALPHA,
|
|
610
|
+
[ OneMinusConstantAlphaFactor ]: gl.ONE_MINUS_CONSTANT_ALPHA
|
|
604
611
|
};
|
|
605
612
|
|
|
606
|
-
function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {
|
|
613
|
+
function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, blendColor, blendAlpha, premultipliedAlpha ) {
|
|
607
614
|
|
|
608
615
|
if ( blending === NoBlending ) {
|
|
609
616
|
|
|
@@ -696,6 +703,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
696
703
|
currentBlendDst = null;
|
|
697
704
|
currentBlendSrcAlpha = null;
|
|
698
705
|
currentBlendDstAlpha = null;
|
|
706
|
+
currentBlendColor.set( 0, 0, 0 );
|
|
707
|
+
currentBlendAlpha = 0;
|
|
699
708
|
|
|
700
709
|
currentBlending = blending;
|
|
701
710
|
currentPremultipledAlpha = premultipliedAlpha;
|
|
@@ -732,6 +741,15 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
732
741
|
|
|
733
742
|
}
|
|
734
743
|
|
|
744
|
+
if ( blendColor.equals( currentBlendColor ) === false || blendAlpha !== currentBlendAlpha ) {
|
|
745
|
+
|
|
746
|
+
gl.blendColor( blendColor.r, blendColor.g, blendColor.b, blendAlpha );
|
|
747
|
+
|
|
748
|
+
currentBlendColor.copy( blendColor );
|
|
749
|
+
currentBlendAlpha = blendAlpha;
|
|
750
|
+
|
|
751
|
+
}
|
|
752
|
+
|
|
735
753
|
currentBlending = blending;
|
|
736
754
|
currentPremultipledAlpha = false;
|
|
737
755
|
|
|
@@ -750,7 +768,7 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
750
768
|
|
|
751
769
|
( material.blending === NormalBlending && material.transparent === false )
|
|
752
770
|
? setBlending( NoBlending )
|
|
753
|
-
: setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha );
|
|
771
|
+
: setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.blendColor, material.blendAlpha, material.premultipliedAlpha );
|
|
754
772
|
|
|
755
773
|
depthBuffer.setFunc( material.depthFunc );
|
|
756
774
|
depthBuffer.setTest( material.depthTest );
|
|
@@ -1174,6 +1192,7 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
1174
1192
|
gl.blendEquation( gl.FUNC_ADD );
|
|
1175
1193
|
gl.blendFunc( gl.ONE, gl.ZERO );
|
|
1176
1194
|
gl.blendFuncSeparate( gl.ONE, gl.ZERO, gl.ONE, gl.ZERO );
|
|
1195
|
+
gl.blendColor( 0, 0, 0, 0 );
|
|
1177
1196
|
|
|
1178
1197
|
gl.colorMask( true, true, true, true );
|
|
1179
1198
|
gl.clearColor( 0, 0, 0, 0 );
|
|
@@ -1231,6 +1250,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
1231
1250
|
currentBlendEquationAlpha = null;
|
|
1232
1251
|
currentBlendSrcAlpha = null;
|
|
1233
1252
|
currentBlendDstAlpha = null;
|
|
1253
|
+
currentBlendColor = new Color( 0, 0, 0 );
|
|
1254
|
+
currentBlendAlpha = 0;
|
|
1234
1255
|
currentPremultipledAlpha = false;
|
|
1235
1256
|
|
|
1236
1257
|
currentFlipSided = null;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import MaterialNode from './MaterialNode.js';
|
|
2
|
-
import { materialReference } from './MaterialReferenceNode.js';
|
|
3
|
-
import { normalView } from './NormalNode.js';
|
|
4
|
-
import { normalMap } from '../display/NormalMapNode.js';
|
|
5
|
-
import { bumpMap } from '../display/BumpMapNode.js';
|
|
6
|
-
import { addNodeClass } from '../core/Node.js';
|
|
7
|
-
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
8
|
-
|
|
9
|
-
class ExtendedMaterialNode extends MaterialNode {
|
|
10
|
-
|
|
11
|
-
constructor( scope ) {
|
|
12
|
-
|
|
13
|
-
super( scope );
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getNodeType( builder ) {
|
|
18
|
-
|
|
19
|
-
const scope = this.scope;
|
|
20
|
-
let type = null;
|
|
21
|
-
|
|
22
|
-
if ( scope === ExtendedMaterialNode.NORMAL || scope === ExtendedMaterialNode.CLEARCOAT_NORMAL ) {
|
|
23
|
-
|
|
24
|
-
type = 'vec3';
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return type || super.getNodeType( builder );
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
setup( builder ) {
|
|
33
|
-
|
|
34
|
-
const material = builder.material;
|
|
35
|
-
const scope = this.scope;
|
|
36
|
-
|
|
37
|
-
let node = null;
|
|
38
|
-
|
|
39
|
-
if ( scope === ExtendedMaterialNode.NORMAL ) {
|
|
40
|
-
|
|
41
|
-
if ( material.normalMap ) {
|
|
42
|
-
|
|
43
|
-
node = normalMap( this.getTexture( 'normalMap' ), materialReference( 'normalScale', 'vec2' ) );
|
|
44
|
-
|
|
45
|
-
} else if ( material.bumpMap ) {
|
|
46
|
-
|
|
47
|
-
// @TODO: Replace material.bumpMap to this.getTexture( 'bumpMap' )
|
|
48
|
-
node = bumpMap( material.bumpMap, materialReference( 'bumpScale', 'float' ) );
|
|
49
|
-
|
|
50
|
-
} else {
|
|
51
|
-
|
|
52
|
-
node = normalView;
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
} else if ( scope === ExtendedMaterialNode.CLEARCOAT_NORMAL ) {
|
|
57
|
-
|
|
58
|
-
node = material.clearcoatNormalMap ? normalMap( this.getTexture( 'clearcoatNormalMap' ), materialReference( 'clearcoatNormalScale', 'vec2' ) ) : normalView;
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return node || super.setup( builder );
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
ExtendedMaterialNode.NORMAL = 'normal';
|
|
69
|
-
ExtendedMaterialNode.CLEARCOAT_NORMAL = 'clearcoatNormal';
|
|
70
|
-
|
|
71
|
-
export default ExtendedMaterialNode;
|
|
72
|
-
|
|
73
|
-
export const materialNormal = nodeImmutable( ExtendedMaterialNode, ExtendedMaterialNode.NORMAL );
|
|
74
|
-
export const materialClearcoatNormal = nodeImmutable( ExtendedMaterialNode, ExtendedMaterialNode.CLEARCOAT_NORMAL );
|
|
75
|
-
|
|
76
|
-
addNodeClass( 'ExtendedMaterialNode', ExtendedMaterialNode );
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import MaterialNode from './MaterialNode.js';
|
|
2
|
-
import { addNodeClass } from '../core/Node.js';
|
|
3
|
-
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
4
|
-
|
|
5
|
-
class LineMaterialNode extends MaterialNode {
|
|
6
|
-
|
|
7
|
-
setup( /*builder*/ ) {
|
|
8
|
-
|
|
9
|
-
return this.getFloat( this.scope );
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
LineMaterialNode.SCALE = 'scale';
|
|
16
|
-
LineMaterialNode.DASH_SIZE = 'dashSize';
|
|
17
|
-
LineMaterialNode.GAP_SIZE = 'gapSize';
|
|
18
|
-
LineMaterialNode.LINEWIDTH = 'linewidth';
|
|
19
|
-
LineMaterialNode.DASH_OFFSET = 'dashOffset';
|
|
20
|
-
|
|
21
|
-
export default LineMaterialNode;
|
|
22
|
-
|
|
23
|
-
export const materialLineScale = nodeImmutable( LineMaterialNode, LineMaterialNode.SCALE );
|
|
24
|
-
export const materialLineDashOffset = nodeImmutable( LineMaterialNode, LineMaterialNode.DASH_OFFSET );
|
|
25
|
-
export const materialLineDashSize = nodeImmutable( LineMaterialNode, LineMaterialNode.DASH_SIZE );
|
|
26
|
-
export const materialLineGapSize = nodeImmutable( LineMaterialNode, LineMaterialNode.GAP_SIZE );
|
|
27
|
-
export const materialLineWidth = nodeImmutable( LineMaterialNode, LineMaterialNode.LINEWIDTH );
|
|
28
|
-
|
|
29
|
-
addNodeClass( 'LineMaterialNode', LineMaterialNode );
|