Commit Graph

47 Commits

Author SHA1 Message Date
Ivan Avdeev aaa6de330c vk: rt: add experimental second Á-Trous pass for indirect diffuse
Now indirect diffuse channel gets blurred with 2 Á-Trous passes. It
mostly follows the paper, except for Σd_i, which gives very bad
viusal artifacts.
2024-02-01 10:36:34 -05:00
Ivan Avdeev a56e6a42a5 vk: rt: parametrize different light channels differently in denoiser 2024-01-29 12:49:32 -05:00
Ivan Avdeev 5d6c1d4bfc vk: rt: tune denoiser "a-trous" parameters a bit 2024-01-29 12:07:20 -05:00
Ivan Avdeev be8da3252a vk: rt: fixup too bright direct lighting 2024-01-26 14:38:31 -05:00
Ivan Avdeev a578becdd9 vk: rt: add diffuse and specular debug display modes
These will display diffuse and specular channels, both direct and
indirect, after spatial denoiser, but before temporal one.
2024-01-26 14:02:19 -05:00
Ivan Avdeev 6169734f91 vk: rt: do À-Trous lighting denoise
Works reasonably well, but a bit under-tuned, and remains only single-pass for now.
2024-01-26 13:59:15 -05:00
Ivan Avdeev cf59921c41 vk: rt: degrade spatial image quality by box blur denoiser
Our gaussian blur is incorrect, as it doesn't preserve luminance, and
the final imaga ends up being darker than it should be.

Do a box blur as a simple test. It does result in a correctly looking
white furnace test image (modulo square blocks and luminance leaking).
2024-01-26 12:50:08 -05:00
Ivan Avdeev e8400398bd vk: rt: add debug non-blurring denoiser code
Enabling it makes it clear that blurSamples() loses luminance.
Also it exposes temporal denoiser glitches.
2024-01-26 11:24:49 -05:00
Ivan Avdeev 6d58ad8df0 vk: rt: add white furnace debug display mode
Known issues:
- it doesn't really look how it's supposed to look
- using debug display mode for it was a mistake
2024-01-26 10:34:46 -05:00
Ivan Avdeev 18269ebf81 vk: rt: fixup 2024-01-23 12:13:48 -05:00
Ivan Avdeev b01fa98c8b vk: rt: improve spec-vs-diff estimation for bounces
Estimate relative specular contribution based on fresnel term and
base_color. Pick bounce type based on that.
2024-01-23 10:47:21 -05:00
Ivan Avdeev e7ff1f3d3a vk: filter out degenerate triangles in brush models
This fixes lighting NaNs caused by NaN poison from invalid/zero normals.
2024-01-16 12:29:15 -05:00
Ivan Avdeev 0fd97e2544 vk: rt: sample point light sources as spherical
1. Sample point lights as spheres. Use existing pdf value (`one_over_pdf`), as it was basically correct.
   Compute max_theta angle based on light radius and distance to the
   center. Sample cone direction based on this theta angle, in z=n space.
   Don't do anyhting fancy wrt horizon, etc.

2. Sample environment light with max theta derived from real world sun
   solid angle. Uses the same cone direction sampling.

Known issues:
- still get some NaNs sometimes, esp. on test_light map.
- Too many different light sources try to use the same code. They should
  be split.

Relevant issues: #266, #151
2024-01-12 13:31:02 -05:00
Ivan 'provod' Avdeev 3153a83621 vk: rt: add material debug display mode
Also add debug display modes info
2024-01-11 11:56:23 -05:00
Ivan Avdeev c64000195d vk: rt: organize shader printf debugging
Introduce several shader debugging/validation tiers:
1. Basic key values validation, to make sure there are no nasty NaNs or
   invalid values written to G-buffers. Enabled by `DEBUG_VALIDATE` macro
   in debug.glsl
2. Key value validation with whining: use `debugPrintfEXT()` function to
   report any invalid values to Vulkan validation layers. Enabled using
   `DEBUG_VALIDATE_PRINT` macro. Currently this is the one enabled, as
   it allows us to catch any serious numerical issues during development
   and testing.
3. Extra validation and printing for intermediate values. This is for
   deeper investigations, and enabled only there temporarily.
2024-01-09 12:05:31 -05:00
Ivan Avdeev a147c89a53 vk: rt: fixup reprojection black borders 2024-01-08 13:55:39 -05:00
Ivan 'provod' Avdeev 20e9af6496 vk: rt: allow disabling debug printfs in shaders 2024-01-08 13:45:00 -05:00
Ivan 'provod' Avdeev 96b4ea6345 vk: rt: use shader printf debugging to fix some nans 2024-01-08 12:03:56 -05:00
Ivan Avdeev 55fe48659e [wip] vk: rt: add 2nd bounces w/ idiotic sampling
Completely rework bounces, allow 2nd+ bounces.

Still work in progress with lots of debug code.
2024-01-04 13:10:26 -05:00
Ivan Avdeev e9b05ff849 vk: rt: add direct_{diff,spec} debug display
also try to simplify brdf ggx math
2024-01-02 13:32:49 -05:00
Ivan Avdeev 88b24ad3bd vk: rt: rewrite direct-eval brdfs from scratch
Deprecate `brdf.h` usage, start writing our own BRDF functions.

Use glTF 2.0 BRDF mixing model as a simple starting point.
Mix-in base_color into specular early, as it is light-direction
dependent and cannot be easily separated.

Disable bounces for now, as we don't have yet good sampling story, need
to write "backwards" BRDFs that give us ray directions to sample, and
accommodate for that sampling bias in BRDF attenuation itself.

Also introduces some other weird artifacts on `test_material` map, investigation pending.

Related to black metals in #666
2024-01-02 13:01:58 -05:00
Ivan Avdeev 3bc293d8aa vk: rt: compute legacy blending in sRGB-γ colorspace
This makes all blending look very close to the original, and fixes a
whole class of blending-looking-wrong issues.

Fixes #668
2023-12-29 12:10:54 -05:00
Ivan Avdeev caac371681 vk: rt: tune emissive/additive blending so that it matches original
To match original more closely it additive geometry should be added to
final color in sRGB-γ space. You might not like that it is physically
incorrect, but this is what peak compatibility looks like.

Related to #668
2023-12-22 14:23:22 -05:00
Ivan Avdeev c8123952a2 vk: rt: fix incorrect basecolor brdf multiplication
PBR model used implies the following rules:
- for metals both diffuse and specular components should be tinted by
  material base color.
- for dielectrics, only diffuse should be tinted, specular should remain
  as is.

Partially fixes #666
2023-12-11 11:48:44 -05:00
Ivan Avdeev e00f758594 vk: revert back indirect specular kernel size 2023-12-05 11:14:25 -05:00
Ivan Avdeev 84f6d7d10b vk: rt: fix reading garbage values out of indirect spec bounds
Indirect specular and diffuse have half frame resolution.
Denoiser code was incorrectly reading past the valid range for indirect
specular values. This was sometimes giving visual glitches at frame
borders.

Fixes #685
2023-12-04 12:14:44 -05:00
Ivan Avdeev 605647aecc vk: rt: support changing screen resolution
Fixes #343
2023-11-30 13:01:40 -05:00
Ivan Avdeev 2139b32f75 vk: rt: allow disabling temporal denoiser 2023-11-21 12:10:14 -05:00
Ivan Avdeev 4897da4f45 vk: document frame comparison effort 2023-11-20 13:02:21 -05:00
Ivan Avdeev a25bf841ac vk: fix bright artifacts coming from unpatched chrome materials
Fixes a typo that rewrote roughness value with garbage.

Also adds a few more debug channel displays for lighting phases. And
prints out available debug displays.

