Files
parallel-dc/tools/pvr
LibretroAdmin 49a9b143f0 shadows: per-triangle renderers scale the base and offset colours too
Inside a modifier volume the PowerVR2 scales what a polygon is shaded
with, its base and offset colours, and then combines them with the
texture and fogs the result as usual. The OpenGL and Vulkan
per-triangle renderers darkened the finished pixel instead, with one
quad over the screen. That is the same thing for a modulated texture
and nothing else: it also darkened a decal texture, which the hardware
leaves alone, and the fog on top.

They now do what the per-pixel renderers do, by drawing twice. Once
the volumes are in the stencil buffer, the opaque and punch-through
polygons that take shadows are drawn again with a shader variant that
scales the two colours (pp_Shadowed), into the pixels that are theirs
(depth equal) and in a volume (stencil).

What that costs is kept to where the shadows are. The rectangle of the
screen the pass's volumes cover is taken from their vertices; only
polygons that reach into it are drawn again, and only the part of them
inside it, by scissor. Nothing outside that rectangle can be in a
volume, so this leaves out no pixel that would have changed. A frame
without modifier volumes does nothing new, and the shaders of polygons
drawn the first time are the same as before.

The darkening quad stays, for what cannot be drawn twice: polygons
that are blended, and opaque ones that wrote no depth to be found by.
The pixels drawn again are marked in stencil bit 6 and the quad skips
them; anything not marked is darkened as it was. Where two polygons
are at the very same depth, the mark is also what keeps the one that
was left showing the first time as the one left showing now.

Within a frame of several render passes only the pass's own polygons
are drawn again. Bump-mapped polygons have their offset values scaled
like any others, as in the per-pixel renderers.

rend/shadows.h holds what the two renderers share. tools/pvr's OpenGL
ES 2 test compiles the shadowed variants on an OpenGL ES 2 context and
checks that white comes out grey without a texture and green with a
green decal texture.
2026-10-06 06:42:39 +02:00
..