-
Notifications
You must be signed in to change notification settings - Fork 61
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
Multiply with var_Color in lightMapping after u_AlphaThreshold check #1417
base: master
Are you sure you want to change the base?
Conversation
Fixes an issue creating a void effect, where vertex + color/diffuse map produces different results in depth pre-pass `generic` and `lightMapping` shaders, due to different check/multiplication order.
So what is "alphagen vertex" used for? Also why does q3map2 even write values other than 1 to the alpha of the vertex color? Seems weird |
I suppose it's still used for blending. |
It is used for terrain blending, for example in a single shader you have a rock and a sand stage, and one of the stage receives its alpha channel from the vertex, this makes possible to blend two terrains per surface. |
Do we have an example of such a shader? |
The garden in station15 (grass/mud), the outdoor of thunder (rock/sand). |
It modifies the way the grass/mud floor is rendered in the garden: Before: After: Now it's possible that is the map that is wrong. I had to edit it to workaround a q3map2 bug, but I remember I struggled to get the effect in the first screenshot, as I didn't seen much correlation between what I did in editor and the result I was getting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a discussion in IRC in which SomaZ said that actually the generic shader is the "correct" one, in terms of matching q3 behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing vertex alpha multiplication to be performed after the alpha discard is wrong (in terms of compatibility). Changing it to be performed before the discard in the other shaders like the generic shader would be the correct fix in terms of compatibility. This should also fix the incorrect void effect illwieckz encountered on station15 with the trees.
The generic shader actually does multiplication after discard. |
I tried that, and the small plants on the ground in station15 in the same area started disappearing based on distance. Although perhaps that is another map bug that was trying to workaround an engine issue. |
Probably it's the same issue as the trees, with the alpha volumes, which are intended to affect only the ground, doing collateral damage to the plant models? If there are a lot of bad alpha volumes, maybe it would be easier to put Changes like this which break the current version of our assets can be targeted to the |
Actually multiplying before testing makes sense if one wants to combine This may look weird, but it allows to do alpha blending with a strong cutoff: instead of linearly blending from moss to mud, only values above 50% makes mud appear, and everything elle displays full moss. The fact I didn't felt something was meaningful between what was done in the editor and what was gotten in game was because I did not notice that cut-off. Now that I know about it, what I get in game is what I do in editor while taking such cut-off in consideration (only using alpha brushes higher than 50%). |
Yes, it's likely the same problem, as we see on above screenshot some plants are in some alpha volumes. It can be worked around by having smaller alpha volume that only hits the brushes intersections to mark them. Doing a large alpha brush is just a lazy way to mark all brushes intersections from a whole area. Also for the tree, the alpha brush can just be made less high, but that would not work for plants. Actually I'm happy we start grasping what's going on after all those years. |
I've added a commit that reverts the change to lightMapping and changes the generic shader instead, but now the plant isn't rendered. Maybe you could look at thr map if it's a map bug. |
LGTM for putting on the 0.56 branch. |
Fixes an issue creating a void effect, where vertex + color/diffuse map produces different results in depth pre-pass
generic
andlightMapping
shaders, due to different check/multiplication order.Fixes #119. I've also tried moving the multiplication before the check in
generic
shader, but it ended up making surfaces disappear based on distance to them.