Skip to content

TSL: Introduce Chromatic Aberration #31236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 8, 2025
Merged

TSL: Introduce Chromatic Aberration #31236

merged 10 commits into from
Jun 8, 2025

Conversation

pashaydev
Copy link
Contributor

@pashaydev pashaydev commented Jun 6, 2025

Description

This pull request adds a new post-processing node for chromatic aberration effect in Three.js WebGPU/TSL.

webgpu_postprocessing_ca

Implementation Details

The ChromaticAberrationNode provides:

  • Strength control: Adjustable intensity of the color separation effect (0-3 range)
  • Center point: Customizable origin point for the radial distortion (defaults to screen center)
  • Scale factor: Controls the stepped scaling of color channels from the center
  • Per-channel processing:
    • Red channel is scaled outward
    • Green channel remains at original scale
    • Blue channel is scaled inward

Example Usage

import { chromaticAberration } from 'three/addons/tsl/display/ChromaticAberrationNode.js';

// Apply chromatic aberration to render output

// With static values (using uniform nodes)
const caPassStatic = chromaticAberration( outputPass, 1.0, null, 1.1 );

// With procedural nodes
const animatedStrength = sin( time ).mul( 0.5 ).add( 1.0 );
const dynamicCenter = vec2( cos( time ).mul( 0.1 ).add( 0.5 ), 0.5 );
const caPassProcedural = chromaticAberration( outputPass, animatedStrength, dynamicCenter, 1.0 );

postProcessing.outputNode = caPass;

Demo

https://github.com/pashaydev/three.js/blob/ca_node/examples/webgpu_postprocessing_ca.html

PS:
I was looking into that effect build-in TLS but not found, if it will be helpful to someone like me i will be glad)

@pashaydev pashaydev changed the title Ca node Chromatic Aberration TSL Jun 6, 2025
PashaDev2 added 2 commits June 7, 2025 13:10
Add nodeObject in ca params, for ability to use a procedural node

Update example gui to toggle procedural / static
@pashaydev pashaydev requested review from sunag and Mugen87 June 7, 2025 10:22
@sunag sunag changed the title Chromatic Aberration TSL TSL: Introduce Chromatic Aberration function Jun 8, 2025
@sunag sunag changed the title TSL: Introduce Chromatic Aberration function TSL: Introduce Chromatic Aberration Jun 8, 2025
@sunag sunag merged commit e9f3ce4 into mrdoob:dev Jun 8, 2025
11 checks passed
@sunag sunag added this to the r178 milestone Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants