Coder Social home page Coder Social logo

post-processing's Introduction

repository-banner.png

npm package npm downloads discord chat


Post-Processing

Collection of useful helpers and fully functional, ready-made post-processing effects for Tres

  • πŸ’‘ Build your effects with Vue components only.
  • ⚑️ Powered by Vite
  • 🦾 Fully Typed

Installation

pnpm i @tresjs/post-processing

Docs

Checkout the docs

Demos

Contributing

We are open to contributions, please read the contributing guide to get started.

Build

To build the package run:

pnpm run build

Playground

To run the playground run, its a great way to test the components and helpers locally:

First install dependencies

pnpm i

And then to run the development server on http://localhost:5173

pnpm run playground

Test

TODO...

Docs

To run de docs in dev mode

pnpm run docs:dev

To build them

pnpm run docs:build

License

MIT

Sponsors

Be the first to support this project here ☺️

post-processing's People

Contributors

alvarosabu avatar antoninrousset avatar renovate[bot] avatar tinoooo avatar whereiswolf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

post-processing's Issues

Support for OutlinePass

Is your feature request related to a problem? Please describe.
Outlinepass is not available as a component in this module.

Describe the solution you'd like
Have a component available to add the OutlinePass to the EffectComposer.

Suggested solution
Adding the component. πŸ˜„

Multisampling prop isn't passed corerctly to EffectComposer

Describe the bug

The multisampling prop on <EffectComposer /> is incorrectly passed to postprocessing's EffectComposer constructor.

Reproduction
A Stackblitz example: https://stackblitz.com/edit/tresjs-multisampling-bug?file=src%2Fcomponents%2FNoAliasing.vue

Steps
Steps to reproduce the behavior:

  1. In a scene add <EffectComposer :multisampling="8" /> and any other effect you want (tested on Outline / Vignette)
  2. The aliasing occurs.

Expected behavior
The EffectComposer passess multisampling prop correctly to postprocessing's EffectComposer, and enables mutlisampling.

Screenshots
If applicable, add screenshots to help explain your problem.

πŸ‘‡ With <EffectComposer :multisampling="8" />
image
☝️ Without post-processing and with default antialiasing.

System Info

System:
    OS: macOS 14.3.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 287.05 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
    bun: 1.0.27 - ~/.bun/bin/bun
  Browsers:
    Chrome: 122.0.6261.129
    Safari: 17.3.1
  npmPackages:
    @tresjs/cientos: ^3.8.0 => 3.8.0 
    @tresjs/core: ^3.7.0 => 3.7.0 
    @tresjs/leches: ^0.14.0 => 0.14.0 
    @tresjs/post-processing: link:@tresjs/post-processing => 0.7.0 
    vite: ^5.1.5 => 5.1.6 

Additional context
The problem's with a reverse order of multisampling checks in effectComposerParams:

// src/core/EffectComposer.vue
...
const effectComposerParams = computed(() => {
  const plainEffectComposer = new EffectComposerImpl()
  const params = {
    depthBuffer: props.depthBuffer !== undefined ? props.depthBuffer : plainEffectComposer.inputBuffer.depthBuffer,
    stencilBuffer:
      props.stencilBuffer !== undefined ? props.stencilBuffer : plainEffectComposer.inputBuffer.stencilBuffer,
    multisampling: isWebGL2Available()
-      ? 0
-      : props.multisampling !== undefined
-        ? props.multisampling
-        : plainEffectComposer.multisampling,
+      ? props.multisampling !== undefined
+        ? props.multisampling
+        : plainEffectComposer.multisampling
+      : 0,
    frameBufferType: props.frameBufferType !== undefined ? props.frameBufferType : HalfFloatType,
  }
  plainEffectComposer.dispose()

  return params
})
...

need help, How can we pass custom effect?

thanks for this great package, it's so elagant, really appreciate

I'm having difficulty in passing custom shader effect into the EffectComposer, is it possible currently?

<Suspense>
       <EffectComposer ref="composer">
            <Bloom   />
       </EffectComposer>
</Suspense>

Suppose besides Bloom Effect, i still want to pass another shader effect, how could i achieve that?

import { ShaderPass } from 'postprocessing';
import Shader from './shader.js

<script setup>
    const shaderEffect = new ShaderPass(Shader)
    const composer  = ref()

   onMounted(()=>{
        if (composer.value) {
            composer.value.addPass(shaderEffect)
            composer.value.render()
          }
    })
</script>

That's my first attempt, but it didn't work, any help? thanks

Improve bloom docs

Is your feature request related to a problem? Please describe.
The bloom effect seems like it is not working when used with the default parameters.

Describe the solution you'd like
The docs should convey how to use the bloom effect so it is visible in the scene.

Similar linting rules throughout the Tresjs packages

Is your feature request related to a problem? Please describe.
As a developer using post-processing, I would like to have clear linting rules in the Tresjs ecosystem.

Describe the solution you'd like
Follow the rules of Tresjs/core

Postprocessing breaks on Nuxt

Describe the bug
Postprocessing Render seems to break on Nuxt.

Reproduction
https://stackblitz.com/edit/nuxt-starter-2qaqwx?file=nuxt.config.ts,components%2FTheExperience.vue,package.json,app.vue

Steps
Steps to reproduce the behavior:

  1. Go to Reproduction
  2. Resize

Reproduction
When resizing the clear color also goes blank. Effects don't work etc

Expected behavior
All smooth and working lol

Screenshots
Screenshot 2023-09-27 at 13 26 13

System Info
Output of npx envinfo --system --npmPackages '{vite,@tresjs/*, three, vue}' --binaries --browsers

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.20.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.6.10 - /usr/local/bin/pnpm
  npmPackages:
    @tresjs/nuxt: ^1.1.7 => 1.1.7 
    @tresjs/post-processing: ^0.4.0 => 0.4.0 

Additional context
Add any other context about the problem here.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency pathe to v1.1.2
  • chore(deps): update dependency unplugin-auto-import to v0.17.6
  • chore(deps): update dependency vite-plugin-qrcode to v0.2.3
  • chore(deps): update dependency vue-tsc to v1.8.27
  • chore(deps): update dependency @vitejs/plugin-vue to v4.6.2
  • chore(deps): update dependency nuxt to v3.11.2
  • chore(deps): update dependency prettier to v3.2.5
  • chore(deps): update dependency release-it to v17.2.1
  • chore(deps): update dependency rollup-plugin-visualizer to v5.12.0
  • chore(deps): update dependency typescript to v5.4.5
  • chore(deps): update dependency unplugin-vue-components to ^0.27.0
  • chore(deps): update dependency vue to v3.4.27
  • fix(deps): update dependency @tresjs/cientos to v3.9.0
  • fix(deps): update dependency @tresjs/core to v3.9.0
  • fix(deps): update dependency @tresjs/nuxt to v1.3.0
  • fix(deps): update dependency @vueuse/core to v10.9.0
  • fix(deps): update dependency postprocessing to v6.35.4
  • fix(deps): update dependency three-stdlib to v2.30.0
  • fix(deps): update dependency vue-router to v4.3.2
  • chore(deps): update dependency vue-tsc to v2
  • chore(deps): update pnpm to v9
  • πŸ” Create all rate-limited PRs at once πŸ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/lint-pr.yml
  • amannn/action-semantic-pull-request v5
.github/workflows/lint.yml
  • actions/checkout v4
  • pnpm/action-setup v2
  • actions/setup-node v4
  • ubuntu 20.04
npm
docs/package.json
  • @tresjs/cientos ^3.6.0
  • @tresjs/core ^3.5.1
  • gsap ^3.12.3
  • @tresjs/leches ^0.14.0
  • unocss ^0.58.0
  • unplugin-vue-components ^0.26.0
  • vite-svg-loader ^5.1.0
  • vitepress 1.0.0-rc.31
package.json
  • @tresjs/core ^3.5.1
  • @unocss/core ^0.58.0
  • @vueuse/core ^10.6.1
  • postprocessing ^6.33.4
  • three-stdlib ^2.28.7
  • @release-it/conventional-changelog ^8.0.1
  • @tresjs/eslint-config-vue ^0.2.1
  • @types/three ^0.159.0
  • @vitejs/plugin-vue ^4.5.1
  • gsap ^3.12.3
  • kolorist ^1.8.0
  • pathe ^1.1.1
  • prettier ^3.1.0
  • release-it ^17.0.0
  • rollup-plugin-analyzer ^4.0.0
  • rollup-plugin-visualizer ^5.10.0
  • three ^0.159.0
  • typescript ^5.3.2
  • unocss ^0.58.0
  • vite ^5.0.4
  • vite-plugin-banner ^0.7.1
  • vite-plugin-dts 3.6.4
  • vite-svg-loader ^5.1.0
  • vitepress 1.0.0-rc.31
  • vue ^3.3.9
  • vue-tsc ^1.8.24
  • three >=0.133
  • vue >=3.3
  • pnpm 8.11.0
playground-nuxt/package.json
  • @tresjs/cientos ^3.5.1
  • @tresjs/nuxt ^1.2.2
  • @types/three ^0.152.1
  • nuxt ^3.8.0
  • vue ^3.3.7
  • vue-router ^4.2.5
playground/package.json
  • @tresjs/cientos ^3.6.0
  • @tresjs/core 3.5.1
  • vue-router ^4.2.5
  • @tresjs/leches ^0.14.0
  • @types/three ^0.159.0
  • unplugin-auto-import ^0.17.2
  • unplugin-vue-components ^0.26.0
  • vite-plugin-qrcode ^0.2.2
playground/public/nuxt-stones/package.json
  • @tresjs/cientos ^3.0.1
  • @tresjs/core ^3.2.2
  • gsap ^3.11.5
  • unocss ^0.52.3
  • unplugin-vue-components ^0.24.1
  • vite-svg-loader ^4.0.0
  • vitepress 1.0.0-beta.1

  • Check this box to trigger a request for Renovate to run again on this repository

Cannot read properties of undefined (reading 'canvas')

Describe the bug
A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks!

Hi! Fist of all, What a great library! I'm playing with it, and so far... I LOVE IT! now... to the error, I am currently trying to use the post-processing package on a scene and I get the following error when I use it:

image

Reproduction
This same happens whenever you check the examples:
https://playground.tresjs.org/experiments/nuxt-stones

image

Steps
Steps to reproduce the behavior:

  1. Just adding the EffectComposer with a default bloom effect.

Expected behavior
For the effect composer component to work

Screenshots
If applicable, add screenshots to help explain your problem.

System Info
Output of npx envinfo --system --npmPackages '{vite,@tresjs/*, three, vue}' --binaries --browsers

System:
    OS: macOS 13.4.1
    CPU: (8) arm64 Apple M1
    Memory: 323.22 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
  Browsers:
    Chrome: 116.0.5845.110
    Safari: 16.5.2
  npmPackages:
    @tresjs/cientos: ^3.1.0 => 3.1.0 
    @tresjs/core: ^3.1.0 => 3.1.0 
    @tresjs/post-processing: ^0.3.0 => 0.3.0 
    vite: ^2.8.0 => 2.9.16 

Additional context
Add any other context about the problem here.

Bloom demo is broken

When looking at docs for Bloom I can see empty canvas box with console message saying:

framework.8oxMyIc2.js:1 TypeError: Class constructor ue cannot be invoked without 'new'
    at guide_effects_bloom.md.7kCtuEBS.js:1:914
    at Object.i [as default] (framework.8oxMyIc2.js:1:16078)
    at Proxy.<anonymous> (useRouteDisposal.tyh0ETgK.js:3645:321145)
    at ei (framework.8oxMyIc2.js:1:16394)
    at Mi.F [as fn] (framework.8oxMyIc2.js:1:49505)
    at Mi.run (framework.8oxMyIc2.js:1:4163)
    at B.p.update (framework.8oxMyIc2.js:1:49779)
    at B (framework.8oxMyIc2.js:1:49805)
    at ie (framework.8oxMyIc2.js:1:48650)
    at V (framework.8oxMyIc2.js:1:48444)

[Nuxt - Astro] Maximum recursive updates exceeded on window resize

Describe the bug
A scene using EffectComposer gets broken when resizing the screen

Reproduction
Reproduction

Steps
Steps to reproduce the behavior:

  1. Go to '...'
  2. Resize Scene

Expected behavior
Scene with post-processing doesn't break

Screenshots

Screen.Recording.2023-11-14.at.10.42.19.mov

System Info
Output of npx envinfo --system --npmPackages '{vite,@tresjs/*, three, vue}' --binaries --browsers

  System:
    OS: macOS 14.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 89.77 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.14.1 - ~/.nvm/versions/node/v18.14.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.3.1 - ~/.nvm/versions/node/v18.14.1/bin/npm
  Browsers:
    Brave Browser: 118.1.59.124
    Chrome: 119.0.6045.105
    Firefox: 118.0.1
    Safari: 17.1
  npmPackages:
    @tresjs/cientos: ^3.6.0 => 3.6.0 
    @tresjs/leches: 0.14.0-next.0 => 0.14.0-next.0 
    @tresjs/nuxt: ^1.2.2 => 1.2.2 
    @tresjs/post-processing: 0.6.0 => 0.6.0 

Additional context
Add any other context about the problem here.

depth of effects is wrong

Describe the bug
The effects seem to happen on a different layer. Examples would be the outside not being visible, the bloom being behind other objects and the glitch happening behind the object being glitched.

Reproduction
See demos in playground.

Steps
check demos in playground

Refactor existing effects

Is your feature request related to a problem? Please describe.
The existing effects have some code parts in common that can probably be shared.

Describe the solution you'd like
Share common code parts.

Refactor Effects to .vue files

Is your feature request related to a problem? Please describe.
As of now, effects are typescript .ts files with defineComponent.

export const Glitch = defineComponent<GlitchProps>({
  name: 'Glitch',
  props: [
    'delay',
    'duration',
    'strength',
    'mode',
    'active',
    'ratio',
    'columns',
    'chromaticAberrationOffset',
    'peturbationMap',
    'dtSize',
  ] as unknown as undefined,

  async setup(props, { expose }) {
    const { state } = useCore()
    const composer = inject<any>('effectComposer')
    const pass = ref<EffectPass | null>(null)

    expose({ getPass: () => pass.value })

    watchEffect(() => {
      if (state.camera && composer && composer.value) {
        pass.value = new EffectPass(unref(state.camera), new GlitchEffect(props))
        composer.value?.addPass(toRaw(pass.value))
      }
    })

    watch(
      () => props.active,
      value => {
        if (pass.value) {
          pass.value.enabled = value as boolean
        }
      },
    )

    return () => {
      pass
    }
  },
})

Describe the solution you'd like

Use a similar approach as cientos and use vue SFC components

EffectComposer does not correctly react to canvas resizing

Describe the bug
When resizing the viewport with an active effect composer, the scene gets distorted.

Reproduction
Steps

  1. open demo (in playground for example)
  2. change canvas size

Expected behavior
The scene should not become distorted

Screenshots
Kapture 2023-06-22 at 16 37 18

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.