Skip to content

Alternative blend mode #798

@pekkavaa

Description

@pekkavaa

According to my experiments (writeup) and the angry lion source, the RDP blender equation is asymmetric

The "B" term in (P*A) + (Q*B) seems to get a small (1/64?) bias: https://github.com/ata4/angrylion-rdp-plus/blob/9c8b9ed3e7d7f00dff8bc872ccdd3fba1a3673fc/src/core/n64video/rdp/blender.c#L109

This is why sometimes users might want to try the alternative if alpha precision is an issue. My proposed alternative formula that swaps "P" and "Q" terms

rdpq_mode_filter(FILTER_BILINEAR);
rdpq_set_env_color((color_t){.r=0, .g=0, .b=0, .a=255});
rdpq_mode_combiner(RDPQ_COMBINER1((0, 0, 0,TEX0), (1, TEX0, ENV, 0)));
rdpq_mode_blender(RDPQ_BLENDER((MEMORY_RGB, IN_ALPHA, IN_RGB, INV_MUX_ALPHA)));

For reference, RDPQ_BLENDER_MULTIPLY is RDPQ_BLENDER((IN_RGB, IN_ALPHA, MEMORY_RGB, INV_MUX_ALPHA).

My original theory was that this would make sprites' opaque alpha=255 pixels transparent, but I can't make it happen with a test case. Anyway this is how it looks. The difference is admittedly tiny.

Before (RDPQ_BLENDER_MULTIPLY) and After (above):

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions