Reply 20 of 25, by Dege
😀 😀 😀
"prologue in heaven" in a discussion between you and Paul Gardiner in 2003 (you knew
Good old days... 😀
So, has this simple hack solved the shadow-glitch?
I don't really understand why you wanted to OR the constant colors coming from different calls, it won't give good results. By the way, reading back my previous post I must refine my words:
Also, the point is, GR_COLORCOMBINE_CCRGB is only used to draw the shadow AFAIR. Different mode is used for all other untextured polygons (because they are lightened, e.g. Lara's arms and legs, etc.).
GR_COLORCOMBINE_CCRGB might not be used only for the shadow and black text bkgnd, can't tell it by head by now 😀 , but as far as I remember, all pipeline config is done in guColorCombineFunction(GR_COLORCOMBINE_CCRGB), grConstantColorValue(color) order. Except for the magic 0x7f000000 value, because calling grConstantColorValue seems to be forgotten for that value. So when dgvoodoo set 0x7f000000 as the const color, it doesn't mess up anything because TR's subsequent grConstantColorValue call overwrites that. (It wouldn't work in reverse order.)
And, why is this working on a real voodoo after all without that hack? It's a mystery for me, maybe the case is as Paul said (and the document isn't precise), or a bug in the drivers, who knows... 😀
In TR Unfinished Business I saw (but only now that you explained I can see why) it changes, but eventually boils down to the same business via a call to grConstantColorValue4() taking four float's instead of an int.
One important thing about constant color to clarify: actually there are two different instances of constant colors maintained in voodoo driver's internals. They are for different purposes. One can be set with grConstantColorValue and the other can be set with grConstantColorValue4. They have nothing to do with each other, so that grConstantColorValue4 won't overwrite the constant color set with grConstantColorValue and vice-versa.
grConstantColorValue is used when the pixelpipeline refers to GR_COMBINE_xxxxx_CONSTANT.
grConstantColorValue4 is used when the pixelpipeline refers to GR_COMBINE_xxxxx_ITERATED and delta0 mode is enabled.
So that if I do a call like this:
grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_CONSTANT, FXFALSE)
and enable delta0, then the color output turns to be grConstantColorValue4*grConstantColorValue. Of course, if delta0 is disabled then output is iteratedvertexcolor*grConstantColorValue.
dgVoodoo handles this one simply as well, if delta0 is enabled then it sets all triangle vertex colors to grConstantColorValue4 in place of the ones coming from the GrVertex strucs.
code snippet:
...
GrVertex *vertex;
...
actVertexPtr->specular = (actVertexPtr->diffuse = (astate.flags & STATE_DELTA0) ? astate.delta0Rgb : GetARGB(vertex)) ^ 0xFF000000;
...
EDIT:
I must correct myself, I'm silly.
So that if I do a call like this:
grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_CONSTANT, FXFALSE)
and enable delta0,
Actually, this can't be done I think because delta0 can only be enabled via guColorCombineFunction by GR_COLORCOMBINE_ITRGB_DELTA0 and GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB_DELTA0. All other values disable delta0.
But there is a conundrum here: what happens on a real voodoo after the following call pattern:
guColorCombineFunction (GR_COLORCOMBINE_ITRGB_DELTA0);
grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_CONSTANT, FXFALSE);
Whether delta0 mode remains enabled or not? 😁