Skip to content

Commit

Permalink
feat: refactor usecore to new state context provider (#44)
Browse files Browse the repository at this point in the history
* chore: first tests regarding refactoring

* feat: made effect composer use useTresContext

* chore: refactored bloom effect; fixed watcher being called too often in outline effect

* chore: set bloom blend function to documented default

* feat: migrated glitch effect to use new state context provider

* chore: removed useCore.ts

* chore: added expose (pass, effect) to effects

* chore: removed problematic props in EffectComposer; made use of sizes from context provider

* chore: bumped versions of core and cientos to 3.0.x; reenabled components from cientos

* chore: made use of postprocessing defaults in effect composer

* chore: removed obsolete type castings

* chore: bumped package version

* chore: removed deprecated props of bloom effect

---------

Co-authored-by: Tino Koch <tino.koch@xpoli.eu>
  • Loading branch information
Tinoooo and Tino Koch authored Aug 18, 2023
1 parent 5725498 commit 9f920f1
Show file tree
Hide file tree
Showing 20 changed files with 621 additions and 4,374 deletions.
6 changes: 3 additions & 3 deletions docs/.vitepress/theme/components/BloomDemo.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<script setup lang="ts">
import { Color } from 'three'
import { reactive } from 'vue'
import { TresCanvas } from '@tresjs/core'
import { BasicShadowMap, NoToneMapping } from 'three'
import { BlendFunction } from 'postprocessing'
import { EffectComposer, Bloom } from '/@'
import { reactive } from 'vue'
const gl = {
clearColor: '#121212',
Expand All @@ -19,6 +18,7 @@ const bloomParams = reactive({
intensity: 8,
radius: 0.5,
disableRender: true,
blendFunction: BlendFunction.ADD,
})
</script>

Expand Down
18 changes: 8 additions & 10 deletions docs/guide/effects/bloom.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ import { EffectComposer, Bloom } from '@tresjs/post-processing'

## Props

| Prop | Description | Default |
| -------------------- | ---------------------------------------------------------------------------------------------------- | ------------------ |
| `intensity` | The intensity of the bloom effect. | `1` |
| `blurPass` | An efficient, incremental blur pass. | |
| `width` | The width of the render. | |
| `height` | The height of the render. | |
| `kernelSize` | The kernel size. | `KernelSize.LARGE` |
| `luminanceThreshold` | The luminance threshold. Raise this value to mask out darker elements in the scene. Range is [0, 1]. | `0.9` |
| `luminanceSmoothing` | Controls the smoothness of the luminance threshold. Range is [0, 1]. | `0.025` |
| `mipMapBlur` | Enables mip map blur. (UnrealBloom) | `false` |
| 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) |
| `intensity` | The intensity of the bloom effect. | `1` |
| `kernelSize` | The kernel size. | `KernelSize.LARGE` |
| `luminanceThreshold` | The luminance threshold. Raise this value to mask out darker elements in the scene. Range is [0, 1]. | `0.9` |
| `luminanceSmoothing` | Controls the smoothness of the luminance threshold. Range is [0, 1]. | `0.025` |
| `mipMapBlur` | Enables mip map blur. (UnrealBloom) | `false` |
25 changes: 13 additions & 12 deletions docs/guide/effects/glitch.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ import { EffectComposer, Glitch } from '@tresjs/post-processing'

## Props

| Prop | Description | Default |
| --------------------------- | ----------------------------------------------------------------------------------------- | --------------------- |
| `delay` | The minimum and maximum delay between glitch activations in seconds. | `[1.5, 3.5]` |
| `duration` | The minimum and maximum duration of a glitch in seconds. | `[0.6, 1.0]` |
| `strength` | The strength of weak and strong glitches. | `[0.3, 1.0]` |
| `mode` | The glitch mode. Can be DISABLED, SPORADIC, CONSTANT_MILD, or CONSTANT_WILD. | `GlitchMode.SPORADIC` |
| `active` | Turn the effect on and off. | `undefined` |
| `ratio` | The threshold for strong glitches. | `0.85` |
| `columns` | The scale of the blocky glitch columns. | `0.05` |
| `chromaticAberrationOffset` | A chromatic aberration offset. If provided, the glitch effect will influence this offset. | `undefined` |
| `peturbationMap` | A perturbation map. If none is provided, a noise texture will be created. | `undefined` |
| `dtSize` | The size of the generated noise map. Will be ignored if a perturbation map is provided. | `64` |
| Prop | Description | Default |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `blendFunction` | The blend function of this effect. This prop is not reactive. |  [BlendFunction.NORMAL](https://github.com/pmndrs/postprocessing/blob/3fbe7b770f826019933b1386d27ebc04315feb00/src/enums/BlendFunction.js#L36) |
| `delay` | The minimum and maximum delay between glitch activations in seconds. | `[1.5, 3.5]` |
| `duration` | The minimum and maximum duration of a glitch in seconds. | `[0.6, 1.0]` |
| `strength` | The strength of weak and strong glitches. | `[0.3, 1.0]` |
| `mode` | The glitch mode. Can be DISABLED, SPORADIC, CONSTANT_MILD, or CONSTANT_WILD. | `GlitchMode.SPORADIC` |
| `active` | Turn the effect on and off. | `undefined` |
| `ratio` | The threshold for strong glitches. | `0.85` |
| `columns` | The scale of the blocky glitch columns. | `0.05` |
| `chromaticAberrationOffset` | A chromatic aberration offset. If provided, the glitch effect will influence this offset. | `undefined` |
| `perturbationMap` | A perturbation map. If none is provided, a noise texture will be created. | `undefined` |
| `dtSize` | The size of the generated noise map. Will be ignored if a perturbation map is provided. This prop is not reactive. | `64` |
Loading

0 comments on commit 9f920f1

Please sign in to comment.