Skip to content

Commit fb07657

Browse files
authored
fix: Support shadow.intensity parameter (#85)
* PCSS shader add support for `light.shadow.intensity` parameter
1 parent 73753d9 commit fb07657

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.storybook/stories/PCSS.stories.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const PcssStory = async () => {
3232
size: 25,
3333
focus: 0,
3434
samples: 10,
35+
intensity: 1,
3536
}
3637

3738
const folder = gui.addFolder('Settings')
@@ -42,6 +43,7 @@ export const PcssStory = async () => {
4243
folder.add(args, 'size', 1, 100, 1)
4344
folder.add(args, 'focus', 0, 2, 0.1)
4445
folder.add(args, 'samples', 1, 20, 1)
46+
folder.add(args, 'intensity', 0, 1, 0.1)
4547

4648
const { renderer, scene, camera, render } = Setup()
4749

@@ -62,6 +64,7 @@ export const PcssStory = async () => {
6264
light.shadow.mapSize.width = 1024
6365
light.shadow.mapSize.height = 1024
6466
light.shadow.camera.far = 20
67+
light.shadow.intensity = 1
6568

6669
scene.add(light)
6770

@@ -113,8 +116,10 @@ export const PcssStory = async () => {
113116
}
114117
})
115118

116-
const updatePCSS = (args: { enabled: boolean; size: number; focus: number; samples: number }) => {
117-
const { enabled, size, focus, samples } = args
119+
const updatePCSS = (args: { enabled: boolean; size: number; focus: number; samples: number; intensity: number }) => {
120+
const { enabled, size, focus, samples, intensity } = args
121+
122+
light.shadow.intensity = intensity
118123

119124
if (reset) {
120125
reset(renderer, scene, camera)

src/core/pcss.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const pcss = ({ focus = 0, size = 25, samples = 10 }: SoftShadowsProps =
151151
)
152152
.replace(
153153
'#if defined( SHADOWMAP_TYPE_PCF )',
154-
'\nreturn PCSS(shadowMap, shadowCoord);\n#if defined( SHADOWMAP_TYPE_PCF )'
154+
'\nreturn mix( 1.0, PCSS(shadowMap, shadowCoord), shadowIntensity );\n#if defined( SHADOWMAP_TYPE_PCF )'
155155
)
156156
return (gl: THREE.Renderer, scene: THREE.Scene, camera: THREE.Camera) => {
157157
THREE.ShaderChunk.shadowmap_pars_fragment = original

0 commit comments

Comments
 (0)