Commit Graph

488 Commits

Author SHA1 Message Date
Ivan 'provod' Avdeev
4dee7b48cf rtx: add initial spotlight support
not done:
- light cluster culling
- environment (directional-only lights, e.g. sun)
- proper names for things
2021-10-20 11:58:53 -07:00
Ivan Avdeev
af8a6413e4 rtx: tweak and improve point lights
- scaled down emissive surface lights by 10 (as in qrad)
- added more verbose light debugging
- move light tweaks away from shader, have different tweaks for
  different point light source types
- implement non-singular point light attenuation by yuksel
- improve point light adding
2021-10-20 11:58:53 -07:00
Ivan 'provod' Avdeev
4935340432 rtx: add qrad light intensity scaling 2021-10-20 11:58:53 -07:00
Ivan 'provod' Avdeev
1b71237279 rtx: bring back naive point light implementation
- scale dlight intensity
- attenuate based on brdf
- early culling if color contribution is small
2021-10-20 11:58:53 -07:00
Ivan 'provod' Avdeev
832b719bed rtx: remove direct sun sampling attempt
apparently there's no singular sun. there are spot_lights (+light_environment) that function like a sun (directional light).
2021-10-20 11:58:53 -07:00
Ivan 'provod' Avdeev
208d7528ad rtx: move Lights buffer definition to common header 2021-10-20 11:58:53 -07:00
NightFox
119c73abfa fix +0~TNNL_LGT1 2021-10-18 23:36:42 -07:00
NightFox
64626c1601 fix +0~LIGHT2A 2021-10-18 23:36:42 -07:00
NightFox
d3faaa59f1 Almost perfect 2021-10-18 23:36:42 -07:00
NightFox
b8a5b55795 More correct 2021-10-18 23:36:42 -07:00
NightFox
a9b7982ba5 More correct vagonchik, shlakbaum 2021-10-18 23:36:42 -07:00
NightFox
4d9f228769 fix c0a0c 2021-10-18 23:36:42 -07:00
Ivan Avdeev
489d04f0ec
Merge pull request #109 from 0x4E69676874466F78/vulkan
Update rad
2021-10-13 23:53:37 -07:00
NightFox
108ad4d226 UPPERCASE 2021-10-14 03:14:52 +03:00
NightFox
3e7abee0e3 UPPERCASE 2021-10-14 03:13:13 +03:00
NightFox
a06f8e1c26 corrected c1a0b, c1a0c, c1a0e 2021-10-14 02:58:25 +03:00
NightFox
a9a85c6584 corrected c1a0a 2 2021-10-14 01:32:38 +03:00
NightFox
98241a977f corrected c1a0a 2021-10-14 01:08:49 +03:00
Ivan Avdeev
de8a7e10e9 rtx: update to use safe COM_ParseFile 2021-10-13 12:42:20 -07:00
Ivan Avdeev
cb07b2ffaf rtx: remove comment 2021-10-13 12:27:24 -07:00
Ivan Avdeev
8ffab567b9 rtx: dynamically cull and add moving surface lights 2021-10-13 12:27:24 -07:00
Ivan Avdeev
157af769ff rtx: add vk_lights_dump command
It prints out light clusters debugging info.
2021-10-13 12:27:24 -07:00
Ivan Avdeev
af83e47f41 rtx: revert c0a0/YELLOW to original value 2021-10-13 12:27:24 -07:00
Ivan Avdeev
72fcf52837 rtx: simplify toggling light clusters debug visualization in shader 2021-10-13 12:27:24 -07:00
Ivan Avdeev
846651565c rtx: explictly disable light sources with zero intensity 2021-10-13 12:27:24 -07:00
Ivan Avdeev
46722c4a37 rtx: depend on throughput when culling 2021-10-13 12:27:24 -07:00
Ivan Avdeev
1eadd60587 rtx: implement late light culling
the idea is to not do very expensive shadow ray when the resulting color
won't affect the visible pixel anyway.
2021-10-13 12:27:24 -07:00
Ivan Avdeev
f4c75ec08c rtx: slight clean up surface light culling code 2021-10-13 12:27:24 -07:00
Ivan Avdeev
520fedde2b rtx: cull light clusters by plane normals
(note that real pdf culling doesn't seem to be necessary, as shader
confirms that it's usually not culled that much)
2021-10-13 12:27:24 -07:00
Ivan Avdeev
19b8025fc6 rtx: add light clusters debug helpers
1. add a way to enable only certain lights
2. add commented out code to highligh affected light clusters, culling
   modes, etc.
3. add affected light clusters counter when collecting lights
2021-10-13 12:27:24 -07:00
Ivan Avdeev
20369dd9ab rtx: move push constant definition to a common place; specialize shader constants 2021-10-13 12:27:24 -07:00
Ivan Avdeev
417caad50b rtx: work around crash on map load
xash tries to render a couple of frames after map has been destroyed and
before the new one was created (R_NewMap called). vk_light expects map
to be there at all times, so it tries to reference things that don't
exist.

boom

here we just check that map exists, and if it doesn't we just skip
referencing lights.

no boom.
2021-10-13 12:27:24 -07:00
Ivan Avdeev
53fd5b6b23 rtx: compute lighting in hl-native units, remap color in the end (#98) 2021-10-13 12:27:24 -07:00
Ivan Avdeev
8f7bc69cb2 rtx: cull surface lights based on estimated light intensity 2021-10-13 12:27:24 -07:00
Ivan Avdeev
869c21e42d rtx: fix bsp visibility based light cluster generation
1. fix indexiing (+1)
2. fix rle skipping (*8)
3. fix bbox ranges (floorf .. ceilf)
2021-10-13 12:27:24 -07:00
Ivan Avdeev
3f90408108 work around stack corruption when parsing entities
we have a limited buffer for string when reading tokens and no way to
specify buffer space. just increase buffer size.

proper fix would be to change ref api to allow passing buffer size as an
argument.
2021-10-13 12:27:24 -07:00
Ivan Avdeev
4b0033985d rtx: construct light grid based on bsp visibility data
unfortunately it's broken and ends up producing incorrect light lists
per grid cells. we'll fix it eventually
2021-10-13 12:27:24 -07:00
Ivan Avdeev
87cb23eb8b rtx: collect per-leaf emissive surfaces with pvs data 2021-10-13 12:27:24 -07:00
Ivan Avdeev
9006d679ec rtx: associate msurfaces with mleafs 2021-10-13 12:27:24 -07:00
Ivan Avdeev
436ab8709e rtx: start collecting light sources per leaf 2021-10-13 12:27:24 -07:00
Ivan Avdeev
8b704ed9a6 handle externally provided swapchain resolution, fix #53 2021-09-24 20:58:01 -07:00
Ivan 'provod' Avdeev
6b1eb26c24 improve screenshot performance, fix #87
make sure that we use host_cached memory, otherwise device_local will be picked by default, which is very slow to read from.
2021-09-22 20:29:31 -07:00
Ivan Avdeev
fe52ff3d1a
Merge pull request #84 from 0x4E69676874466F78/vulkan
Update rad files
2021-09-21 08:57:26 -07:00
Ivan Avdeev
16df678fd2 fix linux build 2021-09-20 23:35:49 -07:00
Ivan 'provod' Avdeev
100ba22f0e rtx: add broken sun sampling
i cant into math. sun direction is completely incorrect
2021-09-20 23:35:49 -07:00
Ivan 'provod' Avdeev
f8b0b8c672 rtx: make light entity parsing extensible
x macros ftw
2021-09-20 23:35:49 -07:00
Ivan 'provod' Avdeev
fe931fcfd7 rtx: collect d/elights and static entity point lights
sample all of them unconditionally for now
2021-09-20 23:35:49 -07:00
Ivan 'provod' Avdeev
1953bf7b4f rtx: install known rads into valve/maps
fix #76
2021-09-20 23:35:49 -07:00
NightFox
70ae807b3d
+0~TNNL_LGT4 for c0a0d 2021-09-20 12:40:59 +03:00
NightFox
5e97b4dd28
Correction +0~TNNL_LGT4 for c0a0c
Do not tune rad files under rays while it is still unfinished, check only with qrad
2021-09-20 12:24:54 +03:00
NightFox
b5f263d56a
Correction +0~TNNL_LGT4 for c0a0c
Do not tune rad files under rays while it is still unfinished, check only with qrad
2021-09-20 12:22:01 +03:00
NightFox
907310c5bd
Update rad files
More correct light for c0a0c and c0a0d + correct RED for other rads.
2021-09-20 12:09:08 +03:00
NightFox
c68b82ca40
Added correct goldsrc era rad files ( #76 )
Base lights.rad/valve.rad from worldcraft v2.0 or HLSDK (thx Valve).
Base c1a0.rad and c1a0d.rad from HLSDK (thx Valve).
Some texture name get from hl_lights.rad by Hezus (thx Hezus and SNMetamorph for file).
Others was mined by me manually through bspguy and etc.

File structure and formatting redesigned.
Some numbers have been rounded for convenience.
Added splitting by WAD files (for the present only for lights.rad).

See README.txt for codestyle.
2021-09-18 17:08:01 +03:00
NightFox
add86b4018
Removed incorrect (source engine) rad files.
These rad files are not very useful for the goldsrc version.
2021-09-18 16:56:50 +03:00
Ivan 'provod' Avdeev
10127868ef rtx: skip RAD entries with "//" in the name, fix #42
Consider these to be commented out.
2021-09-16 11:09:21 -07:00
Ivan 'provod' Avdeev
31a5db1974 rtx: fix hit pos for translated brush modles, fixes #64
also add shadow offset to fix light flickering for moving sources
2021-09-16 11:09:21 -07:00
Ivan 'provod' Avdeev
4ff669c023 rtx: fix scratch buffer validation error, #69
New Vulkan SDK (1.2.189.2) has a new validation check that verifies that AS build scratch buffer has been created with VK_BUFFER_USAGE_STORAGE_BUFFER_BIT.
2021-09-16 11:09:21 -07:00
Ivan Avdeev
a7288eba69 fix linux build 2021-09-14 17:47:05 -07:00
Ivan 'provod' Avdeev
50200262df rtx: slightly improve black outlines on studio models (see #48)
The core of the issue is that there are backfacing interpolated normals, NdotL and/or NdotV end up being negative for them.
Things we tried:
1. Explicitly using geometry normals for some things. Doesn't really work that well.
2. Clamping NdotX to some small value instead of just ignoring light contribution. Works better, but there are still some artifacts.
2021-09-14 17:47:05 -07:00
Ivan 'provod' Avdeev
96709ac37c rtx: questionable attenuation for emissive surfaces
1. I suspect that we don't actually need to compute emissive contribution even for specular. Except when doing direct lighting.
2. Using emissive color as is looks orders of magnitude too bright. It should be scaled by something. But by what? Try to use to-metric mapping similar to direct lighting for testing.
2021-09-14 17:47:05 -07:00
Ivan 'provod' Avdeev
fbd8973a6d rtx: add command to reload rad files, fix #41
vk_rtx_reload_rad
2021-09-14 17:47:05 -07:00
Ivan 'provod' Avdeev
afa1e8557a rtx: fix c0a0d emissive toxic liquid, fix #56
It was missing msurface_t reference which is (unnecessarily) required for light clusters computation

Also add more verbose debug names for dynamic models.
2021-09-14 17:47:05 -07:00
Ivan Avdeev
3d0dafa8b4 fix rad filenames for maps 2021-09-11 15:47:16 -07:00
Ivan 'provod' Avdeev
7f1e6c8256 rtx: slightly improve (decrease) acne
how: we do not need to add emissive when doing diffuse gi bounce, as contribution from these lights will be computed in computeLighting.
They only need to be sampled for specular bounce.

The rest of the acne should be mitigated by denoiser i think.

Fix #51
2021-09-11 15:47:16 -07:00
Ivan 'provod' Avdeev
5ce91209ce rtx: load rad files from rad/<mapname>.rad, fix #43 2021-09-11 15:47:16 -07:00
Ivan Avdeev
cfe5612a3a attenuate area lights by projected area, fix #46
Also, tune "tonemapping"
2021-09-08 10:08:47 -07:00
Ivan Avdeev
0839f9673b update todo; move materials draft to separate file 2021-09-06 14:24:36 -07:00
Ivan Avdeev
ae12b4505d remove material flags 2021-09-06 14:24:36 -07:00
Ivan Avdeev
de611e159a assume textures are linear
this way it looks more like traditional renderer w/ lightmaps
2021-09-06 14:24:36 -07:00
Ivan Avdeev
2b2552cd72 fix rad file parsing
parsing strings in c is hard
2021-09-06 14:24:36 -07:00
Ivan Avdeev
86d669c708 enlarge scratch buffer to support more models 2021-09-06 12:03:44 -07:00
Ivan Avdeev
b9f5f87c76 bring back ray traced transparency
1. Probabilistically let ray through material or reflect it based on
   transparency probability (which is essentially just alpha for now).
2. Introduce opaque flag to be able to treat transparent objects as not
   casting shadows. This is not very realistic, but oh well.
2021-09-06 11:57:23 -07:00
Ivan Avdeev
9759221e02 rtx: fix linux build 2021-09-04 13:50:05 -07:00
Ivan 'provod' Avdeev
672b2de75a rtx: cascading rad sheets
Read rad data from lights.rad and then mapname.rad
2021-09-04 13:50:05 -07:00
Ivan 'provod' Avdeev
c90187f57f rtx: use a common definition for Kusok; pass color
Also pass alpha (not used yet)
2021-09-04 13:50:05 -07:00
Ivan 'provod' Avdeev
22e76513a4 rtx: better lighting scaling
Remove arbitrary lightness fudge in favor of proper distance scaling.
According to TEH INTERNETS one unit is one inch. So there are 39.37 units per meter.
Scale distances to meters for lighting calculations.
2021-09-04 13:50:05 -07:00
Ivan 'provod' Avdeev
36cfe22e8d rtx: add sbt hit entry w/o any hit
Majority of materials are without alphamask, so no need to have any hit shader
2021-09-04 13:50:05 -07:00
Ivan Avdeev
8cf040f9be rtx: improve emissive surface sampling
Sample a single triangle not in a loop.
2021-09-04 13:50:05 -07:00
Ivan Avdeev
e4aea1486f ingest more of brdf for bounces 2021-09-04 13:50:05 -07:00
Ivan Avdeev
9c330e4118 add brdfs for lights
Just straight copy-paste CC brdf header from Ray Tracing Gems 2 chapter
14.
Use these brdfs for direct lighting.
2021-09-04 13:50:05 -07:00
Ivan Avdeev
d8ebf5ac33 rtx: add emissive color, remove emissive flag 2021-08-31 11:19:44 -07:00
Ivan Avdeev
8d06058aa4 rtx: add first iteration of material flags support
it's clearly suboptimal, but no worries, we'll iterate
2021-08-31 11:19:44 -07:00
Ivan 'provod' Avdeev
0259c09e9a add swizzle for RGBA-BGRA format pair when saving screenshot
this is the pair that breaks on nvidia (yay there's at least one thing that amd is better at!)
2021-08-31 11:19:44 -07:00
Ivan Avdeev
280e6109c6 add screenshots
now vulkan can do screenshots too. however, it depends on blits being
available between swapchain and rgba8 formats, so if it's not the case
for some reason, the resulting image will have mixed components.
2021-08-31 11:19:44 -07:00
Ivan Avdeev
3b605a19b5 fix depth test for glow render mode; comments
also add a lot of observations to ref_vk/TODO.md related to materials
2021-08-31 11:19:44 -07:00
Ivan Avdeev
76b82ac884 rtx: calculate maxVertex correctly
after we've updated how brush index buffer references vertices to allow
for draw call coalescing ray tracing broke on amd.
this is because amd cards expect a correct value in
VkAccelerationStructureGeometryTrianglesDataKHR::maxVertex. make sure we
fill a correct value there.
2021-08-18 09:39:33 -07:00
Ivan Avdeev
93cab236ba split device enumeration and creation, fixes #28 2021-08-16 23:22:13 -07:00
Ivan 'provod' Avdeev
ee8e9d8ff7 concat brush drawcalls
make all geoms share the same constant vertex offset so that continuous indices can be exploited to generate only a single draw call for a group of geometries with the same texture
2021-08-15 11:30:38 -07:00
Ivan 'provod' Avdeev
a0a36f5a14 fix c89 2021-08-15 11:14:33 -07:00
Ivan 'provod' Avdeev
dc6b874cae restore debug labels for traditional renderer 2021-08-15 11:02:57 -07:00
Ivan Avdeev
ba761b370d
Merge pull request #27 from w23/aftermath-fix
fix building with aftermath
2021-08-14 19:00:19 -07:00
Ivan 'provod' Avdeev
fe0223c8d3 fix building with aftermath 2021-08-14 18:30:52 -07:00
Ivan Avdeev
5208219b44 join alloc+lock operations on buffer init
this simplifies the api and implementation
2021-08-11 11:43:33 -07:00
Ivan Avdeev
90e5500e83 add per-vertex studio model lighting
it doesn't correctly sample lightmaps for env lighting yet. we'll figure this out some time later ....
2021-08-07 19:56:38 -07:00
Ivan Avdeev
e6f8d8e47a enable anisotropy if available
also force require vulkan 1.2 for now, need to have 1.0 device for testing lower versions (TODO)
2021-08-07 18:06:48 -07:00
Ivan Avdeev
0028899eac rtx: add better hashes
from: Mark Jarzynski and Marc Olano, Hash Functions for GPU Rendering, Journal of Computer Graphics Techniques (JCGT), vol. 9, no. 3, 21-38, 2020
http://www.jcgt.org/published/0009/03/02/
2021-08-04 19:32:56 -07:00
Ivan Avdeev
378c1e52e0 enable anisotropy only for rtx
this doesn't make any visible impact for rtx rendering. but does affect non-rtx rendering when running with rtx enabled (kekw)
2021-08-04 18:56:11 -07:00
Ivan Avdeev
94ac51a527 rtx: sample mip levels based on ray cone width
this is mostly copied from ray tracing gems 2 chapter 7 (Texture Coordinate Gradients Estimation for Ray Cones, by Wessam Bahnassi).
There's a weird bit about radians vs degrees. We'll figure it out later when the book becomes available.
2021-08-04 18:36:53 -07:00
Ivan Avdeev
71bf85d4f8 fix mips generation 2021-08-04 17:44:21 -07:00
Ivan Avdeev
dbd5a7a2e4 add texture mipmaps
they're still corrupted a bit
2021-08-02 10:55:26 -07:00
Ivan Avdeev
074fdf84b4 update todo 2021-07-31 12:43:35 -07:00
Ivan Avdeev
fc2c7185df rtx: add basic transparency and reflections
this is very proof-of-concept quality. it should be definitely done some other way

e.g. we should control reflectivity and transparency differently (and not together)
and they should be based on texture ids, not on render_mode

it's also unfortunate that transparency required a lot of bounces. we should probably control transparency bounces separately from light bounces.
alternatively, transparency effects (beams, sprites) should be done with custom intersection shaders and not based on transparent geometry
2021-07-31 12:35:59 -07:00
Ivan Avdeev
1d94f5da00 rtx: fix c90 compilation errors 2021-07-17 12:40:26 -07:00
Ivan Avdeev
c2729c9d63 rtx: fix reflections; update todo 2021-07-17 12:37:12 -07:00
Ivan Avdeev
eeb83bd99f rtx: dont trace ray when there's no geometry
We used to dispatch rays anyway even if there was no models to render and tlas wasn't built (which is the case for the first few frames).
This ended up crashing AMD gpu when using some (but not all) variants of rgen shaders.

With this change we'll check for whether there are any models to render, and if there are none, then we'll just clear frame to black.

This change also refactors ray tracing a bit.
2021-07-17 11:45:28 -07:00
Ivan Avdeev
316e77df78 rtx: add alpha mask transparency 2021-07-14 11:54:21 -07:00
Ivan Avdeev
d7fc697de4 rtx: HACK: workaround for amd
for some reason amd will lose device whenever the first rendered frame has multiple push-constant-depndent bounces and break on line 138 in rgen.
when both break is commented out and bounces are compile-time constant, it will work just fine.
moreover, if we start xash with the workaround shader, get it to draw a few frames, and only then bring back both break and pc-bounces, recompile and reload shader, it will run just fine. not losing device and all.

wtf
2021-07-14 11:49:37 -07:00
Ivan Avdeev
59361f91cb rtx: remove old compute shader 2021-07-14 10:15:56 -07:00
Ivan Avdeev
4fa079b05a rtx: restore multiple bounces and dlights 2021-07-14 10:10:20 -07:00
Ivan Avdeev
38c636cad4 rtx: make freeman drunk again 2021-07-14 09:48:32 -07:00
Ivan Avdeev
04d92508ae rtx: bring back random sampling lights 2021-07-14 09:43:36 -07:00
Ivan Avdeev
caa284f835 rtx: add shadows 2021-07-12 10:59:52 -07:00
Ivan Avdeev
7d6ee9623b rtx: add lighting w/o shadows 2021-07-12 10:42:20 -07:00
Ivan Avdeev
d1fe897966 Merge remote-tracking branch 'origin/vulkan' into amd_ray_tracing_fixes 2021-07-12 09:45:26 -07:00
Ivan Avdeev
def7fac402 rtx: fixup build after merge 2021-07-12 09:23:50 -07:00
Ivan Avdeev
02da9652bf make vulkan deps conditional at configure time 2021-07-11 15:47:51 -07:00
Ivan Avdeev
76d381388b improve vulkan api definitions 2021-07-11 14:07:25 -07:00
Ivan Avdeev
64469b1a3d fix ci build 2021-07-10 12:42:47 -07:00
Ivan Avdeev
a46b0dffdc rtx: enable textures
- use non-uniform indexing because AMD requires it (which is technically correct by spec, it's just nvidia that supports it transparently)
- disable immutable samplers, as that breaks filtering on amd for some reason (TODO)
2021-07-10 12:37:14 -07:00
Ivan Avdeev
dd6fe33a16 add ghetto device selection, allow skipping first device
device selection should be performed by vulkan physical device index, but we have no way to read numeric cmdline arguments from xash
see #21
2021-07-10 11:34:59 -07:00
Ivan Avdeev
d66ee6b3ce rtx: fix hit/miss shader order
also move geometries offsets to ranges struct instead of adding offsets to buffers addresses
2021-07-10 11:06:55 -07:00
Ivan Avdeev
9623d6ef31 rtx: add stub closest hit and miss shaders to rt pipeline 2021-07-07 12:02:12 -07:00
Ivan Avdeev
2ca2e2058e fix compile warnings for CI, part 2 2021-07-06 12:54:45 -07:00
Ivan Avdeev
c51d593679 rtx: get ray tracing pipeline to draw at least something
on amd gpus it won't draw anything at all unless you have the entire ray tracing pipeline set up fully and correctly:
- have at least rgen, rmiss and rchit shaders
- set up shader groups to reference them
- set up sbt to reference shader groups
it is not enough to just have a single rgen shader operating like a compute shader. amd will have a shader preamble that checks for something and exit early w/o actually running any shader code you wrote

meh
2021-07-06 11:28:24 -07:00
Ivan Avdeev
56007bdb1d rtx: don't forget to destroy shaders 2021-07-06 09:42:16 -07:00
Ivan Avdeev
cdefb7a50a fix compiler warnings for CI 2021-07-06 09:41:48 -07:00
Ivan Avdeev
23697d75eb Merge branch 'vulkan' into amd_ray_tracing_fixes 2021-07-05 14:50:19 -07:00
Ivan Avdeev
364b46ea87 [WIP] rtx: first build with ray tracing pipeline and black screen 2021-07-05 13:24:57 -07:00
Ivan Avdeev
34359e2f75 rtx: start splitting ray tracing into functional modules
move model management into vk_ray_model
2021-07-05 10:59:14 -07:00
Ivan Avdeev
c662695056 rtx: add runtime toggle between ray tracing and traditional renderer
new command is `vk_rtx_toggle`
2021-07-04 13:17:03 -07:00
Ivan Avdeev
750d3b7608 rtx: fix brush models being invisible
An incorrect range of used vertices was pased into `VkAccelerationStructureGeometryTrianglesDataKHR`.
 `maxVertex` was being set to a count of vertices per geometry, not a maximum used vertex number.

The fix is to track `vertex_offset` of the first used vertex, which makes `maxVertex` correct.
2021-07-04 12:48:32 -07:00
Ivan Avdeev
2034acbe76 rtx: fix build_ranges incorrect pointer indirection 2021-07-04 12:05:21 -07:00
Ivan Avdeev
3ed4d84653 rtx: add runtime toggle between ray tracing and traditional renderer
new command is `vk_rtx_toggle`
2021-07-04 11:18:28 -07:00
Ivan Avdeev
20d38fead5 fix ISO C90 mixing declaration and code 2021-06-23 17:04:26 -04:00
Ivan Avdeev
20c42a7815 fix ISO C90 mixing declarations and code 2021-06-23 17:04:26 -04:00
Ivan 'provod' Avdeev
f2e90cc420 rtx: fix cached blas mismatched size assert, fixes #10
apparently we also need to track max primitives per blas
2021-06-23 17:04:26 -04:00
Ivan 'provod' Avdeev
e272539136 enable crude beams and sprites support back 2021-06-23 17:04:26 -04:00
Ivan 'provod' Avdeev
5211c33cce rtx: add shader specialization 2021-06-23 17:04:26 -04:00
Ivan 'provod' Avdeev
01cd55641b fix oob mem access when parsing rad files 2021-06-23 17:04:26 -04:00
Ivan 'provod' Avdeev
355ebd8d23 rtx: add reflections for water; add sky as emissive surfaces 2021-06-19 12:52:13 -07:00
Ivan 'provod' Avdeev
0356013db6 update todo; add more diags for rtx as handling 2021-06-19 10:51:21 -07:00
Ivan 'provod' Avdeev
8321dda9d9 rtx: fix water normals performance and culling 2021-06-19 13:44:28 -04:00
Ivan 'provod' Avdeev
4e599b4070 cull water side surfaces 2021-06-19 13:44:28 -04:00
Ivan 'provod' Avdeev
531fcd9393 move water warping to vk_brush 2021-06-19 13:44:28 -04:00
Ivan 'provod' Avdeev
74e0fb2947 add initial water surfaces
still need to cull them, generate normals, etc.
2021-06-19 13:44:28 -04:00
Ivan Avdeev
f8dc37b0eb 🤦 2021-06-07 12:21:47 -07:00
Ivan Avdeev
a004656b57 ref_vk: remove verbose ci info; fix win23 func ptr 2021-06-07 12:05:47 -07:00
Ivan Avdeev
fd11b00469 ref_vk: add more debug around VULKAN_SDK for CI 2021-06-07 10:14:04 -07:00
Ivan Avdeev
cb7fb0a1c5 ref_vk: attempt to fix win32 glslc path 2021-06-07 09:55:33 -07:00
Ivan Avdeev
6cd543927c ref_vk: update merge 2021-06-07 00:39:40 -07:00
Ivan Avdeev
266f407b40 ref_vk: use poolhandle_t 2021-06-07 00:16:54 -07:00
Ivan Avdeev
1e82ae7103 ref_vk: try another way to disable it on android 2021-06-06 23:36:37 -07:00
Ivan Avdeev
c5bb450a5a ref_vk: yet anothe var def 2021-06-06 23:14:35 -07:00
Ivan Avdeev
ef1f88005f ref_vk: force disable on android for now 2021-06-06 23:13:53 -07:00
Ivan Avdeev
22eec42a60 ref_vk: --//-- 2021-06-06 23:00:05 -07:00
Ivan Avdeev
ab215f35b6 ref_vk: --//-- 2021-06-06 22:55:49 -07:00
Ivan Avdeev
388f684f12 ref_vk: another var declaration fix 2021-06-06 22:46:04 -07:00
Ivan Avdeev
735bfbb8db ref_vk: fix unused var declaration 2021-06-06 21:59:23 -07:00
Ivan 'provod' Avdeev
656c00d0b8 fix building and running on linux 2021-06-06 14:17:35 -07:00
Ivan 'provod' Avdeev
b58eb5b4b2 rtx: slightly improve fake poc lighting 2021-06-05 13:06:03 -07:00
Ivan 'provod' Avdeev
00518d3251 rtx: implement dynamic lights
track brush models movement and update lights grid clusters with model transform and stuff

also implement animated textures for rtx

and also increase per-cluster lights limits
2021-06-05 12:48:16 -07:00
Ivan 'provod' Avdeev
43175ae003 update todo 2021-05-28 10:27:16 -07:00
Ivan 'provod' Avdeev
eaaadf024e rtx: coalesce building blases in a single command buffer 2021-05-28 10:10:20 -07:00
Ivan 'provod' Avdeev
74e7a00604 rtx: add AS memory and models validation
also fix new map cache cleanup
2021-05-26 10:55:46 -07:00
Ivan 'provod' Avdeev
ad2405547b rtx: rename model creation and move tlas creation 2021-05-26 09:35:36 -07:00
Ivan 'provod' Avdeev
44909ccbe5 rtx: improve render-ray interop
make a vk_ray_model_t that stores everything ray-tracing related, and can also be cached directly
2021-05-24 11:14:03 -07:00
Ivan 'provod' Avdeev
5de30a4ff0 fix compilation warnings 2021-05-24 11:12:44 -07:00
Ivan 'provod' Avdeev
35275e0916 add aftermath sdk for gpu dump generation
unfortunately, it's not very helpful tho
2021-05-22 14:01:43 -07:00
Ivan 'provod' Avdeev
947ad9d7fa update todo 2021-05-17 10:57:16 -07:00
Ivan 'provod' Avdeev
6614a6935b add debug names to various objects 2021-05-17 10:36:40 -07:00
Ivan 'provod' Avdeev
ddd7403bd0 rtx: implement draft blas caching
It still crashes on some maps, tho
2021-05-17 09:24:15 -07:00
Anton Baskanov
1ae5cfe548 rtx: presumably fix gray textures
Modulate the subsequent bounces with texture color. This makes it
consistent with the way surface lights and dlights work.
2021-05-14 15:04:51 +07:00
Ivan 'provod' Avdeev
fb05afb24c rtx: don't recreate tlas on every frame. improve fps 2021-05-10 09:17:03 -07:00
Ivan 'provod' Avdeev
5ddeb6853d rtx: fix corrupted geometry
TLAS creation pattern ended up allocating memory in a temporary region. It was later reused for BLAS data, and subsequently corrupted by TLAS rebuild.

Also fixed memory leak, added freeze-models command, added model debug code into shaders, etc.
2021-05-08 14:34:42 -07:00
Ivan 'provod' Avdeev
354eef1c0a rtx: fix validation complaint, ask for more caps 2021-05-08 14:30:33 -07:00
Ivan 'provod' Avdeev
be42bd29a5 add ring temp allocator logic 2021-05-03 11:17:01 -07:00
Ivan 'provod' Avdeev
819540d5ec rtx: move descset stuff into vk_descriptor 2021-05-01 11:48:24 -07:00
Ivan 'provod' Avdeev
9e8ca13dcc rtx: add studio models
but they crash a lot kek
2021-04-24 12:53:42 -07:00
Ivan 'provod' Avdeev
e522acf8b3 rtx: add textures 2021-04-22 10:45:38 -07:00
Ivan 'provod' Avdeev
5b7eaa8e1c rtx: fix light surfaces bleeding backwards 2021-04-22 10:42:19 -07:00
Ivan 'provod' Avdeev
c255041bd9 rtx: clear light clusters properly on new map 2021-04-19 11:44:15 -07:00
Ivan 'provod' Avdeev
bd8c67e4e7 rtx: fix missing emissive textures, enlarge light radius based on intensity 2021-04-19 11:17:17 -07:00
Ivan 'provod' Avdeev
2f965b00d4 rtx: read emissive texture params from rad files
Got rad files from https://github.com/MaestroFenix/Half-Life-Resized-Maps
These seem to work mostly fine and finally levels have recognizable appearance.
2021-04-17 12:33:46 -07:00
Ivan 'provod' Avdeev
7c02012c8d rtx: add light to neighbour cells; increase cell limit 2021-04-17 10:35:53 -07:00
Ivan 'provod' Avdeev
b1f85a05a4 rtx: make light clusters grid-based 2021-04-16 11:43:37 -07:00
Ivan 'provod' Avdeev
28f2c06bdb rtx: cache and destroy model blases
Unfortunately Xash3D doesn't allow us to destroy models properly.
It doesn't call Mod_ProcessRenderData for all brush models (only map).
And by the time we get into R_Shutdown all models are already gone, so
we can't enumerate and destroy them properly.
2021-04-13 10:46:33 -07:00
Ivan 'provod' Avdeev
01e6a267d5 rtx: fix toilet crash
Toilet contained brush model with presumably water surfaces which
were not loaded due to how we treat surface flags. That ended up
creating a model with no geometries, which is just rude.
We don't try to render those kind of models now.
2021-04-13 10:13:17 -07:00
Ivan 'provod' Avdeev
ad7b210228 rtx: improve surface lights
use bsp/pvs-based visibility data for acceleration:
+ fps 5 -> 60
- correctness: some areas have too many lights, which ends up culling visible ones too

also fix shadow artefacts
2021-04-12 11:07:41 -07:00
Ivan 'provod' Avdeev
0407f12638 rtx: read kusochki data, add dynamic lights back
also add fps
2021-04-10 12:46:37 -07:00
Ivan 'provod' Avdeev
573c291cef rtx: fix tlas rebuild 2021-04-10 10:58:46 -07:00
Ivan 'provod' Avdeev
3a8f2ebc45 rtx: build blas and tlas only once 2021-04-09 14:59:04 -07:00
Ivan 'provod' Avdeev
af5e20269d add persistent model api and use it for brushes
this needed for better rtx blas management
2021-04-07 12:11:20 -07:00
Ivan Avdeev
7fe55e6d90 wasuremono 2021-03-28 13:56:46 -07:00
Ivan Avdeev
39a5568614 rtx: wip bake lighting data using bsp/pvs 2021-03-28 13:52:25 -07:00
Ivan Avdeev
014925b3d4 fix linux build 2021-03-20 16:21:26 -07:00
Ivan 'provod' Avdeev
0b9ec7ee42 rtx: sample previous frame to get a naive blurry denoiser 2021-03-20 13:42:15 -07:00
Ivan 'provod' Avdeev
1b73a509e6 rtx: sample emissive surfaces as lights
this is done incorrectly, and also needs lots of culling and optimization
2021-03-20 12:34:34 -07:00
Ivan 'provod' Avdeev
3045c6ea1f rtx: render into fixed 720p framebuffer then upscale
help with perf stability
2021-03-20 11:15:57 -07:00
Ivan 'provod' Avdeev
d6c56d4e1b rtx: add emissive surfaces/textures
This is a massive hack, because we hardcoded some valve/lights.rad file
right into vk_rtx.c, and this is most certainly is not correct data. We
expect maps to have more custom rad file entries.
TODO: consult https://github.com/MaestroFenix/Half-Life-Resized-Maps

Also, emissive surfaces are no importance sampled, so it's noise fest.
2021-03-17 09:15:33 -07:00
Ivan 'provod' Avdeev
b81a36a850 rtx: make beams emissive 2021-03-15 10:49:45 -07:00
Ivan 'provod' Avdeev
aab15ff366 rtx: fix AS allocation memory corruption; dev-localize buffers 2021-03-15 10:23:26 -07:00
Ivan 'provod' Avdeev
581f1eed0d rtx: add vk_rtx_bounces cvar to control ray bounces count 2021-03-15 09:44:15 -07:00
Ivan 'provod' Avdeev
f85a174d8b rtx: add a bunch of ray bounces
while fps dips below 1, it still looks like modern art
2021-03-13 17:04:45 -08:00
Ivan 'provod' Avdeev
379f6ee409 rtx: add static light entities
This was an attempt to add map lighting w/o lightmaps. Unfortunately
there are just not enought of them to explain all light in maps. We're
missing something else. A lot of it.
2021-03-13 16:33:17 -08:00
Ivan 'provod' Avdeev
a04b367a32 rtx: use model matrices to open doors and move wagonchik 2021-03-13 14:31:48 -08:00
Ivan 'provod' Avdeev
7fa3f2dc8d render: split mvp matrix to separate model,view,projection matrices
This will help with RTX model transformations.
2021-03-13 13:35:50 -08:00
Ivan 'provod' Avdeev
a039e7e5ae rtx: add vk_rtx_reload command to reload rtx.comp.psv shader
This allows faster shader iterations. Do `bind z vk_rtx_reload`.
Still need to recompile the shader outside xash process manually.
2021-03-13 12:29:17 -08:00
Ivan 'provod' Avdeev
7b482d2b3b rtx: glShadeModel(GL_SMOOTH)
Compute normal based on all triangle vertices according to their
barycentrics.
2021-03-13 10:46:25 -08:00
Ivan 'provod' Avdeev
e235c97be9 rtx: make soft shadows by random sampling dlight surface
it includes bad random function, bad sampling strategy, bad performance,
etc

but it works somewhat
2021-03-10 13:04:11 -08:00
Ivan 'provod' Avdeev
44b93dd30b rtx: add hard shadows 2021-03-10 10:15:09 -08:00
Ivan 'provod' Avdeev
6d1dac453e rtx: add dynamic lights
no shadows and such stuff yet
2021-03-10 09:38:06 -08:00
Ivan 'provod' Avdeev
77288a205b rtx: read vertex normals according to isec indexes
Had to align vec3 fields of vk_vertex_t.
2021-03-08 12:09:11 -08:00
Ivan 'provod' Avdeev
ea9b880865 add studio models normals for dynamic lighting 2021-03-08 09:54:26 -08:00
Ivan 'provod' Avdeev
47c3c4fa75 fix dlight attenuation 2021-03-06 19:59:18 -08:00
Ivan 'provod' Avdeev
cbed97948c add preliminary support for dlights
Move descriptors away from vk_core
Add UBO for dlights
Add test lighting in brush shader
Add brush normals
2021-03-06 16:40:35 -08:00
Ivan 'provod' Avdeev
78d9a87344 fix projection matrix vulkan fixup
we were mixing up row vs column major matrices
now RTX ray generation is fixes, and traditional rasterizer rendering
should also be projecting similar to gl render
2021-03-06 13:26:38 -08:00
Ivan 'provod' Avdeev
28cdeaeb1d propagate proj/view matrices to rtx shader
And get RTX picture we deserve (i.e. glitchy and incorrect).
Will fix later.
2021-03-03 11:58:40 -08:00
Ivan Avdeev
9b8af6d28b shaders: add compute shaders; fix shaders install dir 2021-03-01 23:34:20 -08:00
Ivan Avdeev
dc71afd08a Merge remote-tracking branch 'upstream/vulkan' into vulkan-glslc 2021-03-01 23:22:40 -08:00
Ivan Avdeev
74bcb56abf
Merge pull request #5 from FWGS/vulkan-upstream-move-cvars
upstream sync: move cvars that are expected from render to engine
2021-03-01 22:59:40 -08:00
Ivan 'provod' Avdeev
e0ee4b756b rtx: make it draw yellow screen
this basically checks that acceleration structurs are building without
any vulkan errors (we still don't know whether they are bulding with
correct geometry though).

we also have compute shader pipeline ready for ray tracing (yay)
but it doesn't do any raytracing yet
2021-03-01 11:22:58 -08:00
Ivan Avdeev
5e3010489b rtx: blindly add tlas and compute rendering
it's unknown whether it works at all
no real ray tracing yet
2021-03-01 10:52:08 -08:00
af48821eec ref_vk: move cvars that expected to exist by client.dll from render dll to engine 2021-03-01 20:09:37 +03:00
Ivan 'provod' Avdeev
c77f39e353 rtx: fix blas creation validation/memory errors 2021-02-27 15:40:57 -08:00
Ivan Avdeev
9954288450 rtx: add blas building skeleton 2021-02-27 13:43:49 -08:00
Ivan Avdeev
973ef4c677 separate buffer space allocation from buffer uploading
Now each geometry is first allocated a slot with VK_RenderBufferAlloc,
and then VK_RenderBufferLock/Unlock are used to upload buffer contents.

This allow for two things:
1. Uploading buffer data to GPU memory on/after Unlock.
2. (Re)building BLAS for RTX on/after Unlock.

These buffers are now directly referenced by render_draw_t, which also
will be helpful in the future for both renderers.
2021-02-22 18:57:46 -08:00
Ivan 'provod' Avdeev
4349d6b7fa rtx: update vulkan version req to 1.2 2021-02-22 10:16:58 -08:00
Ivan Avdeev
46da9ad457 rtx: request RTX device extensions when -rtx argument is present
It doesn't do anything yet.
2021-02-22 09:46:29 -08:00
Ivan 'provod' Avdeev
ded8442993 auto-detect VULKAN_SDK path on windows 2021-02-21 23:28:33 -08:00
Ivan Avdeev
3f70b76208 engage scene rendering in VK_RenderFrame and not in EndFrame
Rework a bit how matrices are computed. More global state dependencies
;_;

Buffer-up draw commands, and only schedule them for drawing at EndFrame.
2021-02-20 14:54:57 -08:00
Ivan Avdeev
a5e279f580 fix sprite blending
Disable depth test and set dst blend factor to 1 for kRenderGlow mode.
Sprites are occluded in software.

(does this break any other code depending on Glow mode? who knows)
2021-02-20 12:46:16 -08:00
Ivan Avdeev
8dc0d4256d add VK_RenderDebugLabelBegin/End calls; fix studio model labeling 2021-02-20 12:35:04 -08:00
Ivan Avdeev
e66810a05b remove ubo management from "public" vk_render api
Now rendering submodules specify their colors and matrices using
VK_RenderState global stat api. This is a trade-off between making all
submodules track their state on their own, or managing that state
centrally.
2021-02-20 12:00:31 -08:00
Ivan Avdeev
15fdcab5fe add plan for stream 2021-02-19 23:07:45 -08:00
Ivan Avdeev
56c68dea0b fix beam entities piling up 2021-02-17 13:48:41 -08:00
Ivan Avdeev
3b1e7be112 add beams rendering
not all beam types are supported yet

also changes studio api init sequence, fixes missing cvars
vertex type struct is no longer names as brush-specific
uniform buffer allocation is now in vk_render

blending issues still remain
2021-02-17 13:26:09 -08:00
Ivan Avdeev
b22cd90184 add initial sprite rendering
alpha blending is broken
animations are weird, but we do draw them nonetheless somehow
2021-02-15 12:20:25 -08:00
Ivan Avdeev
538ae9191f coalesce studio model draw calls
it's easier to debug, and supposedly is faster to render too
2021-02-15 10:11:12 -08:00
Ivan Avdeev
c53bfaf484 add view(weapon) models 2021-02-15 09:55:42 -08:00
Ivan Avdeev
6fbd63bd1f fix models rendering and animation
RI.drawMode affects how time is interpreted for models, so make sure it
uses the correct time

implement indexing for model rendering -- this fixes weird holes
2021-02-13 23:24:21 -08:00
Ivan Avdeev
778cc60453 add broken studio models drawing
there are several issues with it:
- there are holes in models
- movement is jerky
- no lighting applied
2021-02-13 17:19:59 -08:00
Ivan Avdeev
e14f004785 Merge remote-tracking branch 'upstream/vulkan-anim-textures' into vulkan 2021-02-10 11:08:49 -08:00
Ivan Avdeev
5ebe36c54c move buffer allocation to vk_render.c from vk_bruh.c 2021-02-10 10:33:44 -08:00
074e4fd540 glslc: rework tool, support dependency scan, preliminary work on making tool dependless from compiler(like ccroot) 2021-02-10 03:51:11 +03:00
c1ef953672 waf: add glslc module 2021-02-10 03:50:55 +03:00
cbdca0abf9 implement texture animation and random tiling 2021-02-10 03:45:38 +03:00
Ivan Avdeev
ad5d515200 move entity enumeration from vk_brush to vk_scene 2021-02-08 10:57:27 -08:00
Ivan Avdeev
e5b14c0393 fix glitches on intel gpus due to misaligned uniform buffer offsets
Use VkPhysicalDeviceLimits.minUniformBufferOffsetAlignment to align dynamic uniform buffer offsets used per brush.
2021-02-07 23:19:22 -08:00
Ivan Avdeev
2704f442e9 fix lightmap corruption 2021-02-06 13:51:23 -08:00
Ivan Avdeev
45ad261129 make unimplemented message less verbose 2021-02-06 13:38:38 -08:00