Commit Graph

845 Commits

Author SHA1 Message Date
Eric Wasylishen 3056971ae6 light: fix issue with lights within 1 unit of a face not casting light on that face
fixes https://github.com/ericwa/tyrutils-ericw/issues/10
2016-02-25 23:02:43 -07:00
Eric Wasylishen 48830f2b1a light: revert CalcPoints changes as it was causing light leaking in jam2_mfx
(points on the top edge of a face were crossing a wall, but ended up in the open so they were accepted as OK)
2016-02-25 15:34:07 -07:00
Eric Wasylishen ceec7b16c7 light: optimize TraceFaces 2016-02-22 22:11:12 -07:00
Eric Wasylishen 4ed6db3020 light: add new TraceFaces API which gives accurate info on the first hit face of a trace.
Need to use this for: dirtmapping, fence textures, GI
2016-02-21 22:31:06 -07:00
Eric Wasylishen 4e74e530c0 light: dynamically allocate memory for lighting each face 2016-02-20 14:43:38 -07:00
Eric Wasylishen 22dd1726de light: move lightsurf_t etc. to header 2016-02-20 14:41:58 -07:00
Eric Wasylishen 942c87a98b light: fix phong shading for sunlight 2016-02-16 19:16:42 -07:00
Eric Wasylishen ae04899ce5 light: make CalcPointNormal more robust; don't use micro-triangles (<1 unit area) for interpolating normals 2016-02-16 19:09:43 -07:00
Eric Wasylishen 465cb2a555 light: avoid NaN's due to rounding error when calculating angles for weighting normals 2016-02-15 20:28:05 -07:00
Eric Wasylishen 1fd1637de1 light: add -phongdebug option 2016-02-15 20:27:03 -07:00
Eric Wasylishen fdc1f25276 light: add phong shading debug function 2016-02-15 17:59:05 -07:00
Eric Wasylishen a515a13107 Lightmap_ForStyle: change back to taking a const lightsurf_t* 2016-02-15 16:20:29 -07:00
Eric Wasylishen 537937f0eb Lightmap_Soften: remove stack allocation 2016-02-15 16:20:29 -07:00
Eric Wasylishen e896f3126b entities.c: make SetWorldKeyValue / WorldKeyValue safer 2016-02-15 16:20:29 -07:00
Eric Wasylishen b0777c2075 suppress compile warnings 2016-02-15 16:20:29 -07:00
Eric Wasylishen b2687481d6 WriteLightmaps: revert to how I was getting the sample points 2016-02-15 16:20:29 -07:00
Eric Wasylishen 7128a8e956 code formatting, normalize most whitespace to 4 spaces 2016-02-15 16:20:29 -07:00
Eric Wasylishen 1f05b7976a fix wrong FindTexinfo call
fix Lightmap_ForStyle call
change M_PI to Q_PI
switch to Q_strncasecmp
2016-02-15 16:18:51 -07:00
Eric Wasylishen 1630b8756e tyrutils-ericw-spike rebased on to 998c9d3acb 2016-02-15 16:16:37 -07:00
Eric Wasylishen 9496991e60 LightFace_Min: allow delay 4 lights to use lightstyles 2016-02-14 20:45:56 -07:00
Eric Wasylishen 651e7ca827 CalcPoints: if NearWall() fails, first try fudging by 0.25 units in each direction 2016-02-11 23:30:21 -07:00
Eric Wasylishen a439f891a1 CalcPoints: Skip the trace if a PointContents says the point is already unobstructed.
Handles beveled walkways in telefragged.bsp which touch a wall along one edge, but don't split the wall.
Previously, the walkways were blocking most of the traces for the wall, messing up all of the wall sample points.
2016-02-11 22:38:23 -07:00
Eric Wasylishen 7a5c7bbf6b light: cleanup _sunlight3 code, support _sunlight3 without _sunlight2 properly 2015-12-10 14:58:49 -07:00
Eric Wasylishen 99d5a4d4f9 build: setup CPack to package binaries in a zip file 2015-12-09 16:23:36 -08:00
Eric Wasylishen 420125cc67 replace tabs with spaces.
for FILE in $(find . -name "*.h" -or -name "*.c"); do cat $FILE | expand > temp; cat temp > $FILE; done
2015-12-07 15:08:48 -07:00
Eric Wasylishen c149ed2bf6 build: VS2015 support 2015-12-07 14:23:13 -07:00
Eric Wasylishen fe65004f17 light: test out _sunlight3 2015-12-05 21:40:15 -07:00
Eric Wasylishen e6fcf3d6da light: add -surflight_dump option to export generated surface lights to a map file 2015-12-05 20:27:51 -07:00
Eric Wasylishen 81cefad71a light: handle surface lights on rotators 2015-12-05 20:07:20 -07:00
Eric Wasylishen 50b556993a light: experimental -parse_escape_sequences option to toggle \b escape sequence (toggles bold text) 2015-11-26 18:30:10 -07:00
Eric Wasylishen f154a00e3a light: fix "_mincolor" bmodel key which was only accepting 0-255
now accepts 0-1 or 0-255.
2015-11-20 14:27:25 -08:00
Eric Wasylishen b3472d89e7 light: fix antilights which were broken with the light culling change 2015-11-07 11:58:07 -07:00
Eric Wasylishen 8e18933f5d light: silence "no model has face" warning 2015-10-25 23:41:19 -06:00
Eric Wasylishen d0fb0bd410 light: remove entity->fadedist, it was error-prone, and instead just check light level. it's only very slightly slower. 2015-10-25 23:18:17 -06:00
Eric Wasylishen 7f1beca6b4 light: add "_surface_spotlight" key for making surface lights into spotlights based on the surface normal 2015-10-25 22:35:29 -06:00
Eric Wasylishen 1e9a0ac2b3 light: add "-sunsamples" flag to control number of samples for _sunlight_penumbra and _sunlight2 2015-10-23 19:54:41 -06:00
Eric Wasylishen 69fab3fc96 light: clean up SetupSkyDome 2015-10-23 18:31:39 -06:00
Eric Wasylishen c0d61d4147 light: cull light bounding sphere against surface bounding sphere before checking each surface point. gives a modest speedup. 2015-10-23 15:10:35 -06:00
Eric Wasylishen 244243b121 light: fix "-gate" (was calculating too-large bounding spheres for delay 2 lights.) 2015-10-23 01:36:16 -06:00
Eric Wasylishen d4d63efd87 light/trace.c: Adjust the trace algorithm to match that in q3map.
Fixes some weird artifacts I noticed when experimenting with lava surface lights in jam6_ericwtronyn.map
2015-09-25 00:13:25 -06:00
Eric Wasylishen 532704f54e light: fix duplicate surface lights being generated 2015-09-14 22:16:53 -06:00
Eric Wasylishen 1cf7af0c17 light: remove unused FaceArea function 2015-09-12 19:07:58 -06:00
Eric Wasylishen 8e29319309 light: avoid doing the trace twice when there is no obstruction 2015-09-12 18:53:56 -06:00
Eric Wasylishen 46cbcfd12b light: add -dirtangle flag to control dirtmapping cone angle 2015-08-28 20:22:54 -06:00
Eric Wasylishen 3c918db489 light: add -onlyents switch 2015-08-20 12:14:13 -06:00
Eric Wasylishen b345dccfe7 light: disable deviance if samples <= 1 or deviance <= 0. 2015-08-14 14:28:53 -06:00
Eric Wasylishen 79d1871e56 light: document -surflight_subdivide key 2015-08-10 10:04:25 -06:00
Eric Wasylishen 72a5885437 light: fix crash in "Bad texture axes on face:" error. Print more detailed face info. 2015-08-09 12:27:55 -06:00
Eric Wasylishen 18dce775dd light: fix lighting of rotatating entities (hiprotate). the model offset was not being used correctly.
todo: the trace code needs to take the model offset into account too, so shadow casting and self-shadowing are broken for hiprotate.
2015-08-08 21:37:58 -06:00
Eric Wasylishen b68ba8c983 light: average the color to get the value to write to the .bsp lightmap.
This avoids issues with some engines that require the lit and internal lightmap to have the same intensity. (MarkV, some QW engines).
Previously, if you used low-value colors (e.g. "0.2 0 0"), the .bsp lightmap and .lit file could have vastly different brightness.
2015-08-05 13:47:04 -06:00
Eric Wasylishen bc0e1778dc light: allow negative surface offsets for niche use 2015-08-05 12:10:17 -06:00
Eric Wasylishen 3005504fe5 vis, light: set low process priority on windows 2015-08-05 12:10:17 -06:00
Eric Wasylishen 5302a3b539 light: add -surflight_subdivide command line flag to control subdivision size 2015-08-05 12:10:14 -06:00
Eric Wasylishen 6004e1b94c light: log total number of lights including generated ones 2015-08-05 12:08:55 -06:00
Eric Wasylishen f24b1a1101 light: update usage text 2015-07-13 15:07:46 -06:00
Eric Wasylishen a56dad56c2 light: add logprint for "_anglescale"/"_anglesense" worldspawn key (to control angle sensitivity of sunlight) 2015-07-13 14:33:21 -06:00
Eric Wasylishen e9f240b623 light: .lux file support from Spike 2015-07-09 16:34:12 -06:00
Eric Wasylishen a219d3e0a0 light: WriteEntitiesToString: add explanation from Spike 2015-07-09 16:34:06 -06:00
Eric Wasylishen 6ca1c6957a light: fence texture tracing: fix handling of negative texture coords 2015-07-09 16:33:44 -06:00
Eric Wasylishen e242a9c910 light: Add gamma control with -gamma flag and "_gamma" key 2015-07-09 16:33:07 -06:00
Eric Wasylishen 26a03ace45 light: optimization: avoid iterating over non-light entities in light thread. 2015-06-02 00:51:37 -06:00
Eric Wasylishen 4105bc505f light: optimization: avoid unnecessary memsets, from spike 2015-06-01 23:14:19 -06:00
Eric Wasylishen e0d3f872ff light: rewrite part of WriteLightmaps for more readable code 2015-05-31 12:27:40 -06:00
Eric Wasylishen c39971bb94 light: rename -dirty flag to -dirt for consistency 2015-05-19 12:11:17 -06:00
Eric Wasylishen ab78c07320 light: make fence texture tracing opt-in 2015-05-16 23:33:39 -06:00
Eric Wasylishen 1996bce56d light: support switchable lights with any light* classname, not just "light" 2015-05-15 09:54:19 -06:00
Eric Wasylishen 8bde00a732 light: ensure "_surface" value is case-insensitive 2015-05-14 17:42:26 -06:00
Eric Wasylishen 3a109ac84d build: split up cmake build system into subprojects.
-DDOUBLEVEC_T now correctly used for qbsp only.
2015-05-05 12:34:39 -06:00
Eric Wasylishen 86d3aa990d light: remove "Jittering" debug message 2015-05-04 14:13:18 -06:00
Eric Wasylishen 0a6d3f4167 light: fix hang when using _deviance, make _samples default to 16 when _deviance is set. 2015-05-01 02:17:29 -06:00
Eric Wasylishen d2840f4cba light: fix for always generating a .lit file when surface lights are used 2015-04-30 14:54:23 -06:00
Eric Wasylishen 54e7c2ab8e light: fence texture tracing 2015-04-27 00:26:42 -06:00
Eric Wasylishen a33c4b0136 light: surface light support via "_surface" "texturename" light key 2015-04-26 02:24:57 -06:00
Eric Wasylishen 59bb786880 light: remove unused bsp_origin constant 2015-04-25 21:18:28 -06:00
Eric Wasylishen aa5dfa8b19 light: respect "_dirt" "-1" bmodel key in -dirtdebug mode 2015-04-25 20:46:05 -06:00
Eric Wasylishen 6fe67cd2fb light: allow setting _dist and _range in worldspawn 2015-04-25 20:46:00 -06:00
Eric Wasylishen ef471ee44f Support "_dirt" "-1" on bmodels to disable dirtmapping 2015-04-25 20:45:54 -06:00
Eric Wasylishen be8c42460c _sunlight2 (sky light, light dome) support from q3map2
_sunlight penumbra (deviance) from q3map2
light penumbra from q3map2
2015-04-25 20:45:44 -06:00
Eric Wasylishen 741d341332 Dirtmapping (ambient occlusion) from q3map2 2015-04-25 20:45:32 -06:00
Eric Wasylishen 2d5ea4fe73 light: accept _sunlight_mangle as an alternative for _sun_mangle 2015-03-27 00:35:28 -06:00
Eric Wasylishen 2cd885729a light: MatchTargets: disable copying 'style' key/value to the targeting entity. Don't see any reason why that would be done. 2015-03-27 00:33:32 -06:00
Eric Wasylishen c51326e8b0 trace.c: Undo part of cc36d8e that flipped the signs of ON_EPSILON for one of the checks in the TraceLine.
This fixes cracks in sunlight shadows spotted by Lunaran, and greatly improves the AO quality
2015-02-05 11:36:59 -07:00
Eric Wasylishen 11678eaa74 trace.c: fix bug in determining hitpoint->point 2015-02-05 11:35:15 -07:00
Eric Wasylishen 24c6b9524a _color support: support values in the range 0-1 by automatically scaling them to 0-255 2015-02-05 11:33:21 -07:00
Eric Wasylishen 4df394f9fe light: Increase precision of lightmap extents calculations
This bug is a counterpart to this bug in quakespasm:
   https://sourceforge.net/p/quakespasm/patches/15/

If the precision of the calculation in WorldToTexCoord done by ‘light’
is significantly different than the precision of the same calculation
in the engine, you can get corrupted lightmaps. The problem affects
light when it’s built as something other than vanilla 32-bit
x86. (e.g. x86_64 on a mac).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2014-06-30 12:58:30 +09:30
Kevin Shanahan d68748d1d8 light: fix minlight clamping for coloured lights
Colours need to be scaled correctly by the light intensity.
Thanks to Mechtech for reporting this issue.

Reported-by: Paul R <automan1001@yahoo.com>
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2014-02-15 18:56:44 +10:30
Kevin Shanahan 4b1e3aec1a light, vis, bsputil, bspinfo: Add BSP2 support
Add BSP2 support to the remaining utils.  Since these share the common
bspfile.[ch] files, it was more effort than is justifiable to break this
into multiple staged patches - so you just get this disgustingly big
commit instead.  Here is basically what was done:

 * Modify the bspdata_t struct with a union of the two bsp formats
 * Modify the tools to use bsp2_t for all internal processing
 * Split out the byte swapping routines for the different bsp data types
 * Add simple (although verbose) code to convert bsp29 <-> bsp2

Hundreds of lines added to bspfile.c, but mostly trivial stuff.  The tools
internally had little modification except to substitute the bsp2 type
names.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-09-25 15:18:50 +09:30
Kevin Shanahan e970bea8c7 common: save the bsp version in the bspdata struct
Adjust the Load and Write API functions as appropriate.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-22 13:25:47 +09:30
Kevin Shanahan 89abf25218 common: convert all tools to instanced bsp data
Transition all tools to access the BSP data via the bspdata struct instead
of the shared globals.  Remove the compatibility code from bspfile which
copied the global values to/from the instanced bspdata struct.

Mostly the changes just involved passing along the bspdata struct to the
various functions which needed to reference the data.  TraceLine and
MakeTNodes in light got some extra changes so that we cache the node
dplane pointer and remove the need to pass the bspdata struct to every
trace operation!

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-22 11:01:08 +09:30
Kevin Shanahan d0617760f5 common: add the ability to pass an arg to spawned threads
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-20 19:27:40 +09:30
Kevin Shanahan 6ddb109dde light: convert WriteLitFile to use the bspdata struct
Avoids reference to global LightDataSize.  Need to move writing the lit
file above the call to WriteBSPFile, since that will do the byte swapping.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-20 15:23:04 +09:30
Kevin Shanahan 51419621ec common: add the bsp2/bsp29 data types
Rename the default bsp29 data types and add the bsp2 data types to
the common bspfile.h.  Propogate the bsp29 names into the other tools as
simple renames for now.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-20 13:25:16 +09:30
Kevin Shanahan 1612d60a5f light: keep debug helper for dumping face info
Used this to help with debugging, but may as well keep it around for
future debugging rather than implement it all over again next time.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 16:52:19 +09:30
Kevin Shanahan 23591535b4 light: show face area for bad texture axis error
Often these errors are caused by super small faces on brushes, show the
area of the offending face to make it more obvious if that is the case.
Kind of lost in the diff, but moved the TriArea, etc. functions up and
added FaceArea() and then augmented the error message.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-03 16:47:15 +09:30
Kevin Shanahan c94414f288 light: allocate one extra lightmap to simplify handling overflow
Rather than allocating the overflow map within each function and
having to handle it as a special case in each, we always allocate the
extra lightmap in the base LightFace function and use common helper
functions to handle allocation and warning on overflow.

We lose a tiny bit of debugging info here about the specific light
that made the surface overflow MAXLIGHTSTYLES, but that never gave us
all the sources, only the last one encountered.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-10 13:47:58 +09:30
Kevin Shanahan 35bf3f4232 light: factor out adding and clamping of light samples
Simple functions, but just helps to tidy up the bodies of the other
LightFace functions and makes sure we're handling light & colours
consistently across each (we weren't in the case of coloured local
minlights, previously).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-08 15:42:50 +09:30
Kevin Shanahan e09c1f8e2a light: rename FixMinLight -> LightFace_Min
Move away from the "Fix" naming ~ it's not a fix, we're applying the
minimum lighting values as requested.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-08 13:30:38 +09:30
Kevin Shanahan 23f8f1a35e light: unify allocation of new face light styles
Factor out the allocation of new light styles - slightly increases the
code size, but we get two benefits; first is that we now don't
allocate the style 0 lightmap unless we actually need it; second, we
get warnings if sunlight or minlight is unable to be applied due to
lack of a style 0 lightmap.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-04 14:29:47 +09:30
Kevin Shanahan f498ed5ec3 light: pass the sun direction vector into LightFace_Sky
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-03 16:32:03 +09:30
Kevin Shanahan ca78568cae light: rename SkyLightFace -> LightFace_Sky
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-03 14:55:56 +09:30
Kevin Shanahan 7abfeb35da light: rename SingleLightFace -> LightFace_Entity
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-03 14:54:21 +09:30
Kevin Shanahan 12e24085c1 light: always calculate color values for light samples
Simplify the code by removing the if (colored) conditionals from the
code path.  CPU cost is insignificant compared to tracing the rays.
As before, only write the lit file if colored lights are detected or
the use explicity requests it.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-03 13:03:27 +09:30
Kevin Shanahan c3bf54e494 common: add printf attribute to Error() declaration in cmdlib.h
Fix a number of warnings now generated as a result.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-23 14:39:44 +09:30
Kevin Shanahan 5082e3ffaa light: reduce "no model has face" to a warning
Since the newskip.exe tool leaves the faces in the bsp but removes
references, we will just skip over lighting such faces.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 13:11:22 +09:30
Kevin Shanahan d14793f7ab common: make LoadBSPFile take a bspdata struct
No longer update the globals in this function - make the callers do it
instead.

bspinfo no longer refers to the globals at all.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 16:51:45 +09:30
Kevin Shanahan 35024bfa7d common: make dtexdata a union
Just having one base pointer was kind of annoying because you have to cast
to get to the lump offsets, then cast to byte * to find the miptex, etc.
Now we can access the same pointer using the correct types in each case.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 16:34:30 +09:30
Kevin Shanahan 37a3a98eff common: make WriteBSPFile take a bspdata struct as input
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 15:52:31 +09:30
Kevin Shanahan 022b927d79 trivial: fix typo in error message
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 15:08:55 +09:30
Kevin Shanahan 4275149cee light: improve "bad surface extents" error info
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 14:59:35 +09:30
Kevin Shanahan f20033fdd7 light: dynamically allocate entities and entstring
Removes the MAX_MAP_ENTITIES and MAX_MAP_ENTSTRING limitations by
counting how much space we will need before parsing/writing.

Now that I look at it, I'm not sure why we should even be re-writing
the entity string in the new bsp file, but I'll leave that behaviour
alone... for now.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-18 09:45:52 +09:30
Kevin Shanahan c193c18d5b make -gate affect linear falloff lights as well
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-06 13:25:11 +10:30
Kevin Shanahan ee2dc38f71 light: make command line set sun anglescale as well
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-06 08:35:38 +10:30
Kevin Shanahan 4625245b09 light: implement the -addmin command line parameter
Makes minlight additive rather than just bringing low levels up to the
minimum.  Not entirely identical to the bjp implementation as it seems to
treat local minlights in some strange ways, but in most cases the
behaviour should be identical.

Added missing help text for -anglescale|-anglesense parameters too.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-04 15:55:58 +10:30
Kevin Shanahan b4ff9663cc build: add ability to compile for WIN64 using MinGW64
Fix a few minor int<->pointer size warnings.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-15 21:49:16 +10:30
Kevin Shanahan 636a94f260 light: implemented _anglescale key (AKA "_angelsense")
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-15 21:27:14 +10:30
Kevin Shanahan 4abc7d31b7 light: remove the old -compress option
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-15 20:43:12 +10:30
Kevin Shanahan cc8477c6d9 light: implement -soft command line option
Add the -soft command line option which implements post-processing on
the lightmap surface to blend adjacent samples together to smooth out
hard shadow lines.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-14 11:28:22 +10:30
Kevin Shanahan 31484a8bcd light: remove comment about removing texmins, etc. from surfinfo_t
A relatively small amount of state to keep, just leave it there rather
than inventing any more types to pass around. Now that lightmap_t,
surfinfo_t & texorg_t are separate, I'm less concerned.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-13 11:59:48 +10:30
Kevin Shanahan cc36d8eadc light: rewrite light tracing function and update callers
Substantial changes to TestLineOrSky which now becomes TraceLine to
more conveniently trace lines through the BSP and, terminate the trace
on specific contents and return information about the termination
point.

