Commit Graph

97 Commits

Author SHA1 Message Date
Ivan 'provod' Avdeev 5f3a0c233b vk: rt: investigate more nans
Found that some studio models end up producing zero-length normals. See #731
2024-01-19 11:34:31 -05:00
Ivan Avdeev 0e403e119f vk: silence degenerate triangle diagnostic logs 2024-01-18 11:13:16 -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 'provod' Avdeev 8f5b5657ce vk: rt: skip loading zero-area polygon lights
These cause NaNs in lighting computation, which leads to visual glitches, like strong yellow or green lighting.

Fixes #461
2024-01-11 10:35:37 -05:00
Ivan Avdeev 310ecff585 vk: rt: make additive brush models single-sided
Fixes #665
2023-12-22 15:19:24 -05:00
Ivan Avdeev 180f3ed9cb vk: rt: allow per-model back face culling
Make transparent studio models, e.g. holograms, single-sided.

Related: #665
2023-12-22 15:14:27 -05:00
Ivan Avdeev 6fc318143e vk: rt: allow hiding all SURF_DRAWSKY surfaces while retaining skybox
Neede for getting rid of some skybox 𝘱𝘦𝘯𝘦𝘵𝘳𝘢𝘵𝘪𝘰𝘯 glitches, see #579
2023-12-14 10:54:07 -05:00
Ivan Avdeev 3cbc11a8f0 vk: rt: optimize hires skybox loading
- Do not load skybox at all if there are no SURF_DRAWSKY, #706, #579
- Do not reload the same skybox, #706

Also refactor skybox loading a bit. Prepare for KTX2 skyboxes.
2023-12-14 10:33:26 -05:00
Ivan Avdeev 4ac62076bb vk: use original texture for sprites in rasterization mode
Traditional rasterization should not use any of the patched textures.

Fixes #695
2023-12-11 12:55:32 -05:00
Ivan Avdeev 4fc6db36b4 vk: rt: fix adding switchable/animated light twice
Skip adding animated surfaces as static lights. We'd like them to be
static, but currently there's no distinction between immovable lights
and switchable lights or lights with dynamic emissive value.

Fixes #679
2023-12-04 13:48:12 -05:00
Ivan Avdeev 0549822d53 vk: print 'vk/module' in logs 2023-12-04 11:29:38 -05:00
Ivan Avdeev 32f05816e1 vk: rt: extract dynamic polylight to brush model
They don't really belong to neither rt_model_t, nor render model.
Allows having dynamic polylights for func_water entities without "main"
render model, and only water submodels.
2023-11-30 11:20:32 -05:00
Ivan Avdeev d5f8b593f9 vk: make rendermode patching a bit less ugly 2023-11-30 10:20:47 -05:00
Ivan Avdeev dd21e665b1 vk: patch rendermode for entities
Probably not the best way to do it, but this is an attempt.

Issue #663
2023-11-28 13:01:14 -05:00
Ivan Avdeev 735260a3c5 vk: brush: fixup per-model material mapping
fixes #669
2023-11-27 13:20:06 -05:00
Ivan Avdeev f0b80887e8 vk: brush: support normalmaps for water surfaces
Adds missing tangents.

Fixes #655
2023-11-17 11:06:09 -05:00
Ivan Avdeev de80c0da64 vk: comment on no light under emissive acid
ref: #56
2023-11-17 10:22:53 -05:00
Ivan Avdeev 85fbe15f65 vk: make conveyors move again
Known issues: validation-induced crash on changlevel

fixes #465
2023-11-16 13:00:00 -05:00
Ivan Avdeev f535020f94 vk: update emissive color for water surfaces
In a not super efficient way: it will re-upload kusochki every time,
even though there has been no update.
2023-11-16 10:35:07 -05:00
Ivan Avdeev e4d7858330 vk: add emissive water surfaces to polygon lights
Makes acid water surfaces emissive again.
However, they are not assinged proper emissive color values for direct
ray hits yet, so they do emit light, but look dar still.

Ref: #56
2023-11-16 09:56:21 -05:00
Ivan Avdeev a3c52a8001 vk: hide "back" water surfaces
Only leave water surfaces directed towards "air".
This is consistent with:
- non-`kRenderNormal` surfaces, for which there's only one surface present
- opt2 for translucent surfaces, where we aim to detect medium boundary
  direction based on normal-vs-ray-direction

Also add notes about translucent surfaces in general, more info about
water rendering under ref_gl, etc.

Fixes #264
2023-11-14 11:44:29 -05:00
Ivan Avdeev 78548960e7 vk: improve culling; add notes about water and culling
Cull everything except:
- opaque geometry: to avoid shadow and reflection holes
- bleded geometry: particles and such should be visible from any angle

Alpha-tested geometries result in visual glitches when not culled
(double-sided ladders, double shadows, etc). These glitches are worse
than slightly misaligned shadows.

Translucent geometries are still matter of research.
2023-11-13 12:22:23 -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 f6c19527d5 vk: brush: hide side water surfaces for entities w/o EF_WATERSIDES
Worldmodel draws all water surfaces regardless of their
orientation/PLANE_Z.

All other entities only draw sides when EF_WATERSIDES effect bit is set.
2023-11-09 12:55:56 -05:00
Ivan Avdeev 4145969198 vk: brush: do not try to invert water height when underwater
Not sure that we need it.
2023-11-09 10:49:53 -05:00
Ivan Avdeev 5c3be09161 vk: brush: force worldmodel alternate_anims textures static
Many static worldmodel surfaces still contain alternate texture chains.
That was making these surfaces dynamic, even though there's no way to
trigger these alternate anims.

Make worldmodel ignore alternate_anims when looking for animated
surfaces.

Fixes #644
2023-11-09 10:32:47 -05:00
Ivan Avdeev 3e9f6bc7a4 vk: half-fix water levels being too high
Pass current entity to compute wave height. Still doesn't switch to
negative height when underwater for some reason.
And still displays water sides.

Add some notes regarding water geometry generation and drawing.
2023-11-07 13:45:25 -05:00
Ivan Avdeev 2c0e7033ed vk: fix crashing on maps with skybox
We were using a negative value for `SURF_SKY` surfaces, which hit an
assert on uploading kusochki.
2023-11-07 13:30:46 -05:00
Ivan Avdeev c6c58a9842 vk: allow rotating matrices in patches
Adds `_xvk_tex_rotate` field for surface patches. Angle is specified in
degrees.

Note that it rotates the texture around origin, which might be very far
away. So offset patching might be needed to re-align.
2023-11-07 12:03:40 -05:00
Ivan Avdeev 4509e2075d vk: fix changing textures on buttons, etc
Detect changes in alternate_anims sequences.

Fixes #640
2023-11-06 11:42:07 -05:00
Ivan Avdeev 2a3f48fd50 vk: fix occasional inverted normal maps
When texture coordinates are inverted, it makes tangent look into
oppsite direction, which inverts TBN and therefore normal map.

Make sure the tangent points to a consistent direction.

Fixes #627
2023-11-02 10:58:11 -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 Avdeev 737d1324e8 vk: assign translucent material mode to transparent studio models
fixes #613
2023-10-31 11:15:15 -04:00
Ivan Avdeev 1f043a90a6 vk: remove dummy textures for new material name resolution
Use dedicated hash table for new material names.
Updates a lot of dependent code:
- surface patches now target materials, not textures:
  `s/_xvk_textures/_xvk_material`
- patching now affects only materials, not texture ids. All logic that
  depends on texture ids now operate on original textures.
- brush normal smoothing now ignores patched surface materials when
  deciding whether two surfaces can be smoothed.

The rationale is that patching should only affect newer PBR/RT code paths.
2023-10-30 12:43:26 -04:00
Ivan Avdeev c36080c982 vk: move things around between {r,vk}_texture
Another step in preparation for new hash table and better lifetime
management
2023-10-24 11:32:42 -04:00
Ivan Avdeev b315f463cf vk: rename vk_textures to r_textures 2023-10-20 11:18:55 -04:00
Ivan Avdeev 18261da713 vk: massage texture module function names
Bring function names to a single style.
Make them state what they actually do.
2023-10-19 11:15:48 -04:00
Ivan Avdeev e1d478fa28 vk: free textures on map change (DO NOT USE)
Leads to texture corruption and GPU crashes on Linux.
2023-10-17 11:43:38 -04:00
NightFox ecdb68370b
Merge branch 'vulkan' into materials-table 2023-10-10 20:32:04 +03:00
NightFox 56737fd05f
Merge pull request #591 from w23/everything-is-smooth
vk: patch: allow smoothing entire brush model
2023-10-05 22:00:39 +03:00
Ivan Avdeev 0d6f6d26af vk: material: add material table independent of texture table
It still reuses texture table for name lookup for now.
2023-10-03 12:48:26 -04:00
Ivan Avdeev 6bfa4c90fa vk: brush: assign white texture for kRenderTransColor
kRenderTransColor mode strips geometry of its texture and makes it solid
color. Previously we were noticing this rendermode late, and failed to
update the textures.

Now we depend on reading this rendermode from map entities, and
pre-assigning correct (white) textures on load.

Assumes that rendermode doesn't change at runtime for brush models.

Fixes #528
2023-10-02 11:39:00 -04:00
Ivan Avdeev 1bbcf44864 vk: patch: allow smoothing entire brush model
fixes #589
2023-10-02 11:18:22 -04:00
Ivan Avdeev 8ff89bd5ef vk: materials: add rendermode-specific overrides
Example:
```c1a0d.mat
{
	"for_rendermode" "kRenderTransTexture"
	"for" "table2"
	"basecolor_map" "/colors/white.png"
	"metal_map" "/colors/white.png"
	"roughness_map" "/colors/black.png"
}
```

Fixes #213
2023-09-29 13:59:27 -04:00
Ivan Avdeev e97691b27c vk: patch: allow mapping texture to materials for brush entities
```
{
	"_xvk_ent_id" "39"
	"_xvk_map_material" "generic028 mirror"
}
```

NOTES:
- might severely degrade performance in some cases/under debug as we're
  doing N^2 search with strcmp for rendered entities.
2023-09-29 12:48:32 -04:00
Ivan Avdeev b07c5c3740 vk: rt: pass material mode directly from draw command
Different render sources (model types, render types, etc) might require
different material modes. E.g. brush should be translucent (refractive+mirror)
for blend mix modes. However, smoke particles should not be
mirror/refractive for the same blend mix render type.
2023-09-26 13:14:28 -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 638bd163af vk: remove chrome material type; patch roughness manually instead
Also, material struct is now embedded into geometry, so it can be
individually patched.
2023-09-22 09:43:27 -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 cd4014766b vk: explicitly pass old original texture for trad renderer
Fixes #571
2023-09-19 13:20:04 -04:00