Commit Graph

3745 Commits

Author SHA1 Message Date
Ivan Avdeev 29508cd324
Merge pull request #547 from w23/brush-smoothing
Smooth normals between selected brush surfaces if the angle between them is small enough.

- [x] Per-vertex-per-surface smoothing functionality (differs from qrad, which is per-edge; this gives artifacts as (supposedly) we have higher than lightmap lighting resolution)
- [x] Automatically select surfaces with less than X degrees between normals.
- [x] Make this X threshold adjustable from <map>.bsp.patch
- [ ] ~~Try not joining coplanar surfaces~~ -- doesn't seem to be affecting anything.
- [ ] ~~Think about linking surfaces more. Should we link distant surfaces w/o direct edges to this one?~~ -- it seems that we should be fine for now. Per-surface+vertex vs per-edge smoothing has no clear winner, just different tradeoffs.
- [ ] ~~Scale normals according to surfaces areas, so larger surfaces have more weight (experimental; may improve some artifacts)~~ -- also, non trivial to compute, and may not affect things too much.
- [x] Patch: add explicit smoothing or no-smoothing for given surfaces.

Fixes #139, supersedes #348
2023-09-05 10:18:46 -07:00
Ivan Avdeev bdbfbef8a2 vk: add commented out normal debugging code 2023-09-05 13:06:00 -04:00
Ivan Avdeev f42ea011f1 vk: mapents: fix not clearing smoothing groups 2023-09-05 13:03:53 -04:00
Ivan Avdeev 58ed5e7277 vk: brush: add explicit smoothing group inclusion 2023-09-05 12:54:57 -04:00
Ivan Avdeev 61416cfc66 vk: brush: do not link pairs that were explicitly excluded in patches
This doesn't work as expected in some cases, as surfaces might still get
linked transitively by neighbours. Solving this seems non-trivial for
now, but maybe we can just live with it
2023-09-05 12:35:28 -04:00
Ivan Avdeev d8d5019971 vk: filter smoothing normals by texture
thanks to G.I.F
2023-09-05 12:07:02 -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 a9dcf94f1b vk: add initial support for brush surface normal smoothing
Lots of artifacts

Relevant: #139, #348
2023-09-04 13:49:03 -04:00
Ivan Avdeev 883ccff13f
Merge pull request #537 from w23/blas-mgmt
Improve BLAS management

This PR is to address #533 and related issues, e.g.:
- [x] Fixes #236
- [x] Fixes #350
- [x] Fixes #354
- [x] #364
- [x] Fixes #422
- [x] Fixes #443
- [x] Fixes #533
- [x] Fixes #539
- [x] Fixes #458 

An arbitrary list of other things to do in this PR also:
- [x] Use new model create and render for brushes
- [ ] ? split materials from kusochki
- [x] fix sprite textures: pass texture override and upload dynamic/instanced kusochki
- [x] orient sprites
- [ ] fix NewMap-vs-long allocations for:
  - [ ] accel buffer
  - [ ] kusochki
- [ ] create/allocate tlas only once
- [x] studio models:
  - [x] pre-cached models with prebuilt blases
  - [x] blas update
  - [x] counters for static-vs-dynamic cache entries count
    - [x] better `r_speeds_graphs`
      - [x] add/remove commands which modify the string
      - [x] constant monitoring of the available metrics: metric registering later should start being drawn
  - [ ] ~~cache eviction/LRU (needs proper allocs for accel buffer and kusochki)~~ -- doesn't seem to be a problem for now. Can totally live without.
  - [x] previous vertices and transform
- [x] Fix animated textures: pass and update kusochki
- [x] Fix emissive textures
  - loading order has changes, now kusochki are uploaded when brush model is loaded, and before lighting data is applied, thus losing emissive values
- [x] Remove deprecated APIs:
  - [x] dynamic model
  - [x] `VK_RenderModelInit_old`
  - [x] `VK_RenderModelDraw_old`
  - [x] `deprecated` section from `vk_render_model_t`
  - [x] old ray model
  - [x] old ray model cache
- [x] hide `rt_blas_t` as rt-internal, only expose new `rt_model_t`
- [x] restore TriApi/dynamic geometry for RT
  - [x] dynamic drawing for RT
  - [x] dynamic `rt_blas_t`
- [x] brush water update
  - [x] rt_blas update
  - [x] vk/rt models update
- [x] studio dynamic models
  - [x] reloading c2a5 leads to geometry exhaustion (cannot allocate N vertices M indices, and missing models)
  - [x] better static model detection: many sequences/frames are the same and are not in fact animated. This can be detected at load time.
- [x] `r_speeds` persistent metrics which are not reset on every frame, e.g. allocation counts, cache sizes, etc
2023-08-31 10:10:59 -07:00
Ivan Avdeev 1d9b987379 vk: treat emissive animated texture frames as polylights
Probably not the most optimal solution, but it works.

Fixes, #458
2023-08-31 12:49:30 -04:00
Ivan Avdeev 9c4fd15e65 vk: fix animated textures for brush models 2023-08-31 12:11:17 -04:00
Ivan Avdeev 3e14591082 vk: wkrutily lampotschkee
fixed missing emissive values for brush models
2023-08-31 11:45:51 -04:00
Ivan Avdeev ea1a98716d vk: restore dynamic polygon lights 2023-08-29 13:39:36 -04:00
Ivan Avdeev 0ccc107859 vk: associate more logs with modules 2023-08-29 13:12:35 -04:00
Ivan Avdeev 6d3c5bfa3e vk: add runtime-toggleable debug logs with module granularity
Use e.g. `vk_debug_log "mat,tex,brush"` to enable verbose debug (-dev 2)
logs for Material, Textures and Brush modules.
2023-08-29 12:31:57 -04:00
Ivan Avdeev e978871470 remove unused vk_previous_frame module 2023-08-28 13:12:02 -04:00
Ivan Avdeev ffa9603747 vk: studio: fix motion vectors for denoiser
Track prev_verts by render submodel
2023-08-28 12:59:54 -04:00
Ivan 'provod' Avdeev 2dc68544d6 vk: studio: remove obsolete comments 2023-08-28 09:11:48 -07:00
Ivan 'provod' Avdeev 45a141aa36 vk: studio: clear submodule cache at appropriate times
Add render refcount to submodels to diagnose when it can't properly clear things due to them being used somewhere still.

Also add `speeds.submodels_cache_{dynamic,static}` counters to show how many submodels render models have been allocated.
2023-08-28 09:11:48 -07:00
Ivan 'provod' Avdeev 03fc537d54 vk: studio: implement proper per-submodel rendermodel cache
Gives out individual render submodels for dynamic ones, receives and remembers them when they are not needed anymore.

Stores only one render submodel for static ones. Reuses/instantiates it for everyone.
2023-08-28 09:11:48 -07:00
Ivan 'provod' Avdeev c42cf2088c vk: studio: handle first half of entity reuse
Detect whether studio model has changed, and replace it with a new one.
It does (as predicted) run into a gpu sync issue if reuse happened while previous frame with the old user is still being drawn.
2023-08-28 09:11:48 -07:00
Ivan 'provod' Avdeev 567d014ada vk: studio: precompute per-submodel dynamic-ness
Basically go through all sequences and bones, and try to find out whether a given submodel is affected by animation frames.
2023-08-28 09:11:48 -07:00
Ivan 'provod' Avdeev 9636b541c5 vk: studio: make dynamic-ness detection more granular
also comment on the upcoming submodel caching plans
2023-08-28 09:11:48 -07:00
Ivan Avdeev 47cc51d9b1 vk: studio: track studio model state by entity 2023-08-28 09:11:48 -07:00
Ivan Avdeev 09d8534b01 vk: studio: extract all model/cache stuff into separate files 2023-08-28 09:11:48 -07:00
Ivan Avdeev f99d43ec4c add a bunch of wip changes wrt studio model cache 2023-08-28 09:11:48 -07:00
Ivan Avdeev f691b4b4b0 vk: add "persistent" speeds metrics for used memory, etc
Renames previous METRICS to COUNTERS. These are still reset to zero
every frame.

Adds new METRICS which are preserved, maintained externally to speeds,
and only sampled by speeds code once per frame.

Also adds new metrics:
- `studio.cached_submodels` -- number of submodels in cache
- `geom.used` -- memory used by long allocations
- `geom.{vertices,indices}` -- counts of vertices/indices for long
  allocations
- `geom.dyn_{vertices,indices}` -- counts of vertices/indices for
  single-frame dynamic allocations
2023-06-14 11:23:09 -07:00
Ivan Avdeev d13c0d4748 vk: add studio dynamic and static submodels metrics 2023-06-13 12:19:18 -07:00
Ivan Avdeev 5dda220751 vk/speeds: preserve metric names that might not be registered initially
When `r_speeds_graphs` cvar is read for the first time, not all metrics
might be registered yet. It leads to some graphs missing.