TraceLine also more correcly handles the cases where points are close
enough to the node planes to be considered "on-node" to ensure we get
a good intersection point back, when requested.

Finally, the algorithm for making the small adjustments to surface
points in CalcPoints has been changed so if the surface point can't
see the midpoint, we find the obscuring surface and move the surface
point just above that. Seems to work better and eliminates some (but
not quite all - midpoint is still not quite the ideal point to use)
random black spots.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-12 16:40:16 +10:30
Kevin Shanahan 359ddfa41e light: remove nominlimit option and negative color value support
"nominlimit" is a more sensible default - people expect negative
lights to be able to subtract from minlight. The negative colors never
really worked properly and there's not really any worthwhile use for
the (that I know of).

Hopefully nobody will be too upset by these two changes to the old
behaviour.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-10 20:24:19 +10:30
Kevin Shanahan e8d640f88f light: use lightsample_t for minlight and sunlight
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-10 18:42:35 +10:30
Kevin Shanahan f82562f9e4 light: use lightsample_t for entity light values
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-10 18:28:00 +10:30
Kevin Shanahan d57e7d50fd light: use lightsample_t for modelinfo->minlight
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-10 17:17:42 +10:30
Kevin Shanahan 46277eec41 light: fix -nominlimit option causing extra bright lighting
This option has been broken for a while, because we only dealt with
positive vs. negative colours and didn't properly handle the light
intensity.

All this messing around to try and correctly handle negative colors
seems just stupid. I might have to remove support for that in
future... is there really any good use for it?

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-10 17:07:14 +10:30
Kevin Shanahan f2395a3dd3 light: re-arrange lightdata_t structure into array of lightmap_t
More messing with data structures. Now a single sample has a
brightness and colour component and a lightmap structure captures all
the non-surface lightmap data.

The pointer arithmetic for iterating over the supersamples in
WriteLightmaps is perhaps a little silly, but it works well enough. It
might be smarter to generate the sample points in a different order
instead. Maybe later.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-10 15:45:06 +10:30
Kevin Shanahan f7e76f16b6 light: factor out writing light data from LightFace
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-10 09:37:33 +10:30
Kevin Shanahan 3749cfa734 light: pass the dface pointer into lightface
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-09 19:14:33 +10:30
Kevin Shanahan 5dce6ccc30 light: factor out init of lightsurf and lightdata
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-09 19:04:44 +10:30
Kevin Shanahan a919ad08bc light: split lightinfo_t into surface information and lightmap data
A lot of churn for a small gain, but now the surface information is
separate from the lightmap data. And we can pass the surface
information around via a const pointer.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-09 17:34:31 +10:30
Kevin Shanahan ea440c6da0 light: factor out WorldToTexCoord as a serparte function
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-09 16:36:57 +10:30
Kevin Shanahan 63393eee8e light: define a plane_t structure and use for lightinfo_t
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-09 15:58:26 +10:30
Kevin Shanahan fda3b230f9 light: lightinfo_t structure cleanup, part 1
The big lightinfo_t structure includes a lot of things that are only
loosely related and not used together. Start the cleanup by pulling
out the texture coordinate tranformation data that is used to generate
the surface sample points.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-09 15:38:52 +10:30
Kevin Shanahan d6ef23453a light: implement self shadowing option for brush models
Brush models can now self shadow without casting shadows on their
environment, using the "_shadowself" entity key.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-08 15:02:36 +10:30
Kevin Shanahan dc39137874 light: make shadow bmodels block sunlight too
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-08 13:47:20 +10:30
Kevin Shanahan feda78b4a3 light: compile fix
Incomplete commit for bmodel shadows change.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-08 13:28:50 +10:30
Kevin Shanahan a6e42ab860 light: implement brush model entity shadows
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-08 11:37:36 +10:30
Kevin Shanahan b7c2fd437f light: replace last CastRay user with TestLine and remove
We never made use of the length argument returned.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-08 09:14:02 +10:30
Kevin Shanahan 2964d31016 light: fix truncated light values due to integer division
Since minlight is an integer, need to either cast to float or ensure
promotion by writing the 255 constants as 255.0f. Not all of these are
needed, but just be consistent across the code.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 18:25:00 +10:30
Kevin Shanahan b4387359a4 light: implement minlighting for bmodels
Collect the appropriate keys from the models at load time and pass them
into the minlighting function (if > world minlight).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 18:22:25 +10:30
Kevin Shanahan e734671b03 light: remove unneeded faceoffset argument from {Single,Sky}LightFace
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 16:21:42 +10:30
Kevin Shanahan 44a0bd3660 light: pass minlight/colour values into FixMinlight
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 16:13:43 +10:30
Kevin Shanahan 34050c2bd9 light: replace faceoffset with modeloffset
Not much point worrying about the offset of each face when it's only
per-model. This sets us up for using other per-model info...

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 15:47:30 +10:30
Kevin Shanahan 33b4ba2040 light: remove the never-used nolightface array
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 15:18:36 +10:30
Kevin Shanahan 7b36c6fd2f build: query git for version info and print consistently for each util
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 14:26:14 +10:30
Kevin Shanahan 4063d8aade light: implement the _softangle key for spotlights
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-03 21:37:21 +10:30
Kevin Shanahan fec6d64bf1 light: be more consistent with lightmap/colormap variable names
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-03 20:14:09 +10:30
Kevin Shanahan 0420f83ab9 light: rename scaledLight -> GetLightValue
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-03 13:51:33 +10:30
Kevin Shanahan fc90cfdff4 light: use fadedist instead of scaledDistance()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-03 13:46:31 +10:30
Kevin Shanahan a8d8150791 light: implement the -gate option
Precalculate the distance at which lights will fade to zero brightness.
For lights with inverse falloff, use the gate value to determine the
cut-off distance.  Use this value to cull samples and avoid the ray
tracing overhead.

