archive/wad2, image/lmp, image/spr, data/q3shader, data/q3skin
WAD2 / WAD3 with miptex / qpic / conchars / font / palette images and addImage; Quake .lmp pictures, palette and colormap (palette never embedded); Quake / Half-Life / SPR32 sprites with frame groups; Quake III shader scripts and .skin files. Miptex gains qpic decode / encode and palette mapping; Pixels.keyed keeps the key colour (alpha 0).
This commit is contained in:
1 parent
67e116a6c6
commit
175ca9e823
23 files changed
+5380
-1143
No files matched your search
@@ -0,0 +1,117 @@
|
||||
# data/q3shader and data/q3skin fixtures (tools/fixtures.py): shader scripts in the style of the Quake III Arena
|
||||
# Shader Manual (comments, quoted tokens, braces on their own lines or not, several stages) and .skin files; reference
|
||||
# structure from an independent tokenizer here (COM_ParseExt rules: tokens per line, // and /* */ comments).
|
||||
# tests/gen/q3shader.luau { scripts = { { text, shaders = { { name, directives, stages } } } }, skins = { { text, entries } } }
|
||||
import re
|
||||
|
||||
SCRIPTS = [
|
||||
"""// base walls
|
||||
textures/base_wall/metalfloor_wall_10
|
||||
{
|
||||
qer_editorimage textures/base_wall/metalfloor_wall_10.tga
|
||||
surfaceparm metalsteps
|
||||
{
|
||||
map $lightmap
|
||||
rgbGen identity
|
||||
}
|
||||
{
|
||||
map textures/base_wall/metalfloor_wall_10.tga
|
||||
blendFunc GL_DST_COLOR GL_ZERO
|
||||
rgbGen identity
|
||||
}
|
||||
}
|
||||
|
||||
textures/sfx/flame1 {
|
||||
surfaceparm nolightmap
|
||||
cull none /* both sides */
|
||||
q3map_surfacelight 2500
|
||||
{
|
||||
animMap 10 textures/sfx/flame1.tga textures/sfx/flame2.tga textures/sfx/flame3.tga
|
||||
blendFunc GL_ONE GL_ONE
|
||||
tcMod scale 1 1 // per frame
|
||||
}
|
||||
}
|
||||
""",
|
||||
"""/*
|
||||
* a sky and a quoted path
|
||||
*/
|
||||
textures/skies/hellsky
|
||||
{
|
||||
skyparms "env/hell sky" 512 -
|
||||
surfaceparm noimpact
|
||||
surfaceparm sky
|
||||
{ map textures/skies/clouds.tga
|
||||
tcMod scroll 0.05 0.06 }
|
||||
}
|
||||
models/players/sarge/band
|
||||
{
|
||||
deformVertexes wave 100 sin 0 2 0 1
|
||||
{
|
||||
map models/players/sarge/band.tga
|
||||
alphaFunc GE128
|
||||
depthWrite
|
||||
}
|
||||
}
|
||||
""",
|
||||
]
|
||||
|
||||
SKINS = [
|
||||
"tag_head,\ntag_torso,\nh_head,models/players/sarge/band.tga\nh_cap,models/players/sarge/cigar.tga\n",
|
||||
"u_torso,models/players/sarge/default.tga\r\nl_legs,models/players/sarge/default.tga\r\n",
|
||||
]
|
||||
|
||||
|
||||
def tokenize(text):
|
||||
text = re.sub(r"/\*.*?\*/", lambda m: "\n" * m.group(0).count("\n"), text, flags=re.S)
|
||||
lines = []
|
||||
for raw in text.split("\n"):
|
||||
raw = raw.split("//")[0] if '"' not in raw else raw
|
||||
cur = []
|
||||
for m in re.finditer(r'"([^"]*)"|([{}])|([^\s{}"]+)', raw):
|
||||
if m.group(2):
|
||||
if cur:
|
||||
lines.append(cur)
|
||||
cur = []
|
||||
lines.append([m.group(2)])
|
||||
else:
|
||||
cur.append(m.group(1) if m.group(1) is not None else m.group(3))
|
||||
if cur:
|
||||
lines.append(cur)
|
||||
return lines
|
||||
|
||||
|
||||
def parse(text):
|
||||
lines = tokenize(text)
|
||||
out, k = [], 0
|
||||
while k < len(lines):
|
||||
sh = {"name": lines[k][0], "directives": [], "stages": []}
|
||||
k += 2
|
||||
stage = None
|
||||
while True:
|
||||
d = lines[k]
|
||||
k += 1
|
||||
if d == ["{"]:
|
||||
stage = []
|
||||
elif d == ["}"]:
|
||||
if stage is None:
|
||||
break
|
||||
sh["stages"].append(stage)
|
||||
stage = None
|
||||
elif stage is not None:
|
||||
stage.append(d)
|
||||
else:
|
||||
sh["directives"].append(d)
|
||||
out.append(sh)
|
||||
return out
|
||||
|
||||
|
||||
def generate(ctx):
|
||||
skins = []
|
||||
for s in SKINS:
|
||||
entries = []
|
||||
for line in s.replace("\r", "").split("\n"):
|
||||
if line.strip():
|
||||
a, b = line.split(",", 1)
|
||||
entries.append({"surface": a.strip(), "shader": b.strip()})
|
||||
skins.append({"text": s, "entries": entries})
|
||||
ctx.emit("q3shader", {"scripts": [{"text": s, "shaders": parse(s)} for s in SCRIPTS], "skins": skins})
|
||||
Reference in new issue
Block a user