Chromatic Aberration
In this case we will present you ChromaticAberrationPostprocess step.
Chromatic aberration is a type of optical distortion that occurs when a lens fails to focus all colors of light
to the same point. It happens because different wavelengths of light (such as red, green, and blue) refract,
or bend, by different amounts when passing through a lens. This leads to colored fringes around the edges of
objects in images, visible as red, green, or blue halos.
Agenda:
- Chromatic aberration theory
- ChromaticAberrationPostprocess step usage
Scene setup
Let's use custom scene composer to set up the scene.
Scene consists of:
- shaderball - location: (0, 0, 0)
- plane - location: (0, 0, 0)
- camera - location: (-1.4, 2.4, 2.4)
- point light - location: (-1, 2, 2)
from skyrenderer.cases.utils import ChromaticAberrationSceneComposer
from skyrenderer.render_chain import RenderChain/home/ws3h/projects/content-marketing/skyrenderer/skyrenderer/utils/visualization_helper.py:3: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html from tqdm.autonotebook import tqdm
scene_composer = ChromaticAberrationSceneComposer(antialiasing_level=512)
scene_composer.setup_scene()
scene_composer.renderer_context.define_render_chain(
RenderChain(
render_steps=[scene_composer.visible_light_render_step],
width=1000,
height=1000,
),
)
scene_composer.visualize()2025-09-17 13:24:37,459 | skyrenderer.scene.renderer_context | INFO: Root paths: - root path: /home/ws3h/projects/content-marketing/skyrenderer/skyrenderer - assets path: /dli/mount/assets - config path: /home/ws3h/projects/content-marketing/skyrenderer/skyrenderer/config - gpu sources path: /home/ws3h/projects/content-marketing/skyrenderer/skyrenderer/optix_sources/sources - cache path: /dli/mount/cache - ptx cache path: compiled_ptx/ptx - ocio path: ocio_configs 2025-09-17 13:25:06,442 | skyrenderer.utils.time_measurement | INFO: Setup time: 28.85 seconds 2025-09-17 13:25:07,326 | skyrenderer.utils.time_measurement | INFO: Context update time: 884 ms 2025-09-17 13:25:22,968 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-09-17 13:25:22,969 | skyrenderer.utils.time_measurement | INFO: Render time: 15.64 seconds
Chromatic aberration theory
Chromatic aberration is a type of optical distortion that occurs when a lens fails to focus all colors of light
to the same point. It happens because different wavelengths of light (such as red, green, and blue) refract,
or bend, by different amounts when passing through a lens. This leads to colored fringes around the edges of
objects in images, visible as red, green, or blue halos.
Chromatic aberration can be further classified into two types: longitudinal chromatic aberration and lateral
chromatic aberration.
Longitudinal chromatic aberration: occurs when different wavelengths focus at different distances from the lens
along the optical axis. It affects the sharpness of the image and is more pronounced in high-contrast areas.
Lenses cannot bring all wavelengths into a single focus point, causing a blur of color.
Lateral chromatic aberration: This occurs when different wavelengths are focused at slightly different positions
on the image plane. It is most noticeable toward the edges of an image and manifests as color fringing
(misalignment of colors) in high-contrast areas, especially near the periphery of an image.
In Sky Renderer longitudinal chromatic aberration is modelled.
ChromaticAberrationPostprocess step usage
We define a new render chain with two steps:
- predefined scene composer's visible light render step
- ChromaticAberrationPostprocess step
We need to specify values of desired parameters: red_shift, green_shift, blue_shift. You will notice the colorful
outlines along the edges of the shaderball.
from skyrenderer.render_chain.postprocess_steps.chromatic_aberration import ChromaticAberrationPostprocess chromatic_aberration = ChromaticAberrationPostprocess(
scene_composer.renderer_context,
parameter_provider=ChromaticAberrationPostprocess.create_parameter_provider(
scene_composer.renderer_context, red_shift=6, blue_shift=3
),
)
scene_composer.renderer_context.define_render_chain(
RenderChain(
render_steps=[scene_composer.visible_light_render_step, chromatic_aberration],
width=1000,
height=1000,
),
)
scene_composer.visualize()2025-09-17 13:25:29,838 | skyrenderer.utils.time_measurement | INFO: Setup time: 6.50 seconds 2025-09-17 13:25:30,679 | skyrenderer.utils.time_measurement | INFO: Context update time: 840 ms 2025-09-17 13:25:45,986 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-09-17 13:25:45,987 | skyrenderer.utils.time_measurement | INFO: Render time: 15.31 seconds
ChromaticAberrationPostprocess parameters
The red_shift, green_shift, and blue_shift parameters control the positional displacement of individual
color channels to simulate chromatic aberration effects. These parameters specify how many pixels each color
channel (red, green, blue) should be shifted from its original position.
comparison_renders = {}
scene_composer.define_render_chain_with_chromatic_aberration(red_shift=3, green_shift=3, blue_shift=0)
comparison_renders["red_shift=3, green_shift=3, blue_shift=0"] = scene_composer.get_render()2025-09-17 13:25:53,250 | skyrenderer.utils.time_measurement | INFO: Setup time: 6.90 seconds 2025-09-17 13:25:54,130 | skyrenderer.utils.time_measurement | INFO: Context update time: 879 ms 2025-09-17 13:26:09,734 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-09-17 13:26:09,734 | skyrenderer.utils.time_measurement | INFO: Render time: 15.60 seconds
scene_composer.define_render_chain_with_chromatic_aberration(red_shift=0, green_shift=6, blue_shift=6)
comparison_renders["red_shift=0, green_shift=6, blue_shift=6"] = scene_composer.get_render()2025-09-17 13:26:16,310 | skyrenderer.utils.time_measurement | INFO: Setup time: 6.55 seconds 2025-09-17 13:26:17,201 | skyrenderer.utils.time_measurement | INFO: Context update time: 890 ms 2025-09-17 13:26:30,818 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-09-17 13:26:30,819 | skyrenderer.utils.time_measurement | INFO: Render time: 13.62 seconds
scene_composer.define_render_chain_with_chromatic_aberration(red_shift=15, green_shift=3, blue_shift=3)
comparison_renders["red_shift=15, green_shift=3, blue_shift=3"] = scene_composer.get_render()2025-09-17 13:26:37,437 | skyrenderer.utils.time_measurement | INFO: Setup time: 6.58 seconds 2025-09-17 13:26:38,411 | skyrenderer.utils.time_measurement | INFO: Context update time: 973 ms 2025-09-17 13:26:54,054 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-09-17 13:26:54,055 | skyrenderer.utils.time_measurement | INFO: Render time: 15.64 seconds
scene_composer.visualize_grid_desc(comparison_renders, (500, 1500), n_cols=3,
font_color=scene_composer.SKY_ACCENT_COLOUR, blend_text_background=True,
font_scale=2.5, thickness=2)Summary
In this section you have learnt:
- ChromaticAberrationPostprocess step must be added after visible light render step.
- Chromatic Aberration creates a colorful outline along the edges of objects.
- We can specify 3 types of color shifts: red_shift, blue_shift and green_shift.