Hopefully not too controversially, I am going to default this to "on" with
a gate value of 0.001. Unless you have > 1000 lights contributing
fractional light values across your map, this is not going to make any
visible difference.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-03 13:36:52 +10:30
Kevin Shanahan 8b1a501087 light: trivial tidy up
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-03 13:26:28 +10:30
Kevin Shanahan f5e7e594e4 light: remove redundant ray trace in SingleLightFace
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-03 13:05:11 +10:30
Kevin Shanahan 4879c7e874 light: use TestLine instead of CastRay for LOS test
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-03 13:00:22 +10:30
Kevin Shanahan 888494f0c1 light: test spotlight cone before ray tracing
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-03 12:56:10 +10:30
Kevin Shanahan bea0f0f983 light: bsp_origin is just zero, don't need rel vector
May as well keep dist as the actual distance and just call ScaledDistance
twice (poor function name, btw - it's effectively the equivalent of the
"fade gate" stuff)

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-03 12:50:01 +10:30
Kevin Shanahan 310e28e12a light: use uintptr_t for aligning light data in memory
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-03 12:32:32 +10:30
Kevin Shanahan f075de2fb5 light: re-organise lightinfo_t structure
Rename member lightmapcolors -> colormaps
Remove unused member surfnum
Re-order things so the data lumps are together at the end.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-02 13:39:03 +10:30
Kevin Shanahan 052805c4ca light: fix race in allocation of white/coloured lightmap data
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-02 12:18:54 +10:30
Kevin Shanahan 4cbbb44a23 light: minor tidy up of spot falloff check in SingleLightFace
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-02 11:30:49 +10:30
Kevin Shanahan c0ebc18d96 light: constify surf pointer in LightSingleFace
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-02 11:29:39 +10:30
Kevin Shanahan 453fd7fe31 light: better variable names in WriteLitFile
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-02 11:27:47 +10:30
Kevin Shanahan b746947595 light: use VecStr convenience function for log messages
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-02 11:27:10 +10:30
Kevin Shanahan a1e0f192c7 light: fix use of incorrect color for !nominlimit case
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-01 22:03:36 +10:30
Kevin Shanahan c458099ec7 light: implement the 4x4 oversampling option
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-01 17:26:44 +10:30
Kevin Shanahan 57a161afa2 light: place oversample points correctly around original
Looks like the original code biased these to one side, but the
oversampling will be more accurate if we evenly distribute the points
around the actual lightmap point.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-01 12:42:57 +10:30
Kevin Shanahan ad129c59da light: rename sunmangle variable as sunvec
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-01 11:58:50 +10:30
Kevin Shanahan f07007f8ad light: setup spotlight paramters once at load time
We were calculating these values for every light and for every surface,
which seems a little excessive... Also made the variable names a bit more
sensible - we had stored a direction vector, not the actual mangle values.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-01 11:50:57 +10:30
Kevin Shanahan 580b2912fb light: don't let negative lights on a new style count as a hit
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-01 10:58:11 +10:30
Kevin Shanahan a3ac989224 light: trivial VectorMA substituion
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-01 10:56:19 +10:30
Kevin Shanahan 8ce739fe3f light: remove bsp30 support and automatically generate .lit when needed
Check whether any of the entities have colored fields set and if so,
enable colored light output. Can still be overridden from the command line
if needed.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-01 10:07:53 +10:30
Kevin Shanahan 8f3d28c2ac light: implement delay 4 and 5 as in visbjp light
Implement the two extra light attenuation formulae that were added to
Benjt Jardrup's light util (http://user.tninet.se/~xir870k/readmevis.txt).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-28 16:16:34 +10:30
Kevin Shanahan 725fffbd7a light: fix off-by-one error in MAX_LIGHTMAPS check
I guess this bug has been here a long time. This was preventing us from
using all four available lightmaps in most cases. Now fixed!

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-28 15:51:28 +10:30
Kevin Shanahan d8b7e08683 light: tidy up the FixMinlight function
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-28 14:31:33 +10:30
Kevin Shanahan 5c4e6d4f0b light: trivial, remove old comment
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-28 11:46:47 +10:30
Kevin Shanahan 70fceb5218 light: also pass colors into SingleLightFace
No more games with save/modify/restore on the entity->lightcolor.
Could have actually caused nasty races in the multithreaded case.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-28 10:44:05 +10:30
Kevin Shanahan e8764f5492 light: pass colors into SkyLightFace
Stop playing silly games with saving, modifying and restoring the global
sunlight_color. A couple of variable naming changes in lightface and use
an entity pointer instead of always indexing into the global array.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-28 10:32:30 +10:30
Kevin Shanahan 54a5890217 light: lift light entity field checks into separate function
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-27 21:13:53 +10:30
Kevin Shanahan 854c7b4bb9 light: trivial variable rename
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-27 21:13:12 +10:30
Kevin Shanahan 599742310b light: use an enum for light attenuation formulae
And warn if we are given a formula number we don't know about.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-27 17:13:53 +10:30
Kevin Shanahan 22ca3262f0 light: remove alloc argument to LightStyleForTargetname()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-27 15:59:03 +10:30
Kevin Shanahan ea836f6b0b light: constify light's version of ValueForKey()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 20:10:47 +10:30
Kevin Shanahan 8d4bbbe3dc light: use the common threads progress indicator
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-07 21:12:53 +10:30
Kevin Shanahan 3e20dae28e common: add start arg to RunThreadsOn to set initial progress
In case we are not starting work from 0, allow this to be set...

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-07 20:51:04 +10:30
Kevin Shanahan 853761d0d6 common: remove pacifier argument from RunThreadsOn
Set to true everywhere, just use it unconditionally.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-07 20:46:33 +10:30
Kevin Shanahan 7ee8bc183b light: use the common threads code
Make light use the common threads code.
The common progress indicator code is still not used.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-26 09:35:26 +10:30
Kevin Shanahan 1c8137d400 light: remove stale comment about MAXLIGHTMAPS
Yes, it really is 4.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-20 20:15:54 +10:30
Kevin Shanahan ef6c4c30c5 light: remove unused accounting variable
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-20 20:15:40 +10:30
Kevin Shanahan c51eb01291 light: remove workaround for old compiler bug
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-20 20:15:10 +10:30
Kevin Shanahan 6fab0a5358 light: make pthreads support work
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-20 20:14:39 +10:30
Tyrann ad964e7f28 trivial: remove some redundant assignments and unused variables 2012-01-06 21:34:47 +10:30
Tyrann bcb8e0990d [PATCH] light: increase MAX_TSTACK
Managed to hit this limitation recently, so bump it up.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2008-01-19 21:21:20 +10:30
Tyrann 8a7304a54d [PATCH] TyrUtils v0.4
Quick release to fix the ongoing saga that is my crappy .lit coloured lighting
support. I really did test it this time...

I bumped the qbsp version as well, just to track the utils "package" version.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-09-25 11:18:00 +09:30
Tyrann a97a880bd0 [PATCH] light: fix alignment (again) on lit data
I really should do more testing before I embarress myself by releasing stuff
so obviously broken. Use the right pointer to align lit_filebase against.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-09-25 06:32:10 +09:30
Tyrann 20008a120a [PATCH] light: update version number
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-09-23 16:54:59 +09:30
Tyrann 9209eec0a1 [PATCH] light: Fix litfile memory allocation
Gah! Brown paper bag material here. Memory for the Lit data was never getting
allocated and writes were happening in no man's land off the end of the
lightdata area.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-09-23 16:46:22 +09:30
Tyrann 2c2f3c8eb6 Import initial sources 2006-08-28 23:58:10 +09:30