Three.js Shading Language and Signed Distance Fields
What you'll learn
- Threejs Shading Language
- Signed Distance Fields
- Using TSL with import maps or a build tool
- Setting up a development environment
- TSL imports or color, texture, convertColorSpace and positionLocal
- Writing Fragment and Vertex Shaders
- Generate patterns using fract, sin, cos, atan, floor, mod
- Drawing SDF lines and shapes in 2D and 3D
- Using Uniform and UniformArray
- Drawing distance lines
- Colouring 2D and 3D SDFs
- Raymarching
- Lighting 3D SDFs
- SDF Shadows
- SDF Reflections
- SDF Union, Intersect and Subtraction
- Ambient Occlusion
- Fresnel Effect
- Adaptive DPR
- Atmospheric Scattering
- Fractal Brownian Motion
- Gerstner/Tricoidal water algorithm
- Clouds
- and much more
Requirements
- This is an intermediate course about Three.js and you should already have some experience using it.
- You will need a modern graphics card capable of running GLSL and WGSL shader code.
Description
Three.js Shading Language (TSL) is a framework built to simplify shader development within the Three.js ecosystem.
Signed Distance Fields are a way to draw scenes and animations predominantly using mathematical functions.
You can draw anything with Signed Distance Fields, and TSL makes that more accessible for developers, especially those without deep knowledge of low-level GLSL, WGSL or graphics programming.
So, in the course, we will cover,
Basic environment development setup,
Importing the required libraries,
Using import Maps or a bundler / build tool,
Discuss the prerequisites of a TSL scene,
Fragment Shader coordinates,
Create several animated patterns from easy to more advanced,
Draw various styles of lines,
Implement uniforms and uniform array,
Interact with our scenes using a GUI,
Learn the basics of sign distance Fields,
Draw distance lines using SDF information,
Colouring and animating 2D SDFs,
Practice by building something and adding keyboard interactivity,
Learn the basics of Ray marching,
Lighting 3D SDFs,
Using Lambertian, Ambient and Phong specular,
Using hard and soft shadowing,
Implement SDF reflections,
Implement adaptive device pixel ratio,
Colouring and animating 3D SDFs,
Add atmospheric Scattering,
Implement, Ambient Occlusion,
And apply Fresnel Effect,
Learn all about Fractal Brownian Motion,
Add Gerstner/Trochoidal algorithm water effect,
Add Clouds,
Domain Repetition,
and much more
By using TSL's node-based shader graph system, developers can create and manage shaders without needing to write complex GLSL or WGSL code manually.
TSL is renderer-agnostic, meaning shaders created with it work seamlessly across different rendering backends like WebGL and WebGPU.
Since TSL is written at the Javascript or TypeScript layer, along side your existing Three.js code, you will be able to benefit from the features provided by your IDE, such as IntelliSense code completion, code formatting and linting. Your final production code can also benefit from tree shaking provided by your bundler.
Thanks for taking part in my Three.js Shading Language (TSL) and Signed Distance Fields course.
Sean
Who this course is for:
- People who have experience with Threejs and want to write shader code using the techniques of signed distance fields.
Instructor
Hello, I'm Sean.
For over 25 years I have been an IT engineer building and managing real time, low latency, high availability, asynchronous, multi threaded, remotely managed, fully automated, monitored solutions in the education, aeronautical, banking, drone, gaming and telecommunications industries.
I have also created and written hundreds of Open Source GitHub Repositories, Medium Articles and YouTube video tutorials.