Commit Graph

1266 Commits

Author SHA1 Message Date
Jonathan ec55e5f2da fix some data bugs with lightgrid octree mode 2023-02-11 12:19:00 -05:00
Eric Wasylishen f399b95bb8 light: add octree experimental version of lightgrid lump 2023-02-10 08:54:30 -07:00
Eric Wasylishen 6aa705e5f6 light: expand cluster bounds by 1 unit on each axis, clamp to overall grid size 2023-02-10 00:57:01 -07:00
Eric Wasylishen 22be0c4077 light: add -lightgrid_format option. takes "cluster" or "uniform" 2023-02-10 00:56:21 -07:00
Eric Wasylishen 051cc29afb light: add operator== for lightgrid_samples_t 2023-02-10 00:29:14 -07:00
Eric Wasylishen a8af353461 light: add another experimental LIGHTGRID_PERCLUSTER bspx lump
lower lightgrid_dist default from 64 to 32
2023-02-08 00:12:22 -07:00
Eric Wasylishen 96c7658b80 light: nudge lightgrid points if stuck in solid 2023-02-07 00:56:27 -07:00
Eric Wasylishen aa831d9ac3 light: add -lightgrid_dist 2023-02-07 00:46:54 -07:00
Eric Wasylishen 13fcc75bac Merge branch 'brushbsp' of https://github.com/ericwa/ericw-tools into brushbsp 2023-02-06 22:04:34 -07:00
Eric Wasylishen 1eda091542 light: LightPoint_SurfaceLight: use pvs 2023-02-06 22:03:03 -07:00
Eric Wasylishen e1f40ad995 light: LightGrid: don't calculate lighting for occluded samples 2023-02-06 21:56:51 -07:00
Eric Wasylishen 5f31141ac1 Revert "light: hack for sky + LIGHTGRID lump"
This reverts commit af2e8ae404.
2023-02-06 19:07:45 -07:00
Jonathan 5cd2a334f6 Merge branch 'brushbsp' of https://github.com/ericwa/ericw-tools into brushbsp 2023-02-06 17:08:00 -05:00
Jonathan 11e2c02757 use 512 units per luxel for sky faces (not fully finished/working yet; they still get affected by dirt) 2023-02-06 17:07:46 -05:00
Eric Wasylishen af2e8ae404 light: hack for sky + LIGHTGRID lump
just sample the sunlight omnidirectionally
2023-02-05 23:09:05 -07:00
Eric Wasylishen 712f413ac8 light: LIGHTGRID lump: change packing of sample points 2023-02-05 22:03:07 -07:00
Eric Wasylishen 74f149627a light: finish implementing lightgrid_samples_t::add() to use lowest brightness slot 2023-02-05 21:52:25 -07:00
Eric Wasylishen 2ad437b9e5 light: remove debug spam 2023-02-05 21:46:03 -07:00
Eric Wasylishen 8b38b7d45f light: LIGHTGRID lump: remove special case for 1 lightstyle maps 2023-02-05 21:30:34 -07:00
Eric Wasylishen 2cc513848b light: write styles into the experimental lightgrid lump 2023-02-05 17:16:57 -07:00
Eric Wasylishen 89fa416708 light: new experimental iteration on LIGHTGRID lump 2023-02-05 01:23:04 -07:00
Eric Wasylishen ffdca9b1a4 light: fix GetSurfaceLighting returning negative values 2023-02-04 02:10:32 -07:00
Eric Wasylishen cc8a50631d light: lightgrid,: try averaging incoming light from 6 directions on a cube 2023-02-04 01:02:28 -07:00
Eric Wasylishen fb17ee1218 light: add a LightFace_ScaleAndClamp equivalent for the lightgrid 2023-02-03 23:56:46 -07:00
Eric Wasylishen 357452d6fc light: don't delete lights between DirectLightFace and MakeBounceLights
the light grid code needs them later
2023-02-03 01:52:19 -07:00
Eric Wasylishen 999806f150 light: experimenting with generating a lightgrid
currently a hardcoded 64^3 grid in a LIGHTGRID bspx lump
non-finalized, likely going to change the lump
2023-02-03 01:17:52 -07:00
Eric Wasylishen 13481438e7 light: use DecompressAllVis() for getting visdata 2023-01-30 19:57:20 -07:00
Eric Wasylishen 8f49cf3894 refactor: Mod_Q1BSP_DecompressVis -> DecompressVis 2023-01-30 19:56:40 -07:00
Eric Wasylishen e490eb3ade refactor: move Mod_Q1BSP_DecompressVis to bsputils.cc 2023-01-30 19:56:34 -07:00
Eric Wasylishen d2db75ee81 light: Mod_Q1BSP_DecompressVis: port safety check from DecompressRow 2023-01-30 19:56:24 -07:00
Eric Wasylishen 9edad10b0f common: add convenience version of EntData_Parse 2023-01-30 00:08:45 -07:00
Eric Wasylishen ad77f8fc57 Revert "light: remove unnecessary/confusing scale factor on sunlight direction"
This reverts commit 94dcccf662.
2023-01-29 16:33:30 -07:00
Eric Wasylishen 94dcccf662 light: remove unnecessary/confusing scale factor on sunlight direction 2023-01-29 15:20:42 -07:00
Jonathan 531a0d781f fix crash on bad texel fetch from scaled textures 2023-01-29 14:01:07 -05:00
Eric Wasylishen 6ede7925bc light: apply model offset to embree meshes
Fixes shadows in incorrect places when using shadow-casting rotators
Fixes https://github.com/ericwa/ericw-tools/issues/326
2023-01-24 20:18:14 -07:00
Eric Wasylishen fa8af3845b light: fix default _sunlight angle to be pointing straight down 2023-01-24 00:52:28 -07:00
Jonathan 36b8b21990 set -wrnormals by default on -q2rtx
inherit -phong from worldspawn
2023-01-18 15:49:51 -05:00
Eric Wasylishen c109712079 light: fix spots in AO map in certain cases when combined with phong
The previous GetUpRtVecs (get tangent/bitangent) was not handling normals very near 0,0,1
whereas qv::MakeTangentAndBitangentUnnormalized does
2023-01-16 22:37:28 -07:00
Eric Wasylishen e520c96e28 light: CalcPoints: switch to jitter method for fixing luxels touching world
The previous method involved geometrically shrinking all sides of a face by 1 unit,
and snapping the luxel to the shrunken face. The problem is this could end up moving
the luxel a lot (e.g. 4 units) into vastly different lighting, causing lightmap artifacts.

Jitter method moves the luxel only +/- 0.5 units currently.
2023-01-16 02:01:45 -07:00
Eric Wasylishen 6697beb607 fix _cone default in q2 maps 2023-01-08 20:01:34 -07:00
Eric Wasylishen 91c678254a light: tweaks to _cone support in q2 2023-01-08 19:57:25 -07:00
Jonathan df5f894726 fix _cone in Q2 2023-01-08 20:03:06 -05:00
Eric Wasylishen a9a11159f4 light: add _surface_minlight_scale light key
for tweaking minlight given to faces matching surface light templates.

minlight = _surface_minlight_scale * light

lower default from 64 to 1 in q1 mode
2022-12-30 23:06:28 -07:00
Eric Wasylishen 3d0c756b4f light: fix minlight color on surface lights
- extra `* 255` was unnecessary, setting_color already does this
- don't use qvec3b as it was causing colors to wrap around the 0..255 range
2022-12-20 23:44:21 -07:00
Jonathan d5e29a1c90 add _nofill key, which causes an entity to not count as an entity for the purposes of occupancy (for lights in walls, etc)
add _nonudge key, to disabling nudging of lights "stuck" inside walls
2022-12-15 04:30:22 -05:00
Eric Wasylishen 82aa1e4396 light: make "_light_alpha 0" behave as expected (invisible to light) 2022-12-14 21:46:36 -07:00
Eric Wasylishen 8ce8b9233b light: _shadow_channel_mask defaults to _light_channel_mask if unset 2022-12-14 18:29:05 -07:00
Eric Wasylishen 513c47406b light: fix surface lights to check channel mask 2022-12-14 00:26:38 -07:00
Eric Wasylishen 287ac96363 light: fix sunlight to check object channel mask 2022-12-14 00:15:23 -07:00
Eric Wasylishen aca9820b03 light: don't bounce light for channel != 1 2022-12-13 23:59:58 -07:00
Eric Wasylishen ff73f13830 light: skip vis culling if lighting channels are used 2022-12-13 23:54:49 -07:00
Eric Wasylishen 00754e588e light: setting an _object_channel_mask implicitly enables shadow casting 2022-12-13 23:37:00 -07:00
Eric Wasylishen ea0ed34506 light: fix light bounds culling breaking channel masking
the bounds are only calculated for mask 1, so only apply bounds culling for lights on channel 1
2022-12-13 23:32:14 -07:00
Eric Wasylishen 8aa49699f8 light: rename channel mask keys
models:
_object_channel_mask

lights:
_light_channel_mask
_shadow_channel_mask
2022-12-13 23:20:27 -07:00
Eric Wasylishen 181d608c7a light: add missing RTC_SCENE_FLAG_CONTEXT_FILTER_FUNCTION now needed
also check channelmask/shadowmask in Embree_FilterFuncN
2022-12-13 20:04:22 -07:00
Eric Wasylishen 92d5c75424 light: experimental light channel mask feature 2022-12-13 19:13:58 -07:00
Eric Wasylishen 8728d982c3 light: remove more dead code 2022-12-13 18:59:35 -07:00
Eric Wasylishen 54e598c5fb light: clean up dead code 2022-12-12 18:02:33 -07:00
Eric Wasylishen 63cac32f88 light: quick experiment with a _light_group feature for lights that only affect linked bmodels 2022-12-11 15:36:08 -07:00
Eric Wasylishen bded0ab344 light: fix negative lights breaking when bounce in use 2022-12-10 15:10:36 -07:00
Eric Wasylishen 24f79d13bb light: recognize _cone as an alias for spotlight cone angle (q2 compat) 2022-12-09 00:59:49 -07:00
Eric Wasylishen a5b83e088b light: work around visblocking opaque liquids causing light artifacts with -visapprox vis
in cases when we actually want light to shine through these surfaces
2022-12-09 00:07:50 -07:00
Eric Wasylishen a70c8f4835 light: fix artifacting with translucent shadows
Embree is allowed to call the filter function more than necessary.
The previous implementation had side effects that would cause
the translucent shadows to get darker in this case.

As a limitation, we're back to only allowing 1 layer of glass per ray.
2022-12-07 00:23:26 -07:00
Jonathan cde7fd2908 add back in `_bouncestyled` in worldspawn; default to true on Q2 mode 2022-12-06 21:23:05 -05:00
Eric Wasylishen 185d12996b Merge branch 'brushbsp' of https://github.com/ericwa/ericw-tools into brushbsp 2022-12-06 15:19:46 -07:00
Eric Wasylishen eae434736a light: support _minlightMottle on worldspawn 2022-12-06 15:18:16 -07:00
Jonathan 15b9a78fd1 fix gate being incorrect
add surflight grouping
fix minlight on color'd _surface lights
2022-12-05 20:35:44 -05:00
Eric Wasylishen f66e4790a4 qbsp/light: add no_phong texinfo flag (currently not used/exposed) 2022-12-01 01:16:17 -07:00
Eric Wasylishen 1065adecc6 qbsp/light: implement _phong_group key, equivalent to Q2 "value" field 2022-12-01 00:25:05 -07:00
Eric Wasylishen 9fa9124404 light: redesign Q2 phong check
- always do angle check
- always do gamedef specific exclusions (e.g. warping surfflags don't phong with non-warping)
- if Q2 style phong is requested, but Q1 is not in use, use the default phong angle
- always do smoothing group ID check (preparation for supporting this in Q1 mode via a key)
2022-11-30 23:24:51 -07:00
Eric Wasylishen 96bdf141bb light: block phong if certain surfflag bits differ between the two faces
this prevents liquids from phonging with solids
2022-11-30 22:15:58 -07:00
Eric Wasylishen 5d3fab75b6 light: allow .wal_json metadata to contain "light": [ r, g, b ] to override emissive color
Use this to fix the "emissive lights" test case so it can run on CI without any texture data
2022-11-20 23:01:05 -07:00
Eric Wasylishen 37ced86cec tests: fix light settings not clearing across tests 2022-11-19 19:02:55 -07:00
Eric Wasylishen 0c4aab737d light: fix angled emissive surfaces not shining on adjacent faces 2022-11-19 14:57:56 -07:00
Eric Wasylishen c9111b2a6c
Merge pull request #337 from TTimo/colorcodes
Enable support for ANSI color codes on Windows 10 and newer, without …
2022-11-19 09:10:24 -08:00
Eric Wasylishen 9ab4ea8176 Move SetConsoleMode() call to logging::preinitialize(); helper
Don't do ENABLE_VIRTUAL_TERMINAL_INPUT as it breaks arrow key history
navigation in Windows Terminal after running one of the ericw-tools exe's.
2022-11-19 10:05:14 -07:00
Eric Wasylishen 4c218f5e91 common: factor out LMSCALE_DEFAULT = 16.0; 2022-11-15 23:52:34 -07:00
ttimo fb459253fe Enable support for ANSI color codes on Windows 10 and newer, without needing to enable system wide. Good for CreateProcess CREATE_NEW_CONSOLE situations. 2022-11-15 11:09:19 -06:00
Eric Wasylishen eb3dfe7952 ltface: use bilinear interpolation in WriteSingleLightmap_FromDecoupled 2022-11-15 00:50:11 -07:00
Eric Wasylishen 46d460277a ltface: support -world_units_per_luxel without -novanilla
first pass implementation - quality of vanilla LM is bad, due to nearest sampling
the decoupled lightmap
2022-11-14 23:58:31 -07:00
Eric Wasylishen c6b19fe6da light: implement -novanilla with -world_units_per_luxel
currently it's required because the non-novanilla path
isn't yet implemented
2022-11-14 00:30:37 -07:00
Eric Wasylishen 99e5f15d42 Revert "ci: use older embree/tbb which support Win8.1"
This reverts commit 50c4709d31.
2022-11-13 16:52:14 -07:00
Eric Wasylishen 50c4709d31 ci: use older embree/tbb which support Win8.1 2022-11-13 15:54:30 -07:00
Eric Wasylishen d7acd046c3 light/qbsp: add _surflight_rescale key 2022-11-12 17:07:02 -07:00
Eric Wasylishen a5125583fa light: clear global data so light can run multiple times per process 2022-11-11 16:52:07 -07:00
Eric Wasylishen 74269a0269 light: new Mottle implementation based on world-space "value noise" 2022-11-08 22:18:54 -07:00
Jonathan 66d7ae98e5 half memory usage for lightmaps & ray colors 2022-11-06 02:21:11 -05:00
Eric Wasylishen 221ea65efb light: fix -world_units_per_luxel on sloped faces 2022-11-03 23:45:47 -06:00
Eric Wasylishen ff54f86708 light: fix invisible shadow casters crash 2022-11-03 22:26:41 -06:00
Eric Wasylishen ca0efbf3d3 light: wip -world_units_per_luxel and DECOUPLED_LM BSPX lump 2022-11-03 02:39:15 -06:00
Eric Wasylishen 9edadf93cd light: CalcPoints: use faceextents_t::LMCoordToWorld 2022-11-02 01:16:36 -06:00
Eric Wasylishen 2bd2515792 all: cleanup unused includes (Clion - detect not directly used) 2022-10-31 21:37:34 -06:00
Eric Wasylishen 0924423c20 light: header -> source move 2022-10-31 21:21:28 -06:00
Eric Wasylishen ff5d48e5e1 light: CalcPoints: use faceextents_t::texCoordToWorld
this changes the "one unit in front of surface" from tex space to world space, which
makes more sense
2022-10-30 20:57:44 -06:00
Eric Wasylishen 383266762d light: lightsurf_t: remove texorg member 2022-10-30 19:40:26 -06:00
Eric Wasylishen 728fafde8c light: remove dead code 2022-10-30 18:00:48 -06:00
Eric Wasylishen da5910e732 tests: first steps on a light test case 2022-10-30 15:32:41 -06:00
Eric Wasylishen 35ffc00462 all: add LIGHT_/QBSP_/VIS_ prefixes to epsilons where necessary 2022-10-30 15:08:10 -06:00
Eric Wasylishen f9fc0fc478 light: remove dead code 2022-10-30 12:49:32 -06:00
Eric Wasylishen 636b376577 squash brushbsp-compilation-speedup branch
move function implementations out of headers
2022-10-21 18:00:58 -06:00
Eric Wasylishen c78b0396a9 light: fix wrong opacity of trans33/trans66 translucent shadows
- support _light_alpha key in q2 mode
- add q2 translucent shadows testmap
2022-10-19 00:00:47 -06:00
Jonathan af2f88b93c Merge branch 'brushbsp' of https://github.com/ericwa/ericw-tools into brushbsp 2022-09-21 05:35:18 -04:00
Jonathan 25cbbd42aa fix phong calculation
obj output adjustment
2022-09-21 05:35:11 -04:00
Eric Wasylishen acf334daee cleanup: rename surfflags_t::is_skip to is_nodraw
This is a break to the .json format
2022-09-18 15:47:14 -06:00
Jonathan 6713fedcbc allow changing a brushes' lightmap color scale with `lightcolorscale` 2022-09-10 19:04:17 -04:00
Jonathan 4ecd945587 use kmq2 flag instead of 33 | 66, which no engine supports 2022-09-10 07:49:06 -04:00
Jonathan 986f7da366 adjust default bouncescale to match older compiles 2022-09-03 14:06:11 -04:00
Jonathan 075481a36f add -nocolor for TB, etc
fix crashes on vis and light for invalid options
fix TB and others not receiving output
2022-08-31 12:58:04 -04:00
Jonathan 3564f6085d merge surface lighting and bounce code (wip) 2022-08-30 15:46:14 -04:00
Jonathan c99addc41a fix fastbounce lights being darker on extra2/4
use a more dynamic gate for non-fastbounce (slower but allows them to contribute)
2022-08-28 02:25:08 -04:00
Jonathan 384f74a0eb add separate "surflightskyscale" to handle the scale of sky lights; to help with doubling up with _sun
allow setSetting to report errors
print warnings on invalid worldspawn key values for light
fix setting_mangle not handling "pitch yaw" or "pitch" correctly
2022-08-25 16:30:15 -04:00
Jonathan 5fb0d56da7 maxlight
# Conflicts:
#	include/common/bspfile.hh
2022-08-24 21:50:11 -04:00
Jonathan 928b7f6e16 fix crashes with bounceextra/4 2022-08-24 12:03:05 -04:00
Jonathan 6345d6b616 add support for fast bounce lighting, which is the same as the old code 2022-08-21 22:12:41 -04:00
Jonathan 48c6b7a370 decouple extra and bounce extra; this allows you to still use extra4 but not have to wait like 16x longer for bounce lights to work 2022-08-18 07:35:06 -04:00
Eric Wasylishen f3b9de57c6 build: add tbbmalloc 2022-08-09 00:19:39 -06:00
Jonathan 426668701e clip_back/clip_front to match ChopWindingInPlace
simplify constructors for winding heap
use std::vector again for mapentity_t since it's being copied because of the std::list
2022-08-08 21:08:27 -04:00
Jonathan 335db1c0e4 move map_source_location to parser as parser_source_location since the locations actually come from there rather than from the map; now the parser keeps track of the location, so it's a bit easier to follow 2022-08-05 23:17:15 -04:00
Jonathan 24168c8e40 clang pass 2022-08-02 21:57:33 -04:00
Eric Wasylishen 52dff47a86 fix linux build 2022-08-01 12:47:20 -06:00
Jonathan 26a18d5cc3 add logging::header/funcheader to easily and consistently print function or "active routine" headers
add OOP percent_clock wrapper to make printing percents easier, not used yet
2022-08-01 09:35:21 -04:00
Jonathan d1c3b56e1d don't jitter sun entities 2022-07-31 09:15:51 -04:00
Jonathan d8fd13d481 use <= gating for brightness for surface and bounce lighting, since these can often be very small values (provides a moderate speed increase as well, counter-balancing the next change)
bounce lighting generates a grid of bounces rather than a single light, improving lighting in conditions with larger faces or where the midpoint is blocked by other geometry
2022-07-29 22:26:07 -04:00
Jonathan 91124d296f fix mismatch in surface lighting cull calculation 2022-07-29 21:29:04 -04:00
Jonathan ea5e7f5874 fix reported bounce light count 2022-07-29 13:27:31 -04:00
Jonathan 85f25bbc78 Q2-specific fix; -1 lightmaps are always fullbright, which can cause actual full-dark areas to be full bright by mistake 2022-07-29 10:40:02 -04:00
Jonathan 14ac139cce fix race condition; map operator[] modifies if it doesn't exist 2022-07-29 09:42:11 -04:00
Jonathan 3ee28fc416 fix crash in light from bounce lighting storage
move bounce lights to a forwardly linked list
fix minlight affecting style 0 for switchables
2022-07-29 00:41:24 -04:00
Jonathan 1d8a0c1df3 clang-format pass 2022-07-28 06:14:54 -04:00
Jonathan d9a9046e46 fix some foot-guns with qbsp_plane_t - type is auto-set now 2022-07-28 05:51:55 -04:00
Jonathan 4e3739c751 use a reader/writer-esque lock (shared_mutex) instead of exclusive-only recursive lock to speed up plane stuff 2022-07-24 19:05:28 -04:00
Jonathan 2357f4e660 remove test print 2022-07-22 23:00:54 -04:00
Jonathan 0561766bc9 fix overblown lighting if light color is specified for radiosity 2022-07-22 22:10:22 -04:00
Jonathan b6153e3084 use make_unique where appropriate
use unordered_map/set where ordering isn't important (faster for searching and smaller footprint)
2022-07-18 20:16:50 -04:00
Jonathan da9546e260 change settings semantics to be simpler and more clear:
- no more "isLocked" - use getSource directly (locked is a confusing name)
- no more split parse/setValue functions. there's only one entry point each now, and all they do is pass along the source passed to it from its parser.
- no separate setters, use setValue(value, source)
- add a "game target" source, which is low priority and indicates to the user that the value would have been default but was changed to a better value for the game target
2022-07-14 09:03:59 -04:00
Jonathan 1aa2a9b250 Merge branch 'brushbsp' of https://github.com/ericwa/ericw-tools into brushbsp
# Conflicts:
#	qbsp/qbsp.cc
2022-07-11 01:41:10 -04:00
Jonathan f98dd05f56 new, simpler qbsp3-esque TJunc code;
- currently uses naive brute force approach to finding vertices on faces
- simplify 'face fragments', which now only need to contain vertex indices since they are already emitted
2022-07-11 01:40:10 -04:00
Eric Wasylishen d32d6ea81d light: rename options -> light_options 2022-07-10 17:28:28 -06:00
Eric Wasylishen 050886f32c tests: unify tests under one target
to ease sharing code. vis/light tests are going to need the testqbsp infrastructure.
2022-07-10 16:36:15 -06:00
Jonathan 4c68ba42d3 simplify sample again 2022-07-10 14:11:17 -04:00
Jonathan a329c901c6 just use sample difference instead of trying to re-calculate it 2022-07-10 13:47:08 -04:00
Jonathan 2a70cafa32 kinda fix overbrightness? still needs work..
allow lmshift force on light
2022-07-10 13:31:38 -04:00
Jonathan 8fc089aa34 fix lmscale with bounce lighting 2022-07-09 23:09:02 -04:00
Jonathan 773d20052c write out style numbers to verbose 2022-07-09 01:36:26 -04:00
Jonathan 865217c655 adjust final output warning 2022-07-09 01:36:26 -04:00
Jonathan 30bd8467c3 fix wrong boolean used for warning 2022-07-09 01:36:26 -04:00
Jonathan 0e4066f312 fix LMSTYLE containing 16-bit values sometimes 2022-07-09 01:36:26 -04:00
Jonathan 56e1e2dde0 adjust lightstyle overrun warnings to be less annoying
fix potential overrun in lightstyle writing
2022-07-09 01:36:26 -04:00
Jonathan 7f64c9dfeb simplify saving 2022-07-09 01:36:25 -04:00
Jonathan 88905d4a69 secondary fix to lmstyle code 2022-07-09 01:36:25 -04:00