SPACEto play / pauseARROW RIGHTorLto go forwardARROW LEFTorJto go backwardARROW UPto increase volumeARROW DOWNto decrease volumeFto toggle fullscreenMto toggle mute0 to 9to go to the corresponding part of the videoSHIFT+,to decrease playback speedSHIFT+.or;to increase playback speed
Three.js examples
Shortcuts ⌨️
Unlock content 🔓
To get access to 93 hours of video, a members-only Discord server, subtitles, lesson resources, future updates and much more join us for only $95!
Want to learn more? 🤘
That's the end of the free part of this lesson
- 21 lessons · 24 hours of video
- Quizzes · Certificate
- Members-only Discord server · Future updates
Introduction 00:00
With TSL and WebGPU, Three.js post-processing also got a refresh.
It might sound too early in the chapter to discover such a topic, but I wanted to make the upcoming exercises look good, and there is nothing better than post-processing and a nice bloom for that.
We are going to discover how to set up our project to use post-processing, test a bunch of built-in effects, and create two custom effects: a simple one to get the hang of it, and one more complex and epic.
Setup 02:11
The starter already contains the following:
- The same floor we used in previous lessons
- A model composed of an anvil and a hammer, just to have something on screen
- Some lighting with shadows
OrbitControlsto rotate around- A
SkyMeshto have something to look at in the background - It’s all being rendered with the
WebGPURenderer - An instance of the
Inspector
Tone mapping 02:47
Let’s start with the tone mapping, because yes, tone mapping is considered post-processing, especially with how Three.js now handles rendering.
Don’t worry, it works nearly the same as with the WebGLRenderer.
Tone mapping is a technique to convert HDR to LDR, but it’s also a way to tweak the output color (HDR or not) to mimic real camera effects.
Change the tone mapping like before, on the renderer:
const renderer = new THREE.WebGPURenderer({
// ...
})
renderer.toneMapping = THREE.ACESFilmicToneMapping
The render looks a little bit darker and more contrasted.
And like before, we can play with the exposure using the toneMappingExposure property:
renderer.toneMapping = THREE.ACESFilmicToneMapping
renderer.toneMappingExposure = 3
The tone mapping exposure will multiply the color input, making it look like there is more light getting in the camera, thus making the tone mapping effect more intense and relevant.
Let’s have a bit of fun and add those two properties to the debug UI.
How to use it 🤔
- Download the Starter pack or Final project
- Unzip it
- Open your terminal and go to the unzip folder
-
Run
npm installto install dependencies
(if your terminal warns you about vulnerabilities, ignore it) -
Run
npm run devto launch the local server
(project should open on your default browser automatically) - Start coding
- The JS is located in src/script.js
- The HTML is located in src/index.html
- The CSS is located in src/style.css