From fba8b58dc4e7d9bb380e0931e700b0723deb7f7c Mon Sep 17 00:00:00 2001 From: Damien Montastier Date: Sun, 30 Mar 2025 13:22:28 +0200 Subject: [PATCH 1/8] feat: FXAA (#197) * feat: add and init playground + doc fxaa * fix: doc and code adapation * modify doc, examples --- docs/.vitepress/config.ts | 1 + .../theme/components/pmdrs/FXAADemo.vue | 178 ++++++++++++++++++ docs/components.d.ts | 1 + docs/guide/pmndrs/fxaa.md | 75 ++++++++ playground/src/pages/postprocessing/fxaa.vue | 174 +++++++++++++++++ playground/src/router.ts | 1 + src/core/pmndrs/FXAAPmndrs.vue | 69 +++++++ src/core/pmndrs/index.ts | 3 + 8 files changed, 502 insertions(+) create mode 100644 docs/.vitepress/theme/components/pmdrs/FXAADemo.vue create mode 100644 docs/guide/pmndrs/fxaa.md create mode 100644 playground/src/pages/postprocessing/fxaa.vue create mode 100644 src/core/pmndrs/FXAAPmndrs.vue diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index e22b8786..2f51ec33 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -61,6 +61,7 @@ export default defineConfig({ { text: 'Hue & Saturation', link: '/guide/pmndrs/hue-saturation' }, { text: 'Lens Distortion', link: '/guide/pmndrs/lens-distortion' }, { text: 'Grid', link: '/guide/pmndrs/grid' }, + { text: 'FXAA', link: '/guide/pmndrs/fxaa' }, { text: 'Kuwahara', link: '/guide/pmndrs/kuwahara' }, { text: 'Color Average', link: '/guide/pmndrs/color-average' }, { text: 'Depth of Field', link: '/guide/pmndrs/depth-of-field' }, diff --git a/docs/.vitepress/theme/components/pmdrs/FXAADemo.vue b/docs/.vitepress/theme/components/pmdrs/FXAADemo.vue new file mode 100644 index 00000000..f064d54b --- /dev/null +++ b/docs/.vitepress/theme/components/pmdrs/FXAADemo.vue @@ -0,0 +1,178 @@ + + + + + diff --git a/docs/components.d.ts b/docs/components.d.ts index 37d19677..a6c1d911 100644 --- a/docs/components.d.ts +++ b/docs/components.d.ts @@ -21,6 +21,7 @@ declare module 'vue' { DotScreenDemo: typeof import('./.vitepress/theme/components/pmdrs/DotScreenDemo.vue')['default'] Ducky: typeof import('./.vitepress/theme/components/Ducky.vue')['default'] FishEyeDemo: typeof import('./.vitepress/theme/components/pmdrs/FishEyeDemo.vue')['default'] + FXAADemo: typeof import('./.vitepress/theme/components/pmdrs/FXAADemo.vue')['default'] GlitchDemo: typeof import('./.vitepress/theme/components/pmdrs/GlitchDemo.vue')['default'] GlitchThreeDemo: typeof import('./.vitepress/theme/components/three/GlitchThreeDemo.vue')['default'] GodRaysDemo: typeof import('./.vitepress/theme/components/pmdrs/GodRaysDemo.vue')['default'] diff --git a/docs/guide/pmndrs/fxaa.md b/docs/guide/pmndrs/fxaa.md new file mode 100644 index 00000000..eeabb732 --- /dev/null +++ b/docs/guide/pmndrs/fxaa.md @@ -0,0 +1,75 @@ +# FXAA + + + + + +
+ Demo code + + <<< @/.vitepress/theme/components/pmdrs/FXAADemo.vue{0} +
+ +The `FXAAEffect` effect is part of the [`postprocessing`](https://pmndrs.github.io/postprocessing/public/docs/class/src/effects/FXAAEffect.js~FXAAEffect.html) package. +FXAA offers a performance-optimized anti-aliasing solution that smooths jagged edges while maintaining excellent performance. However, its quality may be modest at times, occasionally resulting in a slightly blurred appearance. + + + @Miamiamia0103 illustration + + Illustration credit @Miamiamia0103 + + + +## Usage + +The `` component is easy to use and provides customizable options to suit different visual styles. + +:::info +When using the `` pipeline, enabling native antialiasing with the [`antialias`](https://docs.tresjs.org/api/tres-canvas.html#props) props on `` is unnecessary. +::: + +```vue{2,12-14,23-27} + + + +``` + +## Props + +| Prop | Description | Default | +| ------------- | ------------------------------------------------------------------- | --------------------------- | +| blendFunction | Defines how the effect blends with the original scene. See the [`BlendFunction`](https://pmndrs.github.io/postprocessing/public/docs/variable/index.html#static-variable-BlendFunction) options. | `BlendFunction.SRC` | +| opacity | The opacity of the effect. | `1` | +| samples | The maximum amount of edge detection samples. | `12` | +| minEdgeThreshold | The minimum edge detection threshold.
Range: `[0.0, 1.0]`. | `0.0312` | +| maxEdgeThreshold | The maximum edge detection threshold.
Range: `[0.0, 1.0]`. | `0.125` | +| subpixelQuality | The subpixel blend quality. Range: `[0.0, 1.0]`. | `0.75` | + +## Further Reading +For more details, see the [FXAAEffect documentation](https://pmndrs.github.io/postprocessing/public/docs/class/src/effects/FXAAEffect.js~FXAAEffect.html) diff --git a/playground/src/pages/postprocessing/fxaa.vue b/playground/src/pages/postprocessing/fxaa.vue new file mode 100644 index 00000000..adf0bf37 --- /dev/null +++ b/playground/src/pages/postprocessing/fxaa.vue @@ -0,0 +1,174 @@ + + + + + diff --git a/playground/src/router.ts b/playground/src/router.ts index 3bed8b56..6bfb96bf 100644 --- a/playground/src/router.ts +++ b/playground/src/router.ts @@ -52,6 +52,7 @@ export const postProcessingRoutes = [ makeRoute('Scanline', '📽️', false), makeRoute('Color Depth', '🔳', false), makeRoute('Grid', '#️⃣', false), + makeRoute('FXAA', '📐', false), makeRoute('Shock Wave', '🌊', false), makeRoute('Brightness Contrast', '🔆', false), makeRoute('Vignette', '🕶️', false), diff --git a/src/core/pmndrs/FXAAPmndrs.vue b/src/core/pmndrs/FXAAPmndrs.vue new file mode 100644 index 00000000..b2fdc9dc --- /dev/null +++ b/src/core/pmndrs/FXAAPmndrs.vue @@ -0,0 +1,69 @@ + diff --git a/src/core/pmndrs/index.ts b/src/core/pmndrs/index.ts index 633fedd0..54819b37 100644 --- a/src/core/pmndrs/index.ts +++ b/src/core/pmndrs/index.ts @@ -28,6 +28,7 @@ import ColorDepthPmndrs, { type ColorDepthPmndrsProps } from './ColorDepthPmndrs import GridPmndrs, { type GridPmndrsProps } from './GridPmndrs.vue' import FishEyePmndrs, { type FishEyePmndrsProps } from './FishEyePmndrs.vue' import BrightnessContrastPmndrs, { type BrightnessContrastPmndrsProps } from './BrightnessContrastPmndrs.vue' +import FXAAPmndrs, { type FXAAPmndrsProps } from './FXAAPmndrs.vue' export { BloomPmndrs, @@ -58,6 +59,7 @@ export { GridPmndrs, FishEyePmndrs, BrightnessContrastPmndrs, + FXAAPmndrs, BloomPmndrsProps, DepthOfFieldPmndrsProps, EffectComposerPmndrsProps, @@ -85,4 +87,5 @@ export { GridPmndrsProps, FishEyePmndrsProps, BrightnessContrastPmndrsProps, + FXAAPmndrsProps, } From 0a89733d567b6502a0fef38bda8432ea66b2fb76 Mon Sep 17 00:00:00 2001 From: Damien Montastier Date: Sun, 30 Mar 2025 20:17:13 +0200 Subject: [PATCH 2/8] feat: SMAA (#199) * init smaa effect source * ad doc and modify source effect * dix: add commentary for props * added workaround for type issue * updated debug mode handling and improve type safety --------- Co-authored-by: Tino Koch <> --- docs/.vitepress/config.ts | 1 + .../theme/components/pmdrs/SMAADemo.vue | 183 ++++++++++++++++++ docs/components.d.ts | 1 + docs/guide/pmndrs/smaa.md | 72 +++++++ playground/src/pages/postprocessing/smaa.vue | 180 +++++++++++++++++ playground/src/router.ts | 1 + src/core/pmndrs/SMAAPmndrs.vue | 164 ++++++++++++++++ src/core/pmndrs/index.ts | 3 + 8 files changed, 605 insertions(+) create mode 100644 docs/.vitepress/theme/components/pmdrs/SMAADemo.vue create mode 100644 docs/guide/pmndrs/smaa.md create mode 100644 playground/src/pages/postprocessing/smaa.vue create mode 100644 src/core/pmndrs/SMAAPmndrs.vue diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 2f51ec33..3689f806 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -62,6 +62,7 @@ export default defineConfig({ { text: 'Lens Distortion', link: '/guide/pmndrs/lens-distortion' }, { text: 'Grid', link: '/guide/pmndrs/grid' }, { text: 'FXAA', link: '/guide/pmndrs/fxaa' }, + { text: 'SMAA', link: '/guide/pmndrs/smaa' }, { text: 'Kuwahara', link: '/guide/pmndrs/kuwahara' }, { text: 'Color Average', link: '/guide/pmndrs/color-average' }, { text: 'Depth of Field', link: '/guide/pmndrs/depth-of-field' }, diff --git a/docs/.vitepress/theme/components/pmdrs/SMAADemo.vue b/docs/.vitepress/theme/components/pmdrs/SMAADemo.vue new file mode 100644 index 00000000..24a4491d --- /dev/null +++ b/docs/.vitepress/theme/components/pmdrs/SMAADemo.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/docs/components.d.ts b/docs/components.d.ts index a6c1d911..680367d8 100644 --- a/docs/components.d.ts +++ b/docs/components.d.ts @@ -40,6 +40,7 @@ declare module 'vue' { ScanlineDemo: typeof import('./.vitepress/theme/components/pmdrs/ScanlineDemo.vue')['default'] SepiaDemo: typeof import('./.vitepress/theme/components/pmdrs/SepiaDemo.vue')['default'] ShockWaveDemo: typeof import('./.vitepress/theme/components/pmdrs/ShockWaveDemo.vue')['default'] + SMAADemo: typeof import('./.vitepress/theme/components/pmdrs/SMAADemo.vue')['default'] SMAAThreeDemo: typeof import('./.vitepress/theme/components/three/SMAAThreeDemo.vue')['default'] TiltShiftDemo: typeof import('./.vitepress/theme/components/pmdrs/TiltShiftDemo.vue')['default'] ToneMappingDemo: typeof import('./.vitepress/theme/components/pmdrs/ToneMappingDemo.vue')['default'] diff --git a/docs/guide/pmndrs/smaa.md b/docs/guide/pmndrs/smaa.md new file mode 100644 index 00000000..38a38215 --- /dev/null +++ b/docs/guide/pmndrs/smaa.md @@ -0,0 +1,72 @@ +# SMAA + + + + + +
+ Demo code + + <<< @/.vitepress/theme/components/pmdrs/SMAADemo.vue{0} +
+ +The `SMAAEffect` effect is part of the [`postprocessing`](https://pmndrs.github.io/postprocessing/public/docs/class/src/effects/SMAAEffect.js~SMAAEffect.html) package. **SMAA** (Subpixel Morphological Antialiasing) is a post-processing antialiasing technique that uses look-up tables to detect edges accurately, preserving texture details while minimizing false positives. + +:::info +**SMAA** generally provides superior visual quality compared to [FXAA](/guide/pmndrs/fxaa), though it is slightly less performant. Note that **SMAA** is distinct from **MSAA**. +::: + +## Usage + +The `` component is easy to use and provides customizable options to suit different visual styles. + +:::info +When using the `` pipeline, enabling native antialiasing with the [`antialias`](https://docs.tresjs.org/api/tres-canvas.html#props) props on `` is unnecessary. +::: + +```vue{2-3,13-15,24-28} + + + +``` + +## Props + +| Prop | Description | Default | +| ------------- | ------------------------------------------------------------------- | --------------------------- | +| blendFunction | Defines how the effect blends with the original scene. See the [`BlendFunction`](https://pmndrs.github.io/postprocessing/public/docs/variable/index.html#static-variable-BlendFunction) options. | `BlendFunction.SRC` | +| opacity | The opacity of the effect. | `1` | +| preset | Define the quality and performance trade-offs. See the [`SMAAPreset`](https://pmndrs.github.io/postprocessing/public/docs/variable/index.html#static-variable-SMAAPreset) options. | `SMAAPreset.MEDIUM` | +| edgeDetectionMode | Define the edge detection modes. See the [`EdgeDetectionMode`](https://pmndrs.github.io/postprocessing/public/docs/variable/index.html#static-variable-EdgeDetectionMode) options. | `EdgeDetectionMode.COLOR` | +| predicationMode | Define the edge detection modes. See the [`PredicationMode`](https://pmndrs.github.io/postprocessing/public/docs/variable/index.html#static-variable-PredicationMode) options. | `PredicationMode.DISABLED` | +| debug | Define the debug mode.
Options:
- `0` : OFF
- `1` : EDGES
- `2` : WEIGHTS | `0` (OFF) | + +## Further Reading +For more details, see the [SMAAEffect documentation](https://pmndrs.github.io/postprocessing/public/docs/class/src/effects/SMAAEffect.js~SMAAEffect.html) diff --git a/playground/src/pages/postprocessing/smaa.vue b/playground/src/pages/postprocessing/smaa.vue new file mode 100644 index 00000000..8bcbdf14 --- /dev/null +++ b/playground/src/pages/postprocessing/smaa.vue @@ -0,0 +1,180 @@ + + + + + diff --git a/playground/src/router.ts b/playground/src/router.ts index 6bfb96bf..adf6eda2 100644 --- a/playground/src/router.ts +++ b/playground/src/router.ts @@ -52,6 +52,7 @@ export const postProcessingRoutes = [ makeRoute('Scanline', '📽️', false), makeRoute('Color Depth', '🔳', false), makeRoute('Grid', '#️⃣', false), + makeRoute('SMAA', '📐', false), makeRoute('FXAA', '📐', false), makeRoute('Shock Wave', '🌊', false), makeRoute('Brightness Contrast', '🔆', false), diff --git a/src/core/pmndrs/SMAAPmndrs.vue b/src/core/pmndrs/SMAAPmndrs.vue new file mode 100644 index 00000000..ab66e70b --- /dev/null +++ b/src/core/pmndrs/SMAAPmndrs.vue @@ -0,0 +1,164 @@ + + + diff --git a/src/core/pmndrs/index.ts b/src/core/pmndrs/index.ts index 54819b37..b6da7b84 100644 --- a/src/core/pmndrs/index.ts +++ b/src/core/pmndrs/index.ts @@ -28,6 +28,7 @@ import ColorDepthPmndrs, { type ColorDepthPmndrsProps } from './ColorDepthPmndrs import GridPmndrs, { type GridPmndrsProps } from './GridPmndrs.vue' import FishEyePmndrs, { type FishEyePmndrsProps } from './FishEyePmndrs.vue' import BrightnessContrastPmndrs, { type BrightnessContrastPmndrsProps } from './BrightnessContrastPmndrs.vue' +import SMAAPmndrs, { type SMAAPmndrsProps } from './SMAAPmndrs.vue' import FXAAPmndrs, { type FXAAPmndrsProps } from './FXAAPmndrs.vue' export { @@ -59,6 +60,7 @@ export { GridPmndrs, FishEyePmndrs, BrightnessContrastPmndrs, + SMAAPmndrs, FXAAPmndrs, BloomPmndrsProps, DepthOfFieldPmndrsProps, @@ -87,5 +89,6 @@ export { GridPmndrsProps, FishEyePmndrsProps, BrightnessContrastPmndrsProps, + SMAAPmndrsProps, FXAAPmndrsProps, } From c5dba7c615f7dc7d985658193ca2794a329b122d Mon Sep 17 00:00:00 2001 From: Damien Montastier Date: Mon, 7 Apr 2025 20:30:09 +0200 Subject: [PATCH 3/8] feat: ASCII (#200) * feat: init ascii source effect * add asciiTexture props * final effect source code * add doc and modify source effect * update pnpm lock file --------- Co-authored-by: Tino Koch <> --- docs/.vitepress/config.ts | 1 + .../theme/components/pmdrs/ASCIIDemo.vue | 96 +++++++++++++ docs/components.d.ts | 1 + docs/guide/pmndrs/ascii.md | 71 ++++++++++ package.json | 2 +- playground/src/pages/postprocessing/ascii.vue | 79 +++++++++++ playground/src/router.ts | 1 + pnpm-lock.yaml | 12 +- src/core/pmndrs/ASCIIPmndrs.vue | 128 ++++++++++++++++++ src/core/pmndrs/index.ts | 3 + 10 files changed, 387 insertions(+), 7 deletions(-) create mode 100644 docs/.vitepress/theme/components/pmdrs/ASCIIDemo.vue create mode 100644 docs/guide/pmndrs/ascii.md create mode 100644 playground/src/pages/postprocessing/ascii.vue create mode 100644 src/core/pmndrs/ASCIIPmndrs.vue diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 3689f806..daed9210 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -61,6 +61,7 @@ export default defineConfig({ { text: 'Hue & Saturation', link: '/guide/pmndrs/hue-saturation' }, { text: 'Lens Distortion', link: '/guide/pmndrs/lens-distortion' }, { text: 'Grid', link: '/guide/pmndrs/grid' }, + { text: 'ASCII', link: '/guide/pmndrs/ascii' }, { text: 'FXAA', link: '/guide/pmndrs/fxaa' }, { text: 'SMAA', link: '/guide/pmndrs/smaa' }, { text: 'Kuwahara', link: '/guide/pmndrs/kuwahara' }, diff --git a/docs/.vitepress/theme/components/pmdrs/ASCIIDemo.vue b/docs/.vitepress/theme/components/pmdrs/ASCIIDemo.vue new file mode 100644 index 00000000..ef9239a9 --- /dev/null +++ b/docs/.vitepress/theme/components/pmdrs/ASCIIDemo.vue @@ -0,0 +1,96 @@ + + + diff --git a/docs/components.d.ts b/docs/components.d.ts index 680367d8..4f521f37 100644 --- a/docs/components.d.ts +++ b/docs/components.d.ts @@ -7,6 +7,7 @@ export {} /* prettier-ignore */ declare module 'vue' { export interface GlobalComponents { + ASCIIDemo: typeof import('./.vitepress/theme/components/pmdrs/ASCIIDemo.vue')['default'] BarrelBlurDemo: typeof import('./.vitepress/theme/components/pmdrs/BarrelBlurDemo.vue')['default'] BlenderCube: typeof import('./.vitepress/theme/components/BlenderCube.vue')['default'] BloomDemo: typeof import('./.vitepress/theme/components/pmdrs/BloomDemo.vue')['default'] diff --git a/docs/guide/pmndrs/ascii.md b/docs/guide/pmndrs/ascii.md new file mode 100644 index 00000000..b33748c5 --- /dev/null +++ b/docs/guide/pmndrs/ascii.md @@ -0,0 +1,71 @@ +# ASCII + + + + + +
+ Demo code + + <<< @/.vitepress/theme/components/pmdrs/ASCIIDemo.vue{0} +
+ +The `ASCIIEffect` effect is part of the [`postprocessing`](https://pmndrs.github.io/postprocessing/public/docs/class/src/effects/ASCIIEffect.js~ASCIIEffect.html) package. +This effect transforms the visual output into a grid of ASCII characters, offering a unique and artistic way to display 3D content. The ASCII characters used can be customized, allowing for a wide range of creative possibilities. + +## Usage + +The `` component is straightforward to integrate and offers a variety of customizable properties, allowing you to adapt it to diverse artistic and visual requirements. + +```vue{2,12-17,29-33} + + + +``` + +## Props + +| Prop | Description | Default | +| -------------- | ----------------------------------------------------------------------------------------------- | --------------------------- | +| blendFunction | Defines how the effect blends with the original scene. See the [`BlendFunction`](https://pmndrs.github.io/postprocessing/public/docs/variable/index.html#static-variable-BlendFunction) options. | `BlendFunction.NORMAL` | +| opacity | The opacity of the effect. | `1.0` | +| cellSize | The size of the ASCII grid cells. | `16` | +| inverted | Controls whether the effect should be inverted. | `false` | +| color | The color of the effect. Can be a [`Color`](https://threejs.org/docs/#api/en/math/Color), `string`, `number`, or `null`. If set to `null`, the colors of the scene will be used. | `null` | +| useSceneColor | Controls whether the effect should use the scene color. If `true`, overrides the `color` prop. | `false` | +| asciiTexture | Options for creating an ASCIITexture instance. | See the [`ASCIITexture`](https://pmndrs.github.io/postprocessing/public/docs/class/src/textures/ASCIITexture.js~ASCIITexture.html) documentation. | + +## Further Reading +For more details, see the [ASCIIEffect documentation](https://pmndrs.github.io/postprocessing/public/docs/class/src/effects/ASCIIEffect.js~ASCIIEffect.html) diff --git a/package.json b/package.json index 35cb1081..12990611 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ }, "dependencies": { "@vueuse/core": "^12.5.0", - "postprocessing": "^6.36.6" + "postprocessing": "^6.37.2" }, "devDependencies": { "@release-it/conventional-changelog": "^10.0.0", diff --git a/playground/src/pages/postprocessing/ascii.vue b/playground/src/pages/postprocessing/ascii.vue new file mode 100644 index 00000000..c334ab89 --- /dev/null +++ b/playground/src/pages/postprocessing/ascii.vue @@ -0,0 +1,79 @@ + + + diff --git a/playground/src/router.ts b/playground/src/router.ts index adf6eda2..696e1e76 100644 --- a/playground/src/router.ts +++ b/playground/src/router.ts @@ -52,6 +52,7 @@ export const postProcessingRoutes = [ makeRoute('Scanline', '📽️', false), makeRoute('Color Depth', '🔳', false), makeRoute('Grid', '#️⃣', false), + makeRoute('ASCII', '🔡', false), makeRoute('SMAA', '📐', false), makeRoute('FXAA', '📐', false), makeRoute('Shock Wave', '🌊', false), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 26e1b16b..f730fc7e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: ^12.5.0 version: 12.5.0(typescript@5.7.3) postprocessing: - specifier: ^6.36.6 - version: 6.36.6(three@0.173.0) + specifier: ^6.37.2 + version: 6.37.2(three@0.173.0) devDependencies: '@release-it/conventional-changelog': specifier: ^10.0.0 @@ -3565,10 +3565,10 @@ packages: resolution: {integrity: sha512-6oz2beyjc5VMn/KV1pPw8fliQkhBXrVn1Z3TVyqZxU8kZpzEKhBdmCFqI6ZbmGtamQvQGuU1sgPTk8ZrXDD7jQ==} engines: {node: ^10 || ^12 || >=14} - postprocessing@6.36.6: - resolution: {integrity: sha512-mjJjoXbC97XMV6iQVhOZYNjD5X93o3+/zpYm9oRmsyjP3LjfwedT8PgusECTk+s5DZeZoJ8vA9htdWuH8JH+mQ==} + postprocessing@6.37.2: + resolution: {integrity: sha512-Xm3n1Usgk2eBkufb1ssYDNGb3EXmV2wdQQIRGAWD9yppOYwsHpb8/w/+Opvnx6uEOFyt3US1dFbET5DTSyrRiA==} peerDependencies: - three: '>= 0.157.0 < 0.173.0' + three: '>= 0.157.0 < 0.176.0' potpack@1.0.2: resolution: {integrity: sha512-choctRBIV9EMT9WGAZHn3V7t0Z2pMQyl0EZE6pFc/6ml3ssw7Dlf/oAOvFwjm1HVsqfQN8GfeFyJ+d8tRzqueQ==} @@ -8373,7 +8373,7 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 - postprocessing@6.36.6(three@0.173.0): + postprocessing@6.37.2(three@0.173.0): dependencies: three: 0.173.0 diff --git a/src/core/pmndrs/ASCIIPmndrs.vue b/src/core/pmndrs/ASCIIPmndrs.vue new file mode 100644 index 00000000..755fab40 --- /dev/null +++ b/src/core/pmndrs/ASCIIPmndrs.vue @@ -0,0 +1,128 @@ + diff --git a/src/core/pmndrs/index.ts b/src/core/pmndrs/index.ts index b6da7b84..0ad9e9f3 100644 --- a/src/core/pmndrs/index.ts +++ b/src/core/pmndrs/index.ts @@ -30,6 +30,7 @@ import FishEyePmndrs, { type FishEyePmndrsProps } from './FishEyePmndrs.vue' import BrightnessContrastPmndrs, { type BrightnessContrastPmndrsProps } from './BrightnessContrastPmndrs.vue' import SMAAPmndrs, { type SMAAPmndrsProps } from './SMAAPmndrs.vue' import FXAAPmndrs, { type FXAAPmndrsProps } from './FXAAPmndrs.vue' +import ASCIIPmndrs, { type ASCIIPmndrsProps } from './ASCIIPmndrs.vue' export { BloomPmndrs, @@ -62,6 +63,7 @@ export { BrightnessContrastPmndrs, SMAAPmndrs, FXAAPmndrs, + ASCIIPmndrs, BloomPmndrsProps, DepthOfFieldPmndrsProps, EffectComposerPmndrsProps, @@ -91,4 +93,5 @@ export { BrightnessContrastPmndrsProps, SMAAPmndrsProps, FXAAPmndrsProps, + ASCIIPmndrsProps, } From 07a9ff51dfb142eb0386f52471fb5905d900754f Mon Sep 17 00:00:00 2001 From: Damien Montastier Date: Mon, 7 Apr 2025 21:52:36 +0200 Subject: [PATCH 4/8] feat: texture (#202) * feat: add texture effect (demo, source code) * clean demos --------- Co-authored-by: Tino Koch <> --- docs/.vitepress/config.ts | 1 + .../theme/components/pmdrs/TextureDemo.vue | 121 ++++++++++++++++++ docs/components.d.ts | 1 + docs/guide/pmndrs/texture.md | 85 ++++++++++++ .../src/pages/postprocessing/texture.vue | 102 +++++++++++++++ playground/src/router.ts | 1 + src/core/pmndrs/TexturePmndrs.vue | 57 +++++++++ src/core/pmndrs/index.ts | 3 + 8 files changed, 371 insertions(+) create mode 100644 docs/.vitepress/theme/components/pmdrs/TextureDemo.vue create mode 100644 docs/guide/pmndrs/texture.md create mode 100644 playground/src/pages/postprocessing/texture.vue create mode 100644 src/core/pmndrs/TexturePmndrs.vue diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index daed9210..72deebef 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -61,6 +61,7 @@ export default defineConfig({ { text: 'Hue & Saturation', link: '/guide/pmndrs/hue-saturation' }, { text: 'Lens Distortion', link: '/guide/pmndrs/lens-distortion' }, { text: 'Grid', link: '/guide/pmndrs/grid' }, + { text: 'Texture', link: '/guide/pmndrs/texture' }, { text: 'ASCII', link: '/guide/pmndrs/ascii' }, { text: 'FXAA', link: '/guide/pmndrs/fxaa' }, { text: 'SMAA', link: '/guide/pmndrs/smaa' }, diff --git a/docs/.vitepress/theme/components/pmdrs/TextureDemo.vue b/docs/.vitepress/theme/components/pmdrs/TextureDemo.vue new file mode 100644 index 00000000..bdaf5a3a --- /dev/null +++ b/docs/.vitepress/theme/components/pmdrs/TextureDemo.vue @@ -0,0 +1,121 @@ + + + diff --git a/docs/components.d.ts b/docs/components.d.ts index 4f521f37..29cb3605 100644 --- a/docs/components.d.ts +++ b/docs/components.d.ts @@ -43,6 +43,7 @@ declare module 'vue' { ShockWaveDemo: typeof import('./.vitepress/theme/components/pmdrs/ShockWaveDemo.vue')['default'] SMAADemo: typeof import('./.vitepress/theme/components/pmdrs/SMAADemo.vue')['default'] SMAAThreeDemo: typeof import('./.vitepress/theme/components/three/SMAAThreeDemo.vue')['default'] + TextureDemo: typeof import('./.vitepress/theme/components/pmdrs/TextureDemo.vue')['default'] TiltShiftDemo: typeof import('./.vitepress/theme/components/pmdrs/TiltShiftDemo.vue')['default'] ToneMappingDemo: typeof import('./.vitepress/theme/components/pmdrs/ToneMappingDemo.vue')['default'] UnrealBloomThreeDemo: typeof import('./.vitepress/theme/components/three/UnrealBloomThreeDemo.vue')['default'] diff --git a/docs/guide/pmndrs/texture.md b/docs/guide/pmndrs/texture.md new file mode 100644 index 00000000..5172c98f --- /dev/null +++ b/docs/guide/pmndrs/texture.md @@ -0,0 +1,85 @@ +# Texture + + + + + +
+ Demo code + + <<< @/.vitepress/theme/components/pmdrs/TextureDemo.vue{0} +
+ +The `TextureEffect` component is part of the [`postprocessing`](https://pmndrs.github.io/postprocessing/public/docs/class/src/effects/TextureEffect.js~TextureEffect.html) package. +It allows rendering a texture with customizable options to create various visual effects. + +## Usage + +The `` component is easy to use and provides customizable options to suit different visual styles. + +:::info +This component is designed to work with a provided texture and **does not** include built-in functionality to modify the texture itself.

+If you need to adjust properties such as **rotation**, **repeat**, or **other attributes**, you should modify them directly the texture *(See usage example below)* that you pass to the `` component. +::: + +```vue{2,16-20,41-45} + + + +``` + +## Props + +| Prop | Description | Default | +| ------------- | ----------------------------------------------------------------------------------------------- | --------------------------- | +| blendFunction | Defines how the effect blends with the original scene. See the [`BlendFunction`](https://pmndrs.github.io/postprocessing/public/docs/variable/index.html#static-variable-BlendFunction) options. | `BlendFunction.NORMAL` | +| texture | The texture used for the effect. See the [`Texture`](https://threejs.org/docs/#api/en/textures/Texture) documentation | `null` | +| opacity | The opacity of the texture. | `1.0` | + +## Further Reading + +For more details, see the [TextureEffect documentation](https://pmndrs.github.io/postprocessing/public/docs/class/src/effects/TextureEffect.js~TextureEffect.html). diff --git a/playground/src/pages/postprocessing/texture.vue b/playground/src/pages/postprocessing/texture.vue new file mode 100644 index 00000000..f53ec165 --- /dev/null +++ b/playground/src/pages/postprocessing/texture.vue @@ -0,0 +1,102 @@ + + + diff --git a/playground/src/router.ts b/playground/src/router.ts index 696e1e76..4fb9e614 100644 --- a/playground/src/router.ts +++ b/playground/src/router.ts @@ -52,6 +52,7 @@ export const postProcessingRoutes = [ makeRoute('Scanline', '📽️', false), makeRoute('Color Depth', '🔳', false), makeRoute('Grid', '#️⃣', false), + makeRoute('Texture', '🧩', false), makeRoute('ASCII', '🔡', false), makeRoute('SMAA', '📐', false), makeRoute('FXAA', '📐', false), diff --git a/src/core/pmndrs/TexturePmndrs.vue b/src/core/pmndrs/TexturePmndrs.vue new file mode 100644 index 00000000..4a3aa614 --- /dev/null +++ b/src/core/pmndrs/TexturePmndrs.vue @@ -0,0 +1,57 @@ + diff --git a/src/core/pmndrs/index.ts b/src/core/pmndrs/index.ts index 0ad9e9f3..99ff091a 100644 --- a/src/core/pmndrs/index.ts +++ b/src/core/pmndrs/index.ts @@ -30,6 +30,7 @@ import FishEyePmndrs, { type FishEyePmndrsProps } from './FishEyePmndrs.vue' import BrightnessContrastPmndrs, { type BrightnessContrastPmndrsProps } from './BrightnessContrastPmndrs.vue' import SMAAPmndrs, { type SMAAPmndrsProps } from './SMAAPmndrs.vue' import FXAAPmndrs, { type FXAAPmndrsProps } from './FXAAPmndrs.vue' +import TexturePmndrs, { type TexturePmndrsProps } from './TexturePmndrs.vue' import ASCIIPmndrs, { type ASCIIPmndrsProps } from './ASCIIPmndrs.vue' export { @@ -63,6 +64,7 @@ export { BrightnessContrastPmndrs, SMAAPmndrs, FXAAPmndrs, + TexturePmndrs, ASCIIPmndrs, BloomPmndrsProps, DepthOfFieldPmndrsProps, @@ -93,5 +95,6 @@ export { BrightnessContrastPmndrsProps, SMAAPmndrsProps, FXAAPmndrsProps, + TexturePmndrsProps, ASCIIPmndrsProps, } From aaa1626b1377bd8fda6cdc59ea015306db18903b Mon Sep 17 00:00:00 2001 From: Tino Koch <17991193+Tinoooo@users.noreply.github.com> Date: Tue, 8 Apr 2025 09:05:00 +0200 Subject: [PATCH 5/8] =?UTF-8?q?omitted=20image=20for=20copyright=20reasons?= =?UTF-8?q?=20=F0=9F=98=A2=20(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tino Koch <> Co-authored-by: Alvaro Saburido --- docs/guide/pmndrs/fxaa.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docs/guide/pmndrs/fxaa.md b/docs/guide/pmndrs/fxaa.md index eeabb732..7940109f 100644 --- a/docs/guide/pmndrs/fxaa.md +++ b/docs/guide/pmndrs/fxaa.md @@ -13,13 +13,6 @@ The `FXAAEffect` effect is part of the [`postprocessing`](https://pmndrs.github.io/postprocessing/public/docs/class/src/effects/FXAAEffect.js~FXAAEffect.html) package. FXAA offers a performance-optimized anti-aliasing solution that smooths jagged edges while maintaining excellent performance. However, its quality may be modest at times, occasionally resulting in a slightly blurred appearance. - - @Miamiamia0103 illustration - - Illustration credit @Miamiamia0103 - - - ## Usage The `` component is easy to use and provides customizable options to suit different visual styles. From 51acad5a92f9952d4f541f6868086644b8822b7b Mon Sep 17 00:00:00 2001 From: Tino Koch <17991193+Tinoooo@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:37:13 +0200 Subject: [PATCH 6/8] docs: 195 have a section mentioning the attach feature in the docs (#203) * feat(docs): add 'Advanced' section with custom guide link * changed link text --------- Co-authored-by: Tino Koch <> Co-authored-by: Alvaro Saburido --- docs/.vitepress/config.ts | 6 ++++++ docs/guide/advanced/you-might-not-need-post-processing.md | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 docs/guide/advanced/you-might-not-need-post-processing.md diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 72deebef..2bb83e0d 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -90,6 +90,12 @@ export default defineConfig({ { text: 'Unreal Bloom', link: '/guide/three/unreal-bloom' }, ].sort((a, b) => a.text.localeCompare(b.text)), }, + { + text: 'Advanced', + items: [ + { text: 'You might not need this module', link: '/guide/advanced/you-might-not-need-post-processing' }, + ], + }, ], socialLinks: [ diff --git a/docs/guide/advanced/you-might-not-need-post-processing.md b/docs/guide/advanced/you-might-not-need-post-processing.md new file mode 100644 index 00000000..6c1391e0 --- /dev/null +++ b/docs/guide/advanced/you-might-not-need-post-processing.md @@ -0,0 +1,5 @@ +# You might not need this module + +Please note that you can use [Tres.js's attach feature](https://docs.tresjs.org/advanced/attach.html#arrays) instead of this module. It enables you to utilize any effect provided by Three.js, even if there is no corresponding component in post-processing. + +We recommend using post-processing because the props of the effects are reactive. The attach feature does not offer prop reactivity. However, if you do not require that advantage, is is a valid option to achieve equal results. From 38002a6a58b955da9235130af217c251d569d79e Mon Sep 17 00:00:00 2001 From: Damien Montastier Date: Sun, 13 Apr 2025 12:12:45 +0200 Subject: [PATCH 7/8] =?UTF-8?q?fix:=20big=20clean=20demo=20=E2=80=94=20doc?= =?UTF-8?q?s=20=E2=80=94=20=20bad=20using=20multisampling=20(#201)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: big clean demo docs, demos, multisampling delete bad using * typo fix --------- Co-authored-by: Tino Koch <17991193+Tinoooo@users.noreply.github.com> --- .../pmdrs/BrightnessContrastDemo.vue | 3 +- .../components/pmdrs/ColorAverageDemo.vue | 1 - .../theme/components/pmdrs/ColorDepthDemo.vue | 1 - .../theme/components/pmdrs/FishEyeDemo.vue | 1 - .../theme/components/pmdrs/GodRaysDemo.vue | 40 ++++++++++++++----- .../theme/components/pmdrs/GridDemo.vue | 1 - .../theme/components/pmdrs/LinocutDemo.vue | 1 - docs/guide/pmndrs/barrel-blur.md | 4 +- docs/guide/pmndrs/bloom.md | 30 +++++++++----- docs/guide/pmndrs/brightness-contrast.md | 14 ++----- docs/guide/pmndrs/chromatic-aberration.md | 6 ++- docs/guide/pmndrs/color-average.md | 10 +++-- docs/guide/pmndrs/color-depth.md | 8 +--- docs/guide/pmndrs/depth-of-field.md | 18 ++++++--- docs/guide/pmndrs/dot-screen.md | 10 +++-- docs/guide/pmndrs/fish-eye.md | 14 +++---- docs/guide/pmndrs/glitch.md | 18 ++++++--- docs/guide/pmndrs/god-rays.md | 27 +++++-------- docs/guide/pmndrs/grid.md | 8 +--- docs/guide/pmndrs/hue-saturation.md | 6 ++- docs/guide/pmndrs/kuwahara.md | 8 ++-- docs/guide/pmndrs/lens-distortion.md | 6 ++- docs/guide/pmndrs/linocut.md | 8 ++-- docs/guide/pmndrs/noise.md | 25 +++++++----- docs/guide/pmndrs/outline.md | 18 ++++++--- docs/guide/pmndrs/pixelation.md | 18 ++++++--- docs/guide/pmndrs/scanline.md | 6 ++- docs/guide/pmndrs/sepia.md | 6 ++- docs/guide/pmndrs/shock-wave.md | 2 +- docs/guide/pmndrs/tilt-shift.md | 6 ++- docs/guide/pmndrs/tone-mapping.md | 6 ++- docs/guide/pmndrs/vignette.md | 24 +++++++---- .../src/pages/postprocessing/barrel-blur.vue | 1 - .../postprocessing/brightness-contrast.vue | 1 - .../postprocessing/chromatic-aberration.vue | 1 - .../pages/postprocessing/color-average.vue | 1 - .../src/pages/postprocessing/color-depth.vue | 1 - .../src/pages/postprocessing/fish-eye.vue | 2 - playground/src/pages/postprocessing/fxaa.vue | 2 +- .../src/pages/postprocessing/god-rays.vue | 1 - playground/src/pages/postprocessing/grid.vue | 1 - .../src/pages/postprocessing/linocut.vue | 1 - .../src/pages/postprocessing/scanline.vue | 1 - .../src/pages/postprocessing/shock-wave.vue | 1 - 44 files changed, 211 insertions(+), 157 deletions(-) diff --git a/docs/.vitepress/theme/components/pmdrs/BrightnessContrastDemo.vue b/docs/.vitepress/theme/components/pmdrs/BrightnessContrastDemo.vue index 35c95187..299c6a59 100644 --- a/docs/.vitepress/theme/components/pmdrs/BrightnessContrastDemo.vue +++ b/docs/.vitepress/theme/components/pmdrs/BrightnessContrastDemo.vue @@ -11,7 +11,6 @@ import '@tresjs/leches/styles' const gl = { clearColor: '#ffffff', toneMapping: NoToneMapping, - multisampling: 8, } const { brightness, contrast, blendFunction } = useControls({ @@ -20,7 +19,7 @@ const { brightness, contrast, blendFunction } = useControls({ blendFunction: { options: Object.keys(BlendFunction).map(key => ({ text: key, - value: BlendFunction[key], + value: BlendFunction[key as keyof typeof BlendFunction], })), value: BlendFunction.SRC, }, diff --git a/docs/.vitepress/theme/components/pmdrs/ColorAverageDemo.vue b/docs/.vitepress/theme/components/pmdrs/ColorAverageDemo.vue index 84ada864..3e82eede 100644 --- a/docs/.vitepress/theme/components/pmdrs/ColorAverageDemo.vue +++ b/docs/.vitepress/theme/components/pmdrs/ColorAverageDemo.vue @@ -14,7 +14,6 @@ import '@tresjs/leches/styles' const gl = { clearColor: '#ffffff', toneMapping: NoToneMapping, - envMapIntensity: 10, } const glComposer = { diff --git a/docs/.vitepress/theme/components/pmdrs/ColorDepthDemo.vue b/docs/.vitepress/theme/components/pmdrs/ColorDepthDemo.vue index ca9345d8..b93d5f91 100644 --- a/docs/.vitepress/theme/components/pmdrs/ColorDepthDemo.vue +++ b/docs/.vitepress/theme/components/pmdrs/ColorDepthDemo.vue @@ -14,7 +14,6 @@ import '@tresjs/leches/styles' const gl = { clearColor: '#ffffff', toneMapping: NoToneMapping, - multisampling: 8, } const ctx = gsap.context(() => {}) diff --git a/docs/.vitepress/theme/components/pmdrs/FishEyeDemo.vue b/docs/.vitepress/theme/components/pmdrs/FishEyeDemo.vue index fb5431cf..7c9c3d11 100644 --- a/docs/.vitepress/theme/components/pmdrs/FishEyeDemo.vue +++ b/docs/.vitepress/theme/components/pmdrs/FishEyeDemo.vue @@ -15,7 +15,6 @@ import '@tresjs/leches/styles' const gl = { clearColor: '#ffffff', toneMapping: NoToneMapping, - multisampling: 8, } const lensParams = [ diff --git a/docs/.vitepress/theme/components/pmdrs/GodRaysDemo.vue b/docs/.vitepress/theme/components/pmdrs/GodRaysDemo.vue index dd4af009..962dbf84 100644 --- a/docs/.vitepress/theme/components/pmdrs/GodRaysDemo.vue +++ b/docs/.vitepress/theme/components/pmdrs/GodRaysDemo.vue @@ -6,30 +6,25 @@ import type { Mesh } from 'three' import { BackSide, NoToneMapping } from 'three' import { BlendFunction, KernelSize } from 'postprocessing' import { EffectComposerPmndrs, GodRaysPmndrs } from '@tresjs/post-processing' -import { ref, watch } from 'vue' +import { onUnmounted, ref, watch } from 'vue' import { gsap } from 'gsap' import '@tresjs/leches/styles' const gl = { toneMapping: NoToneMapping, - multisampling: 8, } +let tween: gsap.core.Tween | null = null + const sphereMeshRef = ref(null) const pbrTexture = await useTexture({ map: '/lens-distortion/room-map.png', }) -const { blur, kernelSize, resolutionScale, opacity, blendFunction, density, decay, weight, exposure, samples, clampMax } = useControls({ - blendFunction: { - options: Object.keys(BlendFunction).map(key => ({ - text: key, - value: BlendFunction[key as keyof typeof BlendFunction], - })), - value: BlendFunction.SCREEN, - }, +const { freezeAnimationLightSource, blur, kernelSize, resolutionScale, opacity, blendFunction, density, decay, weight, exposure, samples, clampMax } = useControls({ + freezeAnimationLightSource: { value: false, label: 'pauseLightSource', type: 'boolean' }, kernelSize: { options: Object.keys(KernelSize).map(key => ({ text: key, @@ -46,6 +41,13 @@ const { blur, kernelSize, resolutionScale, opacity, blendFunction, density, deca clampMax: { value: 1.0, step: 0.1, max: 1.0 }, resolutionScale: { value: 0.5, step: 0.1, min: 0.1, max: 1.0 }, blur: true, + blendFunction: { + options: Object.keys(BlendFunction).map(key => ({ + text: key, + value: BlendFunction[key as keyof typeof BlendFunction], + })), + value: BlendFunction.SCREEN, + }, }) const torusMeshes = [ @@ -57,14 +59,30 @@ const torusMeshes = [ watch(sphereMeshRef, () => { if (!sphereMeshRef.value) { return } - gsap.to(sphereMeshRef.value.position, { + tween = gsap.to(sphereMeshRef.value.position, { x: 20, duration: 3, repeat: -1, yoyo: true, + paused: freezeAnimationLightSource.value, ease: 'sine.inOut', }) }) + +watch(freezeAnimationLightSource, () => { + if (!sphereMeshRef.value) { return } + + if (freezeAnimationLightSource.value) { + tween?.pause() + } + else { + tween?.resume() + } +}) + +onUnmounted(() => { + tween?.revert() +})