How to apply various postprocessing effects like Bloom, Motion Blur, and Pixelation inside a Vue

Leader posted 2 min read

Want to bring cinematic 3D effects to your Vue app? Enter TresJS—a powerful, declarative wrapper around Three.js that plays beautifully with Vue 3's Composition API.

If you’ve ever dreamed of adding Bloom, Pixelation, Motion Blur, or even Glitch effects with just a few lines of code—TresJS makes it possible.


Setup

First, install TresJS and its core dependencies:

npm install @tresjs/core three @tresjs/post-processing

If you're using Vite, you're ready to go. Make sure you’re on Vue 3.


Example 1: Glowing Sphere with Bloom

<!-- GlowingSphere.vue -->
<template>
  <Canvas clear-color="#000">
    <TresPerspectiveCamera :position="[0, 0, 5]" />
    <TresAmbientLight />
    <TresPointLight :intensity="1.5" :position="[5, 5, 5]" />

    <TresMesh>
      <TresSphereGeometry :args="[1, 32, 32]" />
      <TresMeshStandardMaterial color="hotpink" emissive="hotpink" emissiveIntensity="1" />
    </TresMesh>

    <EffectComposer>
      <Bloom :intensity="1.5" :luminanceThreshold="0.4" />
    </EffectComposer>
  </Canvas>
</template>

Result: A smooth glowing neon sphere on a black background—great for sci-fi UIs.


Example 2: Motion Blur for Fast Movement

Motion blur works best with animation. Here’s a spinning cube with blur.

<!-- SpinningCube.vue -->
<template>
  <Canvas>
    <TresPerspectiveCamera :position="[0, 0, 6]" />
    <TresAmbientLight />

    <TresMesh ref="cube" :rotation="rotation">
      <TresBoxGeometry />
      <TresMeshStandardMaterial color="#00ffff" />
    </TresMesh>

    <EffectComposer>
      <MotionBlur :samples="32" />
    </EffectComposer>
  </Canvas>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRenderLoop } from '@tresjs/core'

const rotation = ref([0, 0, 0])

useRenderLoop(({ delta }) => {
  rotation.value[0] += delta
  rotation.value[1] += delta * 1.2
})
</script>

Result: A smoothly rotating cube with natural blur on edges—great for dynamic UIs.


Example 3: Pixelation Effect (Retro Style)

Perfect for game UIs or retro visuals.

<!-- PixelatedScene.vue -->
<template>
  <Canvas>
    <TresPerspectiveCamera :position="[0, 0, 5]" />
    <TresAmbientLight />
    
    <TresMesh>
      <TresTorusKnotGeometry :args="[1, 0.3, 100, 16]" />
      <TresMeshStandardMaterial color="limegreen" />
    </TresMesh>

    <EffectComposer>
      <Pixelation :granularity="5" />
    </EffectComposer>
  </Canvas>
</template>

Result: The entire scene appears in blocky, pixelated chunks—a nostalgic, game-like vibe.


Stacking Multiple Effects

Yes, you can combine them!

<EffectComposer>
  <Bloom :intensity="1.2" />
  <Noise opacity="0.05" />
  <Vignette eskil="false" offset="0.5" darkness="0.8" />
</EffectComposer>

This stack creates a subtle cinematic atmosphere: a glowing bloom, grainy texture, and dark edges—like a movie scene.


Dev Tips

  • Performance: Effects like bloom and motion blur can be GPU-heavy. Test on multiple devices.
  • Declarative FTW: TresJS uses Vue’s reactivity, so animating or toggling effects is dead simple.
  • Debug: Use <Stats /> from TresJS for FPS monitoring.

Final Thoughts

TresJS makes high-end visuals accessible to frontend devs without needing to dive deep into raw WebGL or complex shaders. Whether you're building a dashboard, a product showcase, or an immersive landing page, effects like bloom, blur, and pixelation can instantly make your app stand out.

If you're already in the Vue ecosystem and want cinematic 3D without the Three.js boilerplate—TresJS is your toolkit.


If you read this far, tweet to the author to show them you care. Tweet a Thanks
0 votes

More Posts

How I Built a Smart Elevator Control System in Vue 3 and TypeScript

Toni Naumoski - Jun 19

How to set up TypeScript with Node.js and Express (2025)

Sunny - Jun 6

Express and TypeScript: How to Set Up Your Project

Mubaraq Yusuf - May 26

How to create admin panel in a minutes

IvanBorshchov - May 14

How I Started Writing Unit Tests for Vue Components

ByteMinds - Mar 29
chevron_left