Fixes #641
2023-11-06 12:47:21 -05:00
Ivan Avdeev 28eec97cbf vk: implement r_lightmap for both traditional and RT renderers
Display lightmap plus lighting for traditional.
Display all collected lights (including bounces and simple transparency)
for RT.

Fixes #634
2023-11-03 11:26:57 -04:00
Ivan Avdeev 0ba85e3f08 vk: add `rt_debug_display_only` cvar
Displays only the specified channel.

Fixes #631
2023-11-03 10:58:13 -04:00
Ivan Avdeev dfa240a4db vk: fix weird lines on suit studio model
It was using old pre-transform values for prev_verts, and that was
confusing temporal denoiser.

We should bone-transform vertices first, and only then store them as
prev_verts.

Fixes #585
2023-11-02 10:13:56 -07:00
Ivan Avdeev 6fda8bd977 vk: add a mechanism for exclusion of single surfaces from smoothing
Uses `_xvk_smoothing_excluded` field.

Surfaces can still be smoothed with a limited list of neightbours explicitly
by being included in a smoothing group.

Fixes #619
2023-10-31 09:55:06 -07:00
Ivan 'provod' Avdeev 23341c144c vk: fixup blue noise 3d texture refactoring
Fixed a bunch of validation and shader errors
2023-10-30 13:51:23 -04:00
Ivan Avdeev df3c0e30ba vk: convert blue noise texture to 3D
Note: not tested
2023-10-30 13:43:09 -04:00
NightFox ecdb68370b
Merge branch 'vulkan' into materials-table 2023-10-10 20:32:04 +03:00
Ivan Avdeev fadde2ea0d vk: rt: convert more engine-supplied colors from sRGB to linear
- model.color
- vertex_color
2023-10-10 11:56:42 -04:00
Ivan Avdeev d76d6429d0 vk: rt: ensure that base_color_a is stored in sRGB-γ
Storing it linearly was a mistake: it is 8-bit only, and lacks enough
precision for dark values. It also doesn't really need any more
precision, and should be limited to 0..1 range.

Therefore, it makes sense to treat it as sRGB explicitly.
2023-10-09 14:51:29 -04:00
Ivan Avdeev 60f83245ee vk: rt: make base_color_a linear-space
Convert from gamma to linear at the point where we read from texture.

Prerequisite for making textures in a right colorspace.
2023-10-06 13:51:32 -04:00
Ivan Avdeev a1cae92a2c vk: textures: add blue noise textures
They are not used by anything yet.

Fallback to generating regular noise textures if bluenoise ones weren't
found.

Real blue noise textures require Half-Life-PBR repo textures.
2023-09-11 12:31:03 -04:00
Ivan Avdeev bdbfbef8a2 vk: add commented out normal debugging code 2023-09-05 13:06:00 -04:00
Ivan Avdeev 0856e9e70d vk: add patchable smoothing threshold
Automatically smooth normals between surfaces with normals less than 45
degrees off.

Can be adjusted from map.bsp.patch file like this (e.g. to 50 degrees):
```
{
	"_xvk_smoothing_threshold" "50"
}
```
2023-09-04 14:35:19 -04:00
Ivan Avdeev e55e411639 vk: add a couple of TODO comments 2023-05-18 12:00:58 -07:00
Ivan 'provod' Avdeev 92b1e78d85 vk: make trad sprites more like gl ones
still not fully there:
- glow is slightly off
- TransAlpha has wrong blending mode

apparently pipeline settings for brushes, models, and sprites are substantially different, need different pipelines
2023-02-24 17:43:07 -08:00
Ivan 'provod' Avdeev a5b977c8a3 rt: make emissive surfaces ignore external light
this is not fully correct, but it fixes slightly off sprite colors for now
2023-02-23 20:08:02 -08:00
Ivan Avdeev 053d26e870 move ref_vk to ref/vk 2023-02-16 10:30:31 -08:00