Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparency (alpha blend/clip) #8

Open
Dragorn421 opened this issue Oct 4, 2021 · 11 comments
Open

Transparency (alpha blend/clip) #8

Dragorn421 opened this issue Oct 4, 2021 · 11 comments

Comments

@Dragorn421
Copy link
Owner

Thanks @turpaan64

@Dragorn421
Copy link
Owner Author

Dragorn421 commented Oct 4, 2021

good alpha blend settings maybe @turpaan64

cvg_x_alpha cleared matters

@Dragorn421
Copy link
Owner Author

note: D_80116280 may be worth looking into for alpha blend transparency
looks like it's commonly used to make stuff fade away?

@Dragorn421
Copy link
Owner Author

Current Alpha Clip prevents fog, not ideal. Should take that into account when eventually batch testing

@Dragorn421
Copy link
Owner Author

Dragorn421 commented Oct 4, 2021

Poe, used for Alpha Clip & Alpha Blend I think

@turpaan64

{
    gsDPPipeSync(),
    gsDPSetTextureLUT(G_TT_NONE),
    gsSPTexture(qu016(0.999985), qu016(0.999985), 0, G_TX_RENDERTILE, G_ON),
    gsDPLoadTextureBlock(0x06003910, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 16, 0, G_TX_MIRROR | G_TX_CLAMP, G_TX_MIRROR | G_TX_CLAMP, 5, 4, G_TX_NOLOD, G_TX_NOLOD),
    gsDPSetCombineLERP(TEXEL0, 0, SHADE, 0, 0, 0, 0, TEXEL0, COMBINED, 0, PRIMITIVE, 0, COMBINED, 0, ENVIRONMENT, 0),
    gsDPSetRenderMode(AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | ALPHA_CVG_SEL | GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA), G_RM_AA_ZB_TEX_EDGE2),
    gsSPClearGeometryMode(G_G_CULL_BACK | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR),
    gsSPSetGeometryMode(G_LIGHTING),
    gsDPSetPrimColor(0, 0, 0xFF, 0xFF, 0xFF, 0xFF),
    gsSPDisplayList(0x08000000),
    gsSPVertex(0x060016B8, 3, 0),
    gsSP1Triangle(0, 1, 2, 0),
    gsDPSetCombineLERP(TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED),
    gsDPPipeSync(),
    gsSPClearGeometryMode(G_LIGHTING),
    gsSPDisplayList(0x08000000),
    gsSPVertex(0x060016E8, 3, 0),
    gsSP1Triangle(0, 1, 2, 0),
    gsDPPipeSync(),
    gsSPTexture(0, 0, 0, G_TX_RENDERTILE, G_OFF),
    gsDPSetCombineLERP(SHADE, 0, PRIMITIVE, 0, SHADE, 0, ENVIRONMENT, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED),
    gsDPSetRenderMode(AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA), G_RM_AA_ZB_OPA_SURF2),
    gsSPSetGeometryMode(G_G_CULL_BACK | G_LIGHTING),
    gsDPSetPrimColor(0, 0, 0x00, 0x00, 0x00, 0xFF),
    gsSPDisplayList(0x08000000),
    gsSPVertex(0x06001718, 15, 0),
    gsSP2Triangles(0, 1, 2, 0, 3, 4, 5, 0),
    gsSP2Triangles(6, 7, 8, 0, 9, 10, 11, 0),
    gsSP1Triangle(12, 13, 14, 0),
    gsDPSetCombineLERP(0, 0, 0, PRIMITIVE, 0, 0, 0, ENVIRONMENT, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED),
    gsDPPipeSync(),
    gsSPClearGeometryMode(G_LIGHTING),
    gsSPDisplayList(0x08000000),
    gsSPVertex(0x06001808, 3, 0),
    gsSP1Triangle(0, 1, 2, 0),
    gsDPSetCombineLERP(SHADE, 0, PRIMITIVE, 0, SHADE, 0, ENVIRONMENT, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED),
    gsDPPipeSync(),
    gsSPSetGeometryMode(G_LIGHTING),
    gsSPDisplayList(0x08000000),
    gsSPVertex(0x06001838, 6, 0),
    gsSP2Triangles(0, 1, 2, 0, 3, 4, 5, 0),
    gsSPEndDisplayList(),
}

@Dragorn421
Copy link
Owner Author

Alpha Clip, Cucco:

@turpaan64

{
    gsSPTexture(qu016(0.999985), qu016(0.999985), 0, G_TX_RENDERTILE, G_ON),
    gsDPPipeSync(),
    gsDPSetRenderMode(AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | ALPHA_CVG_SEL | GBL_c1(G
_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA), G_RM_AA_ZB_TEX_EDGE2),
    gsDPSetCombineLERP(TEXEL0, 0, SHADE, 0, 0, 0, 0, TEXEL0, PRIMITIVE, 0, COMBINED, 0, 0, 0, 0, COMBINED),
    gsDPSetTextureLUT(G_TT_NONE),
    gsDPLoadTextureBlock(0x06002080, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 16, 0, G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_T
X_CLAMP, 3, 4, G_TX_NOLOD, G_TX_NOLOD),
    gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, qu102(7), qu102(15)),
    gsDPSetPrimColor(0, qu08(0.5), 0xFF, 0xFF, 0xFF, 0xFF),
    gsSPSetGeometryMode(G_LIGHTING),
    gsSPClearGeometryMode(G_G_CULL_BACK),
    gsSPClearGeometryMode(G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR),
    gsSPVertex(0x060006D0, 3, 0),
    gsSP1Triangle(0, 1, 2, 0),
    gsSPEndDisplayList(),
}

@Dragorn421
Copy link
Owner Author

Alpha Blend, water plane

@turpaan64

{
    gsDPPipeSync(),
    gsDPSetTextureLUT(G_TT_NONE),
    gsSPTexture(qu016(0.999985), qu016(0.999985), 0, G_TX_RENDERTILE, G_ON),
    gsDPLoadTextureBlock(0x06007D20, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR |
G_TX_WRAP, 5, 5, 14, 15),
    gsDPLoadMultiBlock(0x06007520, 0x0100, 1, G_IM_FMT_IA, G_IM_SIZ_16b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMI
RROR | G_TX_WRAP, 5, 5, 15, 14),
    gsDPSetCombineLERP(TEXEL1, TEXEL0, ENV_ALPHA, TEXEL0, 0, 0, 0, 1, COMBINED, 0, SHADE, 0, COMBINED, 0, PRIMITIVE, 0),
    gsDPSetRenderMode(AA_EN | Z_CMP | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | GBL_c1(G_BL_CLR_FOG, G_
BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA), G_RM_AA_ZB_XLU_SURF2),
    gsSPClearGeometryMode(G_G_CULL_BACK | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR),
    gsSPSetGeometryMode(G_FOG),
    gsDPSetPrimColor(0, 0, 0xFF, 0xFF, 0xFF, 0x66),
    gsSPDisplayList(0x0C000000),
    gsSPVertex(0x06004AD0, 5, 0),
    gsSP2Triangles(0, 1, 2, 0, 0, 3, 1, 0),
    gsSP2Triangles(3, 4, 1, 0, 4, 2, 1, 0),
    gsSPEndDisplayList(),
}

@Dragorn421
Copy link
Owner Author

Dragorn421 commented Oct 4, 2021

Alpha Blend, bushes and trees:

@turpaan64

{
    gsDPPipeSync(),
    gsDPSetTextureLUT(G_TT_NONE),
    gsSPTexture(qu016(0.999985), qu016(0.999985), 0, G_TX_RENDERTILE, G_ON),
    gsDPLoadTextureBlock(0x06003790, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 128, 0, G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX
_CLAMP, 5, 7, G_TX_NOLOD, G_TX_NOLOD),
    gsDPSetCombineLERP(TEXEL0, 0, SHADE, 0, 0, 0, 0, TEXEL0, COMBINED, 0, ENVIRONMENT, 0, 0, 0, 0, COMBINED),
    gsDPSetRenderMode(Z_CMP | IM_RD | CVG_DST_FULL | ZMODE_XLU | FORCE_BL | GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_
IN, G_BL_1MA), G_RM_ZB_XLU_SURF2),
    gsSPClearGeometryMode(G_G_CULL_BACK | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR),
    gsSPSetGeometryMode(G_FOG | G_LIGHTING),
    gsDPSetPrimColor(0, 0, 0x23, 0x4C, 0x19, 0xFF),
    gsSPVertex(0x06007DF0, 3, 0),
    gsSP1Triangle(0, 1, 2, 0),
    gsSPEndDisplayList(),
}

@Dragorn421
Copy link
Owner Author

Alpha Clip @turpaan64

@Dragorn421
Copy link
Owner Author

Alpha combiner cycles shouldn't use shade because apparently that makes stuff transparent from far away, for unexplained reasons

More test for batch testing

@Dragorn421
Copy link
Owner Author

Dragorn421 commented Dec 19, 2021

May be relevant for alpha clip (or any kind of alpha really)?

Manual 15.5.4 Alpha Compare Calculation http://n64devkit.square7.ch/pro-man/pro15/15-05.htm#04
gDPSetAlphaCompare http://n64devkit.square7.ch/n64man/gdp/gDPSetAlphaCompare.htm
gDPSetBlendColor http://n64devkit.square7.ch/n64man/gdp/gDPSetBlendColor.htm

gDPSetAlphaCompare(G_AC_THRESHOLD) makes a primitive draw only where its alpha is > the blender color register alpha

@Dragorn421
Copy link
Owner Author

Manual 15.7.2 Transparent Surfaces, XLU_SURF http://n64devkit.square7.ch/pro-man/pro15/15-07.htm#02
Table 15-5 Antialiased Z-Buffered Rendering Modes, G_RM_AA_ZB http://n64devkit.square7.ch/pro-man/pro15/15-07.htm#t15-05

CLR_ON_CVG is meant for alpha blend. In that case the coverage value should be used unaltered (clear alpha_cvg_sel and cvg_x_alpha)

the zbuffer should (indeed) not be written to for alpha blend (see last note in 15.7.2 and table)

see also http://n64devkit.square7.ch/pro-man/pro15/15-07.htm#09 for description of g*DPSetRenderMode() flags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant