-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prepare the softness * Cleanup * Move creation of depth buffer into ParticlesMaterial * Set camera near/far * I have no idea what I'm doing * Simplify shader * Tone down fog a little * Disable logarithmic depth buffer, woops * Eh * ALMOST * ALMOST * SO CLOSE * Move drei to peerdeps * Fix * Add a standalone soft particles example * softness * Tweaks * Cleanup * Tweak * Eh * Switch Fog example to MultiplyBlending * Woops * Woops * Use window resolution for depth buffer * Use normal blending for fog * Remove full screen effects * Eh * Tweako * Fix lo-res switch * Cleanup * Fix typing * Tweak explosion * Tweak Fog some more * Tweak Fog some more * woop * Cleanup * Cleanup * Cleanup * Fix Simple example * Tweak shader some more * Scope main chunks * Add pp * Effects! * PP * Fix types * Tweak effects * Tweak examples and bloom * Tweaks * Tweak bloom * Tweak bloom some more * Tweak shader * WIP Tornado Example * Some debris * Debris -> Dust * Remove Tornado example, unrelated to this branch * Clean up shader in preparation for customizable soft particle functions * Further prep * softnessFunction * Move custom useDB/FBO implementations into example app * Use userland depthtexture * Fix explosion effect * Wrap examples in suspense * Start out own implementation * Cleanup * Cleanup * Fix dpr support * Cleanup * Cleanup * half resolution by default * Fix explosion effect * Remove useFBO * Update uniforms every frame * Cleanup * Changeset
- Loading branch information
Showing
19 changed files
with
445 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
"three-vfx": minor | ||
--- | ||
|
||
**New:** Soft Particles support! `<ParticlesMaterial>` now has new `softness`, `softnessFunction` and `depthTexture` props. | ||
|
||
```tsx | ||
export const SoftParticlesExample = () => { | ||
const depthBuffer = useDepthBuffer() | ||
|
||
return ( | ||
<VisualEffect> | ||
<MeshParticles> | ||
<planeGeometry args={[20, 20]} /> | ||
|
||
<ParticlesMaterial | ||
baseMaterial={MeshStandardMaterial} | ||
color="hotpink" | ||
billboard | ||
transparent | ||
depthWrite={false} | ||
softness={5} | ||
depthTexture={depthBuffer.depthTexture} | ||
/> | ||
|
||
<Emitter | ||
count={1} | ||
setup={(c) => { | ||
c.lifetime = Infinity | ||
}} | ||
/> | ||
</MeshParticles> | ||
</VisualEffect> | ||
) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { useFrame, useThree } from "@react-three/fiber" | ||
import { | ||
AdaptiveLuminancePass, | ||
BlendFunction, | ||
BloomEffect, | ||
EffectComposer, | ||
EffectPass, | ||
Pass, | ||
RenderPass, | ||
SelectiveBloomEffect, | ||
ToneMappingEffect | ||
} from "postprocessing" | ||
import { useEffect, useLayoutEffect, useMemo } from "react" | ||
import { HalfFloatType } from "three" | ||
|
||
const usePass = ( | ||
composer: EffectComposer, | ||
factory: () => Pass, | ||
deps: any[] = [] | ||
) => { | ||
useLayoutEffect(() => { | ||
const pass = factory() | ||
composer.addPass(pass) | ||
return () => composer.removePass(pass) | ||
}, [composer, ...deps]) | ||
} | ||
|
||
export const Rendering = () => { | ||
const { gl, scene, camera } = useThree() | ||
|
||
const composer = useMemo( | ||
() => new EffectComposer(gl, { frameBufferType: HalfFloatType }), | ||
[] | ||
) | ||
|
||
usePass(composer, () => new RenderPass(scene, camera), [scene, camera]) | ||
|
||
const bloomEffect = useMemo(() => { | ||
const effect = new SelectiveBloomEffect(scene, camera, { | ||
blendFunction: BlendFunction.ADD, | ||
mipmapBlur: true, | ||
luminanceThreshold: 0.7, | ||
luminanceSmoothing: 0.3, | ||
intensity: 4 | ||
} as any) | ||
effect.inverted = true | ||
return effect | ||
}, [scene, camera]) | ||
|
||
usePass(composer, () => new EffectPass(camera, bloomEffect), [ | ||
bloomEffect, | ||
camera | ||
]) | ||
|
||
useFrame(() => { | ||
composer.render() | ||
}, 1) | ||
|
||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useTexture } from "@react-three/drei" | ||
import { between, plusMinus, upTo } from "randomish" | ||
import { AdditiveBlending, DoubleSide, MeshStandardMaterial } from "three" | ||
import { | ||
Emitter, | ||
MeshParticles, | ||
ParticlesMaterial, | ||
Repeat, | ||
SpawnSetup, | ||
VisualEffect | ||
} from "three-vfx" | ||
|
||
export const DustExample = ({ intensity = 300 }) => { | ||
const texture = useTexture("/textures/particle.png") | ||
|
||
return ( | ||
<VisualEffect> | ||
<MeshParticles maxParticles={intensity} safetySize={0}> | ||
<planeGeometry /> | ||
|
||
<ParticlesMaterial | ||
baseMaterial={MeshStandardMaterial} | ||
map={texture} | ||
color="#aaa" | ||
blending={AdditiveBlending} | ||
depthTest={true} | ||
depthWrite={false} | ||
side={DoubleSide} | ||
/> | ||
|
||
<Emitter | ||
count={intensity} | ||
setup={(c) => { | ||
c.quaternion.random() | ||
c.position.set(plusMinus(30), plusMinus(30), plusMinus(30)) | ||
c.velocity.randomDirection().multiplyScalar(upTo(0.2)) | ||
c.lifetime = Infinity | ||
|
||
const scale = between(0.1, 0.2) | ||
c.scale[0].setScalar(scale) | ||
c.scale[1].setScalar(scale) | ||
c.alpha = [1, 1] | ||
}} | ||
/> | ||
</MeshParticles> | ||
</VisualEffect> | ||
) | ||
} |
Oops, something went wrong.
baf11be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
three-vfx – ./
three-vfx-examples.vercel.app
three-vfx-hmans.vercel.app
three-vfx-git-main-hmans.vercel.app