From 167a8cb55986ddbca0836ca3184f3d9c8c4bbe92 Mon Sep 17 00:00:00 2001
From: Mugen87 عدد العينات المستخدمة عند طمس خريطة ظل VSM.
+ The intensity of the shadow. The default is `1`. Valid values are in the range `[0, 1]`.
+
diff --git a/docs/api/en/lights/shadows/LightShadow.html b/docs/api/en/lights/shadows/LightShadow.html
index 1724e90d049c50..aded7048876643 100644
--- a/docs/api/en/lights/shadows/LightShadow.html
+++ b/docs/api/en/lights/shadows/LightShadow.html
@@ -47,6 +47,11 @@ The amount of samples to use when blurring a VSM shadow map.
+ The intensity of the shadow. The default is `1`. Valid values are in the range `[0, 1]`.
+
The depth map generated using the internal camera; a location beyond a
diff --git a/docs/api/it/lights/shadows/LightShadow.html b/docs/api/it/lights/shadows/LightShadow.html
index 0f8111c47b28a4..be095d88f1d1ae 100644
--- a/docs/api/it/lights/shadows/LightShadow.html
+++ b/docs/api/it/lights/shadows/LightShadow.html
@@ -50,6 +50,11 @@ [property:Float bias]
[property:Integer blurSamples]
[property:Float intensity]
+ [property:WebGLRenderTarget map]
[property:Float bias]
[property:Integer blurSamples]
[property:Float intensity]
+ [property:WebGLRenderTarget map]
[property:Integer blurSamples]
La quantità di campioni da utilizzare durante la sfocatura di una mappa ombra VSM.
+ The intensity of the shadow. The default is `1`. Valid values are in the range `[0, 1]`. +
+La mappa di profondità generata usando la telecamera interna; una posizione oltre la profondità di un pixel è in ombra. diff --git a/docs/api/zh/lights/shadows/LightShadow.html b/docs/api/zh/lights/shadows/LightShadow.html index 9490943615e9a4..994e2c8cbb90e4 100644 --- a/docs/api/zh/lights/shadows/LightShadow.html +++ b/docs/api/zh/lights/shadows/LightShadow.html @@ -48,6 +48,11 @@
+ The intensity of the shadow. The default is `1`. Valid values are in the range `[0, 1]`. +
+
使用内置摄像头生成的深度图;超出像素深度的位置在阴影中。在渲染期间内部计算。
diff --git a/examples/jsm/nodes/lighting/AnalyticLightNode.js b/examples/jsm/nodes/lighting/AnalyticLightNode.js
index 001449cb9cc6eb..282d7cac78675e 100644
--- a/examples/jsm/nodes/lighting/AnalyticLightNode.js
+++ b/examples/jsm/nodes/lighting/AnalyticLightNode.js
@@ -2,13 +2,13 @@ import LightingNode from './LightingNode.js';
import { NodeUpdateType } from '../core/constants.js';
import { uniform } from '../core/UniformNode.js';
import { addNodeClass } from '../core/Node.js';
-import { /*vec2,*/ vec3, vec4 } from '../shadernode/ShaderNode.js';
+import { vec3, vec4 } from '../shadernode/ShaderNode.js';
import { reference } from '../accessors/ReferenceNode.js';
import { texture } from '../accessors/TextureNode.js';
import { positionWorld } from '../accessors/PositionNode.js';
import { normalWorld } from '../accessors/NormalNode.js';
import { WebGPUCoordinateSystem } from 'three';
-//import { add } from '../math/OperatorNode.js';
+import { mix } from '../math/MathNode.js';
import { Color, DepthTexture, NearestFilter, LessCompare, NoToneMapping } from 'three';
@@ -83,6 +83,7 @@ class AnalyticLightNode extends LightingNode {
//
+ const shadowIntensity = reference( 'intensity', 'float', shadow );
const bias = reference( 'bias', 'float', shadow );
const normalBias = reference( 'normalBias', 'float', shadow );
@@ -159,7 +160,7 @@ class AnalyticLightNode extends LightingNode {
const shadowMaskNode = frustumTest.mix( 1, shadowNode.mix( shadowColor.a.mix( 1, shadowColor ), 1 ) );
this.rtt = rtt;
- this.colorNode = this.colorNode.mul( shadowMaskNode );
+ this.colorNode = this.colorNode.mul( mix( 1, shadowMaskNode, shadowIntensity ) );
this.shadowNode = shadowNode;
this.shadowMaskNode = shadowMaskNode;
diff --git a/examples/webgl_lights_hemisphere.html b/examples/webgl_lights_hemisphere.html
index d0e5eb46a70c93..64bd4a6f0668d3 100644
--- a/examples/webgl_lights_hemisphere.html
+++ b/examples/webgl_lights_hemisphere.html
@@ -218,13 +218,19 @@
dirLight.visible = ! dirLight.visible;
dirLightHelper.visible = ! dirLightHelper.visible;
- }
+ },
+ shadowIntensity: 1
};
const gui = new GUI();
gui.add( params, 'toggleHemisphereLight' ).name( 'toggle hemisphere light' );
gui.add( params, 'toggleDirectionalLight' ).name( 'toggle directional light' );
+ gui.add( params, 'shadowIntensity', 0, 1 ).name( 'shadow intensity' ).onChange( ( value ) => {
+
+ dirLight.shadow.intensity = value;
+
+ } );
gui.open();
//
diff --git a/src/lights/LightShadow.js b/src/lights/LightShadow.js
index f9a1dd19f13004..df79e6cd2d7d7d 100644
--- a/src/lights/LightShadow.js
+++ b/src/lights/LightShadow.js
@@ -14,6 +14,8 @@ class LightShadow {
this.camera = camera;
+ this.intensity = 1;
+
this.bias = 0;
this.normalBias = 0;
this.radius = 1;
@@ -111,6 +113,8 @@ class LightShadow {
this.camera = source.camera.clone();
+ this.intensity = source.intensity;
+
this.bias = source.bias;
this.radius = source.radius;
@@ -130,6 +134,7 @@ class LightShadow {
const object = {};
+ if ( this.intensity !== 1 ) object.intensity = this.intensity;
if ( this.bias !== 0 ) object.bias = this.bias;
if ( this.normalBias !== 0 ) object.normalBias = this.normalBias;
if ( this.radius !== 1 ) object.radius = this.radius;
diff --git a/src/loaders/ObjectLoader.js b/src/loaders/ObjectLoader.js
index 4f34700d8de848..a0531f3c535ea8 100644
--- a/src/loaders/ObjectLoader.js
+++ b/src/loaders/ObjectLoader.js
@@ -1032,6 +1032,7 @@ class ObjectLoader extends Loader {
if ( data.shadow ) {
+ if ( data.shadow.intensity !== undefined ) object.shadow.intensity = data.shadow.intensity;
if ( data.shadow.bias !== undefined ) object.shadow.bias = data.shadow.bias;
if ( data.shadow.normalBias !== undefined ) object.shadow.normalBias = data.shadow.normalBias;
if ( data.shadow.radius !== undefined ) object.shadow.radius = data.shadow.radius;
diff --git a/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js b/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
index 2204379a4f256c..eaf1e8ad641aef 100644
--- a/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
+++ b/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
@@ -68,7 +68,7 @@ IncidentLight directLight;
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
@@ -116,7 +116,7 @@ IncidentLight directLight;
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
@@ -142,7 +142,7 @@ IncidentLight directLight;
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
diff --git a/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js b/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js
index 922f81154f6ce1..7d67054a52db1d 100644
--- a/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js
+++ b/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js
@@ -19,6 +19,7 @@ export default /* glsl */`
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
@@ -34,6 +35,7 @@ export default /* glsl */`
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
struct SpotLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
@@ -50,6 +52,7 @@ export default /* glsl */`
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
@@ -103,7 +106,7 @@ export default /* glsl */`
}
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
@@ -196,7 +199,7 @@ export default /* glsl */`
}
- return shadow;
+ return mix( 1.0, shadow, shadowIntensity );
}
@@ -271,7 +274,7 @@ export default /* glsl */`
}
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
@@ -316,7 +319,7 @@ export default /* glsl */`
}
- return shadow;
+ return mix( 1.0, shadow, shadowIntensity );
}
diff --git a/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js b/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js
index 6f2b23e8e93996..75911cdd018b82 100644
--- a/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js
+++ b/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js
@@ -15,6 +15,7 @@ export default /* glsl */`
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
@@ -28,6 +29,7 @@ export default /* glsl */`
#if NUM_SPOT_LIGHT_SHADOWS > 0
struct SpotLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
@@ -44,6 +46,7 @@ export default /* glsl */`
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
+ float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
diff --git a/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js b/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js
index 9c117f126c80cf..bf001d07428ce0 100644
--- a/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js
+++ b/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js
@@ -13,7 +13,7 @@ float getShadowMask() {
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
@@ -28,7 +28,7 @@ float getShadowMask() {
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
@@ -43,7 +43,7 @@ float getShadowMask() {
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
}
#pragma unroll_loop_end
diff --git a/src/renderers/shaders/UniformsLib.js b/src/renderers/shaders/UniformsLib.js
index e4003ed83ec968..6dab943b5eb675 100644
--- a/src/renderers/shaders/UniformsLib.js
+++ b/src/renderers/shaders/UniformsLib.js
@@ -130,6 +130,7 @@ const UniformsLib = {
} },
directionalLightShadows: { value: [], properties: {
+ shadowIntensity: 1,
shadowBias: {},
shadowNormalBias: {},
shadowRadius: {},
@@ -150,6 +151,7 @@ const UniformsLib = {
} },
spotLightShadows: { value: [], properties: {
+ shadowIntensity: 1,
shadowBias: {},
shadowNormalBias: {},
shadowRadius: {},
@@ -168,6 +170,7 @@ const UniformsLib = {
} },
pointLightShadows: { value: [], properties: {
+ shadowIntensity: 1,
shadowBias: {},
shadowNormalBias: {},
shadowRadius: {},
diff --git a/src/renderers/webgl/WebGLLights.js b/src/renderers/webgl/WebGLLights.js
index 34d2bdf8baf9bb..a8c08ea36ba855 100644
--- a/src/renderers/webgl/WebGLLights.js
+++ b/src/renderers/webgl/WebGLLights.js
@@ -99,6 +99,7 @@ function ShadowUniformsCache() {
case 'DirectionalLight':
uniforms = {
+ shadowIntensity: 1,
shadowBias: 0,
shadowNormalBias: 0,
shadowRadius: 1,
@@ -108,6 +109,7 @@ function ShadowUniformsCache() {
case 'SpotLight':
uniforms = {
+ shadowIntensity: 1,
shadowBias: 0,
shadowNormalBias: 0,
shadowRadius: 1,
@@ -117,6 +119,7 @@ function ShadowUniformsCache() {
case 'PointLight':
uniforms = {
+ shadowIntensity: 1,
shadowBias: 0,
shadowNormalBias: 0,
shadowRadius: 1,
@@ -266,6 +269,7 @@ function WebGLLights( extensions ) {
const shadowUniforms = shadowCache.get( light );
+ shadowUniforms.shadowIntensity = shadow.intensity;
shadowUniforms.shadowBias = shadow.bias;
shadowUniforms.shadowNormalBias = shadow.normalBias;
shadowUniforms.shadowRadius = shadow.radius;
@@ -319,6 +323,7 @@ function WebGLLights( extensions ) {
const shadowUniforms = shadowCache.get( light );
+ shadowUniforms.shadowIntensity = shadow.intensity;
shadowUniforms.shadowBias = shadow.bias;
shadowUniforms.shadowNormalBias = shadow.normalBias;
shadowUniforms.shadowRadius = shadow.radius;
@@ -360,6 +365,7 @@ function WebGLLights( extensions ) {
const shadowUniforms = shadowCache.get( light );
+ shadowUniforms.shadowIntensity = shadow.intensity;
shadowUniforms.shadowBias = shadow.bias;
shadowUniforms.shadowNormalBias = shadow.normalBias;
shadowUniforms.shadowRadius = shadow.radius;
From 0d0758e96fa1816dd2e97565defc42cc9f3c6685 Mon Sep 17 00:00:00 2001
From: Mugen87