Commit Graph

22 Commits

Author SHA1 Message Date
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 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 bec1e0f558 vk: rt: add tunable skybox exposure
E.g. add `desert.mat` alongside `desert.ktx2` (or
`desrt_{rt,lf,...}.png` files) with the following contents:
```
exposure 0.3
```
Skybox texture color will be multiplied by this value.
2023-12-18 12:26:01 -05:00
Ivan Avdeev 605647aecc vk: rt: support changing screen resolution
Fixes #343
2023-11-30 13:01:40 -05:00
Ivan Avdeev bbd96b3e0e vk: consolidate all bindings to the top of shaders
That way it is more clear what we declare, why and how.
2023-11-23 12:25:24 -05:00
Ivan Avdeev d802404d1c vk: brush: investigate water surfaces orientation
Adds a few things:
- verbose logs about surface flags/type/orientation
- same about surface subdivided polys
- tries culling back water surfaces (doesn't work that well)
- tries culling in rt shaders

This still unfinished
2023-11-10 10:30:24 -05: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 7bfba01954 vk: rt: add test for srgb-vs-linear model color 2023-10-09 14:51:07 -04:00
Ivan Avdeev 9b9e89adec vk: make all texture samplers return values in linear space
Make sure that all SRGB-gamma textures are marked with SRGB format (this
includes all the original textues, 8bit PNG textues). All other
textures (roughness, metallic, normal maps) are linear (UNORM).

Trust KTX2 texture that they store in the correct colorspace.

Then we can just sample textures w/o SRGBtoLINEAR'izing them. Supposedly
this is better because of hw interpolation in the correct colorspace.

This is a bit experimental because Compressonator can't really into
BC7_SRGB, which is sad. And also we need to re-gamma all the textures
for the gamma/srgb-unaware traditional renderer.
2023-10-06 15:06:44 -04:00
Ivan 'provod' Avdeev f63dcd14ce vk: rt: draw skybox where ray hasn't hit anything
fixes #579
2023-09-26 12:41:10 -04:00
Ivan Avdeev 9ac7340974 vk: bring back SURF_DRAWSKY geometries
Needed to hide invisible geometry on e.g. c5a1. Breaks de_dust2 roofs
(#474). That will need to be addressed some other way.

Still uses special value for base_color texture to signal SKY SURFACE.
A supposedly better way to do this would be to have them have a special
material.
2023-09-22 10:15:34 -04:00
Ivan Avdeev dce0598962 vk: remove special SURF_DRAWSKY handling
1. Completely remove them from geometries
2. Draw skybox where the ray hasn't hit anything
3. In the same fashion sky is not shadowed when there's nothing hit by
   the shadow ray.

This allows completely removing the sky material flag.
Also supposedly fixes #474
2023-09-21 12:53:17 -04:00
Ivan Avdeev bdbfbef8a2 vk: add commented out normal debugging code 2023-09-05 13:06:00 -04:00
Ivan 'provod' Avdeev 1cfb183cbd rt: extract per-model data from kusochki 2023-05-01 17:03:22 -07:00
Ivan Avdeev 8ac1a76259 rt: rename traceAdditive to traceSimpleBlending
This is to more clearly distinguish between simple blended things that
don't participate in lighting, and future more involved blending with
refraction and being affected by light
2023-04-27 10:59:38 -07:00
Ivan 'provod' Avdeev d576818550 rt: implement mix blending with undefined order
Known issues:
- apparently BLEND_MIX surfaces should also participate in lighting. Figure out how.
- sensitive to ray tracing order. Need proper OIT (or hacks)
2023-04-27 10:59:38 -07:00
Ivan 'provod' Avdeev 5b370509fe rt: group Material and ModelMetadata in Kusok
They have mismatching frequencies. ModelMetadata should be per-Model, there should be only a few dozen of these.
There maybe hundreds (or even thousands) of materials, but one material can be still referenced by many kusochki.

This only moves fields into new structs, which still belong to Kusok. The real extraction will happen later, see #52.
2023-04-27 10:59:38 -07:00
Ivan Avdeev b4dde5bafd
rt: don't cull c/cw triangles to fix shadow leaks (#508)
de_cbble contains a bunch of floating boxes, which makes sunlight leak if internal back-facing surfaces are culled.

Generally, we should not be culling ray traced triangles (unless absolutely necessary for correctness), as it makes the shader perform additional unnecessary checks.

Try disabling culling universally and see whether it breaks anything.

Fixes #507
2023-04-15 09:44:04 -07:00
Ivan 'provod' Avdeev 5f38f3467d rt: originate ray on the near plane
fixes #63

also, compute max distance based on the far plane distance
2023-03-24 14:04:30 -07:00
Ivan Avdeev 053d26e870 move ref_vk to ref/vk 2023-02-16 10:30:31 -08:00