super-three 0.155.0 → 0.157.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/build/three.cjs +361 -324
- package/build/three.js +361 -324
- package/build/three.min.js +2 -2
- package/build/three.module.js +354 -323
- package/build/three.module.min.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +17 -0
- package/examples/jsm/controls/DragControls.js +3 -2
- package/examples/jsm/controls/OrbitControls.js +13 -5
- package/examples/jsm/csm/CSMShader.js +59 -21
- package/examples/jsm/exporters/EXRExporter.js +102 -24
- package/examples/jsm/exporters/GLTFExporter.js +1 -1
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/tween.module.js +790 -735
- package/examples/jsm/libs/utif.module.js +1644 -1558
- package/examples/jsm/lights/LightProbeGenerator.js +37 -3
- package/examples/jsm/lines/LineMaterial.js +90 -156
- package/examples/jsm/loaders/3DMLoader.js +378 -104
- package/examples/jsm/loaders/DDSLoader.js +46 -3
- package/examples/jsm/loaders/EXRLoader.js +4 -4
- package/examples/jsm/loaders/FBXLoader.js +2 -0
- package/examples/jsm/loaders/GLTFLoader.js +18 -8
- package/examples/jsm/loaders/KTX2Loader.js +126 -77
- package/examples/jsm/loaders/LDrawLoader.js +22 -16
- package/examples/jsm/loaders/LogLuvLoader.js +2 -2
- package/examples/jsm/loaders/MMDLoader.js +10 -7
- package/examples/jsm/loaders/RGBELoader.js +48 -66
- package/examples/jsm/loaders/STLLoader.js +7 -0
- package/examples/jsm/loaders/USDZLoader.js +215 -12
- package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
- package/examples/jsm/nodes/Nodes.js +8 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +30 -4
- package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +19 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +4 -5
- package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +29 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +23 -13
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +12 -9
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
- package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/Object3DNode.js +3 -3
- package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
- package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +18 -8
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
- package/examples/jsm/nodes/code/CodeNode.js +1 -1
- package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionNode.js +18 -7
- package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
- package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
- package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
- package/examples/jsm/nodes/core/AttributeNode.js +3 -3
- package/examples/jsm/nodes/core/BypassNode.js +1 -1
- package/examples/jsm/nodes/core/CacheNode.js +1 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/ContextNode.js +2 -2
- package/examples/jsm/nodes/core/IndexNode.js +1 -1
- package/examples/jsm/nodes/core/InputNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +45 -14
- package/examples/jsm/nodes/core/NodeBuilder.js +83 -15
- package/examples/jsm/nodes/core/NodeFrame.js +37 -14
- package/examples/jsm/nodes/core/NodeUniform.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +62 -0
- package/examples/jsm/nodes/core/PropertyNode.js +3 -1
- package/examples/jsm/nodes/core/StackNode.js +5 -5
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +3 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -1
- package/examples/jsm/nodes/core/VaryingNode.js +1 -1
- package/examples/jsm/nodes/core/constants.js +1 -1
- package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
- package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
- package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
- package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
- package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
- package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +21 -7
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
- package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
- package/examples/jsm/nodes/fog/FogNode.js +2 -2
- package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
- package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AONode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
- package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
- package/examples/jsm/nodes/materials/Materials.js +2 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
- 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 +6 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/NodeMaterial.js +39 -29
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
- package/examples/jsm/nodes/math/CondNode.js +1 -1
- package/examples/jsm/nodes/math/HashNode.js +34 -0
- package/examples/jsm/nodes/math/MathNode.js +2 -2
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +85 -28
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
- package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
- package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
- package/examples/jsm/nodes/utils/JoinNode.js +1 -1
- package/examples/jsm/nodes/utils/LoopNode.js +11 -11
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/OscNode.js +2 -2
- package/examples/jsm/nodes/utils/PackingNode.js +2 -2
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
- package/examples/jsm/nodes/utils/SetNode.js +62 -0
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +2 -2
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
- package/examples/jsm/objects/Sky.js +1 -3
- package/examples/jsm/postprocessing/FilmPass.js +3 -5
- package/examples/jsm/postprocessing/OutputPass.js +3 -2
- package/examples/jsm/postprocessing/RenderPass.js +30 -12
- package/examples/jsm/postprocessing/SAOPass.js +23 -98
- package/examples/jsm/postprocessing/SSAOPass.js +10 -30
- package/examples/jsm/renderers/common/Backend.js +11 -8
- package/examples/jsm/renderers/common/Background.js +2 -2
- package/examples/jsm/renderers/common/Binding.js +6 -0
- package/examples/jsm/renderers/common/Bindings.js +4 -5
- package/examples/jsm/renderers/common/Pipelines.js +9 -9
- package/examples/jsm/renderers/common/RenderContext.js +3 -0
- package/examples/jsm/renderers/common/RenderContexts.js +26 -1
- package/examples/jsm/renderers/common/RenderList.js +12 -4
- package/examples/jsm/renderers/common/RenderObject.js +43 -15
- package/examples/jsm/renderers/common/RenderObjects.js +8 -14
- package/examples/jsm/renderers/common/Renderer.js +52 -16
- package/examples/jsm/renderers/common/SampledTexture.js +6 -3
- package/examples/jsm/renderers/common/Sampler.js +1 -1
- package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
- package/examples/jsm/renderers/common/StorageTexture.js +19 -0
- package/examples/jsm/renderers/common/Textures.js +166 -21
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +21 -11
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -7
- package/examples/jsm/renderers/common/nodes/Nodes.js +79 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +702 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +207 -20
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +212 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +4 -4
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +14 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +282 -43
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +93 -60
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +15 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +39 -14
- package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +205 -284
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +6 -5
- package/examples/jsm/shaders/FilmShader.js +11 -54
- package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +4 -4
- package/examples/jsm/shaders/OutputShader.js +2 -2
- package/examples/jsm/shaders/SAOShader.js +0 -13
- package/examples/jsm/shaders/SSAOShader.js +33 -26
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
- package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
- package/package.json +1 -1
- package/src/Three.js +1 -2
- package/src/animation/AnimationUtils.js +3 -20
- package/src/animation/KeyframeTrack.js +8 -8
- package/src/audio/Audio.js +6 -0
- package/src/cameras/Camera.js +1 -5
- package/src/cameras/CubeCamera.js +14 -8
- package/src/constants.js +10 -1
- package/src/core/Object3D.js +1 -14
- package/src/core/RenderTarget.js +16 -7
- package/src/core/UniformsGroup.js +2 -2
- package/src/extras/core/CurvePath.js +4 -1
- package/src/loaders/DataTextureLoader.js +0 -2
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +6 -0
- package/src/materials/Material.js +10 -10
- package/src/math/Color.js +1 -5
- package/src/math/ColorManagement.js +82 -60
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +3 -3
- package/src/math/Vector4.js +4 -4
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +42 -51
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +9 -17
- package/src/renderers/webgl/WebGLLights.js +14 -3
- package/src/renderers/webgl/WebGLProgram.js +36 -5
- package/src/renderers/webgl/WebGLPrograms.js +9 -1
- package/src/renderers/webgl/WebGLTextures.js +19 -8
- package/src/renderers/webgl/WebGLUtils.js +25 -20
- package/src/scenes/Fog.js +1 -0
- package/src/scenes/FogExp2.js +1 -0
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +9 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
- package/src/lights/AmbientLightProbe.js +0 -21
- package/src/lights/HemisphereLightProbe.js +0 -30
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// http://www.russellcottrell.com/photo/matrixCalculator.htm
|
|
4
|
+
|
|
5
|
+
// Linear sRGB => XYZ => Linear Display P3
|
|
6
|
+
const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
|
|
7
|
+
vec3( 0.8224621, 0.177538, 0.0 ),
|
|
8
|
+
vec3( 0.0331941, 0.9668058, 0.0 ),
|
|
9
|
+
vec3( 0.0170827, 0.0723974, 0.9105199 )
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
// Linear Display P3 => XYZ => Linear sRGB
|
|
13
|
+
const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
|
|
14
|
+
vec3( 1.2249401, - 0.2249404, 0.0 ),
|
|
15
|
+
vec3( - 0.0420569, 1.0420571, 0.0 ),
|
|
16
|
+
vec3( - 0.0196376, - 0.0786361, 1.0982735 )
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
|
|
20
|
+
return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
|
|
24
|
+
return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
vec4 LinearTransferOETF( in vec4 value ) {
|
|
4
28
|
return value;
|
|
5
29
|
}
|
|
6
30
|
|
|
7
|
-
vec4
|
|
31
|
+
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
8
32
|
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
|
9
33
|
}
|
|
10
34
|
|
|
35
|
+
// @deprecated, r156
|
|
36
|
+
vec4 LinearToLinear( in vec4 value ) {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// @deprecated, r156
|
|
41
|
+
vec4 LinearTosRGB( in vec4 value ) {
|
|
42
|
+
return sRGBTransferOETF( value );
|
|
43
|
+
}
|
|
11
44
|
`;
|
|
@@ -52,15 +52,6 @@ struct ReflectedLight {
|
|
|
52
52
|
vec3 indirectSpecular;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
struct GeometricContext {
|
|
56
|
-
vec3 position;
|
|
57
|
-
vec3 normal;
|
|
58
|
-
vec3 viewDir;
|
|
59
|
-
#ifdef USE_CLEARCOAT
|
|
60
|
-
vec3 clearcoatNormal;
|
|
61
|
-
#endif
|
|
62
|
-
};
|
|
63
|
-
|
|
64
55
|
#ifdef USE_ALPHAHASH
|
|
65
56
|
|
|
66
57
|
varying vec3 vPosition;
|
|
@@ -13,21 +13,21 @@ export default /* glsl */`
|
|
|
13
13
|
* - Add diffuse light probe (irradiance cubemap) support.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
vec3 geometryPosition = - vViewPosition;
|
|
17
|
+
vec3 geometryNormal = normal;
|
|
18
|
+
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
geometry.normal = normal;
|
|
20
|
-
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
20
|
+
vec3 geometryClearcoatNormal;
|
|
21
21
|
|
|
22
22
|
#ifdef USE_CLEARCOAT
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
geometryClearcoatNormal = clearcoatNormal;
|
|
25
25
|
|
|
26
26
|
#endif
|
|
27
27
|
|
|
28
28
|
#ifdef USE_IRIDESCENCE
|
|
29
29
|
|
|
30
|
-
float dotNVi = saturate( dot( normal,
|
|
30
|
+
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
|
31
31
|
|
|
32
32
|
if ( material.iridescenceThickness == 0.0 ) {
|
|
33
33
|
|
|
@@ -64,14 +64,14 @@ IncidentLight directLight;
|
|
|
64
64
|
|
|
65
65
|
pointLight = pointLights[ i ];
|
|
66
66
|
|
|
67
|
-
getPointLightInfo( pointLight,
|
|
67
|
+
getPointLightInfo( pointLight, geometryPosition, directLight );
|
|
68
68
|
|
|
69
69
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
|
70
70
|
pointLightShadow = pointLightShadows[ i ];
|
|
71
71
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
72
72
|
#endif
|
|
73
73
|
|
|
74
|
-
RE_Direct( directLight,
|
|
74
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
75
75
|
|
|
76
76
|
}
|
|
77
77
|
#pragma unroll_loop_end
|
|
@@ -94,7 +94,7 @@ IncidentLight directLight;
|
|
|
94
94
|
|
|
95
95
|
spotLight = spotLights[ i ];
|
|
96
96
|
|
|
97
|
-
getSpotLightInfo( spotLight,
|
|
97
|
+
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
|
98
98
|
|
|
99
99
|
// spot lights are ordered [shadows with maps, shadows without maps, maps without shadows, none]
|
|
100
100
|
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
@@ -119,7 +119,7 @@ IncidentLight directLight;
|
|
|
119
119
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
120
120
|
#endif
|
|
121
121
|
|
|
122
|
-
RE_Direct( directLight,
|
|
122
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
123
123
|
|
|
124
124
|
}
|
|
125
125
|
#pragma unroll_loop_end
|
|
@@ -138,14 +138,14 @@ IncidentLight directLight;
|
|
|
138
138
|
|
|
139
139
|
directionalLight = directionalLights[ i ];
|
|
140
140
|
|
|
141
|
-
getDirectionalLightInfo( directionalLight,
|
|
141
|
+
getDirectionalLightInfo( directionalLight, directLight );
|
|
142
142
|
|
|
143
143
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|
144
144
|
directionalLightShadow = directionalLightShadows[ i ];
|
|
145
145
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
146
146
|
#endif
|
|
147
147
|
|
|
148
|
-
RE_Direct( directLight,
|
|
148
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
149
149
|
|
|
150
150
|
}
|
|
151
151
|
#pragma unroll_loop_end
|
|
@@ -160,7 +160,7 @@ IncidentLight directLight;
|
|
|
160
160
|
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
|
161
161
|
|
|
162
162
|
rectAreaLight = rectAreaLights[ i ];
|
|
163
|
-
RE_Direct_RectArea( rectAreaLight,
|
|
163
|
+
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
164
164
|
|
|
165
165
|
}
|
|
166
166
|
#pragma unroll_loop_end
|
|
@@ -173,14 +173,18 @@ IncidentLight directLight;
|
|
|
173
173
|
|
|
174
174
|
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
#if defined( USE_LIGHT_PROBES )
|
|
177
|
+
|
|
178
|
+
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|
179
|
+
|
|
180
|
+
#endif
|
|
177
181
|
|
|
178
182
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
179
183
|
|
|
180
184
|
#pragma unroll_loop_start
|
|
181
185
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
182
186
|
|
|
183
|
-
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ],
|
|
187
|
+
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|
184
188
|
|
|
185
189
|
}
|
|
186
190
|
#pragma unroll_loop_end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
2
|
#if defined( RE_IndirectDiffuse )
|
|
3
3
|
|
|
4
|
-
RE_IndirectDiffuse( irradiance,
|
|
4
|
+
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
5
5
|
|
|
6
6
|
#endif
|
|
7
7
|
|
|
8
8
|
#if defined( RE_IndirectSpecular )
|
|
9
9
|
|
|
10
|
-
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance,
|
|
10
|
+
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
11
11
|
|
|
12
12
|
#endif
|
|
13
13
|
`;
|
|
@@ -12,7 +12,7 @@ export default /* glsl */`
|
|
|
12
12
|
|
|
13
13
|
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
|
14
14
|
|
|
15
|
-
iblIrradiance += getIBLIrradiance(
|
|
15
|
+
iblIrradiance += getIBLIrradiance( geometryNormal );
|
|
16
16
|
|
|
17
17
|
#endif
|
|
18
18
|
|
|
@@ -22,17 +22,17 @@ export default /* glsl */`
|
|
|
22
22
|
|
|
23
23
|
#ifdef USE_ANISOTROPY
|
|
24
24
|
|
|
25
|
-
radiance += getIBLAnisotropyRadiance(
|
|
25
|
+
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
|
|
26
26
|
|
|
27
27
|
#else
|
|
28
28
|
|
|
29
|
-
radiance += getIBLRadiance(
|
|
29
|
+
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
|
|
30
30
|
|
|
31
31
|
#endif
|
|
32
32
|
|
|
33
33
|
#ifdef USE_CLEARCOAT
|
|
34
34
|
|
|
35
|
-
clearcoatRadiance += getIBLRadiance(
|
|
35
|
+
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
36
36
|
|
|
37
37
|
#endif
|
|
38
38
|
|
|
@@ -8,16 +8,16 @@ struct LambertMaterial {
|
|
|
8
8
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
void RE_Direct_Lambert( const in IncidentLight directLight, const in
|
|
11
|
+
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
12
12
|
|
|
13
|
-
float dotNL = saturate( dot(
|
|
13
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
14
14
|
vec3 irradiance = dotNL * directLight.color;
|
|
15
15
|
|
|
16
16
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
17
17
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in
|
|
20
|
+
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
21
21
|
|
|
22
22
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
23
23
|
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
2
|
uniform bool receiveShadow;
|
|
3
3
|
uniform vec3 ambientLightColor;
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
#if defined( USE_LIGHT_PROBES )
|
|
6
|
+
|
|
7
|
+
uniform vec3 lightProbe[ 9 ];
|
|
8
|
+
|
|
9
|
+
#endif
|
|
5
10
|
|
|
6
11
|
// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere
|
|
7
12
|
// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
|
|
@@ -94,7 +99,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
94
99
|
|
|
95
100
|
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
|
96
101
|
|
|
97
|
-
void getDirectionalLightInfo( const in DirectionalLight directionalLight,
|
|
102
|
+
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
|
|
98
103
|
|
|
99
104
|
light.color = directionalLight.color;
|
|
100
105
|
light.direction = directionalLight.direction;
|
|
@@ -117,9 +122,9 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
117
122
|
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
|
118
123
|
|
|
119
124
|
// light is an out parameter as having it as a return value caused compiler errors on some devices
|
|
120
|
-
void getPointLightInfo( const in PointLight pointLight, const in
|
|
125
|
+
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
121
126
|
|
|
122
|
-
vec3 lVector = pointLight.position -
|
|
127
|
+
vec3 lVector = pointLight.position - geometryPosition;
|
|
123
128
|
|
|
124
129
|
light.direction = normalize( lVector );
|
|
125
130
|
|
|
@@ -149,9 +154,9 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
149
154
|
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
|
150
155
|
|
|
151
156
|
// light is an out parameter as having it as a return value caused compiler errors on some devices
|
|
152
|
-
void getSpotLightInfo( const in SpotLight spotLight, const in
|
|
157
|
+
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
153
158
|
|
|
154
|
-
vec3 lVector = spotLight.position -
|
|
159
|
+
vec3 lVector = spotLight.position - geometryPosition;
|
|
155
160
|
|
|
156
161
|
light.direction = normalize( lVector );
|
|
157
162
|
|
|
@@ -10,18 +10,18 @@ struct BlinnPhongMaterial {
|
|
|
10
10
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in
|
|
13
|
+
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
14
14
|
|
|
15
|
-
float dotNL = saturate( dot(
|
|
15
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
16
16
|
vec3 irradiance = dotNL * directLight.color;
|
|
17
17
|
|
|
18
18
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
19
19
|
|
|
20
|
-
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction,
|
|
20
|
+
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|
21
21
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in
|
|
24
|
+
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
25
25
|
|
|
26
26
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
27
27
|
|
|
@@ -2,7 +2,7 @@ export default /* glsl */`
|
|
|
2
2
|
PhysicalMaterial material;
|
|
3
3
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
4
4
|
|
|
5
|
-
vec3 dxy = max( abs( dFdx(
|
|
5
|
+
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
6
6
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
7
7
|
|
|
8
8
|
material.roughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.
|
|
@@ -433,11 +433,11 @@ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const
|
|
|
433
433
|
|
|
434
434
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
435
435
|
|
|
436
|
-
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in
|
|
436
|
+
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
437
437
|
|
|
438
|
-
vec3 normal =
|
|
439
|
-
vec3 viewDir =
|
|
440
|
-
vec3 position =
|
|
438
|
+
vec3 normal = geometryNormal;
|
|
439
|
+
vec3 viewDir = geometryViewDir;
|
|
440
|
+
vec3 position = geometryPosition;
|
|
441
441
|
vec3 lightPos = rectAreaLight.position;
|
|
442
442
|
vec3 halfWidth = rectAreaLight.halfWidth;
|
|
443
443
|
vec3 halfHeight = rectAreaLight.halfHeight;
|
|
@@ -473,50 +473,50 @@ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const
|
|
|
473
473
|
|
|
474
474
|
#endif
|
|
475
475
|
|
|
476
|
-
void RE_Direct_Physical( const in IncidentLight directLight, const in
|
|
476
|
+
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
477
477
|
|
|
478
|
-
float dotNL = saturate( dot(
|
|
478
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
479
479
|
|
|
480
480
|
vec3 irradiance = dotNL * directLight.color;
|
|
481
481
|
|
|
482
482
|
#ifdef USE_CLEARCOAT
|
|
483
483
|
|
|
484
|
-
float dotNLcc = saturate( dot(
|
|
484
|
+
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
|
485
485
|
|
|
486
486
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
487
487
|
|
|
488
|
-
clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction,
|
|
488
|
+
clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|
489
489
|
|
|
490
490
|
#endif
|
|
491
491
|
|
|
492
492
|
#ifdef USE_SHEEN
|
|
493
493
|
|
|
494
|
-
sheenSpecular += irradiance * BRDF_Sheen( directLight.direction,
|
|
494
|
+
sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|
495
495
|
|
|
496
496
|
#endif
|
|
497
497
|
|
|
498
|
-
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction,
|
|
498
|
+
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
|
|
499
499
|
|
|
500
500
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
-
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in
|
|
503
|
+
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
504
504
|
|
|
505
505
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
506
506
|
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
-
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in
|
|
509
|
+
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
|
510
510
|
|
|
511
511
|
#ifdef USE_CLEARCOAT
|
|
512
512
|
|
|
513
|
-
clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF(
|
|
513
|
+
clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
514
514
|
|
|
515
515
|
#endif
|
|
516
516
|
|
|
517
517
|
#ifdef USE_SHEEN
|
|
518
518
|
|
|
519
|
-
sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF(
|
|
519
|
+
sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
520
520
|
|
|
521
521
|
#endif
|
|
522
522
|
|
|
@@ -528,11 +528,11 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
528
528
|
|
|
529
529
|
#ifdef USE_IRIDESCENCE
|
|
530
530
|
|
|
531
|
-
computeMultiscatteringIridescence(
|
|
531
|
+
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
|
532
532
|
|
|
533
533
|
#else
|
|
534
534
|
|
|
535
|
-
computeMultiscattering(
|
|
535
|
+
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
|
536
536
|
|
|
537
537
|
#endif
|
|
538
538
|
|
|
@@ -7,15 +7,15 @@ struct ToonMaterial {
|
|
|
7
7
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
void RE_Direct_Toon( const in IncidentLight directLight, const in
|
|
10
|
+
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
11
11
|
|
|
12
|
-
vec3 irradiance = getGradientIrradiance(
|
|
12
|
+
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
|
|
13
13
|
|
|
14
14
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
15
15
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in
|
|
18
|
+
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
19
19
|
|
|
20
20
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
21
21
|
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
export default /* glsl */`
|
|
2
2
|
#ifdef USE_MAP
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
5
|
+
|
|
6
|
+
#ifdef DECODE_VIDEO_TEXTURE
|
|
7
|
+
|
|
8
|
+
// use inline sRGB decode until browsers properly support SRGB8_APLHA8 with video textures
|
|
9
|
+
|
|
10
|
+
sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
|
|
11
|
+
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
diffuseColor *= sampledDiffuseColor;
|
|
5
15
|
|
|
6
16
|
#endif
|
|
7
17
|
`;
|
|
@@ -21,6 +21,14 @@ void main() {
|
|
|
21
21
|
|
|
22
22
|
vec4 texColor = texture2D( t2D, vUv );
|
|
23
23
|
|
|
24
|
+
#ifdef DECODE_VIDEO_TEXTURE
|
|
25
|
+
|
|
26
|
+
// use inline sRGB decode until browsers properly support SRGB8_APLHA8 with video textures
|
|
27
|
+
|
|
28
|
+
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
|
|
29
|
+
|
|
30
|
+
#endif
|
|
31
|
+
|
|
24
32
|
texColor.rgb *= backgroundIntensity;
|
|
25
33
|
|
|
26
34
|
gl_FragColor = texColor;
|
|
@@ -203,7 +203,7 @@ void main() {
|
|
|
203
203
|
|
|
204
204
|
#ifdef USE_CLEARCOAT
|
|
205
205
|
|
|
206
|
-
float dotNVcc = saturate( dot(
|
|
206
|
+
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
207
207
|
|
|
208
208
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
209
209
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Uniform Utilities
|
|
@@ -93,7 +93,7 @@ export function getUnlitUniformColorSpace( renderer ) {
|
|
|
93
93
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
return
|
|
96
|
+
return ColorManagement.workingColorSpace;
|
|
97
97
|
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { BackSide, FrontSide, CubeUVReflectionMapping,
|
|
1
|
+
import { BackSide, FrontSide, CubeUVReflectionMapping, SRGBTransfer } from '../../constants.js';
|
|
2
2
|
import { BoxGeometry } from '../../geometries/BoxGeometry.js';
|
|
3
3
|
import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
|
|
4
4
|
import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
|
|
5
5
|
import { Color } from '../../math/Color.js';
|
|
6
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
6
7
|
import { Mesh } from '../../objects/Mesh.js';
|
|
7
8
|
import { ShaderLib } from '../shaders/ShaderLib.js';
|
|
8
9
|
import { cloneUniforms, getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
|
|
@@ -44,24 +45,15 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
44
45
|
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
const
|
|
48
|
-
const environmentBlendMode = xr.getEnvironmentBlendMode();
|
|
48
|
+
const environmentBlendMode = renderer.xr.getEnvironmentBlendMode();
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
if ( environmentBlendMode === 'additive' ) {
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
forceClear = true;
|
|
54
|
-
break;
|
|
52
|
+
state.buffers.color.setClear( 0, 0, 0, 1, premultipliedAlpha );
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
state.buffers.color.setClear( 0, 0, 0, 1, premultipliedAlpha );
|
|
58
|
-
forceClear = true;
|
|
59
|
-
break;
|
|
54
|
+
} else if ( environmentBlendMode === 'alpha-blend' ) {
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
state.buffers.color.setClear( 0, 0, 0, 0, premultipliedAlpha );
|
|
63
|
-
forceClear = true;
|
|
64
|
-
break;
|
|
56
|
+
state.buffers.color.setClear( 0, 0, 0, 0, premultipliedAlpha );
|
|
65
57
|
|
|
66
58
|
}
|
|
67
59
|
|
|
@@ -117,7 +109,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
117
109
|
boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
118
110
|
boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
119
111
|
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
120
|
-
boxMesh.material.toneMapped = ( background.colorSpace
|
|
112
|
+
boxMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
|
|
121
113
|
|
|
122
114
|
if ( currentBackground !== background ||
|
|
123
115
|
currentBackgroundVersion !== background.version ||
|
|
@@ -173,7 +165,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
173
165
|
|
|
174
166
|
planeMesh.material.uniforms.t2D.value = background;
|
|
175
167
|
planeMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
176
|
-
planeMesh.material.toneMapped = ( background.colorSpace
|
|
168
|
+
planeMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
|
|
177
169
|
|
|
178
170
|
if ( background.matrixAutoUpdate === true ) {
|
|
179
171
|
|
|
@@ -170,7 +170,9 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
170
170
|
numDirectionalShadows: - 1,
|
|
171
171
|
numPointShadows: - 1,
|
|
172
172
|
numSpotShadows: - 1,
|
|
173
|
-
numSpotMaps: - 1
|
|
173
|
+
numSpotMaps: - 1,
|
|
174
|
+
|
|
175
|
+
numLightProbes: - 1
|
|
174
176
|
},
|
|
175
177
|
|
|
176
178
|
ambient: [ 0, 0, 0 ],
|
|
@@ -192,7 +194,8 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
192
194
|
pointShadowMap: [],
|
|
193
195
|
pointShadowMatrix: [],
|
|
194
196
|
hemi: [],
|
|
195
|
-
numSpotLightShadowsWithMaps: 0
|
|
197
|
+
numSpotLightShadowsWithMaps: 0,
|
|
198
|
+
numLightProbes: 0
|
|
196
199
|
|
|
197
200
|
};
|
|
198
201
|
|
|
@@ -220,6 +223,8 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
220
223
|
let numSpotMaps = 0;
|
|
221
224
|
let numSpotShadowsWithMaps = 0;
|
|
222
225
|
|
|
226
|
+
let numLightProbes = 0;
|
|
227
|
+
|
|
223
228
|
// ordering : [shadow casting + map texturing, map texturing, shadow casting, none ]
|
|
224
229
|
lights.sort( shadowCastingAndTexturingLightsFirst );
|
|
225
230
|
|
|
@@ -250,6 +255,8 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
250
255
|
|
|
251
256
|
}
|
|
252
257
|
|
|
258
|
+
numLightProbes ++;
|
|
259
|
+
|
|
253
260
|
} else if ( light.isDirectionalLight ) {
|
|
254
261
|
|
|
255
262
|
const uniforms = cache.get( light );
|
|
@@ -437,7 +444,8 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
437
444
|
hash.numDirectionalShadows !== numDirectionalShadows ||
|
|
438
445
|
hash.numPointShadows !== numPointShadows ||
|
|
439
446
|
hash.numSpotShadows !== numSpotShadows ||
|
|
440
|
-
hash.numSpotMaps !== numSpotMaps
|
|
447
|
+
hash.numSpotMaps !== numSpotMaps ||
|
|
448
|
+
hash.numLightProbes !== numLightProbes ) {
|
|
441
449
|
|
|
442
450
|
state.directional.length = directionalLength;
|
|
443
451
|
state.spot.length = spotLength;
|
|
@@ -456,6 +464,7 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
456
464
|
state.spotLightMatrix.length = numSpotShadows + numSpotMaps - numSpotShadowsWithMaps;
|
|
457
465
|
state.spotLightMap.length = numSpotMaps;
|
|
458
466
|
state.numSpotLightShadowsWithMaps = numSpotShadowsWithMaps;
|
|
467
|
+
state.numLightProbes = numLightProbes;
|
|
459
468
|
|
|
460
469
|
hash.directionalLength = directionalLength;
|
|
461
470
|
hash.pointLength = pointLength;
|
|
@@ -468,6 +477,8 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
468
477
|
hash.numSpotShadows = numSpotShadows;
|
|
469
478
|
hash.numSpotMaps = numSpotMaps;
|
|
470
479
|
|
|
480
|
+
hash.numLightProbes = numLightProbes;
|
|
481
|
+
|
|
471
482
|
state.version = nextVersion ++;
|
|
472
483
|
|
|
473
484
|
}
|