mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-16 01:11:28 +00:00
Lunatic: engine.setupDebugBasePal(), auto-detect 2nd+ shadexfog.translate().
engine.setupDebugBasePal() set up the water base palette such each of the first 15 "ramps" of 16 consecutive colors has a single, "representative" color. For example, color indices 0-15 and black, 16-31 are dark gray. In shadexfog.lua, list remappings from LOOKUP.DAT that are expressible as remappings of 16-tuples. git-svn-id: https://svn.eduke32.com/eduke32@4337 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b79fa42903
commit
caed55e9a4
3 changed files with 57 additions and 8 deletions
|
@ -834,6 +834,10 @@ _`u8`_ `pal`::
|
|||
The ``palette swap'' index of the sprite. This may not be the palette swap that
|
||||
this sprite is ultimately drawn with, though.
|
||||
|
||||
_`u8`_ `blend`::
|
||||
The blending table index of the sprite. See
|
||||
<<blending_table_interfaces,Blending table interfaces>> for more details.
|
||||
|
||||
_`u8`_ `clipdist`::
|
||||
If this sprite is _view-aligned_, controls the distance at which another moving
|
||||
object is considered to be in collision with this *stationary* sprite. (It does
|
||||
|
@ -2080,6 +2084,7 @@ colors from being returned. The shade table loaded from Duke3D's PALETTE.DAT
|
|||
makes color indices 240--254 fullbright, so passing 239 to `lastokcol` achieves
|
||||
the mentioned filtering.]
|
||||
|
||||
[[shade_table_interfaces]]
|
||||
Shade table interfaces
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -2100,21 +2105,23 @@ texel's color index as latexmath:[$i_{\mathrm{in}}$], the resulting pixel's one
|
|||
latexmath:[$i_{\mathrm{out}}$] is computed as
|
||||
|
||||
==========
|
||||
latexmath:[$s_1 = C \cdot \mathrm{shade} + D \cdot \mathrm{visdist}$] +
|
||||
latexmath:[$s_1 = \mathrm{shade} + C \cdot \mathrm{visdist}$] +
|
||||
latexmath:[$s_2 = \mathrm{clamp}(s_1, \: 0, \: \mathrm{Numshades}-1)$] +
|
||||
latexmath:[$\mathrm{shade_index} = \mathrm{round}(s_2)$] +
|
||||
latexmath:[$i_{\mathrm{out}} = \mathrm{palookup}(\mathrm{shade_index}, i_{\mathrm{in}})$] {nbsp}
|
||||
[gray]#// This is only a table lookup, palookup[shade_index][latexmath:[$i_{\mathrm{in}}$]]# +
|
||||
==========
|
||||
|
||||
Here, latexmath:[$C$] and latexmath:[$D$] are positive constants and
|
||||
Here, latexmath:[$C$] is a positive constant and
|
||||
latexmath:[$\mathrm{visdist}$] is the product of a. the distance of an object's
|
||||
sampled pixel to the view plane with b. the object's
|
||||
``visibility''.footnote:[Visibility would be more appropriately called
|
||||
``anti-visibility'' or ``co-visibility'': greater values make objects appear
|
||||
more faded for the same distance. Also, the visibility that is meant here has
|
||||
the origin at 0, unlike `sector[].visibility`.] Thus, shade and visibility are
|
||||
inherently confounded in the 8-bit mode.
|
||||
inherently confounded in the 8-bit mode and the ultimate shade_index is bounded
|
||||
below by (the minimum of latexmath:[$\mathrm{Numshades}-1$] and) the shade of
|
||||
the object.
|
||||
|
||||
===== Examples of effects using shade tables
|
||||
|
||||
|
@ -2221,6 +2228,7 @@ local newsht = engine.getshadetab(0):remap16({[4]=13, [5]=8})
|
|||
engine.setshadetab(22, newsht)
|
||||
----------
|
||||
|
||||
[[blending_table_interfaces]]
|
||||
Blending table interfaces
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -369,10 +369,26 @@ if (ismapster32) then
|
|||
return true
|
||||
end
|
||||
|
||||
local hexmap = {
|
||||
[0] = 0, -14, -- 0, 1: gray ramp
|
||||
14, 0, -- 2, 3: skin color ramp
|
||||
0, 14, -- 4, 5: blue ramp (second part first)
|
||||
14, 0, -- 6, 7: nightvision yellow/green
|
||||
14, -- 8: red first part...
|
||||
8, -- 9: yellow (slightly more red than green)
|
||||
14, 0, -- 10, 11: almost gray ramp, but with a slight red hue
|
||||
8, -- 12: "dirty" orange
|
||||
0, -- 13: ...red second part
|
||||
8, -- 14: blue-purple-red
|
||||
}
|
||||
|
||||
-- Setup base palette 1 (water) to contain one color for each consecutive
|
||||
-- 16-tuple (which I'm calling a 'hex' for brevity), except for the last
|
||||
-- one with the fullbrights.
|
||||
function engine.setupDebugBasePal()
|
||||
for i=0,14 do
|
||||
local ptr = C.basepaltable[1] + 3*(16*i)
|
||||
local src = ptr + 3*i
|
||||
local src = C.basepaltable[0] + 3*(16*i) + 3*hexmap[i]
|
||||
local r, g, b = src[0], src[1], src[2]
|
||||
|
||||
for j=0,15 do
|
||||
|
|
|
@ -27,6 +27,25 @@ local shadexfog = {}
|
|||
-- lua "shadexfog.createremap(30, {[2]=0, [3]=1, [12]=0, [13]=1})"
|
||||
-- creates a pal 30 which maps the blue and orange ramps to the gray ones.
|
||||
-- (Compare with the rows of http://wiki.eduke32.com/wiki/File:Pala.png)
|
||||
--
|
||||
-- Sexdecatuple remappings of Duke3D pals loaded from LOOKUP.DAT:
|
||||
-- Remappings that are not expressible as such and identity maps (pal 3 and 9)
|
||||
-- omitted.
|
||||
--
|
||||
-- 2: { [0]=8, [1]=13, [2]=8, [3]=13, [4]=13, [5]=8, [6]=8, [7]=13, [9]=8, [10]=8, [11]=13, [12]=8, [14]=8, }
|
||||
-- 5: { [8]=2, [13]=3, }
|
||||
-- 7: { [0]=10, [1]=9, [2]=10, [3]=9, [4]=9, [5]=10, [6]=10, [7]=9, [8]=10, [11]=9, [12]=9, [13]=9, [14]=9, }
|
||||
-- 8: { [0]=6, [1]=7, [2]=6, [3]=7, [4]=7, [5]=6, [8]=6, [9]=7, [10]=6, [11]=7, [12]=7, [13]=7, [14]=6, }
|
||||
-- 11: { [4]=7, [5]=6, }
|
||||
-- 12: { [4]=1, [5]=0, }
|
||||
-- 15: { [4]=3, [5]=2, }
|
||||
-- 17: { [2]=5, [3]=4, [4]=7, [5]=6, [6]=5, [7]=4, [12]=5, [14]=4, }
|
||||
-- 18: { [4]=1, [5]=0, }
|
||||
-- 19: { [2]=8, [3]=13, [4]=1, [5]=0, [6]=8, [7]=13, [12]=8, [14]=13, }
|
||||
-- 20: { [2]=5, [3]=4, [4]=1, [5]=0, [6]=5, [7]=4, [12]=5, [14]=4, }
|
||||
-- 21: { [4]=13, [5]=8, }
|
||||
-- 22: { [4]=7, [5]=6, }
|
||||
-- 25: { [6]=8, [7]=13, }
|
||||
function shadexfog.createremap(palnum, remaptab)
|
||||
local sht = engine.getshadetab(0)
|
||||
engine.setshadetab(palnum, sht:remap16(remaptab))
|
||||
|
@ -35,8 +54,8 @@ end
|
|||
-- Create 32 palookups corrensponding to different *shade levels* of a fog
|
||||
-- palookup, called a "shade-x-fog" palookup set in the following.
|
||||
--
|
||||
-- Pals <tartpalnum> .. <startpalnum>+31 will be taken.
|
||||
-- <fogr>, <fogg>, <fogb>: intensities of the fog color, [0 ..63]
|
||||
-- Pals <startpalnum> .. <startpalnum>+31 will be taken.
|
||||
-- <fogr>, <fogg>, <fogb>: intensities of the fog color, [0 .. 63]
|
||||
function shadexfog.create(startpalnum, fogr, fogg, fogb)
|
||||
local MAXPALNUM = 255-31-engine.RESERVEDPALS
|
||||
if (not (startpalnum >= 1 and startpalnum <= MAXPALNUM)) then
|
||||
|
@ -47,7 +66,7 @@ function shadexfog.create(startpalnum, fogr, fogg, fogb)
|
|||
|
||||
-- Encode the shade in different pal numbers! The shade tables are
|
||||
-- constructed with a fog in their place.
|
||||
for dummyshade=1,31 do
|
||||
for dummyshade=0,31 do
|
||||
local sht = engine.shadetab()
|
||||
|
||||
for f=0,31 do
|
||||
|
@ -68,6 +87,11 @@ function shadexfog.create(startpalnum, fogr, fogg, fogb)
|
|||
end
|
||||
|
||||
local function trans(what, startpalnum, fogintensity)
|
||||
if (what.pal >= startpalnum and what.pal <= startpalnum+31) then
|
||||
-- Auto-detect earlier translation with the same <startpalnum>.
|
||||
what.shade = what.pal - startpalnum
|
||||
end
|
||||
|
||||
local shade = min(max(what.shade, 0), 31)
|
||||
what.pal = startpalnum + shade
|
||||
what.shade = fogintensity
|
||||
|
@ -81,7 +105,8 @@ end
|
|||
-- If <vis> is passed, set all sector's visibility to that value.
|
||||
--
|
||||
-- Notes:
|
||||
-- - works only a single time (TODO: autodetection if already applied)
|
||||
-- - auto-detects when the translation has been applied with the *same*
|
||||
-- <startpalnum> (if a different one is desired, must reload map).
|
||||
-- - if shades < 0 or > 31 present, loss of information
|
||||
function shadexfog.translate(startpalnum, fogintensity, vis)
|
||||
for i=0,gv.numsectors-1 do
|
||||
|
|
Loading…
Reference in a new issue