-
Notifications
You must be signed in to change notification settings - Fork 181
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
Add support for BSP "LIGHT" surfaces #111
Conversation
56c694b
to
cd2ae5c
Compare
Hey @apanteleev, what's your opinion on this? |
This is an amazing PR, and will fix many Maps throughout many mods. For instance Lokis Minions almost all maps use emissive textures as lights, so in RTX they are far too dark. Without going through and manually updating maps this is impossible to fix. This fix solves that. There are literally thousands of maps that will possibly fixed by this PR. Kudos! |
Well, in general, I wouldn't mind merging this. But one thing I dislike about the implementation is that there seems to be a significant amount of image processing being done on the CPU at map load time. Maybe it's insignificant, but I feel like our loading process is slow enough already, with all the image extraction from .pkz and decoding being done in a single thread. Have you measured the impact of this processing on load times? |
Well, while the main cvar is "on" by default, it shouldn't matter too much for baseq2, as the mechanism doesn't do any image processing if there's a material.csv entry for the texture, which (to my knowledge) all baseq2 wall textures have. Yes, image processing on the GPU is quite sensible. But the CPU approach more easily fits into the current "upload a bunch of pixels" model, while a GPU processing component will need some enhancements to the texture uploading mechanism. Thanks for your feedback. It's good to know directions to get my ideas shared with the world :) (Unfortunately I don't have hard numbers on the load time difference. I can't quickly produce some right now either - there's no "map load time" measurement built in, and subjectively, the difference is too small to measure manually. Perhaps reporting a "map load time" is a worthwhile addition in itself.) |
I've tested this PR with the current Edit: the change about ignoring baseq2 materials was in another PR that I already merged. Oh well. |
My go-to test was mostly some maps of xatrix (The Reckoning), and it seemed fined there... but yeah, it's very texture-dependent (and also subjective). Yes, a cvar would a good way to quickly see what effects different thresholds have. What would probably be best would be to have a database that allows tweaking of the threshold (maybe other parameters) per texture. In an earlier iteration I had this: BTW, did you mean this: res2k@2415da2 with "ignoring baseq2 materials"? |
Required for proper reloads with custom materials present.
We're using "just" MAT_RegisterPBRMaterial() for synthesized materials, even when reusing a previous material - but that case needs an image registration sequence update. So just "update" a material upon registration.
Previously, the algorithn was to simply extract pixels above a certain dynamic brightness. Some scaling and blurring was applied as well. The results were usable but could be crude-looking. The new approach determines all 'bright' pixels (largest component above a certain) and applies some blurring as well as some filtering with the original image. After some experimentation with the details this resulted in an algorithm that seems to extract emissive images that seem to be relatively faithful to the appearance of the "light" part of original textures.
Makes them look a bit less blocky.
…ntical to the 'baseq2' image
@apanteleev Also check this commit: 937fb77, may affect your experience with Ground Zero. Also, if which levels in Ground Zero did you look at? I'd like to check them out as well. |
Just the first one, |
Please try again with the latest change, this improves lighting there quite dramatically. |
When looking for an override, don't prefer 'game' images over 'base' images. This is more or less another workaround for games that duplicate base textures; in that case, we want to preferably use any high-res overrides and it's additional images.
For lighting, Q2RTX predominantly uses light-emitting surfaces. The amount of light a surface should emit is determined by an entry in the materials list and an "emissive" texture associated with a material. Material definitions and, if appropriate, emissive textures are provided for basically all baseq2 materials.
Unfortunately, if an emissive texture is not present, a surface won't emit light. This is a problem for maps that use materials beyond the baseq2 set - ie from mods or mission packs (see also #77).
Fortunately, the original light information is still present: the
SURF_LIGHT
flag indicates that a surface should emit light.With this information "old" maps could be lit much more like they were intended to.
This patch adds a check for
LIGHT
surfaces and the ability to synthesize an appropriate light-emitting material.An emissive texture is guessed from the diffuse texture by taking the "brightest" pixels. This looks okay for textures in the typical Quake 2 "wall light" style. (An earlier approach was to use the diffuse texture only. While useable, it's not the most attractive look.)
Additionally, while trying out the changes, I noticed:
LIGHT
flag, and it's texture has amaterials.csv
entry, but it lacks the emissive texture (happens in egbase3
). This probably indicates an "artwork problem" - missing emissive texture - that results in surfaces not emitting light, though they were originally intended to.base1
cellar). To see the difference setpt_enable_surface_lights_warp
to 1. I left it off by default since mainly because it's a hack, having water emit light without light textures. That "proper" way is also available (set bothpt_enable_surface_lights
andpt_enable_surface_lights_warp
to 2), but the result looks quite weird/jarring/unappealing.FWIW, the faint "water light" might very well be relevant in certain dark areas, so it might be good to find a way to have it back (without hacks).