-
Notifications
You must be signed in to change notification settings - Fork 64
Naive blending compatibility #1855
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
base: master
Are you sure you want to change the base?
Conversation
Also make sure to invalidate stages with a missing colormap that is of different kind (diffusemap…).
40bba05
to
5302a8b
Compare
For now I haven't implemented a keyword to enforce blended stages to be processed the linear way. The compatibility mode simply makes the texture and the colorGen not being converted from sRGB, making the colors painted as linear, like the naive pipeline did before the linear pipeline was implemented. |
In what scenario is the code intended to be used? For example rendering legacy maps in linear blendspace? Rendering new game models in naive blendspace? |
Rendering maps recompiled for the linear pipeline but without any asset change. You take a legacy map, you rebuild it, you modify nothing else, it would be “good enough”. To complete the port one would have to modify the blending shaders, but this compatibility mode removes that step as a hard requirement. Especially, maps using only the |
Map Point of interest: the background door, behind two windows in a row. Naive blend shaders, naive build, naive renderer: Naive blend shaders, linear build, linear renderer: Naive blend shaders, linear build, linear renderer with compatibility blend mode: Map Point of interest: the force field. Naive blend shaders, naive build, naive renderer: Naive blend shaders, linear build, linear renderer: Naive blend shaders, linear build, linear renderer with compatibility blend mode: The glass in The force field in |
One that suffers a lot is the Map Point of interest: the force field. Naive blend shaders, naive build, naive renderer: Naive blend shaders, linear build, linear renderer: Naive blend shaders, linear build, linear renderer with compatibility blend mode: We notice that without the compatibility mode, we cannot see the grid of the forcefield at all, and the whole surface is too much transparent, while with the compatibility mode, we see the grid and the surface is opaque enough, that fixes an element of gameplay. Of course the color would better be tweaked, and like with |
Alongside Map Points of interest: the various glass surfaces on doors and cylindrical models on the floor. Naive blend shaders, naive build, naive renderer: Naive blend shaders, linear build, linear renderer: Naive blend shaders, linear build, linear renderer with compatibility blend mode: Something we can touch-up a bit in |
Hmm, one that looks ugly with that compatibility mode for |
Hmm, while for That's annoying because I was hoping for a quirk that would be better in average. If we can't be better in average for blend modes as popular as And if a blend mode cannot be automated and we better default to the “non fix” for it, then for consistency we better stick to the default behavior for all blend modes. What this experiment demonstrated though, is that switching to either linear or to naive mode is always a good way to give a better result in a very quick way, without editing the actual files. So I plan to do that:
All the maps I have tested from stock Unvanquished assets and InterStellarOasis ones were able to immediately get something usable just by selecting one mode or another. I assume we can blindly enable the linear mode in all the blend Selecting one mode or another per blend stage is enough to be able to re-release a map just by rebuilding it, without breaking the gameplay. Tweaking the assets to make them look better is only an improvement over that. It's probable that only the quoted force fields may really benefit from manual asset tweaking outside of just flipping a blend mode in a shader (like actually editing an image). |
|
If we do a compatibility mode, it would be the default mode, and would use heuristics to somewhat fix legacy assets in the linear pipeline. And then q3shaders fixed for the linear blending would have a special keyword to tell they're fully linear and skip the heuristics. That was my idea when I first started to work on this. My first idea was that the Now, the results of my tests with I don't see any advantage of making a compatibility mode that doesn't work out of the box, if it requires to flag something to enable the compatibility mode, then it's not a compatibility mode. Now, what we can do is to not have such compatibility mode, but to add compatibility keywords to the shader lexicon. Basically one would do:
This requires every shader that are known to work better the naive way to be tagged this way. With legacy maps it would do nothing, it's already naive, with maps rebuilt for the naive pipeline, it would upload the image as is without transformation, the naive way, because we would have tested we prefer that look. If we can find good heuristics that works “good enough” like 95% of the time, we can consider such automatic compatibility mode, otherwise no. Right now with Now, one thing I need to say is that I want to guarantee mappers and map porters they wont have to edit all the blend images in an image editor to benefit from the linear pipeline. I want to reduce the map migration cost as much as possible, ideally just requiring a rebuild with the new map compilation profile, otherwise we will suffer maps rebuilt the legacy way forever, and this is not good because we have unfixable bugs with maps built the legacy way, especially when we start adding specular maps, etc. If we cannot avoid requiring the edit of some legacy assets when rebuilding map the linear way, then the cost of such edit should be the lowest possible. If switching from linear to naive a blend shader fixes it in an acceptable way, that cost looks small enough for me. Maps usually only have one or two blend shaders, with luck, some of them will already in be rendered in a “good enough way” without doing anything. Using a trick once or twice per map by adding a keyword to a shader is fine. Also I don't mind if such trick hasn't any mathematical meaning. The correct way to fix a blend shader is to edit the image, but if a low-cost stupid and wrong trick provides an acceptable result, we should provide it. In other words: I want the mappers to be able to port the maps first and procrastinate the perfect solution for the only one shader that doesn't work well by default. If we don't give such option, mappers may keep the whole map the legacy way while only one shader is broken the linear way, that would be a shame… |
And by mappers I include myself, I want to rebuild all the Unvanquishes stock maps the linear way as soon as possible, and I want to do the same for the InterstellarOasis maps. I don't want to edit images. I don't want to allocate time to run a trial and error dance while editing images on every step to fix a shader for the linear build. One force field to edit? Why not, but not more than that. |
It's also important to know that once an Unvanquished release is published with the stock maps built the linear way, I will make that map build profile the default in Urcheon and NetRadiant and I will re-release NetRadiant. They will provide a legacy build profile, but the linear one will become the default. That's also why I want to reduce the cost of porting maps to the linear pipeline to zero if possible, almost zero otherwise. If heuristics can do that, let's go. If heuristics can't do, I want the port effort to only require one or two keywords added to shaders, per map, and for not all the maps. We need that starting from a given day, very soon, every newly built map, brand new or rebuilt, will use the linear pipeline, by default. |
It seems wrong to enable compatibility heuristics by default. This means that a mapper starting a new map from scratch will be burdened by compatibility cruft, unless they know about the hidden option to turn it off.
Supposed you have implemented the magical compatibility heuristic that makes everything look good 100% guaranteed. If the compatibility mode is off by default, all you have to do to re-release a map is add the sRGB flags for q3map2, enable the compatibility option, and rebuild. That's hardly more difficult than just changing the q3map2 flags and rebuilding. For artists, the more common pattern is to work on the map for a relatively brief period of time, then stop. Legacy map re-releases are likely to be done by a more technical person such as yourself. It doesn't make sense to hobble artists starting a new map just to make recompiling a legacy map 1% easier. |
Unless newly made shaders use a special syntax that never rely on heuristics. My idea was that the historical So I don't consider such heuristics anymore anyway, unless someone comes with some magic by the end of the next week. |
Well, the Q3A shader manual still seems to be state-of-the-art for shader documentation... the likely result is that 90% of new maps would keep using the old |
5302a8b
to
bf586ee
Compare
So,
Here is how looks the Here is the modified shader: textures/plat23_custom/forcefield
{
qer_editorImage textures/plat23_custom_src/forcefield_p
surfaceparm trans
surfaceparm nomarks
surfaceparm nolightmap
cull none
{
map textures/plat23_custom_src/forcefield_a
tcMod Scroll .1 0
blendFunc add
}
{
map textures/plat23_custom_src/forcegrid_a
tcMod Scroll -.01 0
blendFunc add
naiveBlend
rgbgen wave sin .2 .2 0 .4
}
{
map textures/plat23_custom_src/forcefield_heathaze
stage heathazeMap
deformMagnitude 1
tcmod scale 1 1
tcmod scroll .03 .03
} It's a very easy way to workaround a shader designed for the naive pipeline when rendering with the linear pipeline. I like it. |
Also make sure to not attempt to load a colormap after an animMap.
bf586ee
to
c29689f
Compare
That may be ready. I now believe it's a bad idea to have a cvar to force a blend mode for quickly testing how shaders in a scene render, because there can be multiple blended stages in a single shader, and people may want to only tweak on of them. Such cvar would tweak all of them at once and then would be useless. |
I also implemented the delaying of animation textures. |
This also improves over existing code (even without using the feature):
|
c29689f
to
061fe63
Compare
So we need a way to make an image brighter. The solution proposed here is to load the image with deliberately wrong colorspace management. That works, but it has the drawback of not being adjustable - it's a checkbox rather than a slider. It would be nice to be able to just multiply the colors by some freely chosen value, as if you doing By the way is the design goal of this to make a shader that can load differently depending on the blend regime, or is it just for one-way migrations to linear blending? |
Or perhaps a gamma curve type adjustment like sRGB conversions would indeed be better than simple multiplication, but it would be nice to have an adjustable exponent. Let the user do |
Work-in-progress attempt to implement compatibility for naive blended assets in the linear pipeline.
It includes a patch to delay the loading of textures from pre-collapsed stages to the end of the stage parsing, after the blend mode is known, because it is required to select the right compatibility code for the given stage.