Flat shading and vignette improve visual depth after the main wall projection
is already known. They do not alter DDA traversal, hit distance, or wall
geometry. The active color transforms are the ceiling/floor flat shading pass
and the world-level vignette pass.
Color post-processing
Shading alters color output, never geometry
These passes run after geometry and texture coordinates are already known. Their job is to
improve depth perception and contrast while keeping the underlying wall projection unchanged.
In the current frame flow:
- wall texels are sampled during wall draw
- ceiling and floor colors pass through
apply_flat_shading(...)
- the vignette pass darkens the world near the end of world rendering
- the HUD is drawn after that pass
That ordering keeps the UI readable even when the world view is darkened.
The bonus code contains an apply_wall_shading(...) helper, but the current
wall draw path does not call it. Wall texels are sampled directly, then the
world-level vignette pass can darken the final frame.
If wall shading is reconnected later, it is designed to depend on:
- perpendicular distance
- side hit
- optional face-specific factors
Those inputs are not part of the active wall draw path until the helper is
wired back into draw_wall_column(...).
Flat shading is applied to the ceiling and floor fills.
Instead of using texture coordinates, it derives a factor from the pixel row
relative to the horizon. That creates a simple depth cue on large flat regions
without requiring textured floors or ceilings.
The vignette pass computes a radial factor from the screen center and darkens
pixels near the borders.
Its purpose is visual focus:
- center remains more visible
- borders are darker
- effect is purely post-process
These passes must preserve several guarantees:
- geometry is unchanged
- texel bounds were validated before shading
- frame buffer writes stay valid
- HUD remains outside the vignette pass
The tuning constants for these effects live in:
That includes face factors, minimum ambient values, flat shading ranges, and
vignette strength / power values.
srcs_bonus/retro/shading.c
srcs_bonus/retro/flat_shading.c
srcs/render/draw_vignette.c
srcs/render/render_frame.c
include/defines_bonus.h