-
Notifications
You must be signed in to change notification settings - Fork 62
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
Multiply with var_Color in lightMapping after u_AlphaThreshold check #1417
Conversation
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 the map if it's a map bug. |
LGTM for putting on the 0.56 branch. |
… check Fixes DaemonEngine#119. See DaemonEngine#1417 for details.
0e1634f
to
32bdcdd
Compare
(rebased & squashed, +re-targeted to |
Actually, I tried this with rebasing on master, and all the plants are now rendered correctly, probably because something was fixed on master or how it worked changed. So I think it's fine to merge this into |
Now I'm a bit lost… As far as I understood this branch is not anymore about preventing those models to disappear but to fix the blending math. The model being disappearing should be fixed in the material itself. So if the current patch is doing the contrary to what was initially proposed, i.e. keeping the code that was making models disappear, and modifying the remaining code to do the same, then it looks good to me. I have a branch for the station15 map that moves the alpha brushes out of those models so the models don't disappear, and I remember @SomaZ made some suggestions to modify the materials to prevent the bug to occur even if they are within alpha brushes (I will also test this). The disappearance of those models can be fixed in two ways (one verified, one to be verified) in the map while keeping correct the blending math in engine. |
This doesn't seem to be rebased yet on |
Hmm, I tried this again and now I just get the plant above partially disappearing, and the one in #119 completely invisible. So the result I got earlier might be a shader cache issue.
It is, yeah.
Which branch is that? |
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.
Doing vertex color multiply before discard check is correct in terms of compatibility. Should fix void effect on surfaces using different shaders where it was handled correctly before. Main issue with the trees in this case is, that there's an alpha brush that sets some of the trees vertices alpha. An alphaGen identity in the trees shader should prevent the usage of the incorrectly set vertex alpha values.
… check Fixes DaemonEngine#119. See DaemonEngine#1417 for details.
32bdcdd
to
bc7e247
Compare
(rebased on |
Changing the plants and trees to use |
See DaemonEngine/Daemon#119 and DaemonEngine/Daemon#1417 for details. Also fixes back-face culling being applied to one-sided plants.
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.