Skip to content

Commit eb0d5fb

Browse files
authored
feat: Lensflare update (#231)
1 parent 9eb6982 commit eb0d5fb

File tree

3 files changed

+570
-161
lines changed

3 files changed

+570
-161
lines changed

.storybook/stories/LensFlare.stories.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { BackSide } from 'three'
55
import { Box, useTexture } from '@react-three/drei'
66

77
import { Setup } from '../Setup'
8-
import { EffectComposer, LensFlare, Vignette, Bloom } from '../../src'
8+
import { EffectComposer, LensFlare, Vignette, Bloom, BrightnessContrast } from '../../src'
99

1010
function SkyBox() {
1111
const texture = useTexture('digital_painting_golden_hour_sunset.jpg')
@@ -54,10 +54,12 @@ export const Primary: Story = {
5454

5555
<EffectComposer multisampling={0} disableNormalPass>
5656
<LensFlare {...args} />
57+
<BrightnessContrast contrast={0.2} />
58+
<Vignette />
5759
</EffectComposer>
5860
</>
5961
),
60-
args: {},
62+
args: { colorGain: new THREE.Color(56, 21, 9) },
6163
}
6264

6365
function DirtLensFlare(props) {
@@ -79,8 +81,10 @@ export const Secondary: Story = {
7981

8082
<EffectComposer multisampling={0} disableNormalPass>
8183
<DirtLensFlare {...args} />
84+
<BrightnessContrast contrast={0.2} />
85+
<Vignette />
8286
</EffectComposer>
8387
</>
8488
),
85-
args: { starBurst: true },
89+
args: { starBurst: true, colorGain: new THREE.Color(56, 21, 9) },
8690
}

docs/effects/lensflare.mdx

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,29 @@ Based on [ektogamat/R3F-Ultimate-Lens-Flare](https://github.com/ektogamat/R3F-Ul
1010
```jsx
1111
import { LensFlare } from '@react-three/postprocessing'
1212

13-
return (
14-
<LensFlare
15-
blendFunction={BlendFunction.Screen} // The blend function of this effect.
16-
enabled={true} // Boolean to enable/disable the effect.
17-
opacity={1.0} // The opacity for this effect. Default: 1.0
18-
starBurst={true} // Boolean to enable/disable the start burst effect. Can be disabled to improve performance.
19-
glareSize={0.96} // The glare size. Default: 0.2
20-
followMouse={false} // Set it to follow the mouse, ignoring the lens position. Default: false
21-
lensPosition={[0, 0.5, 0]} // The position of the lens flare in 3d space.
22-
starPoints={6} // The number of points for the star. Default: 6
23-
flareSize={0.01} // The flare side. Default 0.01
24-
flareSpeed={0.01} // The flare animation speed. Default 0.01
25-
flareShape={0.01} // Changes the appearance to anamorphic. Default 0.01
26-
animated={true} // Animated flare. Default: true
27-
anamorphic={false} //Set the appearance to full anamorphic. Default: false
28-
colorGain={new THREE.Color(70, 70, 70)} // Set the color gain for the lens flare. Must be a THREE.Color in RBG format.
29-
lensDirtTexture={'/lensDirtTexture.png'} // Texture to be used as color dirt for starburst effect.
30-
haloScale={0.5} // The halo scale. Default: 0.5
31-
secondaryGhosts={true} // Option to enable/disable secondary ghosts. Default: true.
32-
ghostScale={0.0} // Option to enable/disable secondary ghosts. Default: true.
33-
aditionalStreaks={true} // Option to enable/disable aditional streaks. Default: true.
34-
smoothTime={0.07} // The time that it takes to fade the occlusion. Default: 0.07
35-
/>
36-
)
13+
return <LensFlare />
3714
```
3815

39-
#### Ignoring occlusion on some objects
16+
## Ignoring occlusion on some objects
4017

4118
To disable the occlusion effect, simply add `userData={{ lensflare: 'no-occlusion' }}` to your object/mesh props.
4219

43-
#### Improving performance
20+
## Improving performance
4421

4522
Use bvh `<bvh><Scene></bvh>` to enhance the internal raycaster performance.
4623

47-
#### Limitations
24+
## Limitations
4825

4926
The Ultimate Lens Flare leverages the raycaster to examine the material type of objects and determine if they are `MeshTransmissionMaterial` or `MeshPhysicalMaterial`. It checks for the transmission parameter to identify glass-like materials. Therefore, for an object to behave like glass, its material should have either `transmission = 1` or `transparent = true` and `opacity = NUMBER`. The effect automatically interprets the opacity `NUMBER` value to determine the brightness of the flare.
5027

51-
#### Credits
28+
## Credits
5229

5330
- https://www.shadertoy.com/view/4sK3W3
5431
- https://www.shadertoy.com/view/4sX3Rs
5532
- https://www.shadertoy.com/view/dllSRX
5633
- https://www.shadertoy.com/view/Xlc3D2
5734
- https://www.shadertoy.com/view/XtKfRV
35+
36+
## Example
37+
38+
<Codesandbox id="5ydkm4" />

0 commit comments

Comments
 (0)