Retry searching for these metrics on further frames, thus preserving the
graph list from previous session fully.
2023-06-13 11:52:46 -07:00
Ivan Avdeev c72ff1d0c5 vk: add ability to delete graphs by their names
Also, track single changes vs cvar changes: do not reload everything
from cvar on every update
2023-06-13 10:32:32 -07:00
Ivan Avdeev 0b47621f69 vk: add r_speeds_graph <add/del/clear> command
Allows adding graphs w/o editing the cvar manually

Delete is not implemented yet
2023-06-13 10:12:41 -07:00
Ivan Avdeev 046ae3d7f3 vk: rename metrics to module.name, prettify list
- Add variable name and registration src:line to the
  `r_speeds_list_metrics` output. Makes it easier to reason about where
  does this metric come from.
- Group metrics by their modules, makes it easier to discover.
- Do not print the list immediately on command, do it later in the
  frame. Makes it print correct latest frame values.
2023-06-13 09:39:50 -07:00
Ivan Avdeev 6583ed0c31 vk: fixup sequences fps formatting 2023-06-09 11:34:39 -07:00
Ivan 'provod' Avdeev ba041fce36 vk: update animated studio models geometry
Still slightly KORYAVY as:
- there's no cache eviction, it might get full pretty quick
- static-vs-dynamic animation decision is pretty rudimentary, might consider non-animated things as dynamic
- args passing vs global state is meh
2023-06-09 11:28:30 -07:00
Ivan 'provod' Avdeev cadf3dbdfc rt: update blas for brush water
Enable updating rt_blas, and use that for updating brush water models
2023-06-09 10:03:00 -07:00
Ivan Avdeev 406a5f9d4b vk: remove old dynamic beam segs code 2023-06-07 10:54:09 -07:00
Ivan Avdeev 4409e57a8d rt: fix dynamic models colors 2023-06-07 10:43:54 -07:00
Ivan Avdeev 0b8fe6fe33 rt: implement fast dynamic models
It works, and works really fast.
Known issues:
- missing colors
2023-06-07 10:24:29 -07:00
Ivan Avdeev e6bf0c452a rt: more removals 2023-06-06 11:21:47 -07:00
Ivan Avdeev 789982277d rt: remove more unused and obsolete things 2023-06-06 10:50:16 -07:00
Ivan Avdeev 98f8300ca2 vk: remove lots of obsolete code
TriApi/dynamic stuff is still not passed to RT, but removing old code
makes it easier to reason about.
2023-06-06 10:40:10 -07:00
Ivan Avdeev 8e0a9ac4d4 vk: remove old dynamic model implementation too
Breaks dynamic model RT rendering, as it is not implemented yet
2023-06-06 10:20:00 -07:00
Ivan Avdeev c105d45265 vk: remove public render dynamic model api
It still remains internally, and generates too many BLASes.
2023-06-06 09:50:24 -07:00
Ivan Avdeev 0e13ed38c1 vk: revert beam segs to use triapi, like gl 2023-06-06 09:29:05 -07:00
Ivan Avdeev c271078196 vk/speeds: print current metric value next to graphs 2023-06-06 09:27:52 -07:00
Ivan Avdeev 3e2e5e7cb2 vk: remove old dynamic model api usage from brush+water
This makes water static for now, and also makes it look weird, e.g.:
- no culling of water sides (it is "dynamic" in a sense that it's an
  entity property, not model property)
2023-06-05 12:53:25 -07:00
Ivan 'provod' Avdeev a2b0164e03 vk: put barney back together
Fixes computing total vertices/indices count. Were referencing the same `pmesh` for all meshes.

Floating and missing heads issue seems to be due to incorrect fixed animation frames. I.e. animation frames contain offsets to the correct positions. Should be fixed when animations are done.
2023-06-03 12:10:56 -07:00
Ivan Avdeev df102994c4 vk: pre-build and cache studio submodels on first draw
Known issues:
- no animations, stuck at first rendered frame of a given submodel.
  This is as intended for now, needs BLAS update functionality not yet implemented.
- wrong positions/transforms. Reasons unknown. May be "as intended" too.
- missing heads
- Barney model corruption. Consistent between maps/instances/animation
  frames.
2023-06-02 11:49:02 -07:00
Ivan Avdeev c34c56e203 vk: add r_speeds_list_metrics command, with filter 2023-06-01 12:12:10 -07:00
Ivan Avdeev 3bbca26087 vk: fix disappearing sprites for traditional renderer 2023-06-01 11:42:23 -07:00