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>
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>
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>
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>
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>
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>
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>
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>
"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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>