Commit Graph

742 Commits

Author SHA1 Message Date
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