-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: update versions * feat: noise effect * chore: pass down props to effect * Update playground/src/pages/noise.vue Co-authored-by: Tino Koch <[email protected]> * chore: change playground example blendfunction to screen * chore: release v0.6.0-next.0 * docs: added noise docs * docs: lint NoiseDemo * chore: made order of effects alphabetic * feat: omit blendFunction for watchers --------- Co-authored-by: Tino Koch <[email protected]>
- Loading branch information
1 parent
e15c060
commit cdb9497
Showing
15 changed files
with
175 additions
and
14 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
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,34 @@ | ||
<script setup lang="ts"> | ||
import { TresCanvas } from '@tresjs/core' | ||
import { BasicShadowMap, SRGBColorSpace, NoToneMapping } from 'three' | ||
import { EffectComposer, Noise } from '@tresjs/post-processing' | ||
import { OrbitControls } from '@tresjs/cientos' | ||
import { BlendFunction } from 'postprocessing' | ||
import '@tresjs/leches/styles' | ||
const gl = { | ||
clearColor: '#82DBC5', | ||
shadows: true, | ||
alpha: false, | ||
shadowMapType: BasicShadowMap, | ||
outputColorSpace: SRGBColorSpace, | ||
toneMapping: NoToneMapping, | ||
} | ||
</script> | ||
|
||
<template> | ||
<TresCanvas v-bind="gl"> | ||
<TresPerspectiveCamera :position="[3, 3, 3]" /> | ||
<OrbitControls /> | ||
<TresGridHelper /> | ||
<TresAmbientLight :intensity="1" /> | ||
<Suspense> | ||
<EffectComposer :depth-buffer="true"> | ||
<Noise | ||
premultiply | ||
:blend-function="BlendFunction.SCREEN" | ||
/> | ||
</EffectComposer> | ||
</Suspense> | ||
</TresCanvas> | ||
</template> |
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,37 @@ | ||
# Noise | ||
|
||
<DocsDemo> | ||
<NoiseDemo /> | ||
</DocsDemo> | ||
|
||
Noise is an effect that adds Gaussian noise to the scene. This can be used to simulate a variety of effects, such as static on a TV or film grain. | ||
|
||
## Usage | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
import { BlendFunction } from 'postprocessing' | ||
import { EffectComposer, Bloom } from '@tresjs/post-processing' | ||
</script> | ||
<template> | ||
<EffectComposer> | ||
<Noise | ||
premultiply | ||
:blend-function="BlendFunction.SCREEN" | ||
/> | ||
</EffectComposer> | ||
</template> | ||
``` | ||
|
||
## Props | ||
|
||
| Prop | Description | Default | | ||
| -------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `blendFunction` | The blend function of this effect. This prop is not reactive. | [BlendFunction.SCREEN](https://github.com/pmndrs/postprocessing/blob/c3ce388be247916437a314f17748a75329d65df1/src/enums/BlendFunction.js#L40) | | ||
| `premultiply` | Indicates whether noise will be multiplied with the input colors prior to blending | `false` | | ||
|
||
|
||
## Further Reading | ||
see [postprocessing docs](https://pmndrs.github.io/postprocessing/public/docs/class/src/effects/NoiseEffect.js~NoiseEffect.html) |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@tresjs/post-processing", | ||
"type": "module", | ||
"version": "0.5.0", | ||
"version": "0.6.0-next.0", | ||
"packageManager": "[email protected]", | ||
"description": "Post-processing library for TresJS", | ||
"author": "Alvaro Saburido <[email protected]> (https://github.com/alvarosabu/)", | ||
|
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 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,49 @@ | ||
<script setup lang="ts"> | ||
import { TresCanvas } from '@tresjs/core' | ||
import { BasicShadowMap, SRGBColorSpace, NoToneMapping } from 'three' | ||
import { EffectComposer, Noise } from '@tresjs/post-processing' | ||
import { OrbitControls } from '@tresjs/cientos' | ||
import { TresLeches, useControls } from '@tresjs/leches' | ||
import { BlendFunction } from 'postprocessing' | ||
import '@tresjs/leches/styles' | ||
const gl = { | ||
clearColor: '#82DBC5', | ||
shadows: true, | ||
alpha: false, | ||
shadowMapType: BasicShadowMap, | ||
outputColorSpace: SRGBColorSpace, | ||
toneMapping: NoToneMapping, | ||
} | ||
const { value: premultiply } = useControls({ | ||
premultiply: true, | ||
}) | ||
const { value: blendFunction } = useControls({ | ||
blendFunction: { | ||
options: Object.keys(BlendFunction).map(key => ({ | ||
text: key, | ||
value: BlendFunction[key], | ||
})), | ||
value: BlendFunction.SCREEN, | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<TresLeches /> | ||
<TresCanvas v-bind="gl"> | ||
<TresPerspectiveCamera :position="[3, 3, 3]" /> | ||
<OrbitControls /> | ||
<TresGridHelper /> | ||
<TresAmbientLight :intensity="1" /> | ||
<Suspense> | ||
<EffectComposer :depth-buffer="true"> | ||
<Noise | ||
:premultiply="premultiply" | ||
:blend-function="blendFunction" | ||
/> | ||
</EffectComposer> | ||
</Suspense> | ||
</TresCanvas> | ||
</template> |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,30 @@ | ||
<script lang="ts" setup> | ||
import { BlendFunction, NoiseEffect } from 'postprocessing' | ||
import { useEffect } from '../composables/effect' | ||
import { makePropWatchersUsingAllProps } from '../../util/prop' | ||
import { omit } from '../../util/object' | ||
export interface NoiseProps { | ||
/** | ||
* Whether the noise should be multiplied with the input color. | ||
*/ | ||
premultiply?: boolean | ||
blendFunction?: BlendFunction | ||
} | ||
const props = withDefaults(defineProps<NoiseProps>(), { | ||
premultiply: false, | ||
blendFunction: BlendFunction.SCREEN, | ||
}) | ||
const { pass, effect } = useEffect(() => new NoiseEffect(props)) | ||
defineExpose({ pass, effect }) // to allow users to modify pass and effect via template ref | ||
makePropWatchersUsingAllProps( | ||
omit(props, ['blendFunction']), | ||
effect, | ||
() => new NoiseEffect(), | ||
) | ||
</script> | ||
|
||
<template></template> |
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
Large diffs are not rendered by default.
Oops, something went wrong.