bevyengine / bevyengine/bevy

Specular Anti-Aliasing

Open
#24,288 0 comments 1 reaction 0 assignees View on GitHub
A-Rendering C-Feature D-Complex S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## What problem does this solve or what need does it fill?

Specular aliasing on aggressive norm maps in HDR lit scenes shows up as flickering bright pixels "sparkles" or "fireflies" on tiled surfaces, even when roughness textures look fine. The math is correct, it's just that high freq normal variance under bloom + post proc turns sub pixel facet reflects into visible artefacts.
For projects where TAA is overkill or undesirable (stylized games, mobile, projects shipping with FXAA or no AA), there's currently no built in option to address specular aliasing at the material level. I thought it could be really cool to experiment with specular aa too in bevy :-)

## What solution would you like?

A specular_anti_aliasing: bool toggle on StandardMaterial (default false for backward compat). When enabled, the PBR shader applies the geometric specular AA technique from Kaplanyan/Hill/Patney/Lefohn (HPG 2016) — roughly:

let h_2d = half_vector.xy;
let footprint = fwidth(h_2d);
let variance = SIGMA * SIGMA * footprint * footprint;
let kernel = min(vec2(KAPPA), 2.0 * variance);
alpha = sqrt(alpha * alpha + kernel);

~5 ALU ops per pixel...

## What alternative(s) have you considered?

- TAA — works but is heavyweight and has the ghosting drawbacks above.
- Custom MaterialExtension: Like I did for my game but every project that hits this problem has to re derive the same shader from papers. Feels like exactly the kind of thing that should live in core.

## Additional context

a cool shadertoy demo with side by side comparison with some cool/ref links
https://www.shadertoy.com/view/WssyR7

Contributor guide

Open the contributing guide

Research direction

Start by locating StandardMaterial and the PBR shader in Bevy's rendering code, then trace how material properties reach shader inputs. Review the linked Shadertoy example and the proposed Kaplanyan/Hill/Patney/Lefohn technique. Done means an opt-in material setting applies the behavior without changing the default path, with coverage for the relevant rendering behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, game-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.