Tresjs / post-processing

Post-processing library for TresJS
MIT License
37 stars 6 forks source link

need help, How can we pass custom effect? #86

Closed pilishen closed 4 months ago

pilishen commented 1 year ago

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

alvarosabu commented 1 year ago

@pilishen I will try to prepare an example to show how you would approach Custom Shaders and most probably add docs about it. Thanks for raising this question.

pilishen commented 1 year ago

@pilishen I will try to prepare an example to show how you would approach Custom Shaders and most probably add docs about it. Thanks for raising this question.

glad to hear that, thanks, you're awesome~ @alvarosabu

AntoninRousset commented 8 months ago

To make it easy to add custom effects, could you export useEffect composable? As in #105.

Tinoooo commented 8 months ago

useEffect is now exposed. So passing custom effects should work by creating an own component that uses the composable. The Pixelation component should be a good reference. @pilishen Let me know if this helps.