initial import: tesseract r2280

master
Daniel Kolesa 2020-04-15 18:39:17 +02:00
commit 10515f5f63
364 changed files with 107883 additions and 0 deletions

2
.gitignore vendored 100644
View File

@ -0,0 +1,2 @@
*.o
src/build

83
README 100644
View File

@ -0,0 +1,83 @@
Tesseract is a fork of the Cube 2: Sauerbraten engine. The goal of Tesseract
is to make mapping more fun by using modern dynamic rendering techniques, so
that you can get instant feedback on lighting changes, not just geometry.
No more long calclight pauses... just plop down the light, move it, change its
color, or do whatever else with it. It all happens in real-time now.
Tesseract removes the static lightmapping system of Sauerbraten and replaces
it with completely dynamic lighting system based on deferred shading and
shadowmapping.
It provides a bunch of new rendering features such as:
* deferred shading
* omnidirectional point lights using cubemap shadowmaps
* perspective projection spotlight shadowmaps
* orthographic projection sunlight using cascaded shadowmaps
* HDR rendering with tonemapping and bloom
* real-time diffuse global illumination for sunlight (radiance hints)
* volumetric lighting
* screen-space ambient occlusion
* screen-space reflections and refractions for water and glass (use as many water planes as you want now!)
* screen-space refractive alpha cubes
* deferred MSAA, subpixel morphological anti-aliasing (SMAA 1x, T2x, S2x, and 4x), FXAA, and temporal AA
* runs on both OpenGL Core (3.0+) and legacy (2.0+) contexts
Editing:
To make shadowmapped point lights, just make light entities as normal. Optionally you can control the shadowing properties of the light using attribute 5: 0 = shadows, 1 = no shadows, 2 = static shadows - world and mapmodels only (no playermodels or pickups). Shadowmaps are cached from frame to frame if no dynamic entities such as playermodels are rendered into them, so static lights (2) will generally be much faster than normal lights (0) during gameplay and should be used where possible. Unshadowed lights (1) are even faster as they further reduce shading costs, so they should also be used where possible.
To make cascaded shadowmapped sunlight, just use the normal sunlight commands:
sunlight
sunlightyaw
sunlightpitch
You can also set sunlightyaw and sunlightpitch from your current direction with the following command:
getsundir
You can control the diffuse global illumination of sunlight using the following parameters:
giscale - scales the contribution of indirect light
gidist - limits the distance which indirect light travels (smaller values are more intense, but higher values allow farther travel)
giaoscale - controls the contribution of atmospheric light
skylight - controls the color of atmospheric light
Screen-space ambient occlusion affects mostly ambient light and to a lesser degree sunlight,
but it does not affect point lights. If you want to make use of SSAO in your map, just use
the ambient command to set an appropriate ambient light color/intensity.
To make refractive alpha cubes:
First mark the cubes with the alpha material. Use valpha or texalpha to set the transparency level as normal.
Then use either of the following commands:
vrefract K [R G B]
K is the strength of the refraction, on a scale of 0 to 1, 1 meaning distortion spanning the entire screen, 0.5 spanning half the screen, etc.
The direction of the distortion is taken from the normal-map of the texture.
R G B are optional and specify a color for the refraction, with each component being on a scale of 0 to 1 as well.
After editing operations your map may be full of small cubes and triangles, and you will notice that your map looks faceted.
To fix this you still need to use the calclight command, however, it no longer generates lightmaps anymore.
It just does a remip optimization pass as well as calculates smoothed normals to make things look better.
Eventually this may be done differently using some sort of background optimization while editing.
To make decals:
newent decal SLOT YAW PITCH ROLL SIZE
If you don't specify the yaw, pitch, and roll, or leave them all 0, then newent will fill them with current direction you are looking at.
The slot refers to a decal slot in the map configuration, starting at offset 0.
The size is specified in cube units.
To make decal slots:
decelreset // functions like texture reset, clears all decal texture slots
setshader bumpspecmapdecal // shaders work like for world shaders, but with the -decal suffix instead of -world
texture decal "diffuse.png" // all decal slots start with the "decal" sub-slot instead of "0", and this texture must have an alpha-channel
texture n "normals.png"
texture s "spec.png"
To make volumetric lights:
Set attribute 5 of a light entity to 4.
The intensity of the volumetric lighting medium can be controlled by volscale and the color can by controlled by volcolour.

101
bin_unix/readme.txt 100644
View File

@ -0,0 +1,101 @@
* Installing and Running Tesseract
*nix versions of Tesseract clients and standalone servers.
The clients function identical to the win32 client, see config.html for more
information about command-line options if necessary.
Please run "tesseract_unix" from the root Tesseract dir (NOT from inside the "bin_unix"
directory) to launch these, or set the TESS_DATA variable at the top of the "tesseract_unix"
script to an absolute path to allow it to be run from any location. Note that the "tesseract_unix"
script is set up to write any files (saved maps, configs, etc.) into the user's home
directory at "~/.tesseract".
Clients will need the following dynamic link libraries present:
* libGL (OpenGL)
* SDL2 (>= 2.0.0)
* SDL2_image
* SDL2_mixer
* libpng
* libjpeg
* zlib
If native binaries for your platform are not included, then try the following:
1) Ensure you have the DEVELOPMENT VERSIONS of the above libraries installed.
2) Type "make -C src install".
3) Re-run the "tesseract_unix" script if it succeeded.
The servers (bin_unix/linux_server or bin_unix/native_server) should need no libs
other than libstdc++ and zlib. Note that for the server to see the "config/server-init.cfg",
it must be run from the root Tesseract directory. If you run a server with the
"tesseract_unix -d" command, this happens automatically. However, if you wish to
run the standalone servers instead, then you may need to write an appropriate wrapper
script to change to the appropriate data directory before running the standalone
server binary, as described below in the packaging guide.
* Packaging Guide for Unix-like Operating System Developers/Maintainers
If you are packaging Tesseract up for redistribution in a Linux distribution or other
similar OS, please avoid using the "tesseract_unix" script in its default/unmodified form.
You should at least set the TESS_DATA variable to appropriately find the common Tesseract
data files, or better yet replace it with a more appropriate way of starting Tesseract using
the script as a basis. If the distribution happens to place program binaries in a specific
directory separate from data files, such as "/usr/bin", then much of the lines within the script
that deal with finding an appropriate binary can be removed, as they only exist to help people
running from the original Tesseract tarball. An example run script is shown further
below.
Also, please note, that if your distribution chooses to package the binaries and game data
as separate packages due to whatever licensing rules or cross-architecture package sharing,
that client binaries from newer Tesseract editions are NOT compatible with older versions of
game data, on whole, nor obviously compatible with newer versions of game data. Game data, as a
whole, and client binaries are only roughly compatible within individual Tesseract editions,
though patches to individual Tesseract editions generally always retain compatibility with
the game data.
For those writing custom Tesseract run scripts for packaging, they should adhere to the following
guidelines:
Tesseract finds all game files relative to the current directory from which Tesseract is run,
so any script running Tesseract should set its current directory to where the Tesseract data
files are located before it runs the Tesseract client binaries. No silly symlinking tricks should
be at all necessary.
When running the Tesseract client, one command-line switch should ALWAYS be supplied to
the client binary. This is "-u${HOME}/.tesseract", which will instruct Tesseract to
write any user private files such as saved maps and configurations to a private ".tesseract"
directory within each user's home directory. Tesseract will automatically create this
directory and any subdirectories for each user running it, so do not pre-create this directory
or install any symlinks within it - as some Linux distribution packages have erroneously done.
All command-line switches supplied to the Tesseract run script should be passed to the
Tesseract client after the "-u${HOME}/.tesseract" switch.
A simple script such as the following (with directory/file names set as appropriate) would
ultimately suffice for the client:
#!/bin/sh
TESS_DATA=/usr/share/games/tesseract
TESS_BIN=/usr/bin/tesseract_client
TESS_OPTIONS="-u${HOME}/.tesseract"
cd ${TESS_DATA}
exec ${TESS_BIN} ${TESS_OPTIONS} "$@"
A simple script for the server, which assumes a global default "config/server-init.cfg" in TESS_DATA,
but allows per-user overriding via the home directory, might be:
#!/bin/sh
TESS_DATA=/usr/share/games/tesseract
TESS_SERV_BIN=/usr/bin/tesseract_server
TESS_SERV_OPTIONS="-u${HOME}/.tesseract"
cd ${TESS_DATA}
exec ${TESS_SERV_BIN} ${TESS_SERV_OPTIONS} "$@"
With respect to libraries, make sure that you do not link Tesseract against any other ENet package
than the one that comes included with the Tesseract, as it may be different from the official ENet
releases and might fail to compile or communicate properly.

View File

@ -0,0 +1,47 @@
///////////////////////////////////////////////////////////////////////////////
// Texture-Blending Brush List //
///////////////////////////////////////////////////////////////////////////////
looplist2 n p [
"Dot 1px Soft" dot_1_soft
"Dot 1px Hard" dot_1_hard
"Dot 1px Solid" dot_1_solid
"Circle 8px Soft" circle_8_soft
"Circle 8px Hard" circle_8_hard
"Circle 8px Solid" circle_8_solid
"Circle 16px Soft" circle_16_soft
"Circle 16px Hard" circle_16_hard
"Circle 16px Solid" circle_16_solid
"Circle 32px Soft" circle_32_soft
"Circle 32px Hard" circle_32_hard
"Circle 32px Solid" circle_32_solid
"Circle 64px Soft" circle_64_soft
"Circle 64px Hard" circle_64_hard
"Circle 64px Solid" circle_64_solid
"Circle 128px Soft" circle_128_soft
"Circle 128px Hard" circle_128_hard
"Circle 128px Solid" circle_128_solid
"Circle 256px Soft" circle_256_soft
"Circle 256px Hard" circle_256_hard
"Circle 256px Solid" circle_256_solid
"Noise 64px Soft" noise_64_soft
"Noise 64px Hard" noise_64_hard
"Noise 128px Soft" noise_128_soft
"Noise 128px Hard" noise_128_hard
"Noise 256px Soft" noise_256_soft
"Noise 256px Hard" noise_256_hard
"Noise 512px Soft" noise_512_soft
"Noise 512px Hard" noise_512_hard
"Noise 1024px Soft" noise_1024_soft
"Noise 1024px Hard" noise_1024_hard
"Square 16px Hard" square_16_hard
"Square 16px Solid" square_16_solid
"Square 32px Hard" square_32_hard
"Square 32px Solid" square_32_solid
"Square 64px Hard" square_64_hard
"Square 64px Solid" square_64_solid
"Gradient 16px" gradient_16
"Gradient 32px" gradient_32
"Gradient 64px" gradient_64
"Gradient 128px" gradient_128
] [addblendbrush $n (concatword "media/blendbrush/" $p ".png")]

192
config/default.cfg 100644
View File

@ -0,0 +1,192 @@
// These default settings are executed whenever "saved.cfg" is not available.
// Do not modify anything below, instead change settings in game, or add to autoexec.cfg
///////////////////////////////////////////////////////////////////////////////
// Settings //
///////////////////////////////////////////////////////////////////////////////
name "unnamed"
///////////////////////////////////////////////////////////////////////////////
// Console //
///////////////////////////////////////////////////////////////////////////////
miniconfilter 0x300 // display chat and team chat in mini-console
confilter (&~ 0xFFF $miniconfilter) // don't display other player frags or mini-console stuff in console
///////////////////////////////////////////////////////////////////////////////
// Universal Mouse Scrollwheel //
///////////////////////////////////////////////////////////////////////////////
ums_modifier = 0
ums_setmodifier = [ums_modifier = $arg1; onrelease [ums_modifier = 0]]
ums_delta = [[ums_delta_@(? $editing "edit" "game")_@ums_modifier] $arg1]
bind "MOUSEWHEELUP" [ums_delta 1]
bind "MOUSEWHEELDOWN" [ums_delta -1]
///////////////////////////////////////////////////////////////////////////////
// Game Binds //
///////////////////////////////////////////////////////////////////////////////
bind "MOUSELEFT" [shoot]
bind "MOUSERIGHT" [dozoom]
bind "MOUSEMIDDLE" [melee]
bind "MOUSEBACK" [melee]
bind "MOUSEFORWARD" [melee]
// Movement
bind "W" [forward]
bind "A" [left]
bind "S" [backward]
bind "D" [right]
bind "UP" [forward]
bind "DOWN" [backward]
bind "RIGHT" [right]
bind "LEFT" [left]
bind "F6" [toggleui "map_browser"]
bindvar "F8" [hidehud]
bind "F10" [toggleui "gamebind_reference"]
bind "F11" [toggleconsole; conskip -1000]
bind "F12" [screenshot]
bindvarquiet "PAUSE" [paused]
bind "INSERT" [addbot]
bind "DELETE" [delbot]
bind "PAGEUP" [conskip 5]
bind "PAGEDOWN" [conskip -1000]
bind "BACKQUOTE" [saycommand /]
bind "SLASH" [saycommand /]
bind "TAB" [holdui scoreboard]
bind "LSHIFT" [crouch]
bind "LCTRL" [crouch]
bind "SPACE" [jump]
bind "RETURN" [saycommand]
bind "E" [edittoggle]
bind "F" [melee]
bind "J" [taunt]
bind "R" [dropflag]
bind "T" [saycommand]
bind "Y" [sayteamcommand]
bind "1" [setweapon rail]
bind "2" [setweapon pulse]
bindvar "9" [thirdperson]
bind "0" [menu_master]
// Console scroll -or- Weapon change
ums_delta_game_0 = [if $fullconsole [conskip (* $arg1 3)] [nextweapon $arg1]]
///////////////////////////////////////////////////////////////////////////////
// Specatator Binds //
///////////////////////////////////////////////////////////////////////////////
specbind "MOUSELEFT" [nextfollow]
specbind "MOUSERIGHT" [nextfollow -1]
specbind "MOUSEMIDDLE" [nextspecmode]
specbind "SPACE" [nextspecmode]
specbind "LSHIFT" [floatspeed 1000;onrelease [floatspeed 100]]
specbind "LCTRL" [floatspeed 25;onrelease [floatspeed 100]]
///////////////////////////////////////////////////////////////////////////////
// Edit Binds //
///////////////////////////////////////////////////////////////////////////////
editbind "MOUSELEFT" [if $blendpaintmode [paintblendmap] [editdrag]]
editbind "MOUSEMIDDLE" [selcorners]
editbind "MOUSERIGHT" [if $blendpaintmode [rotateblendbrush] [editextend]]
editbind "MOUSEBACK" [toggleeditmovecut]
editbind "MOUSEFORWARD" [toggleeditmovecut]
editbind "LSHIFT" [floatspeed $editfloatspeed; onrelease [floatspeed 100]]
editbind "COMMA" [ums_setmodifier 9] // vSlot: rotate
editbind "PERIOD" [ums_setmodifier 10] // vSlot: scale
editbindmod "LCTRL" [passthrough]
editbind "SPACE" [cancelsel]
editbind "DELETE" [editdel]
editbind "HOME" [gotosel]
editbind "END" [ums_setmodifier 16; onrelease entautoview] // Hold and scroll to goto selected entities
editbind "1" [ums_setmodifier 11] // Entity attribute modifier 0
editbind "2" [ums_setmodifier 12] // Entity attribute modifier 1
editbind "3" [ums_setmodifier 13] // Entity attribute modifier 2
editbind "4" [ums_setmodifier 14] // Entity attribute modifier 3
editbind "5" [ums_setmodifier 15] // Entity attribute modifier 4
editbindvar "6" [allfaces]
editbindvar "7" [entselsnap]
editbindvar "8" [entediting]
editbind "9" [selentedit]
editbindvar "MINUS" [outline]
editbindvar "EQUALS" [wireframe]
// Editing Menus
editbind "F1" [menu_entity] // Add/Edit Entity
editbind "F2" [toggleui "texture_browser"] // Texture List
editbind "F3" [toggleui "mapmodel"] // Add Mapmodel
editbind "F4" [toggleui "material"] // Edit Material
editbind "F5" [menu_savemap] // Savemap
editbind "F7" [toggleui "env_settings"] // Environment Settings
editbind "F8" [toggleui "geo_prefab"] // World Geometry Prefab
editbind "F9" [toggleui "misc_editing"] // Miscellaneous Editing
editbind "F10" [toggleui "editbind_reference"] // Default Editbind Quick Reference
// Number Keypad
editbind "KP0" [blendpaintmode 0] // Exit paint blendmap mode
editbind "KP1" [blendpaintmode 1]
editbind "KP2" [blendpaintmode 2] // Paint
editbind "KP3" [blendpaintmode 3]
editbind "KP4" [blendpaintmode 4]
editbind "KP5" [blendpaintmode 5] // Erase
editbind "KP8" [nextblendbrush -1] // Select brush -
editbind "KP9" [nextblendbrush 1] // Select brush +
editbind "KP_DIVIDE" [floatspeed 10; echo [floatspeed @floatspeed]]
editbind "KP_MULTIPLY" [floatspeed 50; echo [floatspeed @floatspeed]]
editbind "KP_MINUS" [floatspeed 100; echo [floatspeed @floatspeed]]
editbind "KP_PLUS" [toggleeditmovecut] // Toggle MOUSERIGHT to move selection with or without contents
editbind "KP_ENTER" [entselect insel] // Select entities within area selection
editbind "B" [ums_setmodifier 6] // Change heightmap brush
editbind "C" [editcopy]
editbind "F" [ums_setmodifier 2] // Push face/corners selected
editbind "G" [ums_setmodifier 1] // Grid size
editbind "H" [if $hmapedit [editface 1 -1] [hmapedit 1]]
editbind "I" [redo]
editbind "K" [calclight]
editbindvar "L" [fullbright]
editbindvar "M" [showmat]
editbind "N" [selentfindall]
editbind "O" [ums_setmodifier 7] // vSlot: offset H
editbind "P" [ums_setmodifier 8] // vSlot: offset V
editbind "Q" [ums_setmodifier 3] // Push corner pointed at by cursor
editbind "R" [ums_setmodifier 4] // Geometry rotate -or- blend brush rotate
editbind "U" [undo; passthroughsel 0]
editbind "V" [editpaste]
editbind "X" [editflip] // Geometry flip
editbind "Y" [ums_setmodifier 5] // Change textures
editbind "Z" [history 0] // Repeat last saycommand
ums_delta_edit_0 = [if $fullconsole [conskip (* $arg1 3)] [if $blendpaintmode [nextblendbrush $arg1] [editfacewsel $arg1 1]]] // Console scroll -or- Change blend brush -or- Push/pull geometry
ums_delta_edit_1 = [nodebug [gridpower (+ $arg1 $gridpower)]] // Grid size
ums_delta_edit_2 = [editfacewsel $arg1 0] // Push face/corners selected
ums_delta_edit_3 = [editfacewsel $arg1 2] // Push corner pointed at by cursor
ums_delta_edit_4 = [if $blendpaintmode [rotateblendbrush $arg1] [editrotate $arg1]] // Geometry rotate -or- blend brush rotate
ums_delta_edit_5 = [edittex $arg1] // Change textures
ums_delta_edit_6 = [selecthbrush $arg1] // Change heightmap brush
ums_delta_edit_7 = [vdelta [voffset (* $arg1 $delta_multiplier2) 0]] // vSlot: offset H
ums_delta_edit_8 = [vdelta [voffset 0 (* $arg1 $delta_multiplier2)]] // vSlot: offset V
ums_delta_edit_9 = [vdelta [vrotate $arg1]] // vSlot: rotate
ums_delta_edit_10 = [vdelta [vscale (if (< $arg1 0) 0.5 2)]] // vSlot: scale
ums_delta_edit_11 = [entproperty 0 (* $arg1 $delta_multiplier1)]
ums_delta_edit_12 = [entproperty 1 (* $arg1 $delta_multiplier1)]
ums_delta_edit_13 = [entproperty 2 (* $arg1 $delta_multiplier1)]
ums_delta_edit_14 = [entproperty 3 (* $arg1 $delta_multiplier1)]
ums_delta_edit_15 = [entproperty 4 (* $arg1 $delta_multiplier1)]
ums_delta_edit_16 = [entautoview $arg1]
editbind "LALT" [delta_multiplier1 = 10;onrelease [delta_multiplier1 = 1]] // Entity attribute multiplier
editbind "RALT" [delta_multiplier2 = 32;onrelease [delta_multiplier2 = 16]] // vSlot: offset multiplier
delta_multiplier1 = 1
delta_multiplier2 = 16

View File

@ -0,0 +1,78 @@
// Notice: This list is dynamic and will change with every release.
// Please use a dedicated map.cfg.
mapmodelreset
mapmodel "obj_cube"
mapmodel "obj_sphere"
// Nieb/Complex
mapmodel "nieb/complex/bench/2"
mapmodel "nieb/complex/bench/3"
mapmodel "nieb/complex/box_copy-paper"
mapmodel "nieb/complex/box_large/label_0"
mapmodel "nieb/complex/box_large/label_a"
mapmodel "nieb/complex/box_large/label_b"
mapmodel "nieb/complex/box_small/label_0"
mapmodel "nieb/complex/box_small/label_a"
mapmodel "nieb/complex/box_small/label_b"
mapmodel "nieb/complex/box_small-open/label_0"
mapmodel "nieb/complex/box_small-open/label_a"
mapmodel "nieb/complex/box_small-open/label_b"
mapmodel "nieb/complex/chair_office"
mapmodel "nieb/complex/clock_wall"
mapmodel "nieb/complex/coffee_cup"
mapmodel "nieb/complex/computer_case_v/off"
mapmodel "nieb/complex/computer_case_v/on"
mapmodel "nieb/complex/computer_keyboard"
mapmodel "nieb/complex/computer_monitor"
mapmodel "nieb/complex/computer_mouse"
mapmodel "nieb/complex/cooling_fan"
mapmodel "nieb/complex/copy-machine"
mapmodel "nieb/complex/desk"
mapmodel "nieb/complex/desk/flip"
mapmodel "nieb/complex/door"
mapmodel "nieb/complex/door/flip"
mapmodel "nieb/complex/drinking_fountain"
mapmodel "nieb/complex/filing_cab1"
mapmodel "nieb/complex/filing_cab2"
mapmodel "nieb/complex/fire_alarm"
mapmodel "nieb/complex/fire_extinguisher"
mapmodel "nieb/complex/fire_sprinkler"
mapmodel "nieb/complex/garbage_bin"
mapmodel "nieb/complex/garbage_can"
mapmodel "nieb/complex/light_fluorescent/on"
mapmodel "nieb/complex/light_fluorescent/off"
mapmodel "nieb/complex/locker01"
mapmodel "nieb/complex/locker02"
mapmodel "nieb/complex/mop_bucket"
mapmodel "nieb/complex/pallet_lift"
mapmodel "nieb/complex/phone"
mapmodel "nieb/complex/picture/1"
mapmodel "nieb/complex/picture/2"
mapmodel "nieb/complex/picture/3"
mapmodel "nieb/complex/projector"
mapmodel "nieb/complex/projector_screen"
mapmodel "nieb/complex/safety_post"
mapmodel "nieb/complex/server_rack/1"
mapmodel "nieb/complex/server_rack/2"
mapmodel "nieb/complex/server_rack/3"
mapmodel "nieb/complex/shelf_storage"
mapmodel "nieb/complex/signage/1"
mapmodel "nieb/complex/signage/2"
mapmodel "nieb/complex/signage/3"
mapmodel "nieb/complex/sign_caution"
mapmodel "nieb/complex/sign_drinking"
mapmodel "nieb/complex/sign_exit"
mapmodel "nieb/complex/sign_fire_extinguisher"
mapmodel "nieb/complex/sign_restroom/f"
mapmodel "nieb/complex/sign_restroom/m"
mapmodel "nieb/complex/sign_room/conference"
mapmodel "nieb/complex/sign_room/office"
mapmodel "nieb/complex/sign_room/server"
mapmodel "nieb/complex/storage_tote"
mapmodel "nieb/complex/white_board"
// Nobiax
mapmodel "nobiax/cardboardbox1"
mapmodel "nobiax/gaz_tank"
mapmodel "nobiax/pallet2"

View File

@ -0,0 +1,181 @@
// Notice: This list is dynamic and will change with every release.
// Please use a dedicated map.cfg.
exec "config/default_map_models.cfg" // Default Mapmodel List
// Default Sky/Light Settings
setdefaultenv = [
skybox ""
atmo 1
sunlightpitch 50
sunlightyaw 30
sunlight 0xFFF8E0
skylight 0x7495B8
]
if $emptymap [setdefaultenv]
materialreset
loop+ i 1 4 [
texture [glass@i] "mat_glass/nieb/scratch2.png" // Glass Normals
texture [water@i] "mat_water/nieb/water.png" // Water (Unused)
texture 1 "mat_water/appleflap/water_normal.png" // Water Normals
texture 1 "mat_water/nieb/waterfall.png" // Waterfall Diffuse
texture 1 "mat_water/nieb/waterfall_normal.png" // Waterfall Normals
texture [lava@i] "mat_lava/nieb/lava.png" // Lava Diffuse
texture 1 "mat_lava/nieb/lava_normal.png" // Lava Normals
texture 1 "mat_lava/nieb/lava.png" // Lavafall Diffuse
texture 1 "mat_lava/nieb/lava_normal.png" // Lavafall Normals
]
decalreset
decalload "nieb/complex/loadingbay"
texturereset // Start world texture list
texsky // Dummy "sky" texture
texload "base/base1" // Default geometry texture
texload "base/base2"
texload "base/base3"
texload "base/base4"
texload "base/white"
texload "base/glow"
// Nieb/Complex
texload "nieb/complex/door_rail"
texload "nieb/complex/door_rail"; texrotate 1
texload "nieb/complex/electrical-outlet"
texload "nieb/complex/glass_2"
texload "nieb/complex/glass_subtle"
texload "nieb/complex/light-switch"
texload "nieb/complex/light01_off"
texload "nieb/complex/light01_on"
texload "nieb/complex/step01"
texload "nieb/complex/step01"; texrotate 1
texload "nieb/complex/step02"
texload "nieb/complex/step02"; texrotate 1
texload "nieb/complex/step03"
texload "nieb/complex/step03"; texrotate 1
texload "nieb/complex/tile01"
texload "nieb/complex/tile02"
texload "nieb/complex/vent"
texload "nieb/complex/wall01"
texload "nieb/complex/woodfloor01"
texload "nieb/complex/woodfloor02"
texload "nieb/complex/woodfloor03"
// CGTextures
texload "cgtextures/buildingshighrise0290"
texload "cgtextures/buildingshighrise0341"
texload "cgtextures/buildingshighrise0436"
texload "cgtextures/carpet01"
texload "cgtextures/ceilingtile01"
texload "cgtextures/tilesplain0119"
texload "cgtextures/tilesplain0119"; texrotate 1
// AGF81
texload "agf81/concrete1"
texload "agf81/concrete1w"
texload "agf81/concrete2"
texload "agf81/concrete2"; texrotate 1
texload "agf81/concrete3"
texload "agf81/concrete3"; texrotate 1
texload "agf81/concrete4"
texload "agf81/concrete5"
texload "agf81/door_texture_2"
texload "agf81/metal_a2"
// Nobiax
texload "nobiax/pattern019"
texload "nobiax/pattern037"
texload "nobiax/pattern042"
texload "nobiax/pattern044"
texload "nobiax/pattern045"
texload "nobiax/pattern047"
texload "nobiax/pattern055"
texload "nobiax/pattern056"
texload "nobiax/pattern057"
texload "nobiax/pattern205"
texload "nobiax/pattern208"
// philipk2
texload "philipk2/pk02_ceiling03"
texload "philipk2/pk02_door01"
texload "philipk2/pk02_door02"
texload "philipk2/pk02_door03"
texload "philipk2/pk02_floor01"
texload "philipk2/pk02_floor02"
texload "philipk2/pk02_floor03"
texload "philipk2/pk02_floor04"
texload "philipk2/pk02_floor05"
texload "philipk2/pk02_floor06a"
texload "philipk2/pk02_floor06b"
texload "philipk2/pk02_floor07"
texload "philipk2/pk02_floor08a"
texload "philipk2/pk02_floor08b"
texload "philipk2/pk02_floor09a"
texload "philipk2/pk02_floor09b"
texload "philipk2/pk02_floor10"
texload "philipk2/pk02_floor11"
texload "philipk2/pk02_floor12a"
texload "philipk2/pk02_floor12b"
texload "philipk2/pk02_floor13a"
texload "philipk2/pk02_floor13b"
texload "philipk2/pk02_floor_cyl01"
texload "philipk2/pk02_floor_cyl02"
texload "philipk2/pk02_generic01a"
texload "philipk2/pk02_generic01b"
texload "philipk2/pk02_light01a"
texload "philipk2/pk02_light01b"
texload "philipk2/pk02_panels01a"
texload "philipk2/pk02_panels01b"
texload "philipk2/pk02_panels01c"
texload "philipk2/pk02_plates01a"
texload "philipk2/pk02_plates01b"
texload "philipk2/pk02_rock01"
texload "philipk2/pk02_sand01"
texload "philipk2/pk02_switches01a"
texload "philipk2/pk02_trim01"
texload "philipk2/pk02_trim02"
texload "philipk2/pk02_trim03"
texload "philipk2/pk02_trim04a"
texload "philipk2/pk02_trim04b"
texload "philipk2/pk02_trim_set01a"
texload "philipk2/pk02_trim_set01b"
texload "philipk2/pk02_trim_set02a"
texload "philipk2/pk02_trim_set02b"
texload "philipk2/pk02_wall01"
texload "philipk2/pk02_wall03a"
texload "philipk2/pk02_wall03b"
texload "philipk2/pk02_wall04a"
texload "philipk2/pk02_wall04b"
texload "philipk2/pk02_wall05a"
texload "philipk2/pk02_wall05b"
texload "philipk2/pk02_wall05c"
texload "philipk2/pk02_wall06a"
texload "philipk2/pk02_wall06b"
texload "philipk2/pk02_wall07a"
texload "philipk2/pk02_wall07b"
texload "philipk2/pk02_wall_big01a"
texload "philipk2/pk02_wall_big01b"
texload "philipk2/pk02_wall_big02a"
texload "philipk2/pk02_wall_big02b"
texload "philipk2/pk02_wall08a"
texload "philipk2/pk02_wall08b"
texload "philipk2/pk02_ceiling02"
texload "philipk2/pk02_computer01a"
texload "philipk2/pk02_computer01b"
texload "philipk2/pk02_computer01c"
texload "philipk2/pk02_light02a"
texload "philipk2/pk02_light02b"
texload "philipk2/pk02_light02c"
texload "philipk2/pk02_light02"
texload "philipk2/pk02_light03"
texload "philipk2/pk02_pipes01"
texload "philipk2/pk02_switches01b"
texload "philipk2/pk02_switches01c"
texload "philipk2/pk02_wall02a"
texload "philipk2/pk02_wall02b"
texload "philipk2/pk02_wall02c"
setshader "stdworld"

3
config/font.cfg 100644
View File

@ -0,0 +1,3 @@
loopfiles f "media/interface/font" cfg [
exec (concatword "media/interface/font/" $f ".cfg")
]

38
config/game.cfg 100644
View File

@ -0,0 +1,38 @@
// Game specific config stuff goes here
// Scoreboard Options
defvarp showscore 0 1 1
defvarp showkills 0 1 1
defvarp showdeaths 0 0 1
defvarp showip 0 0 1
defvarp sbtransparent 0 1 1
nextspecmode = [
if $specmode [
specmode (mod (+ $specmode 1) 3)
] [
specmode (? (>= (getfollow) 0) 2 1)
]
]
defvarp zoomtoggle 0 0 1
dozoom = [if $zoomtoggle [zoom (? $zoom -1 1)] [zoom 1 ; onrelease [zoom -1]]]
sayteamcommand = [inputcommand $arg1 [sayteam $commandbuf] "[team]"]
mapcomplete = [complete $arg1 media/map ogz]
mapcomplete map
modenames = "edit rdm pdm rtdm ptdm rctf pctf"
loop i (listlen $modenames) [
mname = (at $modenames $i)
alias $mname [if (mode @i) [if (> $numargs 0) [map $arg1] [map]]]
mapcomplete $mname
]
demo = [stopdemo; if (mode -1) [map $arg1]]
complete demo . dmo
allowedittoggle = [result 1]

24
config/glsl.cfg 100644
View File

@ -0,0 +1,24 @@
exec "config/glsl/shared.cfg"
exec "config/glsl/misc.cfg"
exec "config/glsl/hud.cfg"
exec "config/glsl/world.cfg"
exec "config/glsl/decal.cfg"
exec "config/glsl/grass.cfg"
exec "config/glsl/model.cfg"
exec "config/glsl/ao.cfg"
exec "config/glsl/gi.cfg"
exec "config/glsl/particle.cfg"
exec "config/glsl/stain.cfg"
exec "config/glsl/material.cfg"
exec "config/glsl/deferred.cfg"
exec "config/glsl/tonemap.cfg"
exec "config/glsl/volumetric.cfg"
exec "config/glsl/sky.cfg"
exec "config/glsl/aa.cfg"
exec "config/glsl/scale.cfg"
exec "config/glsl/blur.cfg"
exec "config/glsl/ui.cfg"
exec "config/glsl/postfx.cfg"
exec "config/glsl/edit.cfg"
exec "config/glsl/movie.cfg"

88
config/glsl/aa.cfg 100644
View File

@ -0,0 +1,88 @@
////////////////////////////////////////////////
//
// anti-aliasing
//
////////////////////////////////////////////////
lazyshader 0 "tqaaresolve" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
@(? $tqaaresolvegather [
varying vec2 texcoord1;
])
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
@(? $tqaaresolvegather [
texcoord1 = vtexcoord0 - 0.5;
])
}
] [
@(gfetchdefs tex2)
uniform vec4 quincunx;
uniform sampler2DRect tex0, tex1;
uniform mat4 reprojectmatrix;
uniform vec2 maxvelocity;
uniform vec2 colorweight;
varying vec2 texcoord0;
@(? $tqaaresolvegather [
varying vec2 texcoord1;
])
fragdata(0) vec4 fragcolor;
void main(void)
{
@(gdepthunpack depth [gfetch(tex2, texcoord0)] [
vec4 prevtc = reprojectmatrix * vec4(depth*texcoord0, depth, 1.0);
] [
vec4 prevtc = reprojectmatrix * vec4(texcoord0, depth, 1.0);
])
vec2 vel = prevtc.xy/prevtc.w - texcoord0;
float scale = clamp(maxvelocity.x*inversesqrt(dot(vel, vel) + 1e-6), 0.0, 1.0);
float mask = 1.0 - texture2DRect(tex0, texcoord0 + quincunx.xy).a;
vec4 color = texture2DRect(tex0, texcoord0 + mask*quincunx.xy);
vec4 prevcolor = texture2DRect(tex1, texcoord0 + mask*(quincunx.zw + vel*scale));
@(? $tqaaresolvegather [
vec4 l0 = textureGather(tex0, texcoord1, 1);
vec4 l1 = textureGatherOffset(tex0, texcoord1, ivec2(1, 1), 1);
float l2 = texture2DRectOffset(tex0, texcoord0, ivec2(1, -1)).g;
float l3 = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 1)).g;
vec4 l01min = min(l0, l1), l01max = max(l0, l1);
l01min.xy = min(l01min.xy, l01min.zw);
l01max.xy = max(l01max.xy, l01max.zw);
float lmin = min(min(l01min.x, l01min.y), min(l2, l3));
float lmax = max(max(l01max.x, l01max.y), max(l2, l3));
] [
float l0 = texture2DRect(tex0, texcoord0 + vec2(-1.0, -0.5)).g;
float l1 = texture2DRect(tex0, texcoord0 + vec2( 0.5, -1.0)).g;
float l2 = texture2DRect(tex0, texcoord0 + vec2( 1.0, 0.5)).g;
float l3 = texture2DRect(tex0, texcoord0 + vec2(-0.5, 1.0)).g;
float lmin = min(color.g, min(min(l0, l1), min(l2, l3)));
float lmax = max(color.g, max(max(l0, l1), max(l2, l3)));
])
float weight = 0.5 - 0.5*clamp((colorweight.x*max(prevcolor.g - lmax, lmin - prevcolor.g) + colorweight.y) / (lmax - lmin + 1e-4), 0.0, 1.0);
weight *= clamp(1.0 - 2.0*(prevcolor.a - color.a), 0.0, 1.0);
fragcolor.rgb = mix(color.rgb, prevcolor.rgb, weight);
fragcolor.a = color.a;
}
]
smaaopt = [ >= (strstr $smaaopts $arg1) 0 ]
smaashaders = [
smaapreset = $arg1
smaaopts = $arg2
exec "config/glsl/smaa.cfg"
]
fxaaopt = [ >= (strstr $fxaaopts $arg1) 0 ]
fxaashaders = [
fxaapreset = $arg1
fxaaopts = $arg2
exec "config/glsl/fxaa.cfg"
]

285
config/glsl/ao.cfg 100644
View File

@ -0,0 +1,285 @@
////////////////////////////////////////////////
//
// ambient obscurance
//
////////////////////////////////////////////////
aotapoffsets = [
"-0.933103, 0.025116"
"-0.432784, -0.989868"
"0.432416, -0.413800"
"-0.117770, 0.970336"
"0.837276, 0.531114"
"-0.184912, 0.200232"
"-0.955748, 0.815118"
"0.946166, -0.998596"
"-0.897519, -0.581102"
"0.979248, -0.046602"
"-0.155736, -0.488204"
"0.460310, 0.982178"
]
ambientobscurancevariantshader = [
lineardepth = (>= (strstr $arg2 "l") 0)
packeddepth = (>= (strstr $arg2 "p") 0)
derivnormal = (>= (strstr $arg2 "d") 0)
maxaotaps = $arg3
shader 0 $arg1 [
attribute vec4 vvertex;
@(screentexcoord 0)
@(screentexcoord 1)
varying vec2 texcoord0, texcoord1;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
texcoord1 = vtexcoord1;
}
] [
@(gfetchdefs tex0 (&& $msaasamples [! $lineardepth]) gdepthfetch)
@(gfetchdefs tex1 $msaasamples gnormfetch)
@(gdepthunpackparams)
uniform sampler2D tex2;
uniform vec3 tapparams;
uniform vec2 contrastparams;
uniform vec4 offsetscale;
uniform float prefilterdepth;
@(? (! $derivnormal) [
uniform mat3 normalmatrix;
])
@(? $lineardepth [
#define depthtc gl_FragCoord.xy
] [
#define depthtc texcoord0
])
uniform vec3 gdepthpackparams;
varying vec2 texcoord0, texcoord1;
fragdata(0) vec4 fragcolor;
void main(void)
{
@(if (&& $derivnormal [= $aodepthformat 1]) [result [
@(gdepthunpack depth [gnormfetch(tex1, texcoord0)] [
vec2 tapscale = tapparams.xy/depth;
] [
float w = depth*gdepthscale.y + gdepthscale.z;
depth = gdepthscale.x/w;
vec2 tapscale = tapparams.xy*w;
])
]] [result [
@(gdepthunpack depth [gdepthfetch(tex0, depthtc)] [
vec2 tapscale = tapparams.xy/depth;
] [
float w = depth*gdepthscale.y + gdepthscale.z;
depth = gdepthscale.x/w;
vec2 tapscale = tapparams.xy*w;
] $lineardepth (? $lineardepth (! $aodepthformat) (= $gdepthformat 1)) packdepth)
]])
vec2 dpos = depthtc*offsetscale.xy + offsetscale.zw, pos = depth*dpos;
@(if $derivnormal [result [
vec2 ddepth = vec2(dFdx(depth), dFdy(depth));
ddepth *= step(abs(ddepth), vec2(4.0));
vec3 normal;
normal.xy = (depth+ddepth.yx)*offsetscale.yx;
normal.z = normal.x*normal.y;
normal.xy *= -ddepth;
normal.z -= dot(dpos, normal.xy);
normal = normalize(normal);
]] [result [
vec3 normal = gnormfetch(tex1, texcoord0).rgb*2.0 - 1.0;
float normscale = inversesqrt(dot(normal, normal));
normal *= normscale > 0.75 ? normscale : 0.0;
normal = normalmatrix * normal;
]])
vec2 noise = texture2D(tex2, texcoord1).rg*2.0-1.0;
float obscure = 0.0;
@(loopconcat i $maxaotaps [result [
vec2 offset@[i] = reflect(vec2(@(at $aotapoffsets $i)), noise);
offset@[i] = depthtc + tapscale * offset@[i];
@(gdepthunpack [depth@[i]] [gdepthfetch(tex0, offset@[i])] [] [] $lineardepth (&& $lineardepth (! $aodepthformat)))
vec3 v@[i] = vec3(depth@[i]*(offset@[i]*offsetscale.xy + offsetscale.zw) - pos, depth@[i] - depth);
float dist2@[i] = dot(v@[i], v@[i]);
obscure += step(dist2@[i], tapparams.z) * max(0.0, dot(v@[i], normal) + depth*1.0e-2) / (dist2@[i] + 1.0e-5);
]])
obscure = pow(clamp(1.0 - contrastparams.x*obscure, 0.0, 1.0), contrastparams.y);
@(if $derivnormal [result [
vec2 weights = step(abs(ddepth), vec2(prefilterdepth)) * (2.0*fract((gl_FragCoord.xy - 0.5)*0.5) - 0.5);
]] [result [
vec2 weights = step(fwidth(depth), prefilterdepth) * (2.0*fract((gl_FragCoord.xy - 0.5)*0.5) - 0.5);
]])
obscure -= dFdx(obscure) * weights.x;
obscure -= dFdy(obscure) * weights.y;
@(if $packeddepth [
if $aodepthformat [result [
fragcolor.rg = vec2(obscure, depth);
]] [result [
@(if (&& (! $lineardepth) (!= $gdepthformat 1)) [gpackdepth packdepth depth])
fragcolor = vec4(packdepth, obscure);
]]
] [result [
fragcolor = vec4(obscure, 0.0, 0.0, 1.0);
]])
}
]
]
ambientobscuranceshader = [
ambientobscurancevariantshader (format "ambientobscurance%1%2" $arg1 $arg2) $arg1 $arg2
]
shader 0 "linearizedepth" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
@(gfetchdefs tex0 $msaasamples)
uniform vec3 gdepthpackparams;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
@(if (! $aodepthformat) [
if (= $gdepthformat 1) [result [
fragcolor = gfetch(tex0, texcoord0);
]] [result [
@(gdepthunpack depth [gfetch(tex0, texcoord0)])
@(gpackdepth packdepth depth)
fragcolor = vec4(packdepth, 1.0);
]]
] [result [
@(gdepthunpack depth [gfetch(tex0, texcoord0)])
fragcolor.r = depth;
]])
}
]
bilateralvariantshader = [
linear = (>= (strstr $arg2 "l") 0)
packed = (>= (strstr $arg2 "p") 0)
upscaled = (>= (strstr $arg2 "u") 0)
numtaps = $arg3
reduced = $arg4
filterdir = $arg5
shader 0 $arg1 [
attribute vec4 vvertex;
@(if $reduced [result [
@(screentexcoord 0)
varying vec2 texcoord0;
]])
@(if $upscaled [result [
@(screentexcoord 1)
varying vec2 texcoord1;
]])
void main(void)
{
gl_Position = vvertex;
@(? $reduced [texcoord0 = vtexcoord0;])
@(? $upscaled [texcoord1 = vtexcoord1;])
}
] [
@(gfetchdefs tex1 (&& $msaasamples [! $linear]))
uniform sampler2DRect tex0;
uniform vec2 bilateralparams;
uniform vec3 gdepthpackparams;
@(? $reduced [varying vec2 texcoord0;])
@(? $upscaled [varying vec2 texcoord1;])
fragdata(0) vec4 fragcolor;
void main(void)
{
#define tc @(? $upscaled [texcoord1] [gl_FragCoord.xy])
#define depthtc @(? $reduced [texcoord0] [gl_FragCoord.xy])
#define tapvec(type, i) @(? (=s $filterdir "x") [type(i, 0.0)] [type(0.0, i)])
#define texval(i) texture2DRect(tex0, tc + tapvec(vec2, i))
#define texvaloffset(i) texture2DRectOffset(tex0, tc, tapvec(ivec2, i))
#define depthval(i) gfetch(tex1, depthtc + tapvec(vec2, i))
#define depthvaloffset(i) gfetchoffset(tex1, depthtc, tapvec(ivec2, i))
@(cond [$packed] [
if $aodepthformat [result [
vec2 vals = texture2DRect(tex0, tc).rg;
#define color vals.x
@(if $upscaled [gdepthunpack depth [gfetch(tex1, depthtc)]] [result [
#define depth vals.y
]])
]] [result [
vec4 vals = texture2DRect(tex0, tc);
#define color vals.a
@(if $upscaled [gdepthunpack depth [gfetch(tex1, depthtc)]] [result [
float depth = dot(vals.rgb, gdepthunpackparams);
]])
]]
] [$linear] [result [
float color = gfetch(tex0, tc).r;
@(if $aodepthformat [result [
float depth = gfetch(tex1, depthtc).r;
]] [result [
float depth = dot(gfetch(tex1, depthtc).rgb, gdepthunpackparams);
]])
]] [result [
float color = texture2DRect(tex0, tc).r;
@(gdepthunpack depth [gfetch(tex1, depthtc)])
]])
float weights = 1.0;
@(loopconcat i (* 2 $numtaps) [
curtap = (- $i $numtaps)
if (>= $curtap 0) [curtap = (+ $curtap 1)]
curtapoffset = (* $curtap 2)
curdepthoffset = (<< $curtapoffset $reduced)
curtexval = [texval@(? (<= $mintexrectoffset $curtapoffset $maxtexrectoffset) "offset")(@(+f $curtapoffset))]
curdepthval = [depthval@(? (<= $mintexrectoffset $curdepthoffset $maxtexrectoffset) "offset")(@(+f $curdepthoffset))]
result [
@(cond [$packed] [
if $aodepthformat [result [
vec2 vals@[i] = @[curtexval].rg;
#define color@[i] vals@[i].x
#define depth@[i] vals@[i].y
]] [result [
vec4 vals@[i] = @[curtexval];
#define color@[i] vals@[i].a
float depth@[i] = dot(vals@[i].rgb, gdepthunpackparams);
]]
] [$linear] [
result [
float color@[i] = @[curtexval].r;
@(if $aodepthformat [result [
float depth@[i] = @[curdepthval].r;
]] [result [
float depth@[i] = dot(@[curdepthval].rgb, gdepthunpackparams);
]])
]
] [
result [
float color@[i] = @[curtexval].r;
@(gdepthunpack [depth@[i]] $curdepthval)
]
])
depth@[i] -= depth;
float weight@[i] = exp2(@(-f 0 (* $curtap $curtap))*bilateralparams.x - depth@[i]*depth@[i]*bilateralparams.y);
weights += weight@[i];
color += weight@[i] * color@[i];
]
])
@(if (&& (=s $filterdir "x") $packed) [
if $aodepthformat [result [
fragcolor.rg = vec2(color / weights, depth);
]] [result [
@(if $upscaled [gpackdepth packdepth depth] [result [
#define packdepth vals.rgb
]])
fragcolor = vec4(packdepth, color / weights);
]]
] [result [
fragcolor = vec4(color / weights, 0.0, 0.0, 1.0);
]])
}
]
]
bilateralshader = [
bilateralvariantshader (format "bilateralx%1%2" $arg1 $arg2) $arg1 $arg2 $arg3 x
bilateralvariantshader (format "bilateraly%1%2" $arg1 $arg2) $arg1 $arg2 $arg3 y
]

View File

@ -0,0 +1,68 @@
////////////////////////////////////////////////
//
// separable blur with up to 7 taps
//
////////////////////////////////////////////////
blurshader = [
shader 0 $arg1 [
attribute vec4 vvertex;
@(screentexcoord 0)
uniform float offsets[8];
varying vec2 texcoord0, texcoordp1, texcoordn1;
@(loopconcat+ i 2 (min (- $arg2 1) 2) [result [
varying vec2 texcoordp@i, texcoordn@i;
]])
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
vec2 tcp = vtexcoord0, tcn = vtexcoord0;
tcp.@arg3 += offsets[1];
tcn.@arg3 -= offsets[1];
texcoordp1 = tcp;
texcoordn1 = tcn;
@(loopconcat+ i 2 (min (- $arg2 1) 2) [result [
tcp.@arg3 = vtexcoord0.@arg3 + offsets[@@i];
tcn.@arg3 = vtexcoord0.@arg3 - offsets[@@i];
texcoordp@i = tcp;
texcoordn@i = tcn;
]])
}
] [
uniform float weights[8];
uniform float offsets[8];
uniform sampler@[arg4] tex0;
varying vec2 texcoord0, texcoordp1, texcoordn1;
@(loopconcat+ i 2 (min (- $arg2 1) 2) [result [
varying vec2 texcoordp@i, texcoordn@i;
]])
fragdata(0) vec4 fragcolor;
void main(void)
{
#define texval(coords) texture@[arg4](tex0, (coords))
vec4 val = texval(texcoord0) * weights[0];
@(loopconcat+ i 1 $arg2 [
if (< $i 4) [result [
val += weights[@@i] * (texval(texcoordp@i) + texval(texcoordn@i));
]] [result [
val += weights[@@i] *
@(if (=s $arg3 "x") [result [
(texval(vec2(texcoord0.x + offsets[@@i], texcoord0.y)) + texval(vec2(texcoord0.x - offsets[@@i], texcoord0.y)));
]] [result [
(texval(vec2(texcoord0.x, texcoord0.y + offsets[@@i])) + texval(vec2(texcoord0.x, texcoord0.y - offsets[@@i])));
]])
]]
])
fragcolor = val;
}
]
]
loop+ i 1 7 [
blurshader (format "blurx%1" $i) $i x 2D
blurshader (format "blury%1" $i) $i y 2D
blurshader (format "blurx%1rect" $i) $i x 2DRect
blurshader (format "blury%1rect" $i) $i y 2DRect
]

View File

@ -0,0 +1,290 @@
////////////////////////////////////////////////
//
// decals
//
////////////////////////////////////////////////
// decaltype:
// e -> reserve envmap texture slot
// r -> envmap reflection
// R -> modulate envmap reflection with spec map
// s -> spec
// S -> spec map
// n -> normal map
// p -> parallax
// g -> glow
// G -> pulse glow
// b -> keep normals
// 0 -> pass 0
// 1 -> pass 1
dtopt = [ >= (strstr $decaltype $arg1) 0 ]
decalvariantshader = [
local decaltype
decaltype = $arg2
stype = (? (dtopt "e") 3 1)
srow = (? (dtopt "1") 0 -1)
if (dtopt "G") [
stype = (+ $stype 0x10)
defuniformparam "glowcolor" 1 1 1 // glow color
defuniformparam "pulseglowspeed" 1 // pulse frequency (Hz)
defuniformparam "pulseglowcolor" 0 0 0 // pulse glow color
] [if (dtopt "g") [
defuniformparam "glowcolor" 1 1 1 // glow color
]]
if (dtopt "R") [
defuniformparam "envscale" 1 1 1 // reflectivity map multiplier
] [if (dtopt "r") [
defuniformparam "envscale" 0.2 0.2 0.2 // reflectivity
]]
reuseuniformparam "gloss" 1 // glossiness
if (dtopt "S") [
defuniformparam "specscale" 2 2 2 // spec map multiplier
] [if (dtopt "s") [
defuniformparam "specscale" 1 1 1 // spec multiplier
]]
if (dtopt "p") [
defuniformparam "parallaxscale" 0.06 -0.03 // parallax scaling
]
if (dtopt "n") [
defuniformparam "bumpblend" 1 // alpha-blend strength for normals
]
variantshader $stype $arg1 $srow [
attribute vec4 vvertex;
@(? (dtopt "n") [
attribute vec4 vtangent;
varying mat3 world;
] [
varying vec3 nvec;
])
attribute vec4 vnormal;
attribute vec3 vtexcoord0;
uniform mat4 camprojmatrix;
varying vec4 texcoord0;
@(? (|| (dtopt "p") (dtopt "r")) [
uniform vec3 camera;
varying vec3 camvec;
])
@(? (dtopt "G") [uniform float millis; flat varying float pulse;])
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0.xyz = vtexcoord0;
texcoord0.w = 3.0*vnormal.w;
@(? (dtopt "n") [
vec3 bitangent = cross(vnormal.xyz, vtangent.xyz) * vtangent.w;
// calculate tangent -> world transform
world = mat3(vtangent.xyz, bitangent, vnormal.xyz);
] [
nvec = vnormal.xyz;
])
@(? (|| (dtopt "p") (dtopt "r")) [
camvec = camera - vvertex.xyz;
])
@(? (dtopt "G") [
pulse = abs(fract(millis*pulseglowspeed.x)*2.0 - 1.0);
])
}
] [
@(cond [dtopt "0"] [result [
fragdata(0) vec4 gcolor;
fragblend(0) vec4 gcolorblend;
]] [dtopt "1"] [
? $usepacknorm [
fragdata(0) vec4 gnormal;
] [
fragdata(0) vec4 gnormal;
fragblend(0) vec4 gnormalblend;
]
] [result [
fragdata(0) vec4 gcolor;
fragdata(1) vec4 gnormal;
]])
uniform sampler2D diffusemap;
uniform vec4 colorparams;
varying vec4 texcoord0;
@(? (dtopt "n") [
uniform sampler2D normalmap;
varying mat3 world;
] [
varying vec3 nvec;
#define bumpblend vec4(1.0)
])
@(? (|| (dtopt "p") (dtopt "r")) [varying vec3 camvec;])
@(? (|| (dtopt "g") (dtopt "S")) [uniform sampler2D glowmap;])
@(? (dtopt "G") [flat varying float pulse;])
@(? (dtopt "r") [uniform samplerCube envmap;])
void main(void)
{
@(if (dtopt "n") [result [
@(? (dtopt "p") [
float height = texture2D(normalmap, texcoord0.xy).a;
vec3 camvecn = normalize(camvec);
vec2 dtc = texcoord0.xy + (camvecn * world).xy*(height*parallaxscale.x + parallaxscale.y);
] [
#define dtc texcoord0.xy
])
@(? (|| (! (dtopt "0")) (dtopt "r")) [
vec3 bump = texture2D(normalmap, dtc).rgb*2.0 - 1.0;
vec3 bumpw = world * bump;
#define nvec bumpw
])
]] [result [
#define dtc texcoord0.xy
]])
vec4 diffuse = texture2D(diffusemap, dtc);
@(if (dtopt "g") [result [
vec4 glowspec = texture2D(glowmap, dtc);
#define glow glowspec.rgb
#define spec glowspec.a
glow *= @(? (dtopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]);
glow *= diffuse.a;
]])
@(if (dtopt "0") [result [
@(if (&& (dtopt "S") [! (dtopt "g")]) [result [
float spec = @(? (|| (! (dtopt "n")) (dtopt "p")) [texture2D(glowmap, dtc).r] [texture2D(normalmap, dtc).a]);
]])
@(gspecpack [gloss.x] (if (dtopt "s") [? (dtopt "S") [spec * specscale.x] [specscale.x]]))
]])
@(if (dtopt "1") [
? (dtopt "g") [
vec3 gcolor = diffuse.rgb*colorparams.rgb;
]
] [result [
gcolor.rgb = diffuse.rgb*colorparams.rgb;
@(if (dtopt "r") [result [
@(? (|| (! (dtopt "n")) (! (dtopt "p"))) [
vec3 camvecn = normalize(camvec);
])
float invfresnel = dot(camvecn, nvec);
vec3 rvec = 2.0*nvec*invfresnel - camvecn;
vec3 reflect = textureCube(envmap, rvec).rgb * diffuse.a;
@(? (dtopt "R") [
vec3 rmod = envscale.xyz*spec;
] [
#define rmod envscale.xyz
])
reflect *= diffuse.a;
gcolor.rgb = mix(gcolor.rgb, reflect, rmod*clamp(1.0 - invfresnel, 0.0, 1.0));
]])
]])
@(if (dtopt "g") [gglowpack glow packnorm])
@(if (! (dtopt "0")) [result [
vec3 normal = normalize(nvec);
@(gnormpackdef normal packnorm)
]])
float inside = clamp(texcoord0.z, 0.0, 1.0) * clamp(texcoord0.w, 0.0, 1.0);
float alpha = inside * diffuse.a;
@(cond [dtopt "0"] [result [
gcolor.rgb *= inside;
gcolor.a *= alpha;
gcolorblend = vec4(alpha);
]] [dtopt "1"] [
? $usepacknorm [
gnormal.a = alpha * bumpblend.x;
] [
gnormalblend = vec4(alpha * bumpblend.x);
]
] [result [
gcolor.rgb *= inside;
gcolor.a = alpha;
@(? (dtopt "b") [
gnormal = vec4(0.0);
] [
gnormal.rgb *= alpha * bumpblend.x;
gnormal.a = alpha * bumpblend.x;
])
]])
}
]
]
decalshader = [
decaltype = $arg2
stype = (? (dtopt "e") 3 1)
defershader $stype $arg1 [
if $maxdualdrawbufs [
decalvariantshader @@arg1 @@(concatword $arg2 "0")
if @@(! (dtopt "b")) [
decalvariantshader @@@arg1 @@@(concatword $arg2 "1")
]
] [
decalvariantshader @@arg1 @@arg2
]
]
]
decalshader "stddecal" "b"
decalshader "specdecal" "bs"
decalshader "specmapdecal" "bsS"
decalshader "glowdecal" "g"
decalshader "pulseglowdecal" "gG"
decalshader "envdecal" "ber"
decalshader "envspecdecal" "besr"
decalshader "envspecmapdecal" "besSrR"
decalshader "envglowdecal" "erg"
decalshader "envpulseglowdecal" "ergG"
decalshader "bumpdecal" "n"
decalshader "bumpspecdecal" "ns"
decalshader "bumpspecmapdecal" "nsS"
decalshader "bumpglowdecal" "ng"
decalshader "bumpspecglowdecal" "nsg"
decalshader "bumpspecmapglowdecal" "nsSg"
decalshader "bumppulseglowdecal" "ngG"
decalshader "bumpspecpulseglowdecal" "nsgG"
decalshader "bumpspecmappulseglowdecal" "nsSgG"
decalshader "bumpparallaxdecal" "np"
decalshader "bumpspecparallaxdecal" "nps"
decalshader "bumpspecmapparallaxdecal" "npsS"
decalshader "bumpparallaxglowdecal" "npg"
decalshader "bumpspecparallaxglowdecal" "npsg"
decalshader "bumpspecmapparallaxglowdecal" "npsSg"
decalshader "bumpparallaxpulseglowdecal" "npgG"
decalshader "bumpspecparallaxpulseglowdecal" "npsgG"
decalshader "bumpspecmapparallaxpulseglowdecal" "npsSgG"
decalshader "bumpenvdecal" "ner"
decalshader "bumpenvspecdecal" "nesr"
decalshader "bumpenvspecmapdecal" "nesSrR"
decalshader "bumpenvglowdecal" "nerg"
decalshader "bumpenvspecglowdecal" "neosrg"
decalshader "bumpenvspecmapglowdecal" "nesSrRg"
decalshader "bumpenvpulseglowdecal" "neorgG"
decalshader "bumpenvspecpulseglowdecal" "nesrgG"
decalshader "bumpenvspecmappulseglowdecal" "nesSrRgG"
decalshader "bumpenvparallaxdecal" "nepr"
decalshader "bumpenvspecparallaxdecal" "nepsr"
decalshader "bumpenvspecmapparallaxdecal" "nepsSrR"
decalshader "bumpenvparallaxglowdecal" "neprg"
decalshader "bumpenvspecparallaxglowdecal" "nepsrg"
decalshader "bumpenvspecmapparallaxglowdecal" "nepsSrRg"
decalshader "bumpenvparallaxpulseglowdecal" "neprgG"
decalshader "bumpenvspecparallaxpulseglowdecal" "nepsrgG"
decalshader "bumpenvspecmapparallaxpulseglowdecal" "nepsSrRgG"

View File

@ -0,0 +1,688 @@
////////////////////////////////////////////////
//
// deferred shading
//
////////////////////////////////////////////////
msaadetectedges = [
result [{
@(if (glext "GL_EXT_shader_samples_identical") [result [
if(textureSamplesIdenticalEXT(tex1, ivec2(gl_FragCoord.xy)))
{
@arg1
}
else
]])
{
vec4 e = texelFetch(tex1, ivec2(gl_FragCoord.xy), 0);
e.xyz -= 0.5;
float maxdiff = 0.98*0.98*dot(e.xyz, e.xyz);
@(loopconcat+ i 1 (- $msaasamples 1) [result [
vec4 e@i = texelFetch(tex1, ivec2(gl_FragCoord.xy), @i);
e@i.xyz -= 0.5;
if(abs(e.w-e@i.w) <= 2.0/255.0 && pow(dot(e@i.xyz, e.xyz), 2.0) >= maxdiff*dot(e@i.xyz, e@i.xyz))
{
]])
@arg1
@(loopconcat+ i 1 (- $msaasamples 1) [result [
}
]])
}
}]
]
lazyshader 0 msaaedgedetect [
attribute vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
}
] [
@(? (glext "GL_EXT_shader_samples_identical") [
#extension GL_EXT_shader_samples_identical : enable
])
uniform sampler2DMS tex1;
void main(void)
{
@(msaadetectedges [discard;])
}
]
// deferredlighttype:
// p -> point-light shadow (default cubemap)
// c -> CSM
// a -> AO
// A -> AO sun
// r -> radiance hints
// G -> 5x5 weighted gather filter
// g -> 3x3 weighted gather filter
// E -> 5x5 weighted bilinear filter
// F -> 3x3 weighted bilinear filter
// f -> 4x rotated grid filter
// m -> minimap
// M -> multisampled
// O -> sample 1
// R -> manual resolve
// S -> sample shading
// T -> edge detection
// n -> tile batching
// s -> spotlights
// t -> transparent
// b -> combined base/light variants
// d -> avatar shadow dist bias variants
// D -> disable dist bias
// z -> spec toggle
dlopt = [ >= (strstr $deferredlighttype $arg1) 0 ]
unpacknormbias = 0.005
unpacknormscale = (+f 1 (*f 2 $unpacknormbias))
unpacknorm = [
result [
@arg1 = clamp(@arg1 * @(divf $unpacknormscale 0.5) - @(+f (*f $unpacknormscale (divf 0.25 0.5)) $unpacknormbias), 0.0, 1.0);
]
]
unpackspec = [
result [
vec3 camdir = normalize(camera - pos.xyz);
float facing = 2.0*dot(normal.xyz, camdir);
float specscale = min(3.0*(diffuse.a + 0.5/255.0), 2.999), gloss = floor(specscale);
specscale -= gloss;
specscale = (0.35 + 0.15*gloss) * specscale / (1.5 - specscale);
gloss = 5.0 + 17.0*gloss;
]
]
unpackdistbias = [
cond [$avatar] [result [
#define distbias -@avatarshadowbias
]] [|| $transparent [dlopt "d"] [dlopt "D"] [dlopt "m"]] [result [
#define distbias 0.0
]] [result [
float distbias = -@avatarshadowbias * @(? (dlopt "a") [avatarmask] [step(fogcoord, @avatarshadowdist) * @(? $msaasamples [step(0.75, normal.a)] [normal.a])]);
]]
]
deferredlightvariantshader = [
local deferredlighttype
deferredlighttype = $arg3
numsplits = (+ $arg4 0)
numrh = (+ $arg5 0)
numlights = (+ $arg6 0)
baselight = (< (mod $arg2 4) 2)
spotlight = (>= (mod $arg2 8) 4)
transparent = (<= 8 $arg2 16)
avatar = (<= 17 $arg2 31)
variantshader 0 $arg1 $arg2 (? (< $arg2 0) [
attribute vec4 vvertex;
uniform mat4 lightmatrix;
void main(void)
{
gl_Position = lightmatrix * vvertex;
}
]) [
@(? (&& (dlopt "S") [< $glslversion 400]) [
#extension GL_ARB_sample_shading : enable
])
@(? (&& (dlopt "T") [glext "GL_EXT_shader_samples_identical"]) [
#extension GL_EXT_shader_samples_identical : enable
])
@(if (dlopt "M") [result [
uniform sampler2DMS tex0, tex1, tex3 @(? $transparent [, tex2]);
]] [result [
uniform sampler2DRect tex0, tex1, tex3 @(? $transparent [, tex2]);
]])
@(if (|| (dlopt "p") (dlopt "c")) [
if (|| (dlopt "g") (dlopt "G")) [if (> $usetexgather 1) [result [
uniform sampler2DShadow tex4;
]] [result [
uniform sampler2D tex4;
]]] [result [
uniform sampler2DRectShadow tex4;
]]
])
@(if $numlights [result [
uniform vec4 lightpos[@@numlights];
uniform vec4 lightcolor[@@numlights];
@(if $spotlight [result [
uniform vec4 spotparams[@@numlights];
]])
@(if (dlopt "p") [result [
uniform vec4 shadowparams[@@numlights];
uniform vec2 shadowoffset[@@numlights];
]])
]])
@(if $numsplits [result [
uniform vec4 csmtc[@@numsplits];
uniform vec3 csmoffset[@@numsplits];
uniform vec2 csmz;
]])
@(if (dlopt "c") [result [
uniform mat3 csmmatrix;
uniform vec3 sunlightdir;
uniform vec3 sunlightcolor;
@(if (dlopt "r") [result [
uniform vec3 skylightcolor;
uniform float giscale, rhnudge, rhbounds;
uniform vec4 rhtc[@@numrh];
uniform sampler3D tex6, tex7, tex8, tex9;
]])
]])
uniform vec3 camera;
uniform mat4 worldmatrix;
uniform vec4 fogdir;
uniform vec3 fogcolor;
uniform vec2 fogdensity;
uniform vec4 radialfogscale;
uniform vec2 shadowatlasscale;
uniform vec4 lightscale;
@(? (&& (dlopt "a") [! $avatar] [! $transparent]) [uniform sampler2DRect tex5; uniform vec2 aoscale; uniform vec4 aoparams;])
@(gdepthunpackparams)
fragdata(0) vec4 fragcolor;
@(if (dlopt "p") [
? $spotlight [
vec3 getspottc(vec3 dir, float spotdist, vec4 spotparams, vec4 shadowparams, vec2 shadowoffset, float distbias)
{
vec2 mparams = shadowparams.xy / max(spotdist + distbias, 1e-5);
return vec3((dir.xy - spotparams.xy*(spotdist + (spotparams.z > 0.0 ? 1.0 : -1.0)*dir.z)*shadowparams.z) * mparams.x + shadowoffset, mparams.y + shadowparams.w);
}
] [
vec3 getshadowtc(vec3 dir, vec4 shadowparams, vec2 shadowoffset, float distbias)
{
vec3 adir = abs(dir);
float m = max(adir.x, adir.y), mz = max(adir.z, m);
vec2 mparams = shadowparams.xy / max(mz + distbias, 1e-5);
vec4 proj;
if(adir.x > adir.y) proj = vec4(dir.zyx, 0.0); else proj = vec4(dir.xzy, 1.0);
if(adir.z > m) proj = vec4(dir, 2.0);
return vec3(proj.xy * mparams.x + vec2(proj.w, step(0.0, proj.z)) * shadowparams.z + shadowoffset, mparams.y + shadowparams.w);
}
]
])
@(if (|| (dlopt "p") [dlopt "c"]) [
cond [dlopt "G"] [result [
@(? (> $usetexgather 1) [
#define shadowgather(center, xoff, yoff) textureGatherOffset(tex4, center, shadowtc.z, ivec2(xoff, yoff))
] [
#define shadowgather(center, xoff, yoff) step(shadowtc.z, textureGatherOffset(tex4, center, ivec2(xoff, yoff)))
])
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5), center = (shadowtc.xy - offset)*shadowatlasscale;
vec4 group1 = shadowgather(center, -2, -2);
vec4 group2 = shadowgather(center, 0, -2);
vec4 group3 = shadowgather(center, 2, -2);
vec4 group4 = shadowgather(center, -2, 0);
vec4 group5 = shadowgather(center, 0, 0);
vec4 group6 = shadowgather(center, 2, 0);
vec4 group7 = shadowgather(center, -2, 2);
vec4 group8 = shadowgather(center, 0, 2);
vec4 group9 = shadowgather(center, 2, 2);
vec4 locols = vec4(group1.ab, group3.ab);
vec4 hicols = vec4(group7.rg, group9.rg);
locols.yz += group2.ab;
hicols.yz += group8.rg;
vec4 midcols = vec4(group1.rg, group3.rg) + vec4(group7.ab, group9.ab) +
vec4(group4.rg, group6.rg) + vec4(group4.ab, group6.ab) +
mix(locols, hicols, offset.y);
vec4 cols = group5 + vec4(group2.rg, group8.ab);
cols.xyz += mix(midcols.xyz, midcols.yzw, offset.x);
return dot(cols, vec4(1.0/25.0));
}
]] [dlopt "g"] [result [
@(? (> $usetexgather 1) [
#define shadowgather(center, xoff, yoff) textureGatherOffset(tex4, center, shadowtc.z, ivec2(xoff, yoff))
] [
#define shadowgather(center, xoff, yoff) step(shadowtc.z, textureGatherOffset(tex4, center, ivec2(xoff, yoff)))
])
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5), center = (shadowtc.xy - offset)*shadowatlasscale;
vec4 group1 = shadowgather(center, -1, -1);
vec4 group2 = shadowgather(center, 1, -1);
vec4 group3 = shadowgather(center, -1, 1);
vec4 group4 = shadowgather(center, 1, 1);
vec4 cols = vec4(group1.rg, group2.rg) + vec4(group3.ab, group4.ab) + mix(vec4(group1.ab, group2.ab), vec4(group3.rg, group4.rg), offset.y);
return dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));
}
]] [dlopt "E"] [result [
#define shadowval(xy, xoff, yoff) float(shadow2DRect(tex4, vec3(xy + vec2(xoff, yoff), shadowtc.z)))
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5);
vec4 center = vec4(shadowtc.xy - offset + 0.5, shadowtc.xy - offset*0.5);
vec4 size = vec4(offset + 1.0, 2.0 - offset);
return (1.0/25.0)*dot(size.zxzx*size.wwyy,
vec4(shadowval(center.zw, -1.5, -1.5),
shadowval(center.zw, 2.0, -1.5),
shadowval(center.zw, -1.5, 2.0),
shadowval(center.zw, 2.0, 2.0))) +
(2.0/25.0)*dot(size,
vec4(shadowval(center.zy, 2.0, 0.0),
shadowval(center.xw, 0.0, 2.0),
shadowval(center.zy, -1.5, 0.0),
shadowval(center.xw, 0.0, -1.5))) +
(4.0/25.0)*shadowval(center.xy, 0.0, 0.0);
}
]] [dlopt "F"] [result [
#define shadowval(center, xoff, yoff) float(shadow2DRect(tex4, center + vec3(xoff, yoff, 0.0)))
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5);
vec3 center = shadowtc;
//center.xy -= offset;
//vec4 size = vec4(offset + 1.0, 2.0 - offset), weight = vec4(2.0 - 1.0 / size.xy, 1.0 / size.zw - 1.0);
//return (1.0/9.0)*dot(size.zxzx*size.wwyy,
// vec4(shadowval(center, weight.zw),
// shadowval(center, weight.xw),
// shadowval(center, weight.zy),
// shadowval(center, weight.xy)));
center.xy -= offset*0.5;
vec4 size = vec4(offset + 1.0, 2.0 - offset);
return (1.0/9.0)*dot(size.zxzx*size.wwyy,
vec4(shadowval(center, -0.5, -0.5),
shadowval(center, 1.0, -0.5),
shadowval(center, -0.5, 1.0),
shadowval(center, 1.0, 1.0)));
}
]] [dlopt "f"] [result [
#define shadowval(center, xoff, yoff) float(shadow2DRect(tex4, center + vec3(xoff, yoff, 0.0)))
float filtershadow(vec3 shadowtc)
{
return dot(vec4(0.25),
vec4(shadowval(shadowtc, -0.4, 1.0),
shadowval(shadowtc, -1.0, -0.4),
shadowval(shadowtc, 0.4, -1.0),
shadowval(shadowtc, 1.0, 0.4)));
}
]] [result [
#define filtershadow(shadowtc) float(shadow2DRect(tex4, shadowtc))
]]
])
@(if (dlopt "c") [result [
vec3 getcsmtc(vec3 pos, float distbias)
{
vec3 tc, offset;
pos = csmmatrix * pos;
pos.z -= distbias;
tc.z = csmz.x + pos.z*csmz.y;
@(loopconcat j $numsplits [result [
tc.xy = csmtc[@@j].xy + pos.xy*csmtc[@@j].z;
offset = csmoffset[@@j];
if(max(abs(tc.x), abs(tc.y)) >= csmtc[@@j].w)
{
]])
offset = vec3(-16384.0);
@(loopconcat j $numsplits [result [
}
]])
return tc + offset;
}
@(if (dlopt "r") [result [
vec4 getrhlight(vec3 pos, vec3 norm)
{
vec3 tc;
float offset;
pos += norm*rhnudge;
@(loopconcat j $numrh [result [
tc = rhtc[@@j].xyz + pos*rhtc[@@j].w;
offset = @(divf (+f 0.5 $j) $numrh);
if(max(max(abs(tc.x), abs(tc.y)), abs(tc.z)) >= rhbounds)
{
]])
tc = vec3(4.0);
@(loopconcat j $numrh [result [
}
]])
tc.xy += 0.5;
tc.z = tc.z * @(divf 1 $numrh) + offset;
vec4 shr = texture3D(tex6, tc), shg = texture3D(tex7, tc), shb = texture3D(tex8, tc), sha = texture3D(tex9, tc);
shr.rgb -= 0.5;
shg.rgb -= 0.5;
shb.rgb -= 0.5;
sha.rgb -= 0.5;
vec4 basis = vec4(norm*-(1.023326*0.488603/3.14159*2.0), (0.886226*0.282095/3.14159));
return clamp(vec4(dot(basis, shr), dot(basis, shg), dot(basis, shb), min(dot(basis, sha), norm.z + 1.0)), 0.0, 1.0);
}
]])
]])
void main(void)
{
@(if (dlopt "M") [
if (dlopt "R") [result [
@(if (dlopt "T") [result [
bool shouldresolve = true;
@(msaadetectedges [shouldresolve = false;])
]])
#define gfetch(sampler, coords) texelFetch(sampler, ivec2(coords), sampleidx)
vec4 resolved = vec4(0.0);
#define accumlight(light) resolved.rgb += light
#define accumalpha(alpha) resolved.a += alpha
@(if (&& [dlopt "a"] [! $avatar] [! $transparent]) [result [
float ao = texture2DRect(tex5, gl_FragCoord.xy*aoscale).r;
]])
for(int sampleidx = 0; sampleidx < @msaasamples; sampleidx++)
{
]] [result [
@(if (dlopt "T") [msaadetectedges [discard;]])
#define gfetch(sampler, coords) texelFetch(sampler, ivec2(coords), @(? (dlopt "S") [gl_SampleID] (? (dlopt "O") 1 0)))
#define accumlight(light) fragcolor.rgb = light
#define accumalpha(alpha) fragcolor.a = alpha
]]
] [result [
#define gfetch(sampler, coords) texture2DRect(sampler, coords)
#define accumlight(light) fragcolor.rgb = light
#define accumalpha(alpha) fragcolor.a = alpha
]])
@(if (|| $baselight [> $numlights 1]) [result [
vec4 normal = gfetch(tex1, gl_FragCoord.xy);
@(if $transparent [result [
@(? (! $ghasstencil) [
if(normal.x + normal.y == 0.0) discard;
])
normal.xyz = normal.xyz*2.0 - 1.0;
@(if $usepacknorm [result [
float alpha = dot(normal.xyz, normal.xyz);
normal.xyz *= inversesqrt(alpha);
@(if $baselight [unpacknorm alpha])
]] [result [
#define alpha normal.a
]])
vec4 diffuse = gfetch(tex0, gl_FragCoord.xy);
@(? $baselight [
vec3 glow = gfetch(tex2, gl_FragCoord.xy).rgb;
])
]] [result [
@(? $baselight [
float alpha = float(normal.x + normal.y != 0.0);
] [
#define alpha 1.0
])
normal.xyz = normal.xyz*2.0 - 1.0;
@(if $usepacknorm [result [
float glowscale = dot(normal.xyz, normal.xyz);
normal.xyz *= inversesqrt(glowscale);
@(unpacknorm glowscale)
]] [result [
#define glowscale normal.a
]])
vec4 diffuse = gfetch(tex0, gl_FragCoord.xy);
@(? $baselight [
vec3 glow = diffuse.rgb * (1.0 - glowscale);
])
diffuse.rgb *= glowscale;
]])
]])
@(if (dlopt "m") [if (+ $numlights (dlopt "c")) [
gdepthunpackortho depth [gfetch(tex3, gl_FragCoord.xy)] [
vec3 pos = (worldmatrix * vec4(gl_FragCoord.xy, depth, 1.0)).xyz;
]
]] [if (+ $numlights (dlopt "c")) [result [
@(gdepthunpack depth [gfetch(tex3, gl_FragCoord.xy)] [
vec3 pos = (worldmatrix * vec4(depth*gl_FragCoord.xy, depth, 1.0)).xyz;
] [
vec4 pos = worldmatrix * vec4(gl_FragCoord.xy, depth, 1.0);
pos.xyz /= pos.w;
])
@(? (|| $baselight [> $numlights 1]) [
float fogcoord = length(camera - pos.xyz);
])
@(if (> (+ $numlights (dlopt "c")) 1) [unpackspec])
]] [result [
@(gdepthunpack depth [gfetch(tex3, gl_FragCoord.xy)])
@(? $baselight [
float fogcoord = -depth*length(vec3(gl_FragCoord.xy*radialfogscale.xy + radialfogscale.zw, 1.0));
])
]]])
@(if $baselight [result [
vec3 light = lightscale.rgb;
@(? (dlopt "r") [
vec4 rhlight = getrhlight(pos.xyz, normal.xyz);
light += rhlight.a * skylightcolor;
])
light *= diffuse.rgb;
@(if (&& (dlopt "a") [! $avatar] [! $transparent]) [result [
@(? (! (&& (dlopt "M") [dlopt "R"])) [
float ao = texture2DRect(tex5, gl_FragCoord.xy*aoscale).r;
])
@(if (dlopt "d") [result [
#define aomask ao
]] [result [
float avatarmask = step(fogcoord, @avatarshadowdist) * @(? $msaasamples [step(0.75, normal.a)] [normal.a]);
float aomask = clamp(ao + avatarmask, 0.0, 1.0);
]])
light *= aoparams.x + aomask*aoparams.y;
]])
light += glow * lightscale.a;
]] [result [
vec3 light = vec3(0.0);
]])
@(if (> (+ (? (dlopt "p") $numlights) (dlopt "c")) 1) [unpackdistbias])
@(if (dlopt "c") [result [
@(? (dlopt "r") [
vec3 sunlight = rhlight.rgb * giscale * diffuse.rgb;
])
float sunfacing = dot(sunlightdir, normal.xyz);
if(sunfacing > 0.0)
{
@(if (= (+ (? (dlopt "p") $numlights) (dlopt "c")) 1) [unpackdistbias])
vec3 csmtc = getcsmtc(pos.xyz, distbias);
float sunoccluded = filtershadow(csmtc);
@(if (dlopt "m") [result [
light += diffuse.rgb*sunfacing * sunlightcolor * sunoccluded;
]] [result [
@(if (= (+ $numlights (dlopt "c")) 1) [unpackspec])
float sunspec = pow(clamp(sunfacing*facing - dot(camdir, sunlightdir), 0.0, 1.0), gloss) * specscale;
@(if (dlopt "r") [result [
sunlight += (diffuse.rgb*sunfacing + sunspec) * sunoccluded;
]] [result [
@(? (&& (dlopt "A") [! $avatar] [! $transparent]) [
sunoccluded *= aoparams.z + aomask*aoparams.w;
])
light += (diffuse.rgb*sunfacing + sunspec) * sunoccluded * sunlightcolor;
]])
]])
}
@(if (dlopt "r") [result [
@(? (&& (dlopt "A") [! $avatar] [! $transparent]) [
sunlight *= aoparams.z + aomask*aoparams.w;
])
light += sunlight * sunlightcolor;
]])
]])
@(loopconcat j $numlights [result [
vec3 light@[j]dir = lightpos[@@j].xyz - pos.xyz * lightpos[@@j].w;
float light@[j]dist2 = dot(light@[j]dir, light@[j]dir);
if(light@[j]dist2 < 1.0)
{
@(if (= (+ $numlights $baselight) 1) [result [
vec4 normal = gfetch(tex1, gl_FragCoord.xy);
@(? (&& $transparent [! $ghasstencil]) [
if(normal.x + normal.y == 0.0) discard;
])
normal.xyz = normal.xyz*2.0 - 1.0;
@(? $usepacknorm [
float glowscale = dot(normal.xyz, normal.xyz);
normal.xyz *= inversesqrt(glowscale);
] [
#define glowscale normal.a
])
]])
float light@[j]facing = dot(light@[j]dir, normal.xyz);
if(light@[j]facing > 0.0)
{
float light@[j]invdist = inversesqrt(light@[j]dist2);
@(if $spotlight [result [
float spot@[j]dist = dot(light@[j]dir, spotparams[@@j].xyz);
float spot@[j]atten = 1.0 - (1.0 - light@[j]invdist * spot@[j]dist) * spotparams[@@j].w;
if(spot@[j]atten > 0.0)
{
]])
float light@[j]atten = 1.0 - light@[j]dist2 * light@[j]invdist;
@(? (&& (= (+ $numlights $baselight) 1) [! (dlopt "m")]) [
float fogcoord = length(camera - pos.xyz);
])
@(if (= (+ (? (dlopt "p") $numlights) (dlopt "c")) 1) [unpackdistbias])
@(if $spotlight [
if (dlopt "p") [result [
vec3 spot@[j]tc = getspottc(light@[j]dir, spot@[j]dist, spotparams[@@j], shadowparams[@@j], shadowoffset[@@j], distbias * lightpos[@@j].w);
light@[j]atten *= spot@[j]atten * filtershadow(spot@[j]tc);
]] [result [
light@[j]atten *= spot@[j]atten;
]]
] [
if (dlopt "p") [result [
vec3 shadow@[j]tc = getshadowtc(light@[j]dir, shadowparams[@@j], shadowoffset[@@j], distbias * lightpos[@@j].w);
light@[j]atten *= filtershadow(shadow@[j]tc);
]]
])
@(if (= (+ $numlights $baselight) 1) [result [
vec4 diffuse = gfetch(tex0, gl_FragCoord.xy);
@(if (! $transparent) [result [
@(if $usepacknorm [unpacknorm glowscale])
diffuse.rgb *= glowscale;
]])
]])
light@[j]facing *= light@[j]invdist;
@(if (dlopt "m") [result [
light += diffuse.rgb*light@[j]facing * lightcolor[@@j].rgb * light@[j]atten;
]] [result [
@(if (= (+ $numlights (dlopt "c")) 1) [unpackspec])
float light@[j]spec = pow(clamp(light@[j]facing*facing - light@[j]invdist*dot(camdir, light@[j]dir), 0.0, 1.0), gloss) * specscale;
@(if (dlopt "z") [result [
light@[j]spec *= lightcolor[@@j].a;
]])
light += (diffuse.rgb*light@[j]facing + light@[j]spec) * lightcolor[@@j].rgb * light@[j]atten;
@(? (= (+ $numlights $baselight) 1) [
float foglerp = clamp(exp2(fogcoord*fogdensity.x)*fogdensity.y, 0.0, 1.0);
light *= foglerp;
])
]])
@(? $spotlight [}])
}
}
]])
@(if (dlopt "m") [if $baselight [result [
accumlight(light);
accumalpha(alpha);
]] [result [
accumlight(light);
accumalpha(0.0);
]]] [if (|| $baselight [> $numlights 1]) [result [
float foglerp = clamp(exp2(fogcoord*fogdensity.x)*fogdensity.y, 0.0, 1.0);
@(? $baselight [
accumlight(mix(fogcolor*alpha, light, foglerp));
accumalpha(alpha);
] [
accumlight(light*foglerp);
accumalpha(0.0);
])
]] [result [
accumlight(light);
accumalpha(0.0);
]]])
@(if (dlopt "R") [result [
@(? (dlopt "T") [if(!shouldresolve) break;])
}
@(? (dlopt "T") [if(shouldresolve)]) resolved *= @(divf 1 $msaasamples);
fragcolor = resolved;
]])
}
] $arg7
]
deferredlightshader = [
deferredlighttype = (concatword $arg1 $arg2 $arg3)
shadername = (concatword "deferredlight" $deferredlighttype)
basevariants = (* (max $arg6 1) 2 (? (dlopt "b") 2 1) (? (dlopt "s") 2 1))
maxvariants = $basevariants
if (dlopt "t") [maxvariants = (+ $maxvariants $basevariants 1)]
if (dlopt "d") [maxvariants = (+ $maxvariants $basevariants 1)]
deferredlightvariantshader $shadername -1 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // base shader, no points lights, sunlight
if (dlopt "t") [
deferredlightvariantshader $shadername 16 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // row 16, trasparency, base shader, no points lights, sunlight
]
if (dlopt "d") [
deferredlightvariantshader $shadername 17 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // row 17, avatar, base shader, no points lights, sunlight
]
loop+ i 1 (max $arg6 1) [
if (dlopt "b") [
deferredlightvariantshader $shadername 0 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 0, point lights, sunlight
deferredlightvariantshader $shadername 1 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 1, shadowed point lights, sunlight
]
deferredlightvariantshader $shadername 2 $arg1 $arg4 $arg5 $i $maxvariants // row 2, point lights
deferredlightvariantshader $shadername 3 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 3, shadowed point lights
if (dlopt "s") [
if (dlopt "b") [
deferredlightvariantshader $shadername 4 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 4, spot lights, sunlight
deferredlightvariantshader $shadername 5 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 5, shadowed spot lights, sunlight
]
deferredlightvariantshader $shadername 6 $arg1 $arg4 $arg5 $i $maxvariants // row 6, spot lights
deferredlightvariantshader $shadername 7 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 7, shadowed spot lights
]
if (dlopt "t") [
if (dlopt "b") [
deferredlightvariantshader $shadername 8 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 8, transparent, point lights, sunlight
deferredlightvariantshader $shadername 9 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 9, transparent, shadowed point lights, sunlight
]
deferredlightvariantshader $shadername 10 $arg1 $arg4 $arg5 $i $maxvariants // row 10, transparent, point lights
deferredlightvariantshader $shadername 11 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 11, transparent, shadowed point lights
if (dlopt "s") [
if (dlopt "b") [
deferredlightvariantshader $shadername 12 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 12, transparent, spot lights, sunlight
deferredlightvariantshader $shadername 13 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 13, transparent, shadowed spot lights, sunlight
]
deferredlightvariantshader $shadername 14 $arg1 $arg4 $arg5 $i $maxvariants // row 14, transparent, spot lights
deferredlightvariantshader $shadername 15 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 15, transparent, shadowed spot lights
]
]
if (dlopt "d") [
if (dlopt "b") [
deferredlightvariantshader $shadername 24 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 24, avatar, point lights, sunlight
deferredlightvariantshader $shadername 25 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 25, avatar, shadowed point lights, sunlight
]
deferredlightvariantshader $shadername 26 $arg1 $arg4 $arg5 $i $maxvariants // row 26, avatar, point lights
deferredlightvariantshader $shadername 27 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 27, avatar, shadowed point lights
if (dlopt "s") [
if (dlopt "b") [
deferredlightvariantshader $shadername 28 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 28, avatar, spot lights, sunlight
deferredlightvariantshader $shadername 29 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 29, avatar, shadowed spot lights, sunlight
]
deferredlightvariantshader $shadername 30 $arg1 $arg4 $arg5 $i $maxvariants // row 30, avatar, spot lights
deferredlightvariantshader $shadername 31 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 31, avatar, shadowed spot lights
]
]
]
]

View File

@ -0,0 +1,61 @@
////////////////////////////////////////////////
//
// miscellaneous edit shaders
//
////////////////////////////////////////////////
shader 0 "blendbrush" [
attribute vec4 vvertex, vcolor;
uniform mat4 camprojmatrix;
uniform vec4 texgenS, texgenT;
uniform float ldrscale;
varying vec4 color;
varying vec2 texcoord0;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
color = vec4(ldrscale * vcolor.rgb, vcolor.a);
texcoord0 = vec2(dot(texgenS, vvertex), dot(texgenT, vvertex));
}
] [
uniform sampler2D tex0;
varying vec4 color;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = texture2D(tex0, texcoord0).r * color;
}
]
lazyshader 0 "prefab" [
attribute vec4 vvertex, vcolor;
attribute vec3 vnormal;
uniform mat4 prefabmatrix;
uniform mat3 prefabworld;
varying vec3 nvec;
varying vec4 color;
@(msaainterpvert)
void main(void)
{
gl_Position = prefabmatrix * vvertex;
color = vcolor;
nvec = prefabworld * vnormal;
@(msaapackvert)
}
] [
varying vec3 nvec;
varying vec4 color;
@(msaainterpfrag)
void main(void)
{
gcolor.rgb = color.rgb;
gcolor.a = 0.0;
vec3 normal = normalize(nvec);
@(gnormpackdef normal packnorm)
@(msaapackfrag)
}
]

View File

@ -0,0 +1,375 @@
//
// NVIDIA FXAA 3.11 by TIMOTHY LOTTES
//
// ------------------------------------------------------------------------------
// COPYRIGHT (C) 2010, 2011 NVIDIA CORPORATION. ALL RIGHTS RESERVED.
// ------------------------------------------------------------------------------
// TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
// *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA
// OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR
// CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR
// LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION,
// OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE
// THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGES.
fxaadefs = [
@(if (fxaaopt "g") [result [
#define FXAA_LUMA(color) (color.g)
]] [result [
#define FXAA_LUMA(color) (color.a)
]])
@(case $fxaapreset 0 [result [
#define FXAA_QUALITY_PRESET 10
#define fxaaQualityEdgeThreshold 0.250
#define fxaaQualityEdgeThresholdMin 0.0833
]] 1 [result [
#define FXAA_QUALITY_PRESET 12
#define fxaaQualityEdgeThreshold 0.166
#define fxaaQualityEdgeThresholdMin 0.0833
]] 2 [result [
#define FXAA_QUALITY_PRESET 24
#define fxaaQualityEdgeThreshold 0.125
#define fxaaQualityEdgeThresholdMin 0.0625
]] 3 [result [
#define FXAA_QUALITY_PRESET 39
#define fxaaQualityEdgeThreshold 0.063
#define fxaaQualityEdgeThresholdMin 0.0312
]])
#define fxaaQualitySubpix 0.75
#if (FXAA_QUALITY_PRESET == 10)
#define FXAA_QUALITY_PS 3
#define FXAA_QUALITY_P0 1.5
#define FXAA_QUALITY_P1 3.0
#define FXAA_QUALITY_P2 12.0
#endif
#if (FXAA_QUALITY_PRESET == 11)
#define FXAA_QUALITY_PS 4
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 3.0
#define FXAA_QUALITY_P3 12.0
#endif
#if (FXAA_QUALITY_PRESET == 12)
#define FXAA_QUALITY_PS 5
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 4.0
#define FXAA_QUALITY_P4 12.0
#endif
#if (FXAA_QUALITY_PRESET == 13)
#define FXAA_QUALITY_PS 6
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 4.0
#define FXAA_QUALITY_P5 12.0
#endif
#if (FXAA_QUALITY_PRESET == 14)
#define FXAA_QUALITY_PS 7
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 4.0
#define FXAA_QUALITY_P6 12.0
#endif
#if (FXAA_QUALITY_PRESET == 15)
#define FXAA_QUALITY_PS 8
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 4.0
#define FXAA_QUALITY_P7 12.0
#endif
#if (FXAA_QUALITY_PRESET == 20)
#define FXAA_QUALITY_PS 3
#define FXAA_QUALITY_P0 1.5
#define FXAA_QUALITY_P1 2.0
#define FXAA_QUALITY_P2 8.0
#endif
#if (FXAA_QUALITY_PRESET == 21)
#define FXAA_QUALITY_PS 4
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 8.0
#endif
#if (FXAA_QUALITY_PRESET == 22)
#define FXAA_QUALITY_PS 5
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 8.0
#endif
#if (FXAA_QUALITY_PRESET == 23)
#define FXAA_QUALITY_PS 6
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 8.0
#endif
#if (FXAA_QUALITY_PRESET == 24)
#define FXAA_QUALITY_PS 7
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 3.0
#define FXAA_QUALITY_P6 8.0
#endif
#if (FXAA_QUALITY_PRESET == 25)
#define FXAA_QUALITY_PS 8
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 4.0
#define FXAA_QUALITY_P7 8.0
#endif
#if (FXAA_QUALITY_PRESET == 26)
#define FXAA_QUALITY_PS 9
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 4.0
#define FXAA_QUALITY_P8 8.0
#endif
#if (FXAA_QUALITY_PRESET == 27)
#define FXAA_QUALITY_PS 10
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 4.0
#define FXAA_QUALITY_P9 8.0
#endif
#if (FXAA_QUALITY_PRESET == 28)
#define FXAA_QUALITY_PS 11
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 2.0
#define FXAA_QUALITY_P9 4.0
#define FXAA_QUALITY_P10 8.0
#endif
#if (FXAA_QUALITY_PRESET == 29)
#define FXAA_QUALITY_PS 12
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 2.0
#define FXAA_QUALITY_P9 2.0
#define FXAA_QUALITY_P10 4.0
#define FXAA_QUALITY_P11 8.0
#endif
#if (FXAA_QUALITY_PRESET == 39)
#define FXAA_QUALITY_PS 12
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.0
#define FXAA_QUALITY_P2 1.0
#define FXAA_QUALITY_P3 1.0
#define FXAA_QUALITY_P4 1.0
#define FXAA_QUALITY_P5 1.5
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 2.0
#define FXAA_QUALITY_P9 2.0
#define FXAA_QUALITY_P10 4.0
#define FXAA_QUALITY_P11 8.0
#endif
]
shader 0 [fxaa@fxaapreset@fxaaopts] [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
@fxaadefs
varying vec2 texcoord0;
uniform sampler2DRect tex0;
fragdata(0) vec4 fragcolor;
void main(void)
{
#define posM texcoord0
vec4 rgbyM = texture2DRect(tex0, posM);
float lumaS = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 0, 1)));
float lumaE = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 1, 0)));
float lumaN = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 0, -1)));
float lumaW = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2(-1, 0)));
#define lumaM FXAA_LUMA(rgbyM)
float maxSM = max(lumaS, lumaM);
float minSM = min(lumaS, lumaM);
float maxESM = max(lumaE, maxSM);
float minESM = min(lumaE, minSM);
float maxWN = max(lumaN, lumaW);
float minWN = min(lumaN, lumaW);
float rangeMax = max(maxWN, maxESM);
float rangeMin = min(minWN, minESM);
float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;
float range = rangeMax - rangeMin;
float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);
bool earlyExit = range < rangeMaxClamped;
if(earlyExit)
{
fragcolor = rgbyM;
return;
}
float lumaNW = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2(-1, -1)));
float lumaSE = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 1, 1)));
float lumaNE = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 1, -1)));
float lumaSW = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2(-1, 1)));
float lumaNS = lumaN + lumaS;
float lumaWE = lumaW + lumaE;
float subpixRcpRange = 1.0/range;
float subpixNSWE = lumaNS + lumaWE;
float edgeHorz1 = (-2.0 * lumaM) + lumaNS;
float edgeVert1 = (-2.0 * lumaM) + lumaWE;
float lumaNESE = lumaNE + lumaSE;
float lumaNWNE = lumaNW + lumaNE;
float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;
float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;
float lumaNWSW = lumaNW + lumaSW;
float lumaSWSE = lumaSW + lumaSE;
float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);
float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);
float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;
float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;
float edgeHorz = abs(edgeHorz3) + edgeHorz4;
float edgeVert = abs(edgeVert3) + edgeVert4;
float subpixNWSWNESE = lumaNWSW + lumaNESE;
bool horzSpan = edgeHorz >= edgeVert;
float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
if(!horzSpan) lumaN = lumaW;
if(!horzSpan) lumaS = lumaE;
float subpixB = (subpixA * (1.0/12.0)) - lumaM;
float gradientN = lumaN - lumaM;
float gradientS = lumaS - lumaM;
float lumaNN = lumaN + lumaM;
float lumaSS = lumaS + lumaM;
bool pairN = abs(gradientN) >= abs(gradientS);
float gradient = max(abs(gradientN), abs(gradientS));
float lengthSign = pairN ? -1.0 : 1.0;
float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);
vec2 posB = posM;
vec2 offNP;
offNP.x = (!horzSpan) ? 0.0 : 1.0;
offNP.y = ( horzSpan) ? 0.0 : 1.0;
if(!horzSpan) posB.x += lengthSign * 0.5;
if( horzSpan) posB.y += lengthSign * 0.5;
vec2 posN = posB - offNP * FXAA_QUALITY_P0;
vec2 posP = posB + offNP * FXAA_QUALITY_P0;
float subpixD = ((-2.0)*subpixC) + 3.0;
float lumaEndN = FXAA_LUMA(texture2DRect(tex0, posN));
float subpixE = subpixC * subpixC;
float lumaEndP = FXAA_LUMA(texture2DRect(tex0, posP));
if(!pairN) lumaNN = lumaSS;
float gradientScaled = gradient * 1.0/4.0;
float lumaMM = lumaM - lumaNN * 0.5;
float subpixF = subpixD * subpixE;
bool lumaMLTZero = lumaMM < 0.0;
lumaEndN -= lumaNN * 0.5;
lumaEndP -= lumaNN * 0.5;
bool contN = abs(lumaEndN) < gradientScaled;
bool contP = abs(lumaEndP) < gradientScaled;
if(contN) posN -= offNP * FXAA_QUALITY_P1;
if(contP) posP += offNP * FXAA_QUALITY_P1;
@(loopconcat+ i 2 10 [result [
#if (FXAA_QUALITY_PS > @i)
if(contN || contP)
{
if(contN) lumaEndN = FXAA_LUMA(texture2DRect(tex0, posN));
if(contP) lumaEndP = FXAA_LUMA(texture2DRect(tex0, posP));
if(contN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(contP) lumaEndP = lumaEndP - lumaNN * 0.5;
contN = abs(lumaEndN) < gradientScaled;
contP = abs(lumaEndP) < gradientScaled;
if(contN) posN -= offNP * FXAA_QUALITY_P@i;
if(contP) posP += offNP * FXAA_QUALITY_P@i;
]])
@(loopconcat+ i 2 10 [result [
}
#endif
]])
float dstN = posM.x - posN.x;
float dstP = posP.x - posM.x;
if(!horzSpan) dstN = posM.y - posN.y;
if(!horzSpan) dstP = posP.y - posM.y;
bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;
float spanLength = (dstP + dstN);
bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;
float spanLengthRcp = 1.0/spanLength;
bool directionN = dstN < dstP;
float dst = min(dstN, dstP);
bool goodSpan = directionN ? goodSpanN : goodSpanP;
float subpixG = subpixF * subpixF;
float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;
float subpixH = subpixG * fxaaQualitySubpix;
float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;
float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
vec2 posS = posM;
if(!horzSpan) posS.x += pixelOffsetSubpix * lengthSign;
if( horzSpan) posS.y += pixelOffsetSubpix * lengthSign;
fragcolor = texture2DRect(tex0, posS);
}
]

313
config/glsl/gi.cfg 100644
View File

@ -0,0 +1,313 @@
////////////////////////////////////////////////
//
// radiance hints
//
////////////////////////////////////////////////
lazyshader 0 "rsmsky" [
attribute vec4 vvertex;
uniform mat4 rsmmatrix;
void main(void)
{
gl_Position = rsmmatrix * vvertex;
}
] [
fragdata(0) vec4 gcolor;
fragdata(1) vec4 gnormal;
void main(void)
{
gcolor = vec4(0.0, 0.0, 0.0, 1.0);
gnormal = vec4(0.5, 0.5, 0.5, 0.0);
}
]
rhtapoffsets12 = [
"0.0565813, 0.61211, 0.763359"
"0.375225, 0.285592, 0.987915"
"0.615192, 0.668996, 0.604938"
"0.963195, 0.355937, 0.175787"
"0.0295724, 0.484268, 0.265694"
"0.917783, 0.88702, 0.201972"
"0.408948, 0.0675985, 0.427564"
"0.19071, 0.923612, 0.0553606"
"0.968078, 0.403943, 0.847224"
"0.384503, 0.922269, 0.990844"
"0.480605, 0.342418, 0.00195318"
"0.956664, 0.923643, 0.915799"
]
rhtapoffsets20 = [
"0.0540788, 0.411725, 0.134068"
"0.0163579, 0.416211, 0.992035"
"0.692068, 0.549272, 0.886502"
"0.305795, 0.781854, 0.571337"
"0.791681, 0.139042, 0.247047"
"0.83929, 0.973663, 0.460982"
"0.0336314, 0.0867641, 0.582324"
"0.148198, 0.961974, 0.0378124"
"0.948729, 0.0713828, 0.916379"
"0.586413, 0.591845, 0.031251"
"0.00189215, 0.973968, 0.932981"
"0.435865, 0.0853603, 0.995148"
"0.36848, 0.820612, 0.942717"
"0.500107, 0.0658284, 0.623005"
"0.580187, 0.4485, 0.379223"
"0.258614, 0.0201422, 0.241005"
"0.987152, 0.441664, 0.43318"
"0.925108, 0.917203, 0.921506"
"0.988372, 0.822047, 0.12479"
"0.330393, 0.43611, 0.762566"
]
rhtapoffsets32 = [
"0.0553911, 0.675924, 0.22129"
"0.562975, 0.508286, 0.549883"
"0.574816, 0.703452, 0.0513016"
"0.981017, 0.930479, 0.243873"
"0.889309, 0.133091, 0.319071"
"0.329112, 0.00759911, 0.472213"
"0.314463, 0.985839, 0.54442"
"0.407697, 0.202643, 0.985748"
"0.998169, 0.760369, 0.792932"
"0.0917692, 0.0666829, 0.0169683"
"0.0157781, 0.632954, 0.740806"
"0.938139, 0.235878, 0.87936"
"0.442305, 0.184942, 0.0901212"
"0.578051, 0.863948, 0.799554"
"0.0698569, 0.259194, 0.667592"
"0.872494, 0.576312, 0.344157"
"0.10123, 0.930082, 0.959929"
"0.178594, 0.991302, 0.046205"
"0.690176, 0.527543, 0.930509"
"0.982025, 0.389447, 0.0344554"
"0.033845, 0.0156865, 0.963866"
"0.655293, 0.154271, 0.640553"
"0.317881, 0.598621, 0.97998"
"0.247261, 0.398206, 0.121586"
"0.822626, 0.985076, 0.655232"
"0.00201422, 0.434278, 0.388348"
"0.511399, 0.977416, 0.278695"
"0.32371, 0.540147, 0.361187"
"0.365856, 0.41493, 0.758232"
"0.792871, 0.979217, 0.0309763"
"0.0509049, 0.459151, 0.996277"
"0.0305185, 0.13422, 0.306009"
]
rsmtapoffsets12 = [
"0.031084, 0.572114"
"0.040671, 0.95653"
"0.160921, 0.367819"
"0.230518, 0.134321"
"0.247078, 0.819415"
"0.428665, 0.440522"
"0.49846, 0.80717"
"0.604285, 0.0307766"
"0.684075, 0.283001"
"0.688304, 0.624171"
"0.833995, 0.832414"
"0.975397, 0.189911"
]
rsmtapoffsets20 = [
"0.00240055, 0.643992"
"0.0356464, 0.851616"
"0.101733, 0.21876"
"0.166119, 0.0278085"
"0.166438, 0.474999"
"0.24991, 0.766405"
"0.333714, 0.130407"
"0.400681, 0.374781"
"0.424067, 0.888211"
"0.448511, 0.678962"
"0.529383, 0.213568"
"0.608569, 0.47715"
"0.617996, 0.862528"
"0.631784, 0.0515881"
"0.740969, 0.20753"
"0.788203, 0.41923"
"0.794066, 0.615141"
"0.834504, 0.836612"
"0.89446, 0.0677863"
"0.975609, 0.446056"
]
rsmtapoffsets32 = [
"0.0262032, 0.215221"
"0.0359769, 0.0467256"
"0.0760799, 0.713481"
"0.115087, 0.461431"
"0.119488, 0.927444"
"0.22346, 0.319747"
"0.225964, 0.679227"
"0.238626, 0.0618425"
"0.243326, 0.535066"
"0.29832, 0.90826"
"0.335208, 0.212103"
"0.356438, 0.751969"
"0.401021, 0.478664"
"0.412027, 0.0245297"
"0.48477, 0.320659"
"0.494311, 0.834621"
"0.515007, 0.165552"
"0.534574, 0.675536"
"0.585357, 0.432483"
"0.600102, 0.94139"
"0.650182, 0.563571"
"0.672336, 0.771816"
"0.701811, 0.187078"
"0.734207, 0.359024"
"0.744775, 0.924466"
"0.763628, 0.659075"
"0.80735, 0.521281"
"0.880585, 0.107684"
"0.898505, 0.904047"
"0.902536, 0.718989"
"0.928022, 0.347802"
"0.971243, 0.504885"
]
radiancehintsshader = [
numtaps = (cond [> $arg1 20] 32 [> $arg1 12] 20 12)
shader 0 [radiancehints@arg1] [
attribute vec4 vvertex;
attribute vec3 vtexcoord0;
uniform mat4 rsmtcmatrix;
varying vec3 rhcenter;
varying vec2 rsmcenter;
void main(void)
{
gl_Position = vvertex;
rhcenter = vtexcoord0;
rsmcenter = (rsmtcmatrix * vec4(vtexcoord0, 1.0)).xy;
}
] [
uniform sampler2DRect tex0, tex1, tex2;
uniform mat4 rsmworldmatrix;
uniform vec2 rsmspread;
uniform float rhatten, rhspread, rhaothreshold, rhaoatten, rhaoheight;
uniform vec3 rsmdir;
varying vec3 rhcenter;
varying vec2 rsmcenter;
fragdata(0) vec4 rhr;
fragdata(1) vec4 rhg;
fragdata(2) vec4 rhb;
fragdata(3) vec4 rha;
void calcrhsample(vec3 rhtap, vec2 rsmtap, inout vec4 shr, inout vec4 shg, inout vec4 shb, inout vec4 sha)
{
vec3 rhpos = rhcenter + rhtap*rhspread;
vec2 rsmtc = rsmcenter + rsmtap*rsmspread;
float rsmdepth = texture2DRect(tex0, rsmtc).x;
vec3 rsmcolor = texture2DRect(tex1, rsmtc).rgb;
vec3 rsmnormal = texture2DRect(tex2, rsmtc).xyz*2.0 - 1.0;
vec3 rsmpos = (rsmworldmatrix * vec4(rsmtc, rsmdepth, 1.0)).xyz;
vec3 dir = rhpos - rsmpos;
sha += step(rhaothreshold, dir.z) * vec4(normalize(vec3(dir.xy, min(dot(dir.xy, dir.xy) * rhaoatten - rhaoheight, 0.0))), 1.0);
float dist = dot(dir, dir);
if(dist > 0.000049) dir = normalize(dir);
float atten = clamp(dot(dir, rsmnormal), 0.0, 1.0) / (0.1 + dist*rhatten);
rsmcolor *= atten;
shr += vec4(rsmcolor.r*dir, rsmcolor.r);
shg += vec4(rsmcolor.g*dir, rsmcolor.g);
shb += vec4(rsmcolor.b*dir, rsmcolor.b);
}
void main(void)
{
vec4 shr = vec4(0.0), shg = vec4(0.0), shb = vec4(0.0), sha = vec4(0.0);
@(loopconcat i $numtaps [result [
calcrhsample(vec3(@(at $[rhtapoffsets@numtaps] $i))*2.0 - 1.0, vec2(@(at $[rsmtapoffsets@numtaps] $i))*2.0 - 1.0, shr, shg, shb, sha);
]])
rhr = shr * (vec4(0.5, 0.5, 0.5, 1.0)/@(+f $numtaps)) + vec4(0.5, 0.5, 0.5, 0.0);
rhg = shg * (vec4(0.5, 0.5, 0.5, 1.0)/@(+f $numtaps)) + vec4(0.5, 0.5, 0.5, 0.0);
rhb = shb * (vec4(0.5, 0.5, 0.5, 1.0)/@(+f $numtaps)) + vec4(0.5, 0.5, 0.5, 0.0);
rha = sha * (vec4(0.5, 0.5, 0.5, 1.0)/@(+f $numtaps)) + vec4(0.5, 0.5, 0.5, 0.0);
}
]
]
lazyshader 0 radiancehintsborder [
attribute vec4 vvertex;
attribute vec3 vtexcoord0;
varying vec3 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler3D tex3, tex4, tex5, tex6;
uniform vec3 bordercenter, borderrange, borderscale;
varying vec3 texcoord0;
fragdata(0) vec4 rhr;
fragdata(1) vec4 rhg;
fragdata(2) vec4 rhb;
fragdata(3) vec4 rha;
void main(void)
{
float outside = clamp(borderscale.z*(abs(texcoord0.z - bordercenter.z) - borderrange.z), 0.0, 1.0);
vec3 tc = vec3(texcoord0.xy, clamp(texcoord0.z, bordercenter.z - borderrange.z, bordercenter.z + borderrange.z));
rhr = mix(texture3D(tex3, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rhg = mix(texture3D(tex4, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rhb = mix(texture3D(tex5, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rha = mix(texture3D(tex6, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
}
]
lazyshader 0 radiancehintscached [
attribute vec4 vvertex;
attribute vec3 vtexcoord0;
varying vec3 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler3D tex7, tex8, tex9, tex10;
varying vec3 texcoord0;
fragdata(0) vec4 rhr;
fragdata(1) vec4 rhg;
fragdata(2) vec4 rhb;
fragdata(3) vec4 rha;
void main(void)
{
rhr = texture3D(tex7, texcoord0);
rhg = texture3D(tex8, texcoord0);
rhb = texture3D(tex9, texcoord0);
rha = texture3D(tex10, texcoord0);
}
]
lazyshader 0 radiancehintsdisable [
attribute vec4 vvertex;
uniform vec3 rhcenter;
uniform float rhbounds;
void main(void)
{
gl_Position = vec4((vvertex.xy - rhcenter.xy)/rhbounds, vvertex.zw);
}
] [
fragdata(0) vec4 rhr;
fragdata(1) vec4 rhg;
fragdata(2) vec4 rhb;
fragdata(3) vec4 rha;
void main(void)
{
rhr = vec4(0.5, 0.5, 0.5, 0.0);
rhg = vec4(0.5, 0.5, 0.5, 0.0);
rhb = vec4(0.5, 0.5, 0.5, 0.0);
rha = vec4(0.5, 0.5, 0.5, 0.0);
}
]

View File

@ -0,0 +1,60 @@
////////////////////////////////////////////////
//
// grass shaders
//
////////////////////////////////////////////////
// grasstype:
// b -> blendmap
grassopt = [ >= (strstr $grasstype $arg1) 0 ]
grassvariantshader = [
local grasstype
grasstype = $arg2
variantshader 0 $arg1 (? (grassopt "b") 0 -1) [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
@(ginterpvert)
varying vec2 texcoord0;
varying vec4 colorscale;
@(? (grassopt "b") [uniform vec4 blendmapparams; varying vec2 texcoord1;])
void main(void)
{
gl_Position = camprojmatrix * vvertex;
colorscale = vcolor;
texcoord0 = vtexcoord0;
@(? (grassopt "b") [
texcoord1 = (vvertex.xy - blendmapparams.xy)*blendmapparams.zw;
])
@(gdepthpackvert)
}
] [
uniform sampler2D tex0;
uniform float grasstest;
@(ginterpfrag)
varying vec2 texcoord0;
varying vec4 colorscale;
@(? (grassopt "b") [uniform sampler2D tex1; varying vec2 texcoord1;])
void main(void)
{
vec4 color = texture2D(tex0, texcoord0) * colorscale;
@(? (grassopt "b") [
color.a *= texture2D(tex1, texcoord1).r;
])
if(color.a <= grasstest)
discard;
gcolor = vec4(color.rgb, 0.0);
@(gnormpack [vec3(0.5, 0.5, 1.0)])
@(gdepthpackfrag)
}
]
]
grassshader = [
shadername = (concatword "grass" $arg1)
grassvariantshader $shadername $arg1
grassvariantshader $shadername (concatword $arg1 "b")
]

169
config/glsl/hud.cfg 100644
View File

@ -0,0 +1,169 @@
///////////////////////////////////////////////////
//
// used for rendering to the HUD
//
///////////////////////////////////////////////////
shader 0 "hud" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 hudmatrix;
varying vec2 texcoord0;
varying vec4 colorscale;
void main(void)
{
gl_Position = hudmatrix * vvertex;
texcoord0 = vtexcoord0;
colorscale = vcolor;
}
] [
uniform sampler2D tex0;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
fragcolor = colorscale * color;
}
]
shader 0 "hudtext" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 hudmatrix;
varying vec2 texcoord0;
varying vec4 colorscale;
void main(void)
{
gl_Position = hudmatrix * vvertex;
texcoord0 = vtexcoord0;
colorscale = vcolor;
}
] [
uniform sampler2D tex0;
uniform vec4 textparams;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
void main(void)
{
float dist = texture2D(tex0, texcoord0).r;
float border = smoothstep(textparams.x, textparams.y, dist);
float outline = smoothstep(textparams.z, textparams.w, dist);
fragcolor = vec4(colorscale.rgb * outline, colorscale.a * border);
}
]
shader 0 "hudrgb" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 hudmatrix;
varying vec2 texcoord0;
varying vec4 colorscale;
void main(void)
{
gl_Position = hudmatrix * vvertex;
texcoord0 = vtexcoord0;
colorscale = vcolor;
}
] [
uniform sampler2D tex0;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
fragcolor.rgb = colorscale.rgb * color.rgb;
fragcolor.a = colorscale.a;
}
]
shader 0 "hudnotexture" [
attribute vec4 vvertex, vcolor;
uniform mat4 hudmatrix;
varying vec4 color;
void main(void)
{
gl_Position = hudmatrix * vvertex;
color = vcolor;
}
] [
varying vec4 color;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = color;
}
]
shader 0 "hudrect" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 hudmatrix;
varying vec2 texcoord0;
varying vec4 colorscale;
void main(void)
{
gl_Position = hudmatrix * vvertex;
texcoord0 = vtexcoord0;
colorscale = vcolor;
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = colorscale * texture2DRect(tex0, texcoord0);
}
]
shader 0 "hud3d" [
attribute vec4 vvertex, vcolor;
attribute vec3 vtexcoord0;
uniform mat4 hudmatrix;
varying vec3 texcoord0;
varying vec4 color;
void main(void)
{
gl_Position = hudmatrix * vvertex;
texcoord0 = vtexcoord0;
color = vcolor;
}
] [
uniform sampler3D tex0;
varying vec3 texcoord0;
varying vec4 color;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = color * texture3D(tex0, texcoord0);
}
]
shader 0 "hudcubemap" [
attribute vec4 vvertex, vcolor;
attribute vec3 vtexcoord0;
uniform mat4 hudmatrix;
varying vec3 texcoord0;
varying vec4 colorscale;
void main(void)
{
gl_Position = hudmatrix * vvertex;
texcoord0 = vtexcoord0;
colorscale = vcolor;
}
] [
uniform samplerCube tex0;
varying vec3 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = colorscale * textureCube(tex0, texcoord0);
}
]

View File

@ -0,0 +1,490 @@
///////////////////////////////////////////////////
//
// material shaders
//
///////////////////////////////////////////////////
shader 0 "refractmask" [
attribute vec4 vvertex;
uniform mat4 camprojmatrix;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
}
] [
@(gfetchdefs tex0)
uniform vec3 gdepthpackparams;
fragdata(0) vec4 fragcolor;
void main(void)
{
@(if (= $gdepthformat 1) [result [
vec3 packdepth = gfetch(tex0, gl_FragCoord.xy).rgb;
]] [result [
@(gdepthunpack depth [gfetch(tex0, gl_FragCoord.xy)])
@(gpackdepth packdepth depth)
]])
fragcolor = vec4(packdepth, 0.0);
}
]
lazyshader 0 "waterminimap" [
attribute vec4 vvertex;
uniform mat4 camprojmatrix;
@(ginterpvert)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
@(gdepthpackvert)
}
] [
uniform vec3 watercolor;
@(ginterpfrag)
void main(void)
{
gcolor = vec4(watercolor, 0.0);
@(gnormpack [vec3(0.5, 0.5, 1.0)])
@(gdepthpackfrag)
}
]
watershader = [
lazyshader 0 $arg1 [
attribute vec4 vvertex;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec3 camera;
varying vec2 texcoord0, texcoord1;
varying vec3 surface;
@(? (>= (strstr $arg1 "reflect") 0) [
uniform mat4 raymatrix;
varying vec3 esurface;
])
@(ginterpvert 1)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
surface = vvertex.xyz;
@(? (>= (strstr $arg1 "reflect") 0) [
esurface = (raymatrix * vvertex).xyz;
])
texcoord0 = vtexcoord0 * 0.18;
texcoord1 = vtexcoord0 * 0.08;
@(gdepthpackvert 1)
}
] [
@(gfetchdefs [tex7 tex8 tex9])
uniform float millis;
uniform vec3 camera;
uniform mat4 linearworldmatrix;
varying vec2 texcoord0, texcoord1;
varying vec3 surface;
uniform sampler2D tex0, tex1;
uniform vec4 viewsize;
uniform vec3 watercolor, waterdeepcolor, waterdeepfade;
uniform float waterfog, waterspec;
uniform vec4 waterreflect, waterrefract;
uniform float refractdepth;
@(? (>= (strstr $arg1 "caustics") 0) [
uniform vec3 causticsS, causticsT;
uniform vec3 causticsblend;
uniform sampler2D tex2, tex3;
])
@(? (>= (strstr $arg1 "env") 0) [
uniform samplerCube tex4;
])
@(? (>= (strstr $arg1 "reflect") 0) [
uniform mat4 raymatrix;
varying vec3 esurface;
])
@(ginterpfrag 1)
void main(void)
{
vec3 camdir = camera - surface, camvec = normalize(camdir);
vec3 bump = texture2D(tex1, texcoord0 + millis*vec2( 0.25, 0.75)*0.1250).rgb;
vec3 bump2 = texture2D(tex1, texcoord0 + millis*vec2(-0.75, -0.25)*0.1450).rgb;
vec3 bump3 = texture2D(tex1, texcoord1 + millis*vec2(-0.50, 0.50)*0.0805).rgb;
vec3 bump4 = texture2D(tex1, texcoord1 + millis*vec2( 0.25, -0.75)*0.0825).rgb;
bump = normalize(bump + bump2 + bump3 + bump4 - 2.0);
vec2 rtc = bump.xy * waterrefract.w;
float rmask = clamp(refractdepth*(lineardepth - dot(gfetch(tex7, gl_FragCoord.xy + rtc).rgb, gdepthunpackparams)), 0.0, 1.0);
rtc = gl_FragCoord.xy + rtc*rmask;
vec3 rcolor = gfetch(tex8, rtc).rgb * waterrefract.xyz;
float rdepth = dot(gfetch(tex7, rtc).rgb, gdepthunpackparams);
vec3 rpos = (linearworldmatrix * vec4(rdepth*rtc, rdepth, 1.0)).xyz;
@(if (>= (strstr $arg1 "under") 0) [result [
float above = rpos.z - surface.z;
float alpha = clamp(above, 0.0, 1.0);
]] [result [
vec3 rdir = rpos.xyz - camera;
float raydepth = length(rdir)*(1.0 + camdir.z/rdir.z);
float deep = surface.z - rpos.z;
float alpha = clamp(deep*0.5, 0.0, 1.0);
@(? (>= (strstr $arg1 "caustics") 0) [
vec2 ctc = vec2(dot(causticsS, rpos.xyz), dot(causticsT, rpos.xyz));
float caustics = causticsblend.x*texture2D(tex2, ctc).r + causticsblend.y*texture2D(tex3, ctc).r + causticsblend.z;
rcolor *= caustics;
])
rcolor = mix(watercolor, rcolor, clamp(exp2(waterfog * raydepth), 0.0, 1.0));
rcolor = mix(waterdeepcolor, rcolor, clamp(exp2(deep * waterdeepfade), 0.0, 1.0));
]])
vec3 reflectdir = -reflect(camvec, bump);
reflectdir.z = abs(reflectdir.z);
@(if (>= (strstr $arg1 "reflect") 0) [result [
reflectdir.z += 0.125;
vec3 edir = (raymatrix * vec4(waterreflect.w*reflectdir, 0.0)).xyz;
vec3 epos = esurface + edir;
@(loopconcat i 4 [result [
@(gdepthunpack [edepth@[i]] [gfetchproj(tex9, epos)] [
if(edepth@[i] < epos.z || edepth@[i] > esurface.z) epos += edir;
] [
edepth@[i] = edepth@[i]*gdepthscale.y + gdepthscale.z;
if(gdepthscale.x < epos.z*edepth@[i] || gdepthscale.x > esurface.z*edepth@[i]) epos += edir;
])
]])
vec2 etc = epos.xy/epos.z;
@(? $msaalight [
etc = clamp(etc, vec2(0.0), viewsize.xy);
])
vec3 reflect = gfetch(tex8, etc).rgb * waterreflect.xyz;
float edgefade = clamp(4.0*(0.5 - max(abs(etc.x*viewsize.z - 0.5)*0.75 + 0.25/4.0, abs(etc.y*viewsize.w - 0.5))), 0.0, 1.0);
float fresnel = 0.25 + 0.75*pow(clamp(1.0 - dot(camvec, bump), 0.0, 1.0), 4.0);
rcolor = mix(rcolor, reflect, fresnel*edgefade);
]] [if (>= (strstr $arg1 "env") 0) [result [
vec3 reflect = textureCube(tex4, reflectdir).rgb*0.5;
float fresnel = 0.5*pow(clamp(1.0 - dot(camvec, bump), 0.0, 1.0), 4.0);
rcolor = mix(rcolor, reflect, fresnel);
]]])
gcolor.rgb = vec3(0.0);
@(gspecpack 2.0 [waterspec*alpha])
@(gnormpack bump alpha)
gglow.rgb = rcolor*alpha;
@(gdepthpackfrag)
}
]
]
watershader "water"
watershader "watercaustics"
watershader "waterenv"
watershader "waterenvcaustics"
watershader "waterreflect"
watershader "waterreflectcaustics"
watershader "underwater"
causticshader = [
lazyshader 0 $arg1 [
attribute vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
}
] [
@(gfetchdefs tex9)
uniform mat4 causticsmatrix;
uniform vec3 causticsblend;
uniform sampler2D tex0, tex1;
uniform vec4 waterdeepfade;
fragdata(0) vec4 fragcolor;
void main(void)
{
@(gdepthunpack depth [gfetch(tex9, gl_FragCoord.xy)] [
vec3 ctc = (causticsmatrix * vec4(depth*gl_FragCoord.xy, depth, 1.0)).xyz;
] [
vec4 ctc = causticsmatrix * vec4(gl_FragCoord.xy, depth, 1.0);
ctc.xyz /= ctc.w;
])
float caustics = causticsblend.x*texture2D(tex0, ctc.xy).r + causticsblend.y*texture2D(tex1, ctc.xy).r + causticsblend.z;
caustics *= clamp(ctc.z, 0.0, 1.0) * clamp(exp2(ctc.z*waterdeepfade.w), 0.0, 1.0);
fragcolor.rgb = vec3(0.5 + caustics);
}
]
]
causticshader caustics
waterfogshader = [
lazyshader 0 $arg1 [
attribute vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
}
] [
@(gfetchdefs tex9)
uniform vec3 camera;
uniform mat4 worldmatrix;
uniform vec3 fogcolor;
uniform vec2 fogdensity;
uniform vec3 waterdeepcolor, waterdeepfade;
uniform float waterheight;
fragdata(0) vec4 fragcolor;
void main(void)
{
@(gdepthunpack depth [gfetch(tex9, gl_FragCoord.xy)] [
vec3 pos = (worldmatrix * vec4(depth*gl_FragCoord.xy, depth, 1.0)).xyz;
] [
vec4 pos = worldmatrix * vec4(gl_FragCoord.xy, depth, 1.0);
pos.xyz /= pos.w;
])
float fogbelow = waterheight - pos.z;
float fogcoord = distance(camera, pos.xyz);
float foglerp = clamp(1.0 - exp2(fogcoord*fogdensity.x)*fogdensity.y, 0.0, 1.0);
foglerp *= clamp(2.0*fogbelow + 0.5, 0.0, 1.0);
vec3 color = mix(waterdeepcolor, fogcolor, clamp(exp2(fogbelow*waterdeepfade), 0.0, 1.0));
fragcolor.rgb = color;
fragcolor.a = foglerp;
}
]
]
waterfogshader waterfog
lazyshader 0 "lava" [
attribute vec4 vvertex;
attribute vec3 vnormal;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
varying mat3 world;
varying vec2 texcoord0;
@(ginterpvert)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
vec3 tangent = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), abs(vnormal.x));
vec3 bitangent = mix(vec3(0.0, 0.0, -1.0), vec3(0.0, 1.0, 0.0), abs(vnormal.z));
world = mat3(tangent, bitangent, vnormal);
@(gdepthpackvert)
}
] [
uniform sampler2D tex0, tex1;
uniform float lavaglow, lavaspec;
varying mat3 world;
varying vec2 texcoord0;
@(ginterpfrag)
void main(void)
{
vec3 diffuse = texture2D(tex0, texcoord0).rgb;
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0-1.0;
vec3 bumpw = normalize(world * bump);
gcolor.rgb = diffuse;
@(gspecpack 0.0 lavaspec)
@(gnormpack bumpw)
gglow.rgb = diffuse*lavaglow;
@(gdepthpackfrag)
}
]
lazyshader 0 "waterfallenv" [
attribute vec4 vvertex;
attribute vec3 vnormal;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec4 camera;
varying vec3 camdir;
varying mat3 world;
varying vec2 texcoord0;
@(ginterpvert 1)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
camdir = camera.xyz - vvertex.xyz;
vec3 tangent = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), abs(vnormal.x));
vec3 bitangent = mix(vec3(0.0, 0.0, -1.0), vec3(0.0, 1.0, 0.0), abs(vnormal.z));
world = mat3(tangent, bitangent, vnormal);
@(gdepthpackvert 1)
}
] [
@(gfetchdefs [tex7 tex8])
uniform samplerCube tex3;
uniform sampler2D tex0, tex1;
uniform vec3 waterfallcolor;
uniform float waterfallspec;
uniform vec4 waterfallrefract;
uniform float refractdepth;
varying vec3 camdir;
varying mat3 world;
varying vec2 texcoord0;
@(ginterpfrag 1)
void main(void)
{
vec3 camvec = normalize(camdir);
vec3 diffuse = texture2D(tex0, texcoord0).rgb;
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * waterfallrefract.w;
float rmask = clamp(refractdepth*(lineardepth - dot(gfetch(tex7, gl_FragCoord.xy + rtc).rgb, gdepthunpackparams)), 0.0, 1.0);
rtc = gl_FragCoord.xy + rtc*rmask;
vec3 rcolor = gfetch(tex8, rtc).rgb * waterfallrefract.xyz;
float invfresnel = dot(camvec, bumpw);
vec3 env = textureCube(tex3, 2.0*bumpw*invfresnel - camvec).rgb;
env *= 0.1 + 0.4*pow(clamp(1.0 - invfresnel, 0.0, 1.0), 2.0);
gcolor.rgb = vec3(0.0);
@(gspecpack 2.0 [waterfallspec*(1.0 - dot(diffuse, vec3(0.33)))]);
@(gnormpack bumpw)
gglow.rgb = mix(rcolor, waterfallcolor, diffuse) + env;
@(gdepthpackfrag)
}
]
lazyshader 0 "waterfall" [
attribute vec4 vvertex;
attribute vec3 vnormal;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
varying mat3 world;
varying vec2 texcoord0;
@(ginterpvert 1)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
vec3 tangent = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), abs(vnormal.x));
vec3 bitangent = mix(vec3(0.0, 0.0, -1.0), vec3(0.0, 1.0, 0.0), abs(vnormal.z));
world = mat3(tangent, bitangent, vnormal);
@(gdepthpackvert 1)
}
] [
@(gfetchdefs [tex7 tex8])
uniform sampler2D tex0, tex1;
uniform vec3 waterfallcolor;
uniform float waterfallspec;
uniform vec4 waterfallrefract;
uniform float refractdepth;
varying mat3 world;
varying vec2 texcoord0;
@(ginterpfrag 1)
void main(void)
{
vec3 diffuse = texture2D(tex0, texcoord0).rgb;
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * waterfallrefract.w;
float rmask = clamp(refractdepth*(lineardepth - dot(gfetch(tex7, gl_FragCoord.xy + rtc).rgb, gdepthunpackparams)), 0.0, 1.0);
rtc = gl_FragCoord.xy + rtc*rmask;
vec3 rcolor = gfetch(tex8, rtc).rgb * waterfallrefract.xyz;
gcolor.rgb = vec3(0.0);
@(gspecpack 2.0 [waterfallspec*(1.0 - dot(diffuse, vec3(0.33)))])
@(gnormpack bumpw)
gglow.rgb = mix(rcolor, waterfallcolor, diffuse);
@(gdepthpackfrag)
}
]
lazyshader 0 "glassenv" [
attribute vec4 vvertex;
attribute vec3 vnormal;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec4 camera;
varying vec3 camdir;
varying mat3 world;
varying vec2 texcoord0;
@(ginterpvert 1)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
camdir = camera.xyz - vvertex.xyz;
vec3 tangent = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), abs(vnormal.x));
vec3 bitangent = mix(vec3(0.0, 0.0, -1.0), vec3(0.0, 1.0, 0.0), abs(vnormal.z));
world = mat3(tangent, bitangent, vnormal);
@(gdepthpackvert 1)
}
] [
@(gfetchdefs [tex7 tex8])
uniform samplerCube tex0;
uniform sampler2D tex1;
uniform float glassspec;
uniform vec4 glassrefract;
uniform float refractdepth;
varying vec3 camdir;
varying mat3 world;
varying vec2 texcoord0;
@(ginterpfrag 1)
void main(void)
{
vec3 camvec = normalize(camdir);
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * glassrefract.w;
float rmask = clamp(refractdepth*(lineardepth - dot(gfetch(tex7, gl_FragCoord.xy + rtc).rgb, gdepthunpackparams)), 0.0, 1.0);
rtc = gl_FragCoord.xy + rtc*rmask;
vec3 rcolor = gfetch(tex8, rtc).rgb;
rcolor *= glassrefract.xyz;
float invfresnel = dot(camvec, bumpw);
vec3 env = textureCube(tex0, 2.0*bumpw*invfresnel - camvec).rgb;
env *= 0.1 + 0.4*pow(clamp(1.0 - invfresnel, 0.0, 1.0), 2.0);
gcolor.rgb = vec3(0.0);
@(gspecpack 2.0 glassspec)
@(gnormpack bumpw)
gglow.rgb = rcolor + env;
@(gdepthpackfrag)
}
]
lazyshader 0 "glass" [
attribute vec4 vvertex;
attribute vec3 vnormal;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
varying mat3 world;
varying vec2 texcoord0;
@(ginterpvert 1)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
vec3 tangent = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), abs(vnormal.x));
vec3 bitangent = mix(vec3(0.0, 0.0, -1.0), vec3(0.0, 1.0, 0.0), abs(vnormal.z));
world = mat3(tangent, bitangent, vnormal);
@(gdepthpackvert 1)
}
] [
@(gfetchdefs [tex7 tex8])
uniform sampler2D tex1;
uniform float glassspec;
uniform vec4 glassrefract;
uniform float refractdepth;
varying mat3 world;
varying vec2 texcoord0;
@(ginterpfrag 1)
void main(void)
{
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * glassrefract.w;
float rmask = clamp(refractdepth*(lineardepth - dot(gfetch(tex7, gl_FragCoord.xy + rtc).rgb, gdepthunpackparams)), 0.0, 1.0);
rtc = gl_FragCoord.xy + rtc*rmask;
vec3 rcolor = gfetch(tex8, rtc).rgb;
rcolor *= glassrefract.xyz;
gcolor.rgb = vec3(0.0);
@(gspecpack 2.0 glassspec)
@(gnormpack bumpw)
gglow.rgb = rcolor;
@(gdepthpackfrag)
}
]

View File

@ -0,0 +1,180 @@
shader 0 "null" [
attribute vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
}
] [
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = vec4(1.0, 0.0, 1.0, 1.0);
}
]
//////////////////////////////////////////////////////////////////////
//
// for filling the z-buffer only (i.e. multi-pass rendering, OQ)
//
//////////////////////////////////////////////////////////////////////
shader 0 "nocolor" [
attribute vec4 vvertex;
uniform mat4 camprojmatrix;
void main() { gl_Position = camprojmatrix * vvertex; }
] [
void main() {}
]
shader 0 "bbquery" [
attribute vec4 vvertex;
uniform mat4 camprojmatrix;
uniform vec3 bborigin, bbsize;
void main() { gl_Position = camprojmatrix * vec4(bborigin + vvertex.xyz*bbsize, vvertex.w); }
] [
void main() {}
]
shader 0 "depth" [
attribute vec4 vvertex;
uniform mat4 camprojmatrix;
@(ginterpdepth)
void main()
{
gl_Position = camprojmatrix * vvertex;
@(gdepthpackvert)
}
] [
@(? $gdepthformat [
fragdata(0) vec4 gdepth;
])
@(ginterpdepth)
void main()
{
@(if (= $gdepthformat 1) [result [
@(gpackdepth packdepth lineardepth)
gdepth.rgb = packdepth;
gdepth.a = 0.0;
]] [? (> $gdepthformat 1) [
gdepth.r = lineardepth;
]])
}
]
//////////////////////////////////////////////////////////////////////
//
// LDR variants of default shaders
//
//////////////////////////////////////////////////////////////////////
shader 0 "ldr" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform float ldrscale;
varying vec2 texcoord0;
varying vec4 colorscale;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
colorscale = vec4(ldrscale * vcolor.rgb, vcolor.a);
}
] [
uniform sampler2D tex0;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
fragcolor = colorscale * color;
}
]
shader 0 "ldrnotexture" [
attribute vec4 vvertex, vcolor;
uniform mat4 camprojmatrix;
uniform float ldrscale;
varying vec4 color;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
color = vec4(ldrscale * vcolor.rgb, vcolor.a);
}
] [
varying vec4 color;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = color;
}
]
//////////////////////////////////////////////////////////////////////
//
// fogged variants of default shaders
//
//////////////////////////////////////////////////////////////////////
shader 0 "fogged" [
//:fog
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
varying vec2 texcoord0;
varying vec4 colorscale;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
colorscale = vcolor;
}
] [
uniform sampler2D tex0;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
fragcolor = colorscale * color;
}
]
shader 0 "foggednotexture" [
//:fog
attribute vec4 vvertex, vcolor;
uniform mat4 camprojmatrix;
varying vec4 color;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
color = vcolor;
}
] [
varying vec4 color;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = color;
}
]
shader 0 "fogoverlay" [
attribute vec4 vvertex, vcolor;
varying vec4 color;
void main(void)
{
gl_Position = vvertex;
color = vcolor;
}
] [
varying vec4 color;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = color;
}
]

View File

@ -0,0 +1,374 @@
////////////////////////////////////////////////
//
// model shaders
//
////////////////////////////////////////////////
// skeletal animation with dual quaternions
qtangentdecode = [
? $arg1 [
vec4 qxyz = mquat.xxyy*mquat.yzyz, qxzw = vec4(mquat.xzw, -mquat.w);
vec3 mtangent = (qxzw.yzw*mquat.zzy + qxyz.zxy)*vec3(-2.0, 2.0, 2.0) + vec3(1.0, 0.0, 0.0);
vec3 mnormal = (qxzw.zwx*mquat.yxx + qxyz.ywz)*vec3(2.0, 2.0, -2.0) + vec3(0.0, 0.0, 1.0);
// vec3 mtangent = cross(mquat.xyz, vec3(mquat.wz, -mquat.y))*2.0 + vec3(1.0, 0.0, 0.0);
// vec3 mnormal = cross(mquat.xyz, vec3(mquat.y, -mquat.x, mquat.w))*2.0 + vec3(0.0, 0.0, 1.0);
] [
vec3 mnormal = cross(mquat.xyz, vec3(mquat.y, -mquat.x, mquat.w))*2.0 + vec3(0.0, 0.0, 1.0);
]
]
skelanimdefs = [
result [
attribute vec4 vboneweight, vboneindex;
//:uniform animdata
uniform vec4 animdata[@@(min $maxvsuniforms $maxskelanimdata)];
]
]
skelanim = [
result [
int index = int(vboneindex.x);
@(if (= $arg1 1) [result [
vec4 dqreal = animdata[index];
vec4 dqdual = animdata[index+1];
]] [result [
vec4 dqreal = animdata[index] * vboneweight.x;
vec4 dqdual = animdata[index+1] * vboneweight.x;
index = int(vboneindex.y);
dqreal += animdata[index] * vboneweight.y;
dqdual += animdata[index+1] * vboneweight.y;
@(if (>= $arg1 3) [result [
index = int(vboneindex.z);
dqreal += animdata[index] * vboneweight.z;
dqdual += animdata[index+1] * vboneweight.z;
]])
@(if (>= $arg1 4) [result [
index = int(vboneindex.w);
dqreal += animdata[index] * vboneweight.w;
dqdual += animdata[index+1] * vboneweight.w;
]])
float len = length(dqreal);
dqreal /= len;
dqdual /= len;
]])
vec4 mpos = vec4((cross(dqreal.xyz, cross(dqreal.xyz, vvertex.xyz) + vvertex.xyz*dqreal.w + dqdual.xyz) + dqdual.xyz*dqreal.w - dqreal.xyz*dqdual.w)*2.0 + vvertex.xyz, vvertex.w);
@(if (>= $numargs 2) [result [
vec4 mquat = vec4(cross(dqreal.xyz, vtangent.xyz) + dqreal.xyz*vtangent.w + vtangent.xyz*dqreal.w, dqreal.w*vtangent.w - dot(dqreal.xyz, vtangent.xyz));
@(qtangentdecode $arg2)
]])
]
]
// mdltype:
// a -> alpha test
// b -> dual-quat skeletal animation
mdlopt = [ >= (strstr $modeltype $arg1) 0 ]
shadowmodelvertexshader = [
local modeltype
modeltype = $arg1
result [
attribute vec4 vvertex;
@(if (mdlopt "b") [skelanimdefs $arg2])
uniform mat4 modelmatrix;
@(? (mdlopt "a") [
attribute vec2 vtexcoord0;
uniform vec2 texscroll;
varying vec2 texcoord0;
])
void main(void)
{
@(if (mdlopt "b") [
skelanim $arg2
] [result [
#define mpos vvertex
]])
gl_Position = modelmatrix * mpos;
@(? (mdlopt "a") [
texcoord0 = vtexcoord0 + texscroll;
])
}
]
]
shadowmodelfragmentshader = [
local modeltype
modeltype = $arg1
result [
@(? (mdlopt "a") [
uniform sampler2D tex0;
uniform float alphatest;
varying vec2 texcoord0;
])
void main(void)
{
@(? (mdlopt "a") [
vec4 color = texture2D(tex0, texcoord0);
if(color.a <= alphatest)
discard;
])
}
]
]
shadowmodelshader = [
defershader 0 $arg1 [
shader 0 @arg1 (shadowmodelvertexshader @arg2) (shadowmodelfragmentshader @arg2)
loop+ i 1 4 [
variantshader 0 @@arg1 0 (shadowmodelvertexshader @@(concatword $arg2 "b") $i) []
]
]
]
shadowmodelshader "shadowmodel" ""
shadowmodelshader "alphashadowmodel" "a"
// mdltype:
// a -> alpha test
// e -> envmap
// n -> normalmap
// m -> masks
// d -> decal
// D -> alpha decal
// b -> dual-quat skeletal animation
// c -> disable cullface
// t -> transparent
modelvertexshader = [
local modeltype
modeltype = $arg1
result [
attribute vec4 vvertex, vtangent;
attribute vec2 vtexcoord0;
@(if (mdlopt "b") [skelanimdefs $arg2 (mdlopt "n")])
uniform mat4 modelmatrix;
uniform mat3 modelworld;
uniform vec3 modelcamera;
uniform vec2 texscroll;
@(? (mdlopt "n") [
varying mat3 world;
] [
varying vec3 nvec;
])
@(? (mdlopt "e") [
varying vec3 camvec;
])
@(msaainterpvert)
varying vec2 texcoord0;
void main(void)
{
@(if (mdlopt "b") [
skelanim $arg2 (mdlopt "n")
] [result [
#define mpos vvertex
#define mquat vtangent
@(qtangentdecode (mdlopt "n"))
]])
gl_Position = modelmatrix * mpos;
texcoord0 = vtexcoord0 + texscroll;
@(msaapackvert)
@(? (mdlopt "e") [
camvec = modelworld * normalize(modelcamera - mpos.xyz);
])
@(? (mdlopt "n") [
// composition of tangent -> object and object -> world transforms
// becomes tangent -> world
vec3 wnormal = modelworld * mnormal;
vec3 wtangent = modelworld * mtangent;
vec3 wbitangent = cross(wnormal, wtangent) * (vtangent.w < 0.0 ? -1.0 : 1.0);
world = mat3(wtangent, wbitangent, wnormal);
] [
nvec = modelworld * mnormal;
])
}
]
]
modelfragmentshader = [
local modeltype
modeltype = $arg1
result [
@(? (mdlopt "n") [
varying mat3 world;
] [
varying vec3 nvec;
])
@(? (mdlopt "e") [
uniform vec2 envmapscale;
varying vec3 camvec;
])
uniform vec4 colorscale;
uniform vec2 fullbright;
uniform vec3 maskscale;
@(? (mdlopt "a") [uniform float alphatest;])
uniform sampler2D tex0;
@(? (mdlopt "m") [uniform sampler2D tex1;])
@(? (mdlopt "e") [uniform samplerCube tex2;])
@(? (mdlopt "n") [uniform sampler2D tex3;])
@(? (|| (mdlopt "d") [mdlopt "D"]) [uniform sampler2D tex4;])
@(msaainterpfrag)
varying vec2 texcoord0;
uniform float aamask;
void main(void)
{
vec4 diffuse = texture2D(tex0, texcoord0);
@(? (mdlopt "a") [
if(diffuse.a <= alphatest)
discard;
])
gcolor.rgb = diffuse.rgb*colorscale.rgb;
@(? (|| (mdlopt "d") [mdlopt "D"]) [
vec4 decal = texture2D(tex4, texcoord0);
@(? (mdlopt "D") [
gcolor.rgb = mix(gcolor.rgb, decal.rgb, decal.a);
] [
gcolor.rgb += decal.rgb;
])
])
@(if (mdlopt "n") [result [
vec3 normal = texture2D(tex3, texcoord0).rgb - 0.5;
@(? (mdlopt "c") [
if(!gl_FrontFacing) normal.z = -normal.z;
])
normal = normalize(world * normal);
]] [result [
vec3 normal = normalize(nvec);
@(? (mdlopt "c") [
if(!gl_FrontFacing) normal = -normal;
])
]])
float spec = maskscale.x;
@(if (mdlopt "m") [result [
vec3 masks = texture2D(tex1, texcoord0).rgb;
spec *= masks.r; // specmap in red channel
@(? (mdlopt "e") [
vec3 camn = normalize(camvec);
float invfresnel = dot(camn, normal);
vec3 rvec = 2.0*invfresnel*normal - camn;
float rmod = envmapscale.x*clamp(invfresnel, 0.0, 1.0) + envmapscale.y;
vec3 reflect = textureCube(tex2, rvec).rgb;
gcolor.rgb = mix(gcolor.rgb, reflect, rmod*masks.b); // envmap mask in blue channel
])
float glowk = max(maskscale.z*masks.g, fullbright.y); // glow mask in green channel
]] [result [
float glowk = fullbright.y;
]])
@(gspecpack maskscale.y spec)
float colork = clamp(fullbright.x - glowk, 0.0, 1.0);
@(if (mdlopt "t") [result [
gcolor *= colorscale.a;
gglow.rgb = gcolor.rgb*glowk;
gcolor.rgb *= colork;
#define packnorm colorscale.a
]] [gglowpack "" packnorm])
@(gnormpackdef normal packnorm)
@(msaapackfrag aamask)
}
]
]
modelshader = [
shadername = (concatword "model" $arg1)
maxvariants = 9
shader 0 $shadername (modelvertexshader $arg1) (modelfragmentshader $arg1)
loop+ i 1 4 [
variantshader 0 $shadername 0 (modelvertexshader (concatword $arg1 "b") $i) [] $maxvariants
]
variantshader 0 $shadername 1 [] (modelfragmentshader (concatword $arg1 "t")) $maxvariants
loop i 4 [
variantshader 0 $shadername 1 [0 , @i] 1 $maxvariants
]
]
rsmmodelvertexshader = [
local modeltype
modeltype = $arg1
result [
attribute vec4 vvertex, vtangent;
attribute vec2 vtexcoord0;
@(if (mdlopt "b") [skelanimdefs $arg2 (mdlopt "n")])
uniform mat4 modelmatrix;
uniform mat3 modelworld;
uniform vec2 texscroll;
varying vec2 texcoord0;
varying vec3 nvec;
void main(void)
{
@(if (mdlopt "b") [
skelanim $arg2 (mdlopt "n")
] [result [
#define mpos vvertex
#define mquat vtangent
@(qtangentdecode (mdlopt "n"))
]])
gl_Position = modelmatrix * mpos;
texcoord0 = vtexcoord0 + texscroll;
nvec = modelworld * mnormal;
}
]
]
rsmmodelfragmentshader = [
local modeltype
modeltype = $arg1
result [
varying vec2 texcoord0;
varying vec3 nvec;
uniform vec4 colorscale;
@(? (mdlopt "a") [uniform float alphatest;])
uniform vec3 rsmdir;
uniform sampler2D tex0;
fragdata(0) vec4 gcolor;
fragdata(1) vec4 gnormal;
void main(void)
{
vec4 diffuse = texture2D(tex0, texcoord0);
@(? (mdlopt "a") [
if(diffuse.a <= alphatest)
discard;
])
vec3 normal = normalize(nvec);
@(? (mdlopt "c") [
if(!gl_FrontFacing) normal = -normal;
])
gcolor = vec4(dot(normal, rsmdir)*diffuse.rgb*colorscale.rgb, 1.0);
gnormal = vec4(normal*0.5+0.5, 0.0);
}
]
]
rsmmodelshader = [
shadername = (concatword "rsmmodel" $arg1)
shader 0 $shadername (rsmmodelvertexshader $arg1) (rsmmodelfragmentshader $arg1)
loop+ i 1 4 [
variantshader 0 $shadername 0 (rsmmodelvertexshader (concatword $arg1 "b") $i) []
]
]

View File

@ -0,0 +1,126 @@
////////////////////////////////////////////////
//
// movie encoding
//
////////////////////////////////////////////////
lazyshader 0 "moviergb" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = texture2DRect(tex0, texcoord0);
}
]
lazyshader 0 "movieyuv" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec3 color = texture2DRect(tex0, texcoord0).rgb;
fragcolor = vec4(dot(color, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,
dot(color, vec3(-0.148224, -0.290992, 0.439216)) + 0.501961,
dot(color, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
0.0);
}
]
lazyshader 0 "moviey" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0 + vec2(0.5, 0.0);
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec3 color1 = texture2DRectOffset(tex0, texcoord0, ivec2( -2, 0)).rgb;
vec3 color2 = texture2DRectOffset(tex0, texcoord0, ivec2( -1, 0)).rgb;
vec3 color3 = texture2DRect(tex0, texcoord0).rgb;
vec3 color4 = texture2DRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
fragcolor = vec4(dot(color3, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
dot(color2, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
dot(color1, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
dot(color4, vec3(0.256788, 0.504125, 0.097905)) + 0.062745);
}
]
lazyshader 0 "movieu" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec3 color1 = texture2DRectOffset(tex0, texcoord0, ivec2(-3, 0)).rgb;
vec3 color2 = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb;
vec3 color3 = texture2DRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
vec3 color4 = texture2DRectOffset(tex0, texcoord0, ivec2( 3, 0)).rgb;
fragcolor = vec4(dot(color3, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961,
dot(color2, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961,
dot(color1, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961,
dot(color4, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961);
}
]
lazyshader 0 "moviev" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec3 color1 = texture2DRectOffset(tex0, texcoord0, ivec2(-3, 0)).rgb;
vec3 color2 = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb;
vec3 color3 = texture2DRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
vec3 color4 = texture2DRectOffset(tex0, texcoord0, ivec2( 3, 0)).rgb;
fragcolor = vec4(dot(color3, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,
dot(color2, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,
dot(color1, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,
dot(color4, vec3(0.439216, -0.367788, -0.071427)) + 0.501961);
}
]

View File

@ -0,0 +1,176 @@
////////////////////////////////////////////////
//
// particle shaders
//
////////////////////////////////////////////////
// wobbles the vertices of an explosion sphere
// and generates all texcoords
// and blends the edge color
// and modulates the texture
explosionshader = [
shader 0 $arg1 [
//:fog
attribute vec4 vvertex, vcolor;
uniform mat4 explosionmatrix;
uniform vec3 center;
uniform float millis;
attribute vec2 vtexcoord0;
uniform vec4 texgenS, texgenT;
@(? (>= (strstr $arg1 "soft") 0) [
uniform vec2 lineardepthscale;
varying float lineardepth;
])
varying vec4 color;
varying vec2 texcoord0, texcoord1, texcoord2;
void main(void)
{
vec4 wobble = vec4(vvertex.xyz*(1.0 + 0.5*abs(fract(dot(vvertex.xyz, center) + millis*2.0) - 0.5)), vvertex.w);
gl_Position = explosionmatrix * wobble;
@(? (>= (strstr $arg1 "soft") 0) [
lineardepth = dot(lineardepthscale, gl_Position.zw);
])
color = vcolor;
texcoord0 = vtexcoord0;
vec2 texgen = vec2(dot(texgenS, vvertex), dot(texgenT, vvertex));
texcoord1 = texgen;
texcoord2 = 0.5*texgen - millis*0.5;
}
] [
@(if (>= (strstr $arg1 "soft") 0) [result [
@(gfetchdefs tex2)
uniform vec3 softparams;
varying float lineardepth;
]])
varying vec4 color;
varying vec2 texcoord0, texcoord1, texcoord2;
uniform sampler2D tex0;
uniform vec2 blendparams;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec2 dtc = texcoord0 + texture2D(tex0, texcoord2).xy*0.1; // use color texture as noise to distort texcoords
vec4 diffuse = texture2D(tex0, dtc);
float blend = max(pow(clamp(1.0 - dot(texcoord1, texcoord1), 0.0, 1.0), blendparams.x), blendparams.y);
diffuse *= blend*4.0; // dup alpha into RGB channels + intensify and over saturate
diffuse.b += 0.5 - blend*0.5; // blue tint
@(if (>= (strstr $arg1 "soft") 0) [result [
fragcolor.rgb = diffuse.rgb * color.rgb;
@(gdepthunpack depth [gfetch(tex2, gl_FragCoord.xy)])
fragcolor.a = diffuse.a * max(clamp((depth - lineardepth)*softparams.x - softparams.y, 0.0, 1.0) * color.a, softparams.z);
]] [result [
fragcolor = diffuse * color;
]])
}
]
]
explosionshader "explosion"
explosionshader "explosionsoft"
shader 0 "particlenotexture" [
//:fog
attribute vec4 vvertex, vcolor;
uniform mat4 camprojmatrix;
uniform vec4 colorscale;
varying vec4 color;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
color = vcolor * colorscale;
}
] [
varying vec4 color;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = color;
}
]
shader 0 "particletext" [
//:fog
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform float ldrscale;
varying vec4 color;
varying vec2 texcoord0;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
color = vec4(vcolor.rgb * ldrscale, vcolor.a);
}
] [
uniform vec4 textparams;
uniform sampler2D tex0;
varying vec4 color;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
float dist = texture2D(tex0, texcoord0).r;
float border = smoothstep(textparams.x, textparams.y, dist);
float outline = smoothstep(textparams.z, textparams.w, dist);
fragcolor = vec4(color.rgb * outline, color.a * border);
}
]
particleshader = [
shader 0 $arg1 [
//:fog
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec4 colorscale;
varying vec4 color;
varying vec2 texcoord0;
@(? (>= (strstr $arg1 "soft") 0) [
uniform vec2 lineardepthscale;
varying float lineardepth;
varying vec2 surface;
])
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
color = vcolor * colorscale;
@(? (>= (strstr $arg1 "soft") 0) [
lineardepth = dot(lineardepthscale, gl_Position.zw);
surface = vtexcoord0.xy*2.82842712474619 - 1.4142135623731;
])
}
] [
@(if (>= (strstr $arg1 "soft") 0) [result [
@(gfetchdefs tex2)
uniform vec3 softparams;
varying float lineardepth;
varying vec2 surface;
]])
uniform sampler2D tex0;
varying vec4 color;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec4 diffuse = texture2D(tex0, texcoord0);
@(if (>= (strstr $arg1 "soft") 0) [result [
@(gdepthunpack depth [gfetch(tex2, gl_FragCoord.xy)])
diffuse.a *= clamp((depth - lineardepth)*softparams.x - softparams.y - dot(surface, surface), 0.0, 1.0);
]])
fragcolor = diffuse * color;
}
]
]
particleshader "particle"
particleshader "particlesoft"

View File

@ -0,0 +1,183 @@
////////////////////////////////////////////////
//
// post effects
//
////////////////////////////////////////////////
fsvs = [result [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
@arg2
void main(void)
{
gl_Position = vvertex; // woohoo, no mvp :)
texcoord0 = vtexcoord0;
@arg1
}
]]
fsps = [result [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
@arg2
void main(void)
{
vec4 color = texture2DRect(tex0, texcoord0);
@arg1
}
]]
fsvs4 = [
fsvs [
texcoord1 = vtexcoord0 + vec2(-1.5, -1.5);
texcoord2 = vtexcoord0 + vec2( 1.5, -1.5);
texcoord3 = vtexcoord0 + vec2(-1.5, 1.5);
texcoord4 = vtexcoord0 + vec2( 1.5, 1.5);
@arg1
] [
varying vec2 texcoord1, texcoord2, texcoord3, texcoord4;
]
]
fsps4 = [
fsps [
vec4 s00 = texture2DRect(tex0, texcoord1);
vec4 s02 = texture2DRect(tex0, texcoord2);
vec4 s20 = texture2DRect(tex0, texcoord3);
vec4 s22 = texture2DRect(tex0, texcoord4);
@arg1
] [
varying vec2 texcoord1, texcoord2, texcoord3, texcoord4;
]
]
// some simple ones that just do an effect on the RGB value...
lazyshader 0 "invert" (fsvs) (fsps [fragcolor = 1.0 - color;])
lazyshader 0 "gbr" (fsvs) (fsps [fragcolor = color.yzxw;])
lazyshader 0 "bw" (fsvs) (fsps [fragcolor = vec4(dot(color.xyz, vec3(0.333)));])
// sobel
lazyshader 0 "sobel" (fsvs4) (fsps4 [
vec4 t = s00 + s20 - s02 - s22;
vec4 u = s00 + s02 - s20 - s22;
fragcolor = color + t*t + u*u;
])
// rotoscope
lazyshader 0 "rotoscope" [
attribute vec4 vvertex;
@(screentexcoord 0)
uniform vec4 params;
varying vec2 t11, t00, t12, t01, t20, t02, t21, t10, t22;
void main(void)
{
gl_Position = vvertex;
t11 = vtexcoord0;
t00 = vec2(-1.0, -1.0)*params.x + vtexcoord0;
t12 = vec2( 0.0, 1.0)*params.x + vtexcoord0;
t01 = vec2(-1.0, 0.0)*params.x + vtexcoord0;
t20 = vec2( 1.0, -1.0)*params.x + vtexcoord0;
t02 = vec2(-1.0, 1.0)*params.x + vtexcoord0;
t21 = vec2( 1.0, 0.0)*params.x + vtexcoord0;
t10 = vec2( 0.0, -1.0)*params.x + vtexcoord0;
t22 = vec2( 1.0, 1.0)*params.x + vtexcoord0;
}
] [
uniform sampler2DRect tex0;
varying vec2 t11, t00, t12, t01, t20, t02, t21, t10, t22;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec4 c00 = texture2DRect(tex0, t00);
vec4 c01 = texture2DRect(tex0, t01);
vec4 c02 = texture2DRect(tex0, t02);
vec4 c10 = texture2DRect(tex0, t10);
vec4 c11 = texture2DRect(tex0, t11);
vec4 c12 = texture2DRect(tex0, t12);
vec4 c20 = texture2DRect(tex0, t20);
vec4 c21 = texture2DRect(tex0, t21);
vec4 c22 = texture2DRect(tex0, t22);
vec4 diag1 = c00 - c22;
vec4 diag2 = c02 - c20;
vec4 xedge = (c01 - c21)*2.0 + diag1 + diag2;
vec4 yedge = (c10 - c12)*2.0 + diag1 - diag2;
xedge *= xedge;
yedge *= yedge;
vec4 xyedge = xedge + yedge;
float sobel = step(max(xyedge.x, max(xyedge.y, xyedge.z)), 0.1);
float hue = dot(c11.xyz, vec3(1.0));
c11 /= hue;
vec3 cc = step(vec3(0.2, 0.8, 1.5), vec3(hue));
c11 *= dot(cc, vec3(0.5, 0.5, 1.5));
fragcolor = c11 * max(cc.z, sobel);
}
]
blur3shader = [
lazyshader 0 $arg1 [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0, texcoord1;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0 + vec2(@(? $arg2 -0.5 0.0), @(? $arg3 -0.5 0.0));
texcoord1 = vtexcoord0 + vec2(@(? $arg2 0.5 0.0), @(? $arg3 0.5 0.0));
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0, texcoord1;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = 0.5*(texture2DRect(tex0, texcoord0) + texture2DRect(tex0, texcoord1));
}
]
]
blur3shader hblur3 1 0
blur3shader vblur3 0 1
blur5shader = [
lazyshader 0 $arg1 [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0, texcoord1, texcoord2;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
texcoord1 = vtexcoord0 + vec2(@(? $arg2 -1.333 0.0), @(? $arg3 -1.333 0.0));
texcoord2 = vtexcoord0 + vec2(@(? $arg2 1.333 0.0), @(? $arg3 1.333 0.0));
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0, texcoord1, texcoord2;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = 0.4*texture2DRect(tex0, texcoord0) + 0.3*(texture2DRect(tex0, texcoord1) + texture2DRect(tex0, texcoord2));
}
]
]
blur5shader hblur5 1 0
blur5shader vblur5 0 1
rotoscope = [
clearpostfx
if (>= $numargs 1) [addpostfx rotoscope 0 0 0 $arg1]
if (>= $numargs 2) [
if (= $arg2 1) [addpostfx hblur3; addpostfx vblur3]
if (= $arg2 2) [addpostfx hblur5; addpostfx vblur5]
]
]

View File

@ -0,0 +1,98 @@
//////////////////////////////////////////////////////////////////////
//
// upscaling shaders
//
//////////////////////////////////////////////////////////////////////
shader 0 "scalelinear" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = texture2DRect(tex0, texcoord0);
}
]
loop i 2 [
lazyshader 0 (? $i "scalecubicy" "scalecubicx") [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
vec4 cubic(float s)
{
const float B = @gscalecubicsoft, C = @(divf (-f 1 $gscalecubicsoft) 2);
float s2 = s*s, s3 = s2*s;
return vec4((-1.0/6.0*B - C) * s3 + (0.5*B + 2.0*C) * s2 + (-0.5*B - C) * s + 1.0/6.0*B,
(2.0 - 1.5*B - C) * s3 + (-3.0 + 2.0*B + C) * s2 + (1.0 - 1.0/3.0*B),
(-2.0 + 1.5*B + C) * s3 + (3.0 - 2.5*B - 2.0*C) * s2 + (0.5*B + C)*s + 1.0/6.0*B,
(1.0/6.0*B + C) * s3 - C * s2);
}
void main(void)
{
vec2 center = texcoord0;
@(if $i [result [
float offset = fract(texcoord0.y-0.5);
center.y -= offset;
#define texval(tap) texture2DRect(tex0, center + vec2(0.0, tap))
#define texvaloffset(tap) texture2DRectOffset(tex0, center, ivec2(0, tap))
]] [result [
float offset = fract(texcoord0.x-0.5);
center.x -= offset;
#define texval(tap) texture2DRect(tex0, center + vec2(tap, 0.0))
#define texvaloffset(tap) texture2DRectOffset(tex0, center, ivec2(tap, 0))
]])
vec4 weight = cubic(offset);
weight.y += weight.z;
weight.z /= weight.y;
fragcolor = weight.x*texvaloffset(-1) + weight.y*texval(weight.z) + weight.w*texvaloffset(2);
}
]
]
shader 0 "reorient" [
attribute vec4 vvertex;
uniform vec3 reorientx, reorienty;
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0.x = dot(vvertex.xy, reorientx.xy) + reorientx.z;
texcoord0.y = dot(vvertex.xy, reorienty.xy) + reorienty.z;
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = texture2DRect(tex0, texcoord0);
}
]

View File

@ -0,0 +1,178 @@
lazyshader = [
defershader $arg1 $arg2 [
shader @arg1 @arg2 [@@arg3] [@@arg4]
]
]
ginterpdepth = [
result [
uniform vec2 lineardepthscale;
uniform vec3 gdepthpackparams;
varying float lineardepth;
]
]
ginterpvert = [
if (|| $gdepthformat $arg1) [ginterpdepth]
]
msaainterpvert = [ginterpvert $msaasamples]
ginterpfrag = [
result [
fragdata(0) vec4 gcolor;
fragdata(1) vec4 gnormal;
@(? $gdepthformat [
fragdata(2) vec4 gdepth;
fragdata(3) vec4 gglow;
] [
fragdata(2) vec4 gglow;
])
@(if (|| $gdepthformat $arg1) [ginterpdepth])
]
]
msaainterpfrag = [ginterpfrag $msaasamples]
gdepthpackvert = [
if (|| $gdepthformat $arg1) [result [
lineardepth = dot(lineardepthscale, gl_Position.zw);
]]
]
msaapackvert = [gdepthpackvert $msaasamples]
gpackdepth = [
result [
vec3 @arg1 = @arg2 * gdepthpackparams;
@arg1 = vec3(@arg1.x, fract(@arg1.yz));
@arg1.xy -= @arg1.yz * (1.0/255.0);
]
]
ghashdepth = [
if $arg3 [
arg1 = [(@arg1 + 5.0*@arg3)]
]
if $arg2 [result [
@arg2*0.76 + mix(0.75, 0.25, @arg2)*fract(@arg1*mix(-1.0/192.0, -1.0/64.0, @arg2))
]] [result [
0.75*fract(@arg1*(-1.0/192.0))
]]
]
gdepthpackfrag = [
result [
@(if (= $gdepthformat 1) [result [
@(gpackdepth packdepth lineardepth)
gdepth.rgb = packdepth;
gdepth.a = @(? $arg2 $arg2 [0.0]);
]] [? (> $gdepthformat 1) [
gdepth.r = lineardepth;
]])
@(if $usepacknorm [result [
gnormal.a = @(if $arg1 [ghashdepth lineardepth $arg2 $arg3] [? $arg2 $arg2 [0.0]]);
]])
]
]
msaapackfrag = [gdepthpackfrag $msaasamples $arg1 $arg2]
gspecpack = [
result [
gcolor.a = @(if $arg3 [result [@arg3 *]]) (@arg1 * 85.0/255.0 + 0.5/255.0) @(if $arg2 [result [+ @(if $arg3 [result [@arg4 *]]) 84.0/255.0*clamp(1.5 - 1.5/(1.0 + @arg2), 0.0, 1.0)]]);
]
]
gnormpack = [
if $usepacknorm [result [
gnormal.rgb = @arg1 @(if $arg2 [result [* sqrt(0.25 + 0.5*(@arg2))]]) * 0.5 + 0.5;
]] [result [
gnormal.rgb = @arg1*0.5 + 0.5;
gnormal.a = @(if $arg2 [result [(@arg2)]] [result [1.0]]);
]]
]
gnormpackdef = [
result [
#ifdef @arg2
@(gnormpack $arg1 $arg2)
#else
@(gnormpack $arg1)
#endif
]
]
gglowpack = [
result [
@(if $arg1 [result [
float colork = max(gcolor.r, max(gcolor.g, gcolor.b)), glowk = max(@arg1.r, max(@arg1.g, @arg1.b));
]])
glowk /= glowk + colork + 1.0e-3;
gcolor.rgb = @(if $arg1 [result [mix(gcolor.rgb, @arg1, glowk)]] [result [gcolor.rgb]]) * (1.0 - 2.0*glowk*(glowk - 1.0));
#define @arg2 1.0-glowk
]
]
gdepthunpackparams = [
result [
uniform vec3 gdepthscale;
uniform vec3 gdepthunpackparams;
]
]
gdepthunpack = [
if $arg6 [
if $arg7 [result [
vec3 @[arg7] = @[arg2].rgb;
float @[arg1] = dot(@[arg7], gdepthunpackparams);
@arg3
]] [result [
float @[arg1] = dot(@[arg2].rgb, gdepthunpackparams);
@arg3
]]
] [if (|| $gdepthformat $arg5) [
if (|| (> $gdepthformat 1) $arg5) [result [
float @[arg1] = @[arg2].r;
@arg3
]] [result [
float @[arg1] = dot(@[arg2].rgb, gdepthunpackparams);
@arg3
]]
] [if (=s $arg4 []) [result [
float @[arg1] = gdepthscale.x / (@[arg2].r*gdepthscale.y + gdepthscale.z);
]] [result [
float @[arg1] = @[arg2].r;
@arg4
]]]]
]
gdepthunpackortho = [
result [
float @[arg1] = @(if (= $gdepthformat 1) [result [dot(@[arg2].rgb, gdepthunpackparams)]] [result [@[arg2].r]]);
@arg3
]
]
gfetchdefs = [
gfetchprefix = (? $arg3 $arg3 "gfetch")
if (? (>= $numargs 2) $arg2 $msaalight) [result [
uniform sampler2DMS @(prettylist $arg1);
#define @[gfetchprefix]sample 0
#define @[gfetchprefix](sampler, coords) texelFetch(sampler, ivec2(coords), @[gfetchprefix]sample)
#define @[gfetchprefix]offset(sampler, coords, offset) texelFetch(sampler, ivec2(coords) + offset, @[gfetchprefix]sample)
#define @[gfetchprefix]proj(sampler, coords) texelFetch(sampler, ivec2(coords.xy / coords.z), @[gfetchprefix]sample)
@(if (! $arg3) [gdepthunpackparams])
]] [result [
uniform sampler2DRect @(prettylist $arg1);
#define @[gfetchprefix](sampler, coords) texture2DRect(sampler, coords)
#define @[gfetchprefix]offset(sampler, coords, offset) texture2DRectOffset(sampler, coords, offset)
#define @[gfetchprefix]proj(sampler, coords) texture2DRectProj(sampler, coords)
@(if (! $arg3) [gdepthunpackparams])
]]
]
screentexcoord = [
result [
uniform vec4 screentexcoord@arg1;
#define vtexcoord@arg1 (vvertex.xy * screentexcoord@arg1.xy + screentexcoord@arg1.zw)
]
]

163
config/glsl/sky.cfg 100644
View File

@ -0,0 +1,163 @@
////////////////////////////////////////////////
//
// sky shaders
//
////////////////////////////////////////////////
shader 0 "skybox" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 skymatrix;
uniform float ldrscale;
varying vec4 colorscale;
varying vec2 texcoord0;
void main(void)
{
gl_Position = skymatrix * vvertex;
texcoord0 = vtexcoord0;
colorscale = vec4(ldrscale * vcolor.rgb, vcolor.a);
}
] [
uniform sampler2D tex0;
varying vec4 colorscale;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
fragcolor = colorscale * color;
}
]
shader 0 "skyboxoverbright" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 skymatrix;
uniform float ldrscale;
varying vec4 colorscale;
varying vec2 texcoord0;
void main(void)
{
gl_Position = skymatrix * vvertex;
texcoord0 = vtexcoord0;
colorscale = vec4(ldrscale * vcolor.rgb, vcolor.a);
}
] [
uniform sampler2D tex0;
uniform vec3 overbrightparams;
uniform float ldrscale;
varying vec4 colorscale;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
float lum = dot(vec3(@lumweights), color.rgb);
float overbright = mix(overbrightparams.x, overbrightparams.y, clamp(lum - overbrightparams.z, 0.0, 1.0));
color.rgb *= overbright;
fragcolor = colorscale * color;
}
]
shader 0 "atmosphere" [
attribute vec4 vvertex;
uniform mat4 sunmatrix;
varying vec3 camvec;
void main(void)
{
gl_Position = vvertex;
vec4 p = sunmatrix * vvertex;
camvec = p.xyz / p.w;
}
] [
// adapted from http://blog.cloudparty.com/2013/09/25/stunning-procedural-skies-in-webgl-part-2/
uniform vec3 sunlight;
uniform vec3 sundir;
uniform vec3 sundiskparams;
uniform vec3 atmoradius;
uniform float gm;
uniform vec3 betar, betam, betarm;
uniform vec2 hdrgamma;
uniform float atmoalpha;
varying vec3 camvec;
fragdata(0) vec4 fragcolor;
vec3 calcextinction(float dist)
{
return exp2(-dist * betarm);
}
vec3 calcscatter(float costheta)
{
float rphase = 1.0 + costheta*costheta;
float mphase = pow(1.0 + gm*(gm - 2.0*costheta), -1.5);
return betar*rphase + betam*mphase;
}
float baseopticaldepth(vec3 ray)
{
float a = atmoradius.x * max(ray.z, min(sundir.z, 0.0));
return sqrt(a*a + atmoradius.z) - a;
}
float opticaldepth(vec3 pos, vec3 ray)
{
pos.z = max(pos.z, 0.0) + atmoradius.x;
float a = dot(pos, ray);
return sqrt(a*a + atmoradius.y - dot(pos, pos)) - a;
}
void main(void)
{
vec3 camdir = normalize(camvec);
float costheta = dot(camdir, sundir);
// optical depth along view ray
float raydist = baseopticaldepth(camdir);
// extinction of light along view ray
vec3 extinction = calcextinction(raydist);
// optical depth for incoming light hitting the view ray
float lightraydist = opticaldepth(camdir * (raydist * max(0.15 + 0.75 * sundir.z, 0.0)), sundir);
// cast a ray towards the sun and calculate the incoming extincted light
vec3 incominglight = calcextinction(lightraydist);
// calculate the in-scattering
vec3 scattering = calcscatter(costheta) * (1.0 - extinction);
// combine
vec3 inscatter = incominglight * scattering;
// sun disk
vec3 sundisk = sundiskparams.z * extinction * pow(clamp(costheta*sundiskparams.x + sundiskparams.y, 0.0, 1.0), 8.0);
inscatter += sundisk;
@(hdrgammaencode inscatter)
fragcolor = vec4(sunlight * inscatter, atmoalpha);
}
]
shader 0 "skyfog" [
attribute vec4 vvertex, vcolor;
uniform mat4 skymatrix;
uniform float ldrscale;
varying vec4 color;
void main(void)
{
gl_Position = skymatrix * vvertex;
color = vec4(ldrscale * vcolor.rgb, vcolor.a);
}
] [
uniform sampler2D tex0;
varying vec4 color;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = color;
}
]

View File

@ -0,0 +1,623 @@
// Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com)
// Copyright (C) 2013 Jose I. Echevarria (joseignacioechevarria@gmail.com)
// Copyright (C) 2013 Belen Masia (bmasia@unizar.es)
// Copyright (C) 2013 Fernando Navarro (fernandn@microsoft.com)
// Copyright (C) 2013 Diego Gutierrez (diegog@unizar.es)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to
// do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software. As clarification, there
// is no requirement that the copyright notice and permission be included in
// binary distributions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// _______ ___ ___ ___ ___
// / || \/ | / \ / \
// | (---- | \ / | / ^ \ / ^ \
// \ \ | |\/| | / /_\ \ / /_\ \
// ----) | | | | | / _____ \ / _____ \
// |_______/ |__| |__| /__/ \__\ /__/ \__\
//
// E N H A N C E D
// S U B P I X E L M O R P H O L O G I C A L A N T I A L I A S I N G
//
// http://www.iryoku.com/smaa/
smaadefs = [
#define SMAA_PRESET @smaapreset
#if SMAA_PRESET == 1
#define SMAA_THRESHOLD 0.1
#define SMAA_MAX_SEARCH_STEPS 8
#define SMAA_MAX_SEARCH_STEPS_DIAG 0
#define SMAA_CORNER_ROUNDING 100
#elif SMAA_PRESET == 2
#define SMAA_THRESHOLD 0.1
#define SMAA_MAX_SEARCH_STEPS 16
#define SMAA_MAX_SEARCH_STEPS_DIAG 8
#define SMAA_CORNER_ROUNDING 25
#elif SMAA_PRESET == 3
#define SMAA_THRESHOLD 0.05
#define SMAA_MAX_SEARCH_STEPS 32
#define SMAA_MAX_SEARCH_STEPS_DIAG 16
#define SMAA_CORNER_ROUNDING 25
#else
#define SMAA_THRESHOLD 0.15
#define SMAA_MAX_SEARCH_STEPS 4
#define SMAA_MAX_SEARCH_STEPS_DIAG 0
#define SMAA_CORNER_ROUNDING 100
#endif
#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 2.0
#define SMAA_CORNER_ROUNDING_NORM (float(SMAA_CORNER_ROUNDING) / 100.0)
#define SMAA_AREATEX_MAX_DISTANCE 16
#define SMAA_AREATEX_MAX_DISTANCE_DIAG 20
#define SMAA_AREATEX_WIDTH 160
#define SMAA_AREATEX_HEIGHT 560
#define SMAA_SEARCHTEX_WIDTH 66
#define SMAA_SEARCHTEX_HEIGHT 33
#define SMAA_AREATEX_SUBSAMPLES 80
@(? (smaaopt "g") [
#define SMAA_LUMA(color) (color.g)
] [
#define SMAA_LUMA(color) (color.a)
])
@(? (smaaopt "a") [
#define SMAA_AREA(vals) (vals.ra)
] [
#define SMAA_AREA(vals) (vals.rg)
])
@(? (|| (smaaopt "t") [smaaopt "s"]) [
#define SMAA_AREA_OFFSET(texcoord, offset) texcoord.y += offset*float(SMAA_AREATEX_SUBSAMPLES)
] [
#define SMAA_AREA_OFFSET(texcoord, offset)
])
]
shader 0 [SMAALumaEdgeDetection@smaapreset@smaaopts] [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
@smaadefs
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
// Calculate lumas:
float L = SMAA_LUMA(texture2DRect(tex0, texcoord0));
float Lleft = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)));
float Ltop = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(0, -1)));
// We do the usual threshold:
vec2 delta = abs(L - vec2(Lleft, Ltop));
vec2 edges = step(SMAA_THRESHOLD, delta);
// Then discard if there is no edge:
@(? (smaaopt "d") [
if (edges.x + edges.y == 0.0) discard;
else
] [
if (edges.x + edges.y > 0.0)
])
{
// Calculate right and bottom deltas:
float Lright = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(1, 0)));
float Lbottom = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(0, 1)));
// Calculate the maximum delta in the direct neighborhood:
vec2 maxDelta = max(delta, abs(L - vec2(Lright, Lbottom)));
// Calculate left-left and top-top deltas:
float Lleftleft = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(-2, 0)));
float Ltoptop = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(0, -2)));
// Calculate the final maximum delta:
maxDelta = max(maxDelta, abs(vec2(Lleft, Ltop) - vec2(Lleftleft, Ltoptop)));
/**
* Each edge with a delta in luma of less than 50% of the maximum luma
* surrounding this pixel is discarded. This allows to eliminate spurious
* crossing edges, and is based on the fact that, if there is too much
* contrast in a direction, that will hide contrast in the other
* neighbors.
* This is done after the discard intentionally as this situation doesn't
* happen too frequently (but it's important to do as it prevents some
* edges from going undetected).
*/
edges *= step(max(maxDelta.x, maxDelta.y), SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta);
}
fragcolor = vec4(edges, 0.0, 0.0);
}
]
shader 0 [SMAAColorEdgeDetection@smaapreset@smaaopts] [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
@smaadefs
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
// Calculate color deltas:
vec3 C = texture2DRect(tex0, texcoord0).rgb;
vec3 Cleft = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb);
vec3 Ctop = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(0, -1)).rgb);
vec2 delta;
delta.x = max(max(Cleft.r, Cleft.g), Cleft.b);
delta.y = max(max(Ctop.r, Ctop.g), Ctop.b);
// We do the usual threshold:
vec2 edges = step(SMAA_THRESHOLD, delta);
// Then discard if there is no edge:
@(? (smaaopt "d") [
if (edges.x + edges.y == 0.0) discard;
else
] [
if (edges.x + edges.y > 0.0)
])
{
// Calculate right and bottom deltas:
vec3 Cright = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(1, 0)).rgb);
vec3 Cbottom = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(0, 1)).rgb);
// Calculate left-left and top-top deltas:
vec3 Cleftleft = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(-2, 0)).rgb);
vec3 Ctoptop = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(0, -2)).rgb);
// Calculate the maximum delta in the direct neighborhood:
vec3 t = max(max(Cright, Cbottom), max(Cleftleft, Ctoptop));
// Calculate the final maximum delta:
float maxDelta = max(max(delta.x, delta.y), max(max(t.r, t.g), t.b));
// Local contrast adaptation in action:
edges *= step(maxDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta);
}
fragcolor = vec4(edges, 0.0, 0.0);
}
]
shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
@smaadefs
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0, texcoord1, texcoord2, texcoord3, texcoord4, texcoord5;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
// We will use these offsets for the searches later on (see PSEUDO_GATHER4):
texcoord1 = vtexcoord0 + vec2( -0.25, -0.125);
texcoord2 = vtexcoord0 + vec2( 1.25, -0.125);
texcoord3 = vtexcoord0 + vec2(-0.125, -0.25);
texcoord4 = vtexcoord0 + vec2(-0.125, 1.25);
texcoord5 = vtexcoord0 + vec2( 0.25, 0.0);
}
] [
@smaadefs
varying vec2 texcoord0, texcoord1, texcoord2, texcoord3, texcoord4, texcoord5;
uniform sampler2DRect tex0, tex1, tex2;
uniform vec4 subsamples;
fragdata(0) vec4 fragcolor;
#if __VERSION__ >= 130 || defined(GL_EXT_gpu_shader4)
#define SMAARound(e) round(e)
#else
#define SMAARound(e) floor(e + 0.5)
#endif
//-----------------------------------------------------------------------------
// Diagonal Search Functions
#if SMAA_MAX_SEARCH_STEPS_DIAG > 0
/**
* Allows to decode two binary values from a bilinear-filtered access.
*/
#define SMAADecodeDiagBilinearAccess(e) (e * abs(6.0 * e - 5.0))
/**
* These functions allows to perform diagonal pattern searches.
*/
float SMAASearchDiagRightUp(void) {
vec2 e = texture2DRectOffset(tex0, texcoord0, ivec2(1, -1)).rg;
vec2 texcoord = texcoord0 + vec2(1.0, -1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (e.x + e.y < 1.5) break;
texcoord += vec2(1.0, -1.0);
e = texture2DRect(tex0, texcoord).rg;
}
return (texcoord.x - texcoord0.x) - 1.0;
}
float SMAASearchDiagLeftDown(void) {
vec2 e = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 1)).rg;
vec2 texcoord = texcoord0 + vec2(-1.0, 1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (e.x + e.y < 1.5) break;
texcoord += vec2(-1.0, 1.0);
e = texture2DRect(tex0, texcoord).rg;
}
return (texcoord0.x - texcoord.x) - 1.0 + SMAARound(e.y);
}
float SMAASearchDiagLeftUp(void) {
vec2 e = texture2DRectOffset(tex0, texcoord5, ivec2(-1, -1)).rg;
vec2 texcoord = texcoord5 + vec2(-1.0, -1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (SMAADecodeDiagBilinearAccess(e.x) + e.y < 1.5) break;
texcoord += vec2(-1.0, -1.0);
e = texture2DRect(tex0, texcoord).rg;
}
return (texcoord5.x - texcoord.x) - 1.0;
}
float SMAASearchDiagRightDown(void) {
vec2 e = texture2DRectOffset(tex0, texcoord5, ivec2(1, 1)).rg;
vec2 texcoord = texcoord5 + vec2(1.0, 1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (SMAADecodeDiagBilinearAccess(e.x) + e.y < 1.5) break;
texcoord += vec2(1.0, 1.0);
e = texture2DRect(tex0, texcoord).rg;
}
return (texcoord.x - texcoord5.x) - 1.0 + SMAARound(e.y);
}
/**
* Similar to SMAAArea, this calculates the area corresponding to a certain
* diagonal distance and crossing edges 'e'.
*/
vec2 SMAAAreaDiag(vec2 dist, vec2 e, float offset) {
vec2 texcoord = float(SMAA_AREATEX_MAX_DISTANCE_DIAG) * e + dist;
// We do a scale and bias for mapping to texel space:
texcoord = texcoord + 0.5;
// Diagonal areas are on the second half of the texture:
texcoord.x += 0.5*float(SMAA_AREATEX_WIDTH);
// Move to proper place, according to the subpixel offset:
SMAA_AREA_OFFSET(texcoord, offset);
return SMAA_AREA(texture2DRect(tex1, texcoord));
}
/**
* This searches for diagonal patterns and returns the corresponding weights.
*/
vec2 SMAACalculateDiagWeights(vec2 e) {
vec2 weights = vec2(0.0);
vec2 d;
d.x = e.r > 0.5 ? SMAASearchDiagLeftDown() : 0.0;
d.y = SMAASearchDiagRightUp();
if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3
vec4 coords = vec4(0.25 - d.x, d.x, d.y, -0.25 - d.y) + texcoord0.xyxy;
vec4 c;
c.xy = texture2DRectOffset(tex0, coords.xy, ivec2(-1, 0)).rg;
c.zw = texture2DRectOffset(tex0, coords.zw, ivec2( 1, 0)).rg;
c.xz = SMAADecodeDiagBilinearAccess(c.xz);
c = SMAARound(c);
vec2 e = 2.0 * c.yw + c.xz;
e *= step(d, vec2(float(SMAA_MAX_SEARCH_STEPS_DIAG) - 0.5));
weights += SMAAAreaDiag(d, e, subsamples.z);
}
d.x = SMAASearchDiagLeftUp();
d.y = SMAADecodeDiagBilinearAccess(e.r) > 0.5 ? SMAASearchDiagRightDown() : 0.0;
if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3
vec4 coords = vec4(-d.xx, d.yy) + texcoord0.xyxy;
vec4 c;
c.x = texture2DRectOffset(tex0, coords.xy, ivec2(-1, 0)).g;
c.y = texture2DRectOffset(tex0, coords.xy, ivec2( 0, -1)).r;
c.zw = texture2DRectOffset(tex0, coords.zw, ivec2( 1, 0)).gr;
vec2 e = 2.0 * c.xz + c.yw;
e *= step(d, vec2(float(SMAA_MAX_SEARCH_STEPS_DIAG) - 0.5));
weights += SMAAAreaDiag(d, e, subsamples.w).gr;
}
return weights;
}
#endif
//-----------------------------------------------------------------------------
// Horizontal/Vertical Search Functions
/**
* This allows to determine how much length should we add in the last step
* of the searches. It takes the bilinearly interpolated edge (see
* PSEUDO_GATHER4), and adds 0, 1 or 2, depending on which edges and
* crossing edges are active.
*/
float SMAASearchLength(vec2 e, float bias, float scale) {
e.r = bias + e.r * scale;
return 255.0 * texture2DRect(tex2, e*vec2(float(SMAA_SEARCHTEX_WIDTH), float(SMAA_SEARCHTEX_HEIGHT))).r;
}
/**
* Horizontal/vertical search functions for the 2nd pass.
*/
float SMAASearchXLeft(void) {
/**
* PSEUDO_GATHER4
* This texcoord has been offset by (-0.25, -0.125) in the vertex shader to
* sample between edge, thus fetching four edges in a row.
* Sampling with different offsets in each direction allows to disambiguate
* which edges are active from the four fetched ones.
*/
vec2 e = texture2DRect(tex0, texcoord1).rg;
vec2 texcoord = texcoord1;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.g <= 0.8281 || e.r > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.x -= 2.0;
e = texture2DRect(tex0, texcoord).rg;
}
// We correct the previous (-0.25, -0.125) offset we applied:
// The searches are bias by 1, so adjust the coords accordingly:
// Disambiguate the length added by the last step:
return texcoord.x + (0.25 + 1.0) - SMAASearchLength(e, 0.0, 0.5);
}
float SMAASearchXRight(void) {
vec2 e = texture2DRect(tex0, texcoord2).rg;
vec2 texcoord = texcoord2;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.g <= 0.8281 || e.r > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.x += 2.0;
e = texture2DRect(tex0, texcoord).rg;
}
return texcoord.x - (0.25 + 1.0) + SMAASearchLength(e, 0.5, 0.5);
}
float SMAASearchYUp(void) {
vec2 e = texture2DRect(tex0, texcoord3).rg;
vec2 texcoord = texcoord3;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.r <= 0.8281 || e.g > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.y -= 2.0;
e = texture2DRect(tex0, texcoord).rg;
}
return texcoord.y + (0.25 + 1.0) - SMAASearchLength(e.gr, 0.0, 0.5);
}
float SMAASearchYDown(void) {
vec2 e = texture2DRect(tex0, texcoord4).rg;
vec2 texcoord = texcoord4;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.r <= 0.8281 || e.g > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.y += 2.0;
e = texture2DRect(tex0, texcoord).rg;
}
return texcoord.y - (0.25 + 1.0) + SMAASearchLength(e.gr, 0.5, 0.5);
}
/**
* Ok, we have the distance and both crossing edges. So, what are the areas
* at each side of current edge?
*/
vec2 SMAAArea(vec2 dist, vec2 e, float offset) {
// SMAAArea below needs a sqrt, as the areas texture is compressed
// quadratically:
// Rounding prevents precision errors of bilinear filtering:
vec2 texcoord = float(SMAA_AREATEX_MAX_DISTANCE) * SMAARound(4.0 * e) + sqrt(dist);
// We do a scale and bias for mapping to texel space:
texcoord = texcoord + 0.5;
// Move to proper place, according to the subpixel offset:
SMAA_AREA_OFFSET(texcoord, offset);
return SMAA_AREA(texture2DRect(tex1, texcoord));
}
//-----------------------------------------------------------------------------
// Corner Detection Functions
#if SMAA_CORNER_ROUNDING < 100
vec2 SMAADetectHorizontalCornerPattern(vec3 coords, vec2 d) {
vec2 e;
if(d.x >= d.y) coords.x = coords.z + 1.0 - 0.5*step(d.x, d.y);
e.r = texture2DRectOffset(tex0, coords.xy, ivec2(0, 1)).r;
e.g = texture2DRectOffset(tex0, coords.xy, ivec2(0, -2)).r;
return clamp(1.0 - (1.0 - SMAA_CORNER_ROUNDING_NORM) * e, 0.0, 1.0);
}
vec2 SMAADetectVerticalCornerPattern(vec3 coords, vec2 d) {
vec2 e;
if(d.x >= d.y) coords.y = coords.z + 1.0 - 0.5*step(d.x, d.y);
e.r = texture2DRectOffset(tex0, coords.xy, ivec2( 1, 0)).g;
e.g = texture2DRectOffset(tex0, coords.xy, ivec2(-2, 0)).g;
return clamp(1.0 - (1.0 - SMAA_CORNER_ROUNDING_NORM) * e, 0.0, 1.0);
}
#endif
//-----------------------------------------------------------------------------
// Blending Weight Calculation Pixel Shader (Second Pass)
void main(void)
{
vec4 weights = vec4(0.0);
vec2 e = texture2DRect(tex0, texcoord5).rg;
if (e.g > 0.5) { // Edge at north
#if SMAA_MAX_SEARCH_STEPS_DIAG > 0
// Diagonals have both north and west edges, so searching for them in
// one of the boundaries is enough.
weights.rg = SMAACalculateDiagWeights(e);
// We give priority to diagonals, so if we find a diagonal we skip
// horizontal/vertical processing.
if (weights.r + weights.g == 0.0) {
#endif
// Find the distance to the left:
vec3 coords;
coords.x = SMAASearchXLeft();
coords.y = texcoord3.y; // texcoord3.y = texcoord0.y - 0.25 (CROSSING_OFFSET)
// Find the distance to the right:
coords.z = SMAASearchXRight();
// We want the distances to be in pixel units (doing this here allow to
// better interleave arithmetic and memory accesses):
vec2 d = SMAARound(abs(coords.xz - texcoord0.x));
// Now fetch the left crossing edges, two at a time using bilinear
// filtering. Sampling at -0.25 (see CROSSING_OFFSET) enables to
// discern what value each edge has:
vec2 e;
e.x = texture2DRect(tex0, coords.xy).r;
// Fetch the right crossing edges:
e.y = texture2DRectOffset(tex0, coords.zy, ivec2(1, 0)).r;
// Ok, we know how this pattern looks like, now it is time for getting
// the actual area:
weights.rg = SMAAArea(d, e, subsamples.y);
#if SMAA_CORNER_ROUNDING < 100
// Fix corners:
coords.y = texcoord0.y;
weights.rg *= SMAADetectHorizontalCornerPattern(coords, d);
#endif
#if SMAA_MAX_SEARCH_STEPS_DIAG > 0
} else
e.r = 0.0; // Skip vertical processing.
#endif
}
if (e.r > 0.5) { // Edge at west
// Find the distance to the top:
vec3 coords;
coords.y = SMAASearchYUp();
coords.x = texcoord1.x; // texcoord1.x = texcoord0.x - 0.25;
// Find the distance to the bottom:
coords.z = SMAASearchYDown();
// We want the distances to be in pixel units:
vec2 d = SMAARound(abs(coords.yz - texcoord0.y));
// Fetch the top crossing edges:
vec2 e;
e.x = texture2DRect(tex0, coords.xy).g;
// Fetch the bottom crossing edges:
e.y = texture2DRectOffset(tex0, coords.xz, ivec2(0, 1)).g;
// Get the area for this direction:
weights.ba = SMAAArea(d, e, subsamples.x);
#if SMAA_CORNER_ROUNDING < 100
// Fix corners:
coords.x = texcoord0.x;
weights.ba *= SMAADetectVerticalCornerPattern(coords, d);
#endif
}
fragcolor = weights;
}
]
shader 0 [SMAANeighborhoodBlending@smaapreset@smaaopts] [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
@smaadefs
varying vec2 texcoord0;
uniform sampler2DRect tex0, tex1;
@(? (smaaopt "s") [uniform sampler2DRect tex2, tex3;])
fragdata(0) vec4 fragcolor;
// Neighborhood Blending Pixel Shader (Third Pass)
void main(void)
{
// Fetch the blending weights for current pixel:
vec4 a;
a.xz = texture2DRect(tex1, texcoord0).rb;
a.y = texture2DRectOffset(tex1, texcoord0, ivec2(0, 1)).g;
a.w = texture2DRectOffset(tex1, texcoord0, ivec2(1, 0)).a;
// Up to 4 lines can be crossing a pixel (one through each edge). We
// favor blending by choosing the line with the maximum weight for each
// direction:
vec2 offset;
offset.x = a.w > a.z ? a.w : -a.z; // left vs. right
offset.y = a.y > a.x ? a.y : -a.x; // top vs. bottom
// Then we go in the direction that has the maximum weight:
if (abs(offset.x) > abs(offset.y)) // horizontal vs. vertical
offset.y = 0.0;
else
offset.x = 0.0;
// We exploit bilinear filtering to mix current pixel with the chosen
// neighbor:
fragcolor = texture2DRect(tex0, texcoord0 + offset);
@(? (smaaopt "s") [
a.xz = texture2DRect(tex3, texcoord0).rb;
a.y = texture2DRectOffset(tex3, texcoord0, ivec2(0, 1)).g;
a.w = texture2DRectOffset(tex3, texcoord0, ivec2(1, 0)).a;
offset.x = a.w > a.z ? a.w : -a.z;
offset.y = a.y > a.x ? a.y : -a.x;
if (abs(offset.x) > abs(offset.y))
offset.y = 0.0;
else
offset.x = 0.0;
fragcolor = 0.5*(fragcolor + texture2DRect(tex2, texcoord0 + offset));
])
}
]

View File

@ -0,0 +1,75 @@
////////////////////////////////////////////////
//
// stain shaders
//
////////////////////////////////////////////////
// staintype:
// o -> overbright
// t -> transparent
// f -> fogged
stainopt = [ >= (strstr $staintype $arg1) 0 ]
stainvariantshader = [
local staintype
staintype = $arg2
variantshader 0 $arg1 (? (stainopt "t") 0 -1) (if (! (stainopt "t")) [result [
@(? (stainopt "f") [
//:fog
])
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec4 colorscale;
varying vec4 color;
varying vec2 texcoord0;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
color = vcolor * colorscale;
texcoord0 = vtexcoord0;
}
]]) [
uniform sampler2D tex0;
varying vec4 color;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
@(? (stainopt "t") [
fragdata(1) vec4 gglow;
])
void main(void)
{
vec4 diffuse = texture2D(tex0, texcoord0);
@(if (stainopt "o") [result [
diffuse.rgb = mix(vec3(0.5), diffuse.rgb, color.rgb);
fragcolor.rgb = diffuse.rgb;
fragcolor.a = 0.5;
@(? (stainopt "t") [
gglow.rgb = diffuse.rgb;
gglow.a = 0.5;
])
]] [result [
diffuse *= color;
fragcolor = diffuse;
@(? (stainopt "t") [
gglow.rgb = vec3(0.0);
gglow.a = diffuse.a;
])
]])
}
]
]
stainshader = [
staintype = $arg2
stainvariantshader $arg1 $arg2
if (! (stainopt "f")) [
stainvariantshader $arg1 (concatword $arg2 "t")
]
]
stainshader "stain" ""
stainshader "overbrightstain" "o"
stainshader "foggedstain" "f"

View File

@ -0,0 +1,477 @@
////////////////////////////////////////////////
//
// tonemapping
//
////////////////////////////////////////////////
shader 0 "hdrreduce" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor.rgb = texture2DRect(tex0, texcoord0).rgb;
}
]
shader 0 "hdrreduce2w" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor.rgb = 0.5*(texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb + texture2DRectOffset(tex0, texcoord0, ivec2(1, 0)).rgb);
}
]
shader 0 "hdrreduce2" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor.rgb = 0.25*(texture2DRectOffset(tex0, texcoord0, ivec2(-1, -1)).rgb + texture2DRectOffset(tex0, texcoord0, ivec2(1, -1)).rgb +
texture2DRectOffset(tex0, texcoord0, ivec2(1, 1)).rgb + texture2DRectOffset(tex0, texcoord0, ivec2(-1, 1)).rgb);
}
]
lazyshader 0 msaaresolve [
attribute vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
}
] [
uniform sampler2DMS tex0;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = texelFetch(tex0, ivec2(gl_FragCoord.xy), 0);
}
]
lazyshader 0 msaaresolvedepth [
attribute vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
}
] [
uniform sampler2DMS tex0;
@(if $gdepthformat [result [
@(gdepthunpackparams)
uniform vec2 gdepthinvscale;
fragdata(0) vec4 fragcolor;
]])
void main(void)
{
@(if $gdepthformat [result [
vec4 packdepth = texelFetch(tex0, ivec2(gl_FragCoord.xy), 0);
@(gdepthunpack depth packdepth)
fragcolor = packdepth;
gl_FragDepth = gdepthinvscale.x / depth - gdepthinvscale.y;
]] [result [
gl_FragDepth = texelFetch(tex0, ivec2(gl_FragCoord.xy), 0).r;
]])
}
]
lazyshader 0 msaareducew [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 tap0, tap1;
void main(void)
{
gl_Position = vvertex;
tap0 = vtexcoord0;
tap1 = vtexcoord0 + vec2(-1.0, 0.0);
}
] [
uniform sampler2DMS tex0;
varying vec2 tap0, tap1;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = 0.5*(texelFetch(tex0, ivec2(tap0), 0) + texelFetch(tex0, ivec2(tap1), 0));
}
]
lazyshader 0 msaareduce [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 tap0, tap1, tap2, tap3;
void main(void)
{
gl_Position = vvertex;
tap0 = vtexcoord0;
tap1 = vtexcoord0 + vec2(-1.0, 0.0);
tap2 = vtexcoord0 + vec2( 0.0, -1.0);
tap3 = vtexcoord0 + vec2(-1.0, -1.0);
}
] [
uniform sampler2DMS tex0;
varying vec2 tap0, tap1, tap2, tap3;
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = 0.25*(texelFetch(tex0, ivec2(tap0), 0) + texelFetch(tex0, ivec2(tap1), 0) +
texelFetch(tex0, ivec2(tap2), 0) + texelFetch(tex0, ivec2(tap3), 0));
}
]
lumweights = "0.2126, 0.7152, 0.0722"
//lumweights = "0.299, 0.587, 0.114"
hdrgammadecode = [
if (=f $hdrgamma 2) [result [
@arg1 *= @arg1;
]] [result [
@arg1 = pow(@arg1, vec3(hdrgamma.x));
]]
]
hdrgammaencode = [
if (=f $hdrgamma 2) [result [
@arg1 = sqrt(@arg1);
]] [result [
@arg1 = pow(@arg1, vec3(hdrgamma.y));
]]
]
shader 0 "hdrluminance" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
uniform vec2 hdrgamma;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec3 color = texture2DRect(tex0, texcoord0).rgb*2.0;
@(hdrgammadecode color)
float lum = dot(color, vec3(@lumweights));
float loglum = sqrt(clamp(lum, 0.015625, 4.0)) * (1.0/2.0); // allow values as low as 2^-6, and as high 2^2
fragcolor.rgb = vec3(loglum);
}
]
shader 0 "hdrluminance2w" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
uniform vec2 hdrgamma;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
@(loopconcat i 2 [result [
vec3 color@[i] = texture2DRectOffset(tex0, texcoord0, ivec2(@(at ["-1, 0" "1, 0"] $i))).rgb*2.0;
@(hdrgammadecode [color@[i]])
float lum@[i] = dot(color@[i], vec3(@lumweights));
float loglum@[i] = sqrt(clamp(lum@[i], 0.015625, 4.0)) * (1.0/2.0);
]])
fragcolor.rgb = vec3(0.5*(loglum0 + loglum1));
}
]
shader 0 "hdrluminance2" [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler2DRect tex0;
uniform vec2 hdrgamma;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
@(loopconcat i 4 [result [
vec3 color@[i] = texture2DRectOffset(tex0, texcoord0, ivec2(@(at ["-1, -1" "1, -1" "1, 1" "-1, 1"] $i))).rgb*2.0;
@(hdrgammadecode [color@[i]])
float lum@[i] = dot(color@[i], vec3(@lumweights));
float loglum@[i] = sqrt(clamp(lum@[i], 0.015625, 4.0)) * (1.0/2.0);
]])
fragcolor.rgb = vec3(0.25*(loglum0 + loglum1 + loglum2 + loglum3));
}
]
shader 0 "hdraccum" [
attribute vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
}
] [
uniform sampler2DRect tex0;
uniform float accumscale;
fragdata(0) vec4 fragcolor;
void main(void)
{
float lum = texture2DRect(tex0, vec2(0.5, 0.5)).r * 2.0;
lum *= lum;
fragcolor = vec4(vec3(lum*0.25), accumscale);
}
]
shader 0 "hdrbloom" [
attribute vec4 vvertex;
@(screentexcoord 0)
@(? (>= $hwvtexunits 4) [
uniform sampler2D tex2;
] [
attribute float vcolor;
])
uniform vec4 hdrparams;
varying vec2 texcoord0;
flat varying float lumscale, lumthreshold;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
float avglum = 4.0 * @(? (>= $hwvtexunits 4) [texture2D(tex2, vec2(0.5, 0.5)).r] [vcolor]);
lumscale = hdrparams.x * -log2(1.0 - clamp(avglum, 0.03, 0.3))/(avglum + 1e-4);
lumthreshold = -log2(1.0 - hdrparams.z);
}
] [
uniform sampler2DRect tex0;
uniform vec2 hdrgamma;
varying vec2 texcoord0;
flat varying float lumscale, lumthreshold;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec3 color = texture2DRect(tex0, texcoord0).rgb*2.0;
@(hdrgammadecode color)
float lum = dot(color, vec3(@lumweights));
color *= max(lum*lumscale - lumthreshold, 0.0) / (lum + 1e-4);
@(hdrgammaencode color)
fragcolor.rgb = color;
}
]
hdrtonemapvertexshader = [
result [
attribute vec4 vvertex;
@(screentexcoord 0)
@(screentexcoord 1)
@(? (>= $hwvtexunits 4) [
uniform sampler2D tex2;
] [
attribute float vcolor;
])
uniform vec4 hdrparams;
varying vec2 texcoord0, texcoord1;
flat varying float lumscale, lumsaturate;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
texcoord1 = vtexcoord1;
float avglum = 4.0 * @(? (>= $hwvtexunits 4) [texture2D(tex2, vec2(0.5, 0.5)).r] [vcolor]);
lumscale = hdrparams.x * -log2(1.0 - clamp(avglum, 0.03, 0.3))/(avglum + 1e-4);
lumsaturate = -log2(1.0 - hdrparams.y) / lumscale;
}
]
]
hdrtonemapfrag = [
result [{
// color = 1.0 - exp2(-color*lumscale);
float lum = dot(@arg1, vec3(@lumweights));
@arg1 = min(@arg1, lumsaturate);
@arg1 *= (1.0 - exp2(-lum*lumscale)) / (dot(@arg1, vec3(@lumweights)) + 1e-4);
}]
]
hdrtonemapdefs = [
result [
uniform vec4 hdrparams;
uniform vec2 hdrgamma;
varying vec2 texcoord0, texcoord1;
flat varying float lumscale, lumsaturate;
]
]
hdrtonemapshaders = [
(? $arg1 lazyshader shader) 0 [hdrnop@arg1] [
attribute vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
@arg2
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec3 color = texture2DRect(tex0, texcoord0).rgb;
fragcolor.rgb = color;
@arg4
@(? $arg3 $arg3 [fragcolor.a = 0.0;])
}
]
(? $arg1 lazyshader shader) 0 [hdrtonemap@arg1] (hdrtonemapvertexshader) [
@arg2
uniform sampler2DRect tex0, tex1;
@(hdrtonemapdefs)
fragdata(0) vec4 fragcolor;
void main(void)
{
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 color = texture2DRect(tex0, texcoord0).rgb*2.0;
color += bloom;
@(hdrgammadecode color)
@(hdrtonemapfrag color)
@(hdrgammaencode color)
fragcolor.rgb = color;
@arg4
@(? $arg3 $arg3 [fragcolor.a = 0.0;])
}
]
if $msaasamples [msaatonemapshaders $arg1 $arg2 $arg3 $arg4]
if (= $msaasamples 2) [msaasplitshaders $arg1 $arg2 $arg3 $arg4]
]
msaatonemapshaders = [
if (=s $arg1 "") [lazyshader 0 [msaatonemapsample] (hdrtonemapvertexshader) [
#extension GL_ARB_sample_shading : enable
uniform sampler2DRect tex1;
uniform sampler2DMS tex0;
@(hdrtonemapdefs)
fragdata(0) vec4 fragcolor;
void main(void)
{
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 color = texelFetch(tex0, ivec2(texcoord0), gl_SampleID).rgb*2.0;
color += bloom;
@(hdrgammadecode color)
@(hdrtonemapfrag color)
@(hdrgammaencode color)
fragcolor = vec4(color, 0.0);
}
]]
lazyshader 0 [msaatonemap@arg1] (hdrtonemapvertexshader) [
@arg2
uniform sampler2DRect tex1;
uniform sampler2DMS tex0;
@(hdrtonemapdefs)
fragdata(0) vec4 fragcolor;
void main(void)
{
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 resolved = vec3(0.0);
for(int sampleidx = 0; sampleidx < @msaasamples; sampleidx++)
{
vec3 color = texelFetch(tex0, ivec2(texcoord0), sampleidx).rgb*2.0;
color += bloom;
@(hdrgammadecode color)
@(hdrtonemapfrag color)
@(hdrgammaencode color)
resolved += color;
}
fragcolor.rgb = resolved * @(divf 1 $msaasamples);
@arg4
@(? $arg3 $arg3 [fragcolor.a = 0.0;])
}
]
]
msaasplitshaders = [
lazyshader 0 [msaatonemapsplit@arg1] (hdrtonemapvertexshader) [
@arg2
uniform sampler2DRect tex1;
uniform sampler2DMS tex0;
@(hdrtonemapdefs)
@(loopconcat i $msaasamples [result [
fragdata(@i) vec4 fragcolor@i;
]])
void main(void)
{
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w;
@arg4
@(loopconcat i $msaasamples [result [
vec3 color@i = texelFetch(tex0, ivec2(texcoord0), @i).rgb*2.0 + bloom;
@(hdrgammadecode [color@i])
@(hdrtonemapfrag [color@i])
@(hdrgammaencode [color@i])
fragcolor@i.rgb = color@i;
@(if $arg3 [result [
@(strreplace $arg3 [fragcolor] [fragcolor@i])
]] [result [
fragcolor@i.a = 0.0;
]])
]])
}
]
]
hdrtonemapshaders ""
hdrtonemapshaders "luma" [] [fragcolor.a = dot(fragcolor.rgb, vec3(@lumweights));]
hdrtonemapshaders "stencil" [] [fragcolor.a = 1.0;]
hdrtonemapshaders "masked" (if (= $gdepthformat 1) [
gfetchdefs tex3
] [
gfetchdefs tex4 $msaasamples
]) [
fragcolor.a = mask;
] (if (= $gdepthformat 1) [result [
float mask = gfetch(tex3, texcoord0).a;
]] [result [
float mask = gfetch(tex4, texcoord0).a;
@(? $msaasamples [mask = step(0.75, mask);])
]])

68
config/glsl/ui.cfg 100644
View File

@ -0,0 +1,68 @@
////////////////////////////////////////////////
//
// UI shaders
//
////////////////////////////////////////////////
lazyshader 0 "modelpreview" [
attribute vec4 vvertex;
attribute vec2 vtexcoord0;
varying vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
@(gfetchdefs [tex0 tex1 tex3])
uniform vec3 camera;
uniform mat4 worldmatrix;
uniform vec4 lightscale;
uniform vec3 sunlightdir;
uniform vec3 sunlightcolor;
uniform float cutout;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec4 normal = gfetch(tex1, texcoord0);
if(normal.x + normal.y == cutout) discard;
normal.xyz = normal.xyz*2.0 - 1.0;
@(if $usepacknorm [result [
float glowscale = dot(normal.xyz, normal.xyz);
normal.xyz *= inversesqrt(glowscale);
@(unpacknorm glowscale)
]] [result [
#define glowscale normal.a
]])
vec4 diffuse = gfetch(tex0, texcoord0);
vec3 glow = diffuse.rgb * (1.0 - glowscale);
diffuse.rgb *= glowscale;
vec3 light = diffuse.rgb * lightscale.rgb;
light += glow.rgb * lightscale.a;
float sunfacing = dot(sunlightdir, normal.xyz);
if(sunfacing > 0.0)
{
@(gdepthunpack depth [gfetch(tex3, texcoord0)] [
vec3 pos = (worldmatrix * vec4(depth*texcoord0, depth, 1.0)).xyz;
] [
vec4 pos = worldmatrix * vec4(texcoord0, depth, 1.0);
pos.xyz /= pos.w;
])
@(unpackspec)
float sunspec = pow(clamp(sunfacing*facing - dot(camdir, sunlightdir), 0.0, 1.0), gloss) * specscale;
light += (diffuse.rgb*sunfacing + sunspec) * sunlightcolor;
}
fragcolor.rgb = light;
fragcolor.a = 1.0;
}
]

View File

@ -0,0 +1,239 @@
volopt = [ >= (strstr $volumetrictype $arg1) 0 ]
volumetricvariantshader = [
local volumetrictype
volumetrictype = $arg3
maxsteps = $arg4
spotlight = (>= $arg2 1)
variantshader 0 $arg1 $arg2 (? (< $arg2 0) [
attribute vec4 vvertex;
uniform mat4 lightmatrix;
void main(void)
{
gl_Position = lightmatrix * vvertex;
}
]) [
@(gfetchdefs tex3)
@(if (volopt "p") [
if (|| (volopt "g") (volopt "G")) [if (> $usetexgather 1) [result [
uniform sampler2DShadow tex4;
]] [result [
uniform sampler2D tex4;
]]] [result [
uniform sampler2DRectShadow tex4;
]]
])
uniform vec4 lightpos;
uniform vec3 lightcolor;
@(? $spotlight [
uniform vec4 spotparams;
])
@(? (volopt "p") [
uniform vec4 shadowparams;
uniform vec2 shadowoffset;
])
uniform vec3 camera;
uniform mat4 worldmatrix;
uniform vec4 fogdir;
uniform vec3 fogcolor;
uniform vec2 fogdensity;
uniform vec4 radialfogscale;
uniform vec2 shadowatlasscale;
uniform vec4 volscale;
uniform float volminstep;
uniform float voldistclamp;
uniform float volprefilter;
fragdata(0) vec4 fragcolor;
@(if (volopt "p") [
? $spotlight [
vec3 getspottc(vec3 dir, float spotdist)
{
vec2 mparams = shadowparams.xy / max(spotdist, 1e-5);
return vec3((dir.xy - spotparams.xy*(spotdist + (spotparams.z < 0.0 ? -1.0 : 1.0)*dir.z)*shadowparams.z) * mparams.x + shadowoffset, mparams.y + shadowparams.w);
}
] [
vec3 getshadowtc(vec3 dir)
{
vec3 adir = abs(dir);
float m = max(adir.x, adir.y), mz = max(adir.z, m);
vec2 mparams = shadowparams.xy / max(mz, 1e-5);
vec4 proj;
if(adir.x > adir.y) proj = vec4(dir.zyx, 0.0); else proj = vec4(dir.xzy, 1.0);
if(adir.z > m) proj = vec4(dir, 2.0);
return vec3(proj.xy * mparams.x + vec2(proj.w, step(proj.z, 0.0)) * shadowparams.z + shadowoffset, mparams.y + shadowparams.w);
}
]
])
@(if (volopt "p") [
if (|| (volopt "g") (volopt "G")) [
? (> $usetexgather 1) [
#define filtershadow(shadowtc) float(shadow2D(tex4, vec3(shadowtc.xy*shadowatlasscale, shadowtc.z)))
] [
#define filtershadow(shadowtc) step(shadowtc.z, float(texture2D(tex4, shadowtc.xy*shadowatlasscale)))
]
] [result [
#define filtershadow(shadowtc) float(shadow2DRect(tex4, shadowtc))
]]
])
void main(void)
{
vec2 tc = gl_FragCoord.xy * volscale.xy;
@(gdepthunpack depth [gfetch(tex3, tc)] [
vec3 pos = (worldmatrix * vec4(depth*tc, depth, 1.0)).xyz;
] [
vec4 pos = worldmatrix * vec4(tc, depth, 1.0);
pos.xyz /= pos.w;
])
vec3 ray = pos.xyz - camera;
float dist2 = dot(ray, ray), invdist = inversesqrt(dist2), radialdist = min(dist2 * invdist, voldistclamp);
ray *= invdist;
vec3 camlight = lightpos.xyz - camera * lightpos.w;
float camlight2 = dot(camlight, camlight), v = dot(camlight, ray), d = v*v + 1.0 - camlight2;
float light = 0.0;
if(d > 0)
{
d = sqrt(d);
float front = v - d, back = v + d;
@(? $spotlight [
float spotangle = 1.0 - 1.0/spotparams.w, spotangle2 = spotangle*spotangle,
rayspot = dot(ray, spotparams.xyz), camspot = dot(camlight, spotparams.xyz),
qa = spotangle2 - rayspot*rayspot,
qb = rayspot*camspot - spotangle2*v,
qc = spotangle2*camlight2 - camspot*camspot,
disc = qb*qb - qa*qc;
if(disc > 0)
{
disc = abs(sqrt(disc)/qa);
float t = -qb/qa, t0 = t - disc, t1 = t + disc;
if(t0*rayspot < camspot) front = max(front, t1);
else if(t1*rayspot < camspot) back = min(back, t0);
else { front = max(front, t0); back = min(back, t1); }
])
float maxspace = back - front, stepdist = maxspace * @(divf 1.0 $maxsteps);
front = max(front, 0.0);
back = min(back, radialdist * lightpos.w);
float space = back - front;
if(space > volminstep*stepdist)
{
float dither = dot(fract((gl_FragCoord.xy - 0.5).xyxy*vec4(0.5, 0.5, 0.25, 0.25)), vec4(0.375, 0.9375, 0.25, 0.125));
vec3 lightdir = ray * (back + stepdist*dither) - camlight;
vec3 raystep = ray * -stepdist;
for(int i = 0; i < @maxsteps; i++)
{
lightdir += raystep;
@(if $spotlight [result [
float lightdist2 = dot(lightdir, lightdir);
float lightinvdist = inversesqrt(lightdist2);
float spotdist = dot(lightdir, spotparams.xyz);
float spotatten = 1.0 - (1.0 - lightinvdist * spotdist) * spotparams.w;
if(spotatten > 0.0)
{
float lightatten = clamp(1.0 - lightdist2 * lightinvdist, 0.0, 1.0) * spotatten;
@(? (volopt "p") [
vec3 spottc = getspottc(lightdir, spotdist);
lightatten *= filtershadow(spottc);
])
light += lightatten;
}
]] [result [
float lightatten = clamp(1.0 - length(lightdir), 0.0, 1.0);
@(? (volopt "p") [
vec3 shadowtc = getshadowtc(lightdir);
lightatten *= filtershadow(shadowtc);
])
light += lightatten;
]])
space -= stepdist;
if(space <= 0) break;
}
float fogcoord = front/lightpos.w;
float foglerp = clamp(exp2(fogcoord*fogdensity.x)*fogdensity.y, 0.0, 1.0);
light *= foglerp * stepdist;
@(? $spotlight [
light /= min(maxspace, 1.0);
])
}
@(? $spotlight [}])
}
vec2 weights = step(fwidth(radialdist), volprefilter) * (2.0*fract((gl_FragCoord.xy - 0.5)*0.5) - 0.5);
light -= dFdx(light) * weights.x;
light -= dFdy(light) * weights.y;
fragcolor.rgb = light * lightcolor;
fragcolor.a = 0.0;
}
]
]
volumetricshader = [
volumetrictype = (concatword $arg1 $arg2)
shadername = (concatword "volumetric" $volumetrictype $arg3)
volumetricvariantshader $shadername -1 $arg1 $arg3
volumetricvariantshader $shadername 0 (concatword $arg1 $arg2) $arg3
if (volopt "s") [
volumetricvariantshader $shadername 1 $arg1 $arg3
volumetricvariantshader $shadername 2 (concatword $arg1 $arg2) $arg3
]
]
volumetricbilateralvariantshader = [
numtaps = $arg2
reduced = $arg3
filterdir = $arg4
shader 0 $arg1 [
attribute vec4 vvertex;
@(if $reduced [result [
@(screentexcoord 0)
varying vec2 texcoord0;
]])
void main(void)
{
gl_Position = vvertex;
@(? $reduced [texcoord0 = vtexcoord0;])
}
] [
@(gfetchdefs tex3)
uniform sampler2DRect tex0;
uniform vec2 bilateralparams;
@(? $reduced [varying vec2 texcoord0;])
fragdata(0) vec4 fragcolor;
void main(void)
{
#define tc gl_FragCoord.xy
#define depthtc @(? $reduced [texcoord0] [gl_FragCoord.xy])
#define tapvec(type, i) @(? (=s $filterdir "x") [type(i, 0.0)] [type(0.0, i)])
#define texval(i) texture2DRect(tex0, tc + tapvec(vec2, i))
#define texvaloffset(i) texture2DRectOffset(tex0, tc, tapvec(ivec2, i))
#define depthval(i) gfetch(tex3, depthtc + tapvec(vec2, i))
#define depthvaloffset(i) gfetchoffset(tex3, depthtc, tapvec(ivec2, i))
vec3 color = texture2DRect(tex0, tc).rgb;
@(gdepthunpack depth [gfetch(tex3, depthtc)])
float weights = 1.0;
@(loopconcat i (* 2 $numtaps) [
curtap = (- $i $numtaps)
if (>= $curtap 0) [curtap = (+ $curtap 1)]
curtapoffset = (* $curtap 2)
curdepthoffset = (<< $curtapoffset $reduced)
curtexval = [texval@(? (<= $mintexrectoffset $curtapoffset $maxtexrectoffset) "offset")(@(+f $curtapoffset))]
curdepthval = [depthval@(? (<= $mintexrectoffset $curdepthoffset $maxtexrectoffset) "offset")(@(+f $curdepthoffset))]
result [
vec3 color@[i] = @[curtexval].rgb;
@(gdepthunpack [depth@[i]] $curdepthval)
depth@[i] -= depth;
float weight@[i] = exp2(@(-f 0 (* $curtap $curtap))*bilateralparams.x - depth@[i]*depth@[i]*bilateralparams.y);
weights += weight@[i];
color += weight@[i] * color@[i];
]
])
fragcolor = vec4(color / weights, 0.0);
}
]
]
volumetricbilateralshader = [
volumetricbilateralvariantshader (concatword "volumetricbilateralx" $arg1 $arg2) $arg1 $arg2 x
volumetricbilateralvariantshader (concatword "volumetricbilateraly" $arg1 $arg2) $arg1 $arg2 y
]

View File

@ -0,0 +1,674 @@
////////////////////////////////////////////////////////
//
// world shaders
//
///////////////////////////////////////////////////////
// worldtype:
// e -> reserve envmap texture slot
// r -> envmap reflection
// R -> modulate envmap reflection with spec map
// s -> spec
// S -> spec map
// g -> glow
// G -> pulse glow
// b -> blendmap
// a -> transparent
// A -> refractive
// m -> alpha-mask
// T -> triplanar
// d -> detail
wtopt = [ >= (strstr $worldtype $arg1) 0 ]
worldvariantshader = [
local worldtype
worldtype = $arg2
stype = (? (wtopt "e") 3 1)
srow = -1
if (wtopt "G") [
stype = (+ $stype 0x10)
defuniformparam "glowcolor" 1 1 1 // glow color
defuniformparam "pulseglowspeed" 1 // pulse frequency (Hz)
defuniformparam "pulseglowcolor" 0 0 0 // pulse glow color
] [if (wtopt "g") [
defuniformparam "glowcolor" 1 1 1 // glow color
]]
if (wtopt "R") [
defuniformparam "envmin" 0 0 0 // minimum reflectivity
defuniformparam "envscale" 1 1 1 // reflectivity map multiplier
] [if (wtopt "r") [
defuniformparam "envmin" 0 0 0 // minimum reflectivity
defuniformparam "envscale" 0.2 0.2 0.2 // reflectivity
]]
defuniformparam "gloss" 1 // glossiness
if (wtopt "S") [
defuniformparam "specscale" 2 2 2 // spec map multiplier
] [if (wtopt "s") [
defuniformparam "specscale" 1 1 1 // spec multiplier
]]
if (wtopt "T") [
defuniformparam "triplanarbias" 0.3 0.3 0.3
stype = (+ $stype 0x20)
]
if (wtopt "b") [
srow = 0
]
if (wtopt "a") [
if (wtopt "A") [stype = (+ $stype 4)]
srow = 1
]
variantshader $stype $arg1 $srow [
attribute vec4 vvertex;
attribute vec3 vnormal;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec2 texgenscroll;
varying vec3 nvec;
@(ginterpvert (|| $msaalight [&& $msaasamples [! (wtopt "a")]]))
@(if (wtopt "T") [result [
uniform vec2 texgenscale;
varying vec2 texcoordx, texcoordy, texcoordz;
@(? (wtopt "d") [uniform vec2 detailscale;])
]] [result [
varying vec2 texcoord0;
]])
@(? (wtopt "r") [uniform vec3 camera; varying vec3 camvec;])
@(? (wtopt "G") [uniform float millis; flat varying float pulse;])
@(? (wtopt "b") [
uniform vec4 blendmapparams;
varying vec2 texcoord1;
])
void main(void)
{
gl_Position = camprojmatrix * vvertex;
@(if (wtopt "T") [result [
texcoordx = vec2(vvertex.y, -vvertex.z) * texgenscale;
texcoordy = vec2(vvertex.x, -vvertex.z) * texgenscale;
texcoordz = vvertex.xy * @(? (wtopt "d") "detailscale" "texgenscale");
]] [result [
texcoord0 = vtexcoord0 + texgenscroll;
]])
@(? (wtopt "b") [
texcoord1 = (vvertex.xy - blendmapparams.xy)*blendmapparams.zw;
])
nvec = vnormal;
@(gdepthpackvert (|| $msaalight [&& $msaasamples [! (wtopt "a")]]))
@(? (wtopt "r") [camvec = camera - vvertex.xyz;])
@(? (wtopt "G") [
pulse = abs(fract(millis*pulseglowspeed.x)*2.0 - 1.0);
])
}
] [
@(if (wtopt "A") [result [
@(gfetchdefs refractlight)
uniform vec4 refractparams;
]])
uniform vec4 colorparams;
uniform sampler2D diffusemap;
@(? (|| $msaalight [&& $msaasamples [! (wtopt "a")]]) [uniform float hashid;])
varying vec3 nvec;
@(ginterpfrag (|| $msaalight [&& $msaasamples [! (wtopt "a")]]))
@(if (wtopt "T") [result [
varying vec2 texcoordx, texcoordy, texcoordz;
@(? (wtopt "d") [uniform sampler2D detaildiffusemap;])
]] [result [
varying vec2 texcoord0;
]])
@(? (wtopt "g") [uniform sampler2D glowmap;])
@(? (wtopt "G") [flat varying float pulse;])
@(? (wtopt "r") [uniform samplerCube envmap; varying vec3 camvec;])
@(? (wtopt "b") [
uniform float blendlayer;
uniform sampler2D blendmap;
varying vec2 texcoord1;
])
void main(void)
{
vec3 normal = normalize(nvec);
@(if (wtopt "T") [result [
vec3 triblend = max(abs(normal) - triplanarbias.xyz, 0.001);
triblend *= triblend;
triblend /= triblend.x + triblend.y + triblend.z;
vec4 diffusex = texture2D(diffusemap, texcoordx);
vec4 diffusey = texture2D(diffusemap, texcoordy);
vec4 diffusez = texture2D(@(? (wtopt "d") "detaildiffusemap" "diffusemap"), texcoordz);
vec4 diffuse = diffusex*triblend.x + diffusey*triblend.y + diffusez*triblend.z;
]] [result [
vec4 diffuse = texture2D(diffusemap, texcoord0);
]])
gcolor.rgb = diffuse.rgb*colorparams.rgb;
@(if (wtopt "r") [result [
vec3 camvecn = normalize(camvec);
float invfresnel = dot(camvecn, normal);
vec3 rvec = 2.0*normal*invfresnel - camvecn;
vec3 reflect = textureCube(envmap, rvec).rgb;
@(? (wtopt "R") [
vec3 rmod = envscale.xyz*diffuse.a;
] [
#define rmod envscale.xyz
])
gcolor.rgb = mix(gcolor.rgb, reflect, envmin.xyz + rmod * clamp(1.0 - invfresnel, 0.0, 1.0));
]])
@(if (wtopt "g") [result [
@(? (wtopt "T") [
vec3 glowx = texture2D(glowmap, texcoordx).rgb;
vec3 glowy = texture2D(glowmap, texcoordy).rgb;
vec3 glowz = texture2D(glowmap, texcoordz).rgb;
vec3 glow = glowx*triblend.x + glowy*triblend.y + glowz*triblend.z;
] [
vec3 glow = texture2D(glowmap, texcoord0).rgb;
])
glow *= @(? (wtopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]);
@(if (wtopt "a") [result [
gglow.rgb = glow;
]] [gglowpack glow packnorm])
]] [? (wtopt "a") [
gglow.rgb = vec3(0.0);
]])
@(if (wtopt "a") [
? (wtopt "A") [
vec3 rlight = gfetch(refractlight, gl_FragCoord.xy).rgb;
gglow.rgb += rlight * refractparams.xyz;
] (? (wtopt "m") [
gcolor.rgb *= diffuse.a;
#define packnorm diffuse.a * colorparams.a
] [
#define packnorm colorparams.a
])
])
@(gnormpackdef normal packnorm)
@(gdepthpackfrag (|| $msaalight [&& $msaasamples [! (wtopt "a")]]) "" hashid)
@(? (wtopt "b") [
float blend = abs(texture2D(blendmap, texcoord1).r - blendlayer);
gcolor.rgb *= blend;
gnormal.rgb *= blend;
gnormal.a *= blendlayer;
])
@(gspecpack [gloss.x] (if (wtopt "s") [? (wtopt "S") [diffuse.a*specscale.x] [specscale.x]]) (? (wtopt "b") blendlayer) blend)
}
]
]
worldshader = [
worldtype = $arg2
stype = (? (wtopt "e") 3 1)
if (wtopt "T") [
stype = (+ $stype 0x20)
]
defershader $stype $arg1 [
worldvariantshader @arg1 @arg2
worldvariantshader @arg1 @(concatword $arg2 "b")
worldvariantshader @arg1 @(concatword $arg2 "a")
worldvariantshader @arg1 @(concatword $arg2 "aA")
]
]
worldshader "stdworld" ""
forceshader "stdworld"
worldshader "alphaworld" "m"
worldshader "specworld" "s"
worldshader "specmapworld" "sS"
worldshader "glowworld" "g"
worldshader "pulseglowworld" "gG"
worldshader "glowalphaworld" "gm"
worldshader "pulseglowalphaworld" "gGm"
worldshader "envworld" "er"
worldshader "envspecworld" "esr"
worldshader "envspecmapworld" "esSrR"
worldshader "envglowworld" "erg"
worldshader "envpulseglowworld" "ergG"
worldshader "triplanarworld" "T"
worldshader "triplanardetailworld" "Td"
// bumptype:
// e -> reserve envmap texture slot
// r -> envmap reflection
// R -> modulate envmap reflection with spec map
// s -> spec
// S -> spec map
// p -> parallax
// g -> glow
// G -> pulse glow
// b -> blendmap
// a -> transparent
// A -> refractive
// m -> alpha-mask
// T -> triplanar
// d -> detail
btopt = [ >= (strstr $bumptype $arg1) 0 ]
bumpvariantshader = [
local bumptype
bumptype = $arg2
stype = (? (btopt "e") 3 1)
srow = -1
if (btopt "G") [
stype = (+ $stype 0x10)
defuniformparam "glowcolor" 1 1 1 // glow color
defuniformparam "pulseglowspeed" 1 // pulse frequency (Hz)
defuniformparam "pulseglowcolor" 0 0 0 // pulse glow color
] [if (btopt "g") [
defuniformparam "glowcolor" 1 1 1 // glow color
]]
defuniformparam "gloss" 1 // glossiness
if (btopt "S") [
defuniformparam "specscale" 2 2 2 // spec map multiplier
] [if (btopt "s") [
defuniformparam "specscale" 1 1 1 // spec multiplier
]]
if (btopt "p") [
defuniformparam "parallaxscale" 0.06 -0.03 // parallax scaling
]
if (btopt "R") [
defuniformparam "envmin" 0 0 0 // minimum reflectivity
defuniformparam "envscale" 1 1 1 // reflectivity map multiplier
] [if (btopt "r") [
defuniformparam "envmin" 0 0 0 // minimum reflectivity
defuniformparam "envscale" 0.2 0.2 0.2 // reflectivity
]]
if (btopt "T") [
defuniformparam "triplanarbias" 0.3 0.3 0.3
stype = (+ $stype 0x20)
]
if (btopt "b") [
srow = 0
]
if (btopt "a") [
if (btopt "A") [stype = (+ $stype 4)]
srow = 1
]
variantshader $stype $arg1 $srow [
attribute vec4 vvertex, vtangent;
attribute vec3 vnormal;
attribute vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec2 texgenscroll;
@(ginterpvert (|| $msaalight [&& $msaasamples [! (btopt "a")]] [btopt "A"]))
@(if (btopt "T") [result [
uniform vec2 texgenscale;
varying vec2 texcoordx, texcoordy, texcoordz;
varying vec3 normal;
varying vec3 tangentx, tangenty, tangentz;
@(? (btopt "d") [uniform vec2 detailscale;])
]] [result [
varying vec2 texcoord0;
varying mat3 world;
]])
@(? (|| (btopt "p") (btopt "r") (btopt "T")) [
uniform vec3 camera;
varying vec3 camvec;
])
@(? (btopt "G") [uniform float millis; flat varying float pulse;])
@(? (btopt "b") [
uniform vec4 blendmapparams;
varying vec2 texcoord1;
])
void main(void)
{
gl_Position = camprojmatrix * vvertex;
@(gdepthpackvert (|| $msaalight [&& $msaasamples [! (btopt "a")]] [btopt "A"]))
@(if (btopt "T") [result [
texcoordx = vec2(vvertex.y, -vvertex.z) * texgenscale;
texcoordy = vec2(vvertex.x, -vvertex.z) * texgenscale;
texcoordz = vvertex.xy * @(? (btopt "d") "detailscale" "texgenscale");
normal = vnormal;
tangentx = normalize(vec3(1.001, 0.0, 0.0) - vnormal*vnormal.x);
tangenty = normalize(vec3(0.0, 1.001, 0.0) - vnormal*vnormal.y);
tangentz = normalize(vec3(0.0, 0.0, -1.001) + vnormal*vnormal.z);
]] [result [
texcoord0 = vtexcoord0 + texgenscroll;
vec3 bitangent = cross(vnormal, vtangent.xyz) * vtangent.w;
// calculate tangent -> world transform
world = mat3(vtangent.xyz, bitangent, vnormal);
]])
@(? (|| (btopt "p") (btopt "r") (btopt "T")) [
camvec = camera - vvertex.xyz;
])
@(? (btopt "b") [
texcoord1 = (vvertex.xy - blendmapparams.xy)*blendmapparams.zw;
])
@(? (btopt "G") [
pulse = abs(fract(millis*pulseglowspeed.x)*2.0 - 1.0);
])
}
] [
@(if (btopt "A") [result [
@(gfetchdefs [refractlight refractmask])
uniform vec4 refractparams;
uniform float refractdepth;
]])
uniform vec4 colorparams;
uniform sampler2D diffusemap, normalmap;
@(? (|| $msaalight [&& $msaasamples [! (btopt "a")]]) [uniform float hashid;])
varying mat3 world;
@(ginterpfrag (|| $msaalight [&& $msaasamples [! (btopt "a")]] [btopt "A"]))
@(if (btopt "T") [result [
varying vec2 texcoordx, texcoordy, texcoordz;
varying vec3 normal, tangentx, tangenty, tangentz;
@(? (btopt "d") [uniform sampler2D detaildiffusemap, detailnormalmap;])
]] [result [
varying vec2 texcoord0;
]])
@(? (|| (btopt "p") (btopt "r") (btopt "T")) [varying vec3 camvec;])
@(? (btopt "g") [uniform sampler2D glowmap;])
@(? (btopt "G") [flat varying float pulse;])
@(? (btopt "r") [uniform samplerCube envmap;])
@(? (btopt "b") [
uniform float blendlayer;
uniform sampler2D blendmap;
varying vec2 texcoord1;
])
void main(void)
{
@(? (|| (btopt "p") (btopt "r") (btopt "T")) [
vec3 camvecn = normalize(camvec);
])
@(if (btopt "T") [result [
vec3 triblend = max(abs(normal) - triplanarbias.xyz, 0.001);
triblend *= triblend;
triblend /= triblend.x + triblend.y + triblend.z;
#define worldx mat3(tangenty, tangentz, normal)
#define worldy mat3(tangentx, tangentz, normal)
#define worldz mat3(tangentx, tangenty, normal)
@(if (btopt "p") [result [
float heightx = texture2D(normalmap, texcoordx).a;
float heighty = texture2D(normalmap, texcoordy).a;
float heightz = texture2D(@(? (btopt "d") "detailnormalmap" "normalmap"), texcoordz).a;
vec3 camvect = camvecn * mat3(tangentx, tangenty, tangentz);
vec2 dtcx = texcoordx + camvect.yz*(heightx*parallaxscale.x + parallaxscale.y);
vec2 dtcy = texcoordy + camvect.xz*(heighty*parallaxscale.x + parallaxscale.y);
vec2 dtcz = texcoordz + camvect.xy*(heightz*parallaxscale.x + parallaxscale.y);
]] [result [
#define dtcx texcoordx
#define dtcy texcoordy
#define dtcz texcoordz
]])
vec4 diffusex = texture2D(diffusemap, dtcx);
vec4 diffusey = texture2D(diffusemap, dtcy);
vec4 diffusez = texture2D(@(? (btopt "d") "detaildiffusemap" "diffusemap"), dtcz);
vec4 diffuse = diffusex*triblend.x + diffusey*triblend.y + diffusez*triblend.z;
vec3 bumpx = (texture2D(normalmap, dtcx).rgb*2.0 - 1.0)*triblend.x;
vec3 bumpy = (texture2D(normalmap, dtcy).rgb*2.0 - 1.0)*triblend.y;
vec3 bumpz = (texture2D(@(? (btopt "d") "detailnormalmap" "normalmap"), dtcz).rgb*2.0 - 1.0)*triblend.z;
vec3 bumpw = normalize(worldx*bumpx + worldy*bumpy + worldz*bumpz);
@(? (btopt "A") [
vec2 bump = bumpx.xy + bumpy.xy + bumpz.xy;
])
]] [result [
@(? (btopt "p") [
float height = texture2D(normalmap, texcoord0).a;
vec2 dtc = texcoord0 + (camvecn * world).xy*(height*parallaxscale.x + parallaxscale.y);
] [
#define dtc texcoord0
])
vec4 diffuse = texture2D(diffusemap, dtc);
@(? (&& (btopt "a") [! (btopt "A")] [btopt "m"]) [
vec4 normal = texture2D(normalmap, dtc);
#define bump normal.rgb
] [
vec3 bump = texture2D(normalmap, dtc).rgb;
])
bump = bump*2.0 - 1.0;
vec3 bumpw = normalize(world * bump);
]])
gcolor.rgb = diffuse.rgb*colorparams.rgb;
@(if (btopt "r") [result [
float invfresnel = dot(camvecn, bumpw);
vec3 rvec = 2.0*bumpw*invfresnel - camvecn;
vec3 reflect = textureCube(envmap, rvec).rgb;
@(? (btopt "R") [
vec3 rmod = envscale.xyz*diffuse.a;
] [
#define rmod envscale.xyz
])
gcolor.rgb = mix(gcolor.rgb, reflect, envmin.xyz + rmod * clamp(1.0 - invfresnel, 0.0, 1.0));
]])
@(if (btopt "g") [result [
@(? (btopt "T") [
vec3 glowx = texture2D(glowmap, dtcx).rgb;
vec3 glowy = texture2D(glowmap, dtcy).rgb;
vec3 glowz = texture2D(glowmap, dtcz).rgb;
vec3 glow = glowx*triblend.x + glowy*triblend.y + glowz*triblend.z;
] [
vec3 glow = texture2D(glowmap, dtc).rgb;
])
glow *= @(? (btopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]);
@(if (btopt "a") [result [
gglow.rgb = glow;
]] [gglowpack glow packnorm])
]] [? (btopt "a") [
gglow.rgb = vec3(0.0);
]])
@(if (btopt "a") [
? (btopt "A") [
vec2 rtc = bump.xy*refractparams.w;
float rmask = clamp(refractdepth*(lineardepth - dot(gfetch(refractmask, gl_FragCoord.xy + rtc).rgb, gdepthunpackparams)), 0.0, 1.0);
vec3 rlight = gfetch(refractlight, gl_FragCoord.xy + rtc*rmask).rgb;
gglow.rgb += rlight * refractparams.xyz;
] (? (btopt "m") [
gcolor.rgb *= normal.a;
#define packnorm normal.a * colorparams.a
] [
#define packnorm colorparams.a
])
])
@(gnormpackdef bumpw packnorm)
@(gdepthpackfrag (|| $msaalight [&& $msaasamples [! (btopt "a")]]) "" hashid)
@(? (btopt "b") [
float blend = abs(texture2D(blendmap, texcoord1).r - blendlayer);
gcolor.rgb *= blend;
gnormal.rgb *= blend;
gnormal.a *= blendlayer;
])
@(gspecpack [gloss.x] (if (btopt "s") [? (btopt "S") [diffuse.a*specscale.x] [specscale.x]]) (? (btopt "b") blendlayer) blend)
}
]
]
bumpshader = [
bumptype = $arg2
stype = (? (btopt "e") 3 1)
if (btopt "T") [
stype = (+ $stype 0x20)
]
defershader $stype $arg1 [
bumpvariantshader @arg1 @arg2
bumpvariantshader @arg1 @(concatword $arg2 "b")
bumpvariantshader @arg1 @(concatword $arg2 "a")
bumpvariantshader @arg1 @(concatword $arg2 "aA")
]
]
bumpshader "bumpworld" ""
bumpshader "bumpspecworld" "s"
bumpshader "bumpspecmapworld" "sS"
bumpshader "bumpalphaworld" "m"
bumpshader "bumpspecalphaworld" "sm"
bumpshader "bumpspecmapalphaworld" "sSm"
bumpshader "bumpglowworld" "g"
bumpshader "bumpspecglowworld" "sg"
bumpshader "bumpspecmapglowworld" "sSg"
bumpshader "bumppulseglowworld" "gG"
bumpshader "bumpspecpulseglowworld" "sgG"
bumpshader "bumpspecmappulseglowworld" "sSgG"
bumpshader "bumpparallaxworld" "p"
bumpshader "bumpspecparallaxworld" "ps"
bumpshader "bumpspecmapparallaxworld" "psS"
bumpshader "bumpparallaxglowworld" "pg"
bumpshader "bumpspecparallaxglowworld" "psg"
bumpshader "bumpspecmapparallaxglowworld" "psSg"
bumpshader "bumpparallaxpulseglowworld" "pgG"
bumpshader "bumpspecparallaxpulseglowworld" "psgG"
bumpshader "bumpspecmapparallaxpulseglowworld" "psSgG"
bumpshader "bumpenvworld" "er"
bumpshader "bumpenvspecworld" "esr"
bumpshader "bumpenvspecmapworld" "esSrR"
bumpshader "bumpenvglowworld" "erg"
bumpshader "bumpenvspecglowworld" "eosrg"
bumpshader "bumpenvspecmapglowworld" "esSrRg"
bumpshader "bumpenvpulseglowworld" "eorgG"
bumpshader "bumpenvspecpulseglowworld" "esrgG"
bumpshader "bumpenvspecmappulseglowworld" "esSrRgG"
bumpshader "bumpenvparallaxworld" "epr"
bumpshader "bumpenvspecparallaxworld" "epsr"
bumpshader "bumpenvspecmapparallaxworld" "epsSrR"
bumpshader "bumpenvparallaxglowworld" "eprg"
bumpshader "bumpenvspecparallaxglowworld" "epsrg"
bumpshader "bumpenvspecmapparallaxglowworld" "epsSrRg"
bumpshader "bumpenvparallaxpulseglowworld" "eprgG"
bumpshader "bumpenvspecparallaxpulseglowworld" "epsrgG"
bumpshader "bumpenvspecmapparallaxpulseglowworld" "epsSrRgG"
bumpshader "triplanarbumpworld" "T"
bumpshader "triplanarbumpspecworld" "Ts"
bumpshader "triplanarbumpspecmapworld" "TsS"
bumpshader "triplanarbumpparallaxworld" "Tp"
bumpshader "triplanarbumpspecparallaxworld" "Tps"
bumpshader "triplanarbumpspecmapparallaxworld" "TpsS"
bumpshader "triplanardetailbumpworld" "Td"
bumpshader "triplanardetailbumpspecworld" "Tds"
bumpshader "triplanardetailbumpspecmapworld" "TdsS"
bumpshader "triplanardetailbumpparallaxworld" "Tdp"
bumpshader "triplanardetailbumpspecparallaxworld" "Tdps"
bumpshader "triplanardetailbumpspecmapparallaxworld" "TdpsS"
shader 0 shadowmapworld [
attribute vec4 vvertex;
uniform mat4 shadowmatrix;
void main(void)
{
gl_Position = shadowmatrix * vvertex;
}
] [
void main(void)
{
}
]
defershader 1 "rsmworld" [
loop i 2 [
variantshader 1 "rsmworld" (- $i 1) [
attribute vec4 vvertex;
attribute vec3 vnormal;
attribute vec2 vtexcoord0;
uniform mat4 rsmmatrix;
uniform vec2 texgenscroll;
uniform vec4 colorparams;
uniform vec3 rsmdir;
varying vec4 normal;
varying vec2 texcoord0;
@(? (= $i 1) [
uniform vec4 blendmapparams;
varying vec2 texcoord1;
])
void main(void)
{
gl_Position = rsmmatrix * vvertex;
texcoord0 = vtexcoord0 + texgenscroll;
@(if (= $i 1) [result [
texcoord1 = (vvertex.xy - blendmapparams.xy)*blendmapparams.zw;
]])
normal = vec4(vnormal, dot(vnormal, rsmdir));
}
] [
uniform vec4 colorparams;
uniform sampler2D diffusemap;
varying vec4 normal;
varying vec2 texcoord0;
@(? (= $i 1) [
uniform float blendlayer;
uniform sampler2D blendmap;
varying vec2 texcoord1;
])
fragdata(0) vec4 gcolor;
fragdata(1) vec4 gnormal;
void main(void)
{
vec4 diffuse = texture2D(diffusemap, texcoord0);
@(if (= $i 2) [result [
#define alpha 1.0
]] [result [
#define alpha colorparams.a
]])
gcolor.rgb = normal.w*diffuse.rgb*colorparams.rgb;
gnormal = vec4(normal.xyz*0.5+0.5, 0.0);
@(if (= $i 1) [result [
float blend = abs(texture2D(blendmap, texcoord1).r - blendlayer);
gcolor.rgb *= blend;
gcolor.a = blendlayer;
gnormal *= blend;
]] [result [
gcolor.a = alpha;
]])
}
]
]
]

View File

@ -0,0 +1,140 @@
///////////////////////////////////////////////////////////////////////////////
// Heightmap Brush List //
///////////////////////////////////////////////////////////////////////////////
// a heightmap brush has two parts: the brushmap and the brushhandle
// the brushmap is a 2D field that defines how the brush affects a heightmap
// the brushhandle is a 2D vertex on the brushmap.
// this handle is a reference point on the brushmap which represents
// where the editing cursor is pointed at.
// clearhbrush : resets the brushmap
// hbrushvert <x> <y> <value> : set a point on the brushmap
// hbrushx <x> : the x coordinate of the brushhandle
// hbrushy <y> : the y coordinate of the brushhandle
hbrushhandle = [
hbrushx $arg1
hbrushy $arg2
]
hbrushindex = -1
hbrushmax = -1 // make sure to bump this up if you add more brushes
selecthbrush = [
hbrushindex = ( + $hbrushindex $arg1 )
if (< $hbrushindex 0) [ hbrushindex = $hbrushmax ]
if (> $hbrushindex $hbrushmax) [ hbrushindex = 0 ]
do [hbrush_@hbrushindex]
]
hbrushverts = [
loop y (listlen $arg1) [
bv = (at $arg1 $y)
loop x (listlen $bv) [
hbrushvert $x $y (at $bv $x)
]
]
]
newhbrush = [
hbrushmax = (+ $hbrushmax 1)
do [
hbrush_@hbrushmax = [
hbrushname = [@@@arg1]
clearhbrush
@@(if (> $numargs 1) [result [hbrushhandle @arg2 @arg3; hbrushverts [@@arg4]]])
]
]
]
newhbrush "Circle 1-0" 0 0 [
"1"
]
newhbrush "Circle 2-1" 1 1 [
"0 1 0"
"1 2 1"
"0 1 0"
]
newhbrush "Circle 4-2-1" 2 2 [
"0 0 1 0 0"
"0 1 2 1 0"
"1 2 4 2 1"
"0 1 2 1 0"
"0 0 1 0 0"
]
newhbrush "Square 3x3" 1 1 [
"1 1 1"
"1 1 1"
"1 1 1"
]
newhbrush "Square 5x5" 2 2 [
"1 1 1 1 1"
"1 1 1 1 1"
"1 1 1 1 1"
"1 1 1 1 1"
"1 1 1 1 1"
]
newhbrush "Square 7x7" 3 3 [
"1 1 1 1 1 1 1"
"1 1 1 1 1 1 1"
"1 1 1 1 1 1 1"
"1 1 1 1 1 1 1"
"1 1 1 1 1 1 1"
"1 1 1 1 1 1 1"
"1 1 1 1 1 1 1"
]
newhbrush "Smooth 3x3" 1 1 [
"0 0 0"
"0 0 0"
"0 0 0"
]
newhbrush "Smooth 5x5" 2 2 [
"0 0 0 0 0"
"0 0 0 0 0"
"0 0 0 0 0"
"0 0 0 0 0"
"0 0 0 0 0"
]
newhbrush "Smooth 7x7" 3 3 [
"0 0 0 0 0 0 0"
"0 0 0 0 0 0 0"
"0 0 0 0 0 0 0"
"0 0 0 0 0 0 0"
"0 0 0 0 0 0 0"
"0 0 0 0 0 0 0"
"0 0 0 0 0 0 0"
]
newhbrush "Noise 25x25" 12 12 [
"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0"
"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
"0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0"
"0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 2 2 0"
"0 0 0 0 1 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1"
"0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 0 1 0 0 0 1 1 0 0 1"
"0 0 1 0 0 0 1 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 2 0 0"
"0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 2 0 0 0 0"
"0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 1"
"0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0"
"0 1 0 2 0 1 1 1 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0"
"0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0"
"1 0 1 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0"
"0 0 0 0 0 0 0 1 1 0 1 1 0 0 1 0 0 1 0 0 0 0 1 0 0"
"0 1 1 1 0 3 0 2 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0"
"0 0 1 0 0 1 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0 0 0 0 0"
"0 0 1 1 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1"
"0 1 1 0 1 0 0 1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 0 0"
"1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0"
"0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0"
"0 0 0 0 0 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 0"
"0 0 0 0 1 0 1 1 0 2 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1"
"0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0"
"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0"
"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
]
do [ hbrush_2 ] // 421

133
config/keymap.cfg 100644
View File

@ -0,0 +1,133 @@
// do not modify, use "bind" in autoexec.cfg instead
keymap -1 MOUSELEFT
keymap -2 MOUSEMIDDLE
keymap -3 MOUSERIGHT
keymap -4 MOUSEWHEELUP
keymap -5 MOUSEWHEELDOWN
keymap -6 MOUSEBACK
keymap -7 MOUSEFORWARD
keymap 8 BACKSPACE
keymap 9 TAB
keymap 13 RETURN
keymap 27 ESCAPE
keymap 32 SPACE
keymap 33 EXCLAIM
keymap 34 QUOTEDBL
keymap 35 HASH
keymap 36 DOLLAR
keymap 38 AMPERSAND
keymap 39 QUOTE
keymap 40 LEFTPAREN
keymap 41 RIGHTPAREN
keymap 42 ASTERISK
keymap 43 PLUS
keymap 44 COMMA
keymap 45 MINUS
keymap 46 PERIOD
keymap 47 SLASH
keymap 48 0
keymap 49 1
keymap 50 2
keymap 51 3
keymap 52 4
keymap 53 5
keymap 54 6
keymap 55 7
keymap 56 8
keymap 57 9
keymap 58 COLON
keymap 59 SEMICOLON
keymap 60 LESS
keymap 61 EQUALS
keymap 62 GREATER
keymap 63 QUESTION
keymap 64 AT
keymap 91 LEFTBRACKET
keymap 92 BACKSLASH
keymap 93 RIGHTBRACKET
keymap 94 CARET
keymap 95 UNDERSCORE
keymap 96 BACKQUOTE
keymap 97 A
keymap 98 B
keymap 99 C
keymap 100 D
keymap 101 E
keymap 102 F
keymap 103 G
keymap 104 H
keymap 105 I
keymap 106 J
keymap 107 K
keymap 108 L
keymap 109 M
keymap 110 N
keymap 111 O
keymap 112 P
keymap 113 Q
keymap 114 R
keymap 115 S
keymap 116 T
keymap 117 U
keymap 118 V
keymap 119 W
keymap 120 X
keymap 121 Y
keymap 122 Z
keymap 127 DELETE
keymap 0x40000059 KP1
keymap 0x4000005a KP2
keymap 0x4000005b KP3
keymap 0x4000005c KP4
keymap 0x4000005d KP5
keymap 0x4000005e KP6
keymap 0x4000005f KP7
keymap 0x40000060 KP8
keymap 0x40000061 KP9
keymap 0x40000062 KP0
keymap 0x40000063 KP_PERIOD
keymap 0x40000054 KP_DIVIDE
keymap 0x40000055 KP_MULTIPLY
keymap 0x40000056 KP_MINUS
keymap 0x40000057 KP_PLUS
keymap 0x40000058 KP_ENTER
keymap 0x40000067 KP_EQUALS
keymap 0x40000052 UP
keymap 0x40000051 DOWN
keymap 0x4000004f RIGHT
keymap 0x40000050 LEFT
keymap 0x40000048 PAUSE
keymap 0x40000049 INSERT
keymap 0x4000004a HOME
keymap 0x4000004d END
keymap 0x4000004b PAGEUP
keymap 0x4000004e PAGEDOWN
keymap 0x4000003a F1
keymap 0x4000003b F2
keymap 0x4000003c F3
keymap 0x4000003d F4
keymap 0x4000003e F5
keymap 0x4000003f F6
keymap 0x40000040 F7
keymap 0x40000041 F8
keymap 0x40000042 F9
keymap 0x40000043 F10
keymap 0x40000044 F11
keymap 0x40000045 F12
keymap 0x40000053 NUMLOCK
keymap 0x40000039 CAPSLOCK
keymap 0x40000047 SCROLLOCK
keymap 0x400000e5 RSHIFT
keymap 0x400000e1 LSHIFT
keymap 0x400000e4 RCTRL
keymap 0x400000e0 LCTRL
keymap 0x400000e6 RALT
keymap 0x400000e2 LALT
keymap 0x400000e7 RMETA
keymap 0x400000e3 LMETA
keymap 0x40000065 COMPOSE
keymap 0x40000075 HELP
keymap 0x40000046 PRINT
keymap 0x4000009a SYSREQ
keymap 0x40000076 MENU

View File

@ -0,0 +1,82 @@
// basic server configuration script
// note that some commands are commented out with //, and need to be uncommented and set to a value to work
// optional specific IP for server to use
// serverip N.N.N.N
// optional specific port for server to use
// serverport 42000
// maximum number of allowed clients
maxclients 8
// maximum number of bots a master can add - admins are unaffected by this limit
// set to 0 to disallow bots
serverbotlimit 8
// controls whether or not the server is intended for "public" use
// when set to 0, allows "setmaster 1" and locked/private mastermodes (for coop-editing and such)
// when set to 1, can only gain master by "auth" or admin, and doesn't allow locked/private mastermodes
// when set to 2, allows "setmaster 1" but disallows private mastermode (for public coop-editing)
publicserver 0
// description server shows for the server browser
serverdesc ""
// password required to connect to the server
// generally unnecessary unless you really don't want anyone connecting to your server
// using the serverauth option allows people with an appropriate local authkey to connect regardless
// serverpass ""
// password that allows you to gain admin by "setmaster password_here"
// local authkeys are more secure than this and should be used instead if possible
// adminpass ""
// domain to use for local authkeys to the server so people can authenticate by "auth domain_here"
// must be a non-empty string that should be unique to your server to prevent clashes with other servers
// serverauth ""
// controls whether or not the server reports to the masterserver
updatemaster 1
// optional message of the day to send to players on connect
// servermotd "..."
// controls whether admin privs are necessary to record a demo
// when 1 requires admin (default)
// when 0 only requires master
// restrictdemos 1
// maximum number of demos the server will store
// maxdemos 5
// maximum size a demo is allowed to grow to in megabytes
// maxdemosize 16
// controls whether admin privs are necessary to pause a game
// when 1 requires admin (default)
// when 0 only requires master
// restrictpausegame 1
// whether or not to allow players to vote on maps not in the rotation
// when 1 requires master
// when 2 requires admin
// when 0 allows any votes (default)
// lockmaprotation 0
dmmaps = [
complex alphacorp ot turbine reflection
]
ctfmaps = [
alphacorp steelribs test_ctf reflection waterworks
]
tdmmaps = (listunion $dmmaps $ctfmaps)
maprotationreset
maprotation "*" $dmmaps
maprotation "?tdm" $tdmmaps
maprotation "?ctf" $ctfmaps
teamkillkickreset
teamkillkick "*" 7 30

46
config/sound.cfg 100644
View File

@ -0,0 +1,46 @@
defaultsoundpack = [
soundreset
registersound "uphys/jump" 60
registersound "uphys/land" 180
registersound "uphys/splashin" 160
registersound "uphys/splashout" 100
registersound "soundsnap/burn" 210
registersound // itemspawn
registersound "q009/teleport" 255
registersound "uphys/jumppad" 100
registersound "uphys/punch_swing" 190
registersound "uphys/pulse_third" 255
registersound "uphys/pulse_first" 255
registersound "uphys/pulse_burst" 255
registersound "dacker/rail_third" 255
registersound "dacker/rail_first" 255
registersound "uphys/weapon_switch" 50
registersound // noammo
registersound "free/hit" 100
registersound // pain1
registersound // pain2
registersound "uphys/die1" 150
registersound "uphys/die2" 150
registersound "ctf/flagpickup" 100
registersound "ctf/flagdrop" 100
registersound "ctf/flagreturn" 100
registersound "ctf/flagscore" 100
registersound "ctf/flagreturn" 100
registersound "ctf/flagfail" 100
]
loadsoundpack = [
if $soundpack [
if (! (exec [media/sound/game/@soundpack/soundpack.cfg] 0)) [
error [Failed to load soundpack: @soundpack. Using default sounds.]
defaultsoundpack
]
] [
defaultsoundpack
]
]
defsvarp soundpack "" [loadsoundpack]
defaultsoundpack

241
config/stdedit.cfg 100644
View File

@ -0,0 +1,241 @@
///////////////////////////////////////////////////////////////////////////////
// Entity primary actions //
///////////////////////////////////////////////////////////////////////////////
=enttype = [|| (=s * $arg1) [=s (enttype) $arg1]]
=entattr = [|| (=s * $arg2) [= (entattr $arg1) $arg2]]
// clear ents of given type
clearents = [
if $editing [
entcancel
entselect [=enttype $arg1]
echo Deleted (enthavesel) $arg1 entities
delent
]
]
// replace all ents that match current selection
// with the values given
replaceents = [
if $editing [
do [
entfind @(entget)
entset @(loopconcat+ i 1 $numargs [result $[arg@i]])
]
echo Replaced (enthavesel) entities
]
]
selentedit = [saycommand (concatword "/entset " (entget))]
selreplaceents = [saycommand (concatword "/replaceents " (entget))]
selentfindall = [do [entfind @(entget)]]
// modify given attribute of ent by a given amount
// arg1 attribute
// arg2 value
entproperty = [entattr $arg1 (+ (entattr $arg1) $arg2)]
enttypelist = [
light mapmodel playerstart envmap particles sound spotlight decal
teleport teledest jumppad
flag
]
enttypeselect = [
enttypelength = (listlen $enttypelist)
next = (mod (+ (indexof $enttypelist (enttype)) $arg1) $enttypelength)
if (< $next 0) [ next = (+ $next $enttypelength) ]
do [entset @(listsplice (entget) (at $enttypelist $next) 0 1)]
]
///////////////////////////////////////////////////////////////////////////////
// Copy & Paste //
///////////////////////////////////////////////////////////////////////////////
// 3 types of copying and pasting
// 1. select only cubes -> paste only cubes
// 2. select cubes and ents -> paste cubes and ents. same relative positions
// 3. select only ents -> paste last selected ent. if ents are selected, replace attrs as paste
opaquepaste = 1
entcopymode = 0
editcopy = [
if (|| (havesel) [! (enthavesel)]) [
entcopymode = 0
entcopy
copy
] [
entcopymode = 1
entcopy
]
]
editpaste = [
cancelpaste = (! (|| (enthavesel) [havesel]));
if $entcopymode [
entreplace
if $cancelpaste [cancelsel]
] [
pastehilite
reorient // temp; real fix will be in octaedit
onrelease [
if $opaquepaste delcube
paste; entpaste
if $cancelpaste [cancelsel]
]
]
]
///////////////////////////////////////////////////////////////////////////////
// Selection //
///////////////////////////////////////////////////////////////////////////////
// select ents with given properties
// '*' is wildcard
entfind = [
if $numargs [
entselect (concat [&& [=enttype @@arg1]] (loopconcat i (- $numargs 1) [
result [[=entattr @@i @@[arg@(+ $i 2)]]]
]))
] [entselect 1]
]
entfindinsel = [
if $numargs [
entselect (concat [&& insel [=enttype @@arg1]] (loopconcat i (- $numargs 1) [
result [[=entattr @@i @@[arg@(+ $i 2)]]]
]))
] [entselect insel]
]
drag = [dragging 1; onrelease [dragging 0]]
corners = [selectcorners 1; dragging 1; onrelease [selectcorners 0; dragging 0]]
editmove = [moving 1; onrelease [moving 0]; result $moving]
entdrag = [entmoving 1; onrelease [entmoving 0]; result $entmoving]
editdrag = [cancelsel; || (entdrag) [drag]]
selcorners = [if $hmapedit [hmapselect] [cancelsel; || (entdrag) [corners]]]
editextend = [|| (entdrag) [if (havesel) [selextend; reorient; editmovecut] [drag]]]
editmovewith = [
if (havesel) [
|| (editmove) [arg1]
onrelease [moving 0; dragging 0]
] [
arg1
]
]
editmovecorner = [editmovewith selcorners]
editmovedrag = [editmovewith editdrag]
///////////////////////////////////////////////////////////////////////////////
// Miscellaneous Editing Commands //
///////////////////////////////////////////////////////////////////////////////
editfacewsel = [
if (|| havesel [! (enthavesel)]) [
if $moving [pushsel $arg1] [
entcancel
editface $arg1 $arg2
]
]
]
entswithdirection = [playerstart teledest mapmodel decal]
entdirectionprop = [0 0 1 1 ]
entdirection = [
if (&& (enthavesel) [= (havesel) 0]) [
entdiridx = (indexof $entswithdirection (enttype))
if (>= $entdiridx 0) [
entdirprop = (at $entdirectionprop $entdiridx)
if (> $arg1 0) [
entproperty $entdirprop $arg2
if (> (entattr $entdirprop) 360) [entproperty $entdirprop -360]
] [
entproperty $entdirprop (- 0 $arg2)
if (< (entattr $entdirprop) 0) [entproperty $entdirprop 360]
]
]
result 1
] [
result 0
]
]
selmovecut = 1
toggleeditmovecut = [
selmovecut = (! $selmovecut)
echo (? $selmovecut "Move Selection" "Cut Selection")
]
editmovecut = [
if $selmovecut [editmove] [editcut]
]
editdel = [if (! (enthavesel)) [delcube]; delent]
editflip = [flip; entflip]
editrotate = [|| (entdirection $arg1 15) [rotate $arg1; entrotate $arg1]]
editcut = [
if (moving 1) [
if (= $moving 1) [selsave]
onrelease [
moving 0
if (selmoved) [
selswap
copy; entcopy
delcube; delent
selrestore
paste; entpaste
]
]
]
]
setting_entediting = 1
passthrough = [
passthroughsel $arg1;
if $arg1 [
passthroughcube_bak = $passthroughcube
passthroughcube 1
] [
passthroughcube $passthroughcube_bak
]
entcancel
if $setting_entediting [entediting (! $arg1)]
]
entcomplete = [listcomplete $arg1 $enttypelist]
entcomplete newent
entcomplete entfind
entcomplete clearents
listcomplete editmat "air water clip glass noclip lava gameclip death nogi alpha"
air = [ editmat air $arg1 ]
looplist i ["" 2 3 4] [
[water@i] = [editmat water@i $arg1]
[lava@i] = [editmat lava@i $arg1]
[glass@i] = [editmat glass@i $arg1]
]
clip = [editmat clip $arg1]
noclip = [editmat noclip $arg1]
gameclip = [editmat gameclip $arg1]
death = [editmat death $arg1]
nogi = [editmat nogi $arg1]
alpha = [editmat alpha $arg1]
blendpaintmodes = ["off" "replace" "dig" "fill" "inverted dig" "inverted fill"]
minimaphere = [minimapheight (at (getcampos) 2)]
getsundir = [sunlightyaw (getcamyaw); sunlightpitch (getcampitch)]
defvarp editfloatspeed 1 1000 10000
makeitsnow = [newent particles 13 364 70 0xAAA 550] // derp

60
config/stdlib.cfg 100644
View File

@ -0,0 +1,60 @@
// Console language standard library
// Binds a key so that it will toggle a variable
bindvar = [bind $arg1 [@arg2 (= $@arg2 0); if (= $@arg2 0) [echo @@arg2 OFF] [echo @@arg2 ON]]]
bindvarquiet = [bind $arg1 [@arg2 (= $@arg2 0)]]
editbindvar = [editbind $arg1 [@arg2 (= $@arg2 0); if (= $@arg2 0) [echo @@arg2 OFF] [echo @@arg2 ON]]]
editbindvarquiet = [editbind $arg1 [@arg2 (= $@arg2 0)]]
// Binds a key so that it will set a modifier while held down
bindmod = [bind $arg1 [@arg2 1; onrelease [@@arg2 0]]]
editbindmod = [editbind $arg1 [@arg2 1; onrelease [@@arg2 0]]]
quine = [echo (format "quine = [%1]" $quine)]
issomeoneelsemaster = [
>= (listfind cn $listclients [ismaster $cn]) 0
]
numbots = [
listcount cn $listclients [isai $cn]
]
clearbots = [
looplist cn $listclients [
if (isai $cn) [delbot]
]
]
// Returns given RGB color as an INT color
// usage: (rgbtoint R G B)
rgbtoint = [+ (<< $arg1 16) (<< $arg2 8) $arg3]
// Returns given RGB color as a HEX color
// usage: (rgbtohex R G B)
rgbtohex = [tohex (rgbtoint $arg1 $arg2 $arg3) 6]
// Returns given INT color as an RGB color
// usage: (inttorgb <value> R-var G-var B-var)
inttorgb = [
$arg2 = (& (>> $arg1 16) 0xFF)
$arg3 = (& (>> $arg1 8) 0xFF)
$arg4 = (& $arg1 0xFF)
]
// *.tex file handling
texsky = [setshader "stdworld"; texture 0 "game/sky.png"]
texerror = [setshader "stdworld"; texture 0 "game/notexture.png"]
texnorender = [setshader "stdworld"; texture 0 "game/norender.png"]
texload = [
if (! (exec [media/texture/@arg1.tex] 0)) [
error [texload error: @arg1.tex not found]
texerror
]
]
decalload = [
if (! (exec [media/decal/@arg1.cfg] 0)) [
error [decalload error: @arg1.cfg not found]
]
]

577
config/ui.cfg 100644
View File

@ -0,0 +1,577 @@
// standard menu definitions
// don't modify, add personal menus to autoexec.cfg instead
exec "config/ui/lib.cfg" // UI library
exec "config/ui/style.cfg" // Styles
exec "config/ui/scoreboard.cfg" // Scoreboard
exec "config/ui/edithud.cfg" // Edit HUD
exec "config/ui/fkey.cfg" // F# Key Menus
exec "config/ui/serverbrowser.cfg" // Server Browser
exec "config/ui/stats.cfg" // Player Stats
exec "config/ui/options.cfg" // Options Menu
reui = [
exec "config/ui.cfg"
]
togglemainmenu = [|| hidetopui [toggleui main]]
bind ESCAPE [togglemainmenu]
///////////////////////////////////////////////////////////////////////////////
// Main //
///////////////////////////////////////////////////////////////////////////////
UImenu "main" [
uieschide (! $mainmenu)
uihlist 0 [
uivlist 0 [
UIbutton "hold2" [uitext "Server Browser" 0.65] 0.2 0.04 [hideui "main" ; showui "server_browser"]
UIbutton "hold2" [uitext "Map Browser" 0.65] 0.2 0.04 [hideui "main" ; showui "map_browser"]
uifill 0.2 0.02 [UIbar 1]
UIbutton "hold2" [uitext "Player Setup" 0.65] 0.2 0.04 [hideui "main" ; showui "player_setup"]
UIbutton "hold2" [uitext "Options" 0.65] 0.2 0.04 [hideui "main" ; showui "options"]
if $mainmenu [
UIbutton "hold2" [uitext "Credits" 0.65] 0.2 0.04 [hideui "main" ; showui "credits"]
]
uifill 0.2 0.02 [UIbar 1]
UIbutton "hold2" [uitext "Quit" 0.65] 0.2 0.04 [quit]
]
if (! $mainmenu) [
uifill 0.02 0.24 [UIbar 0 1]
uivlist 0 [
if (isspectator $getclientnum) [
if $scoreboardmultiplayer [
if (ismaster $getclientnum) [
UIbutton "hold2" [uitext "Play" 0.65] 0.2 0.04 [hideui "main" ; spectator 0]
] [
if (> $getmastermode 1) [
uifill 0 0.04 [uitext "^f4Play" 0.65]
] [
UIbutton "hold2" [uitext "Play" 0.65] 0.2 0.04 [hideui "main" ; spectator 0]
]
]
] [
UIbutton "hold2" [uitext "Play" 0.65] 0.2 0.04 [hideui "main" ; spectator 0]
]
] [
UIbutton "hold2" [uitext "Spectate" 0.65] 0.2 0.04 [hideui "main" ; spectator 1]
]
case $getteam [
0] [uifill 0 0.04] [
1] [UIbutton "hold2" [uitext "Join ^f3Rojo" 0.65] 0.2 0.04 [team rojo]] [
2] [UIbutton "hold2" [uitext "Join ^f1Azul" 0.65] 0.2 0.04 [team azul]]
uifill 0.2 0.02 [UIbar 1]
if $scoreboardmultiplayer [
UIbutton "hold2" [uitext "Master" 0.65] 0.2 0.04 [hideui "main" ; showui "master"]
if (ismaster $getclientnum) [
UIbutton "hold2" [uitext "Bots" 0.65] 0.2 0.04 [hideui "main" ; showui "bots"]
] [
uifill 0 0.04
]
] [
uifill 0 0.04
UIbutton "hold2" [uitext "Bots" 0.65] 0.2 0.04 [hideui "main" ; showui "bots"]
]
uifill 0.2 0.02 [UIbar 1]
UIbutton "hold2" [uitext "Disconnect" 0.65] 0.2 0.04 [disconnect]
]
]
]
]
///////////////////////////////////////////////////////////////////////////////
// Player Setup //
///////////////////////////////////////////////////////////////////////////////
UI_pmodel = 0
UI_pteam = 0
UI_pweapon = 1
UImenu "player_setup" [
uihlist 0.01 [
uivlist 0 [
uiplayerpreview $UI_pmodel (case $UI_pteam 0 $playercolor 1 $playercolorazul 2 $playercolorrojo) $UI_pteam $UI_pweapon 0.4 0.5 [
style_generic_default
uiclamp* 1 1 1 1
]
uihlist 0 [
uiclamp 1 1
UIbutton "" [
UIradio [= $UI_pweapon 0] 0.016
uitext "Railgun" 0.6
] 0 0.032 [UI_pweapon = 0] -1
UIbutton "" [
UIradio [= $UI_pweapon 1] 0.016
uitext "Pulse Rifle" 0.6
] 0 0.032 [UI_pweapon = 1] -1
uiclamp* 1 1
]
]
uivlist 0.01 [
uialign -2 -1
uivlist 0.0037 [
uitext "Name" 0.7
uifield name 15 [] 0.7 [uioutline (uifocus? $c_focus $c_line); uiclamp- 1 1 1 1]
]
looplist3 v t l [
"playercolor" 0 9
"playercolorazul" 1 4
"playercolorrojo" 2 4
] [
uivlist 0.0037 [
case $t 1 [
uitext "^f8Azul" 0.7
] 2 [
uitext "^f3Rojo" 0.7
] () [uitext "Solo" 0.7]
uigrid (? (< $t 1) 3 2) 0.005 0.005 [
local color
uihover [UI_pteam = $t]
loop i $l [
color = (getplayercolor $i $t)
uicolor $color 0.0458 0.0458 [
uioutline (? (= $$v $i) $c_fill $color)
uiclamp- 1 1 1 1
uipress [$v $i]
]
]
]
]
]
]
]
] [] [] [] "Player Setup"
///////////////////////////////////////////////////////////////////////////////
// Credits //
///////////////////////////////////////////////////////////////////////////////
UI_creditlist = [
UItitle [
uispace 0.015 0 [
uialign -1 -2
uihlist 0.01 [
uiimage "media/interface/cube.png" 0.03 0.03
uitext [@@@@arg1] 0.7
]
]
] 0 0.032
uispace 0.03 0 [
uifill 0 0 [
uiclamp 1 1
uimodhgradient 0xC0C0C0 0xFFFFFF
uiclamp- 1 1 1 1
uispace 0.02 0.01 [
uialign -1 -2
uivlist 0 [
looplist i $arg2 [
uiwraptext (strreplace (strreplace $i "^"" "^fs^f8^"" "^"^fr") ": " "^f4: ") 0.69 0.6
]
uialign* -1 -2
]
]
]
]
uifill 0 0.02
]
UImenu "credits" [
uihlist 0.01 [
uiscroll 0.8 0.8 [
uifill 0.77
uivlist 0.0008 [
uiclamp 1 1
uialign -2 -1
// Alphabetized by alias
UI_creditlist "Project" [
[Lee "eihrul" Salzman : Code Gatekeeper]
[Shane "Nieb" Nieb : Media Gatekeeper]
]
UI_creditlist "Code" [
[Lee "eihrul" Salzman]
[Benjamin Segovia]
[Kevin "Hirato Kirata" Meyer]
]
UI_creditlist "Art" [
[Shane "Nieb" Nieb : Playermodel, Mapmodels, Textures]
]
UI_creditlist "Sound" [
[Dylan "Dacker" Ackerly]
[Shane "Nieb" Nieb]
[Sławomir "Q009" Błauciak]
[Jannic "Uphys" Böhme]
]
UI_creditlist "Cartography" [
[Dylan "Dacker" Ackerly : complex]
[Shane "Nieb" Nieb : complex, test_ctf]
[Sławomir "Q009" Błauciak : steelribs]
[Jack "Pritchard" Viney : alphacorp]
[Kurt Kessler : waterworks]
[James 'Skur' Rucks : reflection]
[Yannick 'Snowy' Weber : reflection]
]
UI_creditlist "Miscellaneous" [
[Kevin "Hirato Kirata" Meyer : CubeScript Documentation]
[Shane "Nieb" Nieb : UI Design, Tesseract Website]
[Daniel "q66" Kolesa : Build-system Improvements]
["RaZgRiZ" : UI Documentation, UI Design]
]
UI_creditlist "Cube Engine 2" [
[Wouter "Aardappel" van Oortmerssen]
[Lee "eihrul" Salzman]
[Mike "Gilt" Dysart]
[Robert "baby-rabbit" Pointon]
[Quinton "Quin" Reeves]
[John "geartrooper" Siar]
[and others...]
"http://sauerbraten.org/"
]
uiclamp* 1 1
]
]
UIvscroll 0.02 0.8 2.0
]
] [] [] [] "Tesseract Contributors"
///////////////////////////////////////////////////////////////////////////////
// Master //
///////////////////////////////////////////////////////////////////////////////
menu_master = [if $isconnected [if $scoreboardmultiplayer [toggleui "master"]]]
UImenu "master" [
uifill 0 0 [
uivlist 0 [
uihlist 0.01 [
if (ismaster $getclientnum) [
UIbutton "" [uitext "Relinquish Master" 0.65] 0.24 0.06 [setmaster 0]
] [
if (issomeoneelsemaster) [
UIbutton "" [uitext "^f4Claim Master" 0.65] 0.24 0.06 []
] [
UIbutton "" [uitext "Claim Master" 0.65] 0.24 0.06 [setmaster 1]
]
]
if (ismaster $getclientnum) [
uigrid 2 0 0 [
looplist2 n i [
"^f0open ^f4(0)" 0 "^f0veto ^f4(1)" 1
"^f2locked ^f4(2)" 2 "^f3private ^f4(3)" 3
] [
UIbutton "" [
UIradio [= $getmastermode $i] 0.016
uitext $n 0.6
] 0.16 0.03 [mastermode $i] -1
]
]
uivlist 0 [
UIbutton "" [uitext "Clearbans" 0.65] 0.16 0.03 [clearbans]
UIbutton "" [uitext "Bots" 0.65] 0.16 0.03 [hideui "main" ; showui "bots"]
]
] [
uifill 0.49
]
]
uifill 0 0.02 [UIbar 1 ; uiclamp 1 1 1 1]
if (ismaster $getclientnum) [
if (> $getmode 2) [UI_clientlistteam] [UI_clientlistsolo]
] [
if (> $getmode 2) [uifill 1.43 0.312] [uifill 0 0.624]
]
]
]
] [] [] [] "Master"
UI_clientlistsolo = [
uihlist 0 [
uiscroll 0.71 0.624 [
uifill 0.71 0.624 [
uitable 0 0 [
UI_mlc = 0
looplist cn (listclients 1 0) [
uitablerow [
uifill 0.078 0.026 [
uicolortext (concatword $cn " : ") (scoreboardstatus $cn) 0.57
uialign- 1
]
uifill 0.362 0.026 [
uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57
uialign- -1
]
if (= $cn $getclientnum)[
uifill 0.077 0.026
] [
UIbutton "hold2" [
UItriangle 0xCCCCCC 0.01 0.01 270
uitext "Kick" 0.57
] 0.077 0.026 [kick @cn] -1
]
UIbutton "hold2" [
UIradio [= (isspectator $cn) 1] 0.016
uitext "Spec" 0.57
] 0.087 0.026 [spectator @(= (isspectator $cn) 0) @cn] -1
UIbutton "hold2" [
UIradio [= (ismaster $cn) 1] 0.016
uitext (concatword (? (isadmin $cn) "Admin" (? (isauth $cn) "Auth" "Master"))) 0.57
] 0.105 0.026 [setmaster (? (ismaster $cn) 0 1) @cn] -1
] [
UI_mlc = (! $UI_mlc)
uicolor (? $UI_mlc 0x99323232 0x99262626) 0 0 [
uiclamp 1 1 1 1
pushif highlight (scoreboardhighlight $cn) [
uioutline 0xA0A0A0 ; uiclamp- 1 1 1 1
]
]
]
]
]
uialign* -1 -1
]
]
uifill 0.01
UIvscroll 0.02 0.624 1.56
]
]
UI_clientlistteam = [
uihlist 0 [
uiscroll 1.4 0.312 [
uifill 1.4 0.312 [
uihlist 0 [
uialign 0 -1
uitable 0 0 [
uifill 0.695
UI_mlc = 0
looplist cn (listclients 1 0) [
if (= (getclientteam $cn) 1) [
uitablerow [
uifill 0.078 0.026 [
uicolortext (concatword $cn " : ") (scoreboardstatus $cn) 0.57
uialign- 1
]
uifill 0.26 0.026 [
uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57
uialign- -1
]
if (= $cn $getclientnum)[
uifill 0.077 0.026
] [
UIbutton "hold2" [
UItriangle 0xCCCCCC 0.01 0.01 270
uitext "Kick" 0.57
] 0.077 0.026 [kick @cn] -1
]
UIbutton "hold2" [
UItriangle 0xCCCCCC 0.01 0.01 270
uitext "Team" 0.57
] 0.0875 0.026 [setteam @cn @(? (=s (getclientteam $cn) "1") "2" "1")] -1
UIbutton "hold2" [
UIradio [= (isspectator $cn) 1] 0.016
uitext "Spec" 0.57
] 0.087 0.026 [spectator @(= (isspectator $cn) 0) @cn] -1
UIbutton "hold2" [
UIradio [= (ismaster $cn) 1] 0.016
uitext (concatword (? (isadmin $cn) "Admin" (? (isauth $cn) "Auth" "Master"))) 0.57
] 0.105 0.026 [setmaster (? (ismaster $cn) 0 1) @cn] -1
] [
UI_mlc = (! $UI_mlc)
uicolor (? $UI_mlc 0x99333b40 0x99262b33) 0 0 [
uiclamp 1 1 1 1
pushif highlight (scoreboardhighlight $cn) [
uioutline 0xA0A0A0 ; uiclamp- 1 1 1 1
]
]
]
]
]
]
uifill 0.01
uitable 0 0 [
uifill 0.695
UI_mlc = 0
looplist cn (listclients 1 0) [
if (= (getclientteam $cn) 2) [
uitablerow [
uifill 0.078 0.026 [
uicolortext (concatword $cn " : ") (scoreboardstatus $cn) 0.57
uialign- 1
]
uifill 0.26 0.026 [
uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57
uialign- -1
]
if (= $cn $getclientnum)[
uifill 0.077 0.026
] [
UIbutton "hold2" [
UItriangle 0 0.01 0.01 270
uitext "Kick" 0.57
] 0.077 0.026 [kick @cn] -1
]
UIbutton "hold2" [
UItriangle 0 0.01 0.01 270
uitext "Team" 0.57
] 0.0875 0.026 [setteam @cn @(? (=s (getclientteam $cn) "1") "2" "1")] -1
UIbutton "hold2" [
UIradio [= (isspectator $cn) 1] 0.016
uitext "Spec" 0.57
] 0.087 0.026 [spectator @(= (isspectator $cn) 0) @cn] -1
UIbutton "hold2" [
UIradio [= (ismaster $cn) 1] 0.016
uitext (concatword (? (isadmin $cn) "Admin" (? (isauth $cn) "Auth" "Master"))) 0.57
] 0.105 0.026 [setmaster (? (ismaster $cn) 0 1) @cn] -1
] [
UI_mlc = (! $UI_mlc)
uicolor (? $UI_mlc 0x99403333 0x99332626) 0 0 [
uiclamp 1 1 1 1
pushif highlight (scoreboardhighlight $cn) [
uioutline 0xA0A0A0 ; uiclamp- 1 1 1 1
]
]
]
]
]
]
uialign* 0 -1
]
]
]
uifill 0.01
UIvscroll 0.02 0.312 1.56
]
]
///////////////////////////////////////////////////////////////////////////////
// Bots //
///////////////////////////////////////////////////////////////////////////////
UI_botskill = 87
UI_botaddnum = 9
UImenu "bots" [
uifill 0.65 0.27 [
uivlist 0.01 [
uitext (concatword "Bots: " (numbots)) 0.6
uifill 0 0.01
uihlist 0.01 [
uialign 1 ; uitext "Skill Level" 0.6 ; UIhslider UI_botskill 1 100 1 0.5 0.032 [uitext $UI_botskill 0.6]
]
uihlist 0.01 [
uialign 1 ; uitext "#" 0.6 ; UIhslider UI_botaddnum 2 32 1 0.5 0.032 [uitext $UI_botaddnum 0.6]
]
uifill 0 0.015
uihlist 0.05 [
uivlist 0.01 [
UIbutton "" [uitext "Add Bot" 0.65 ; UI_keyref 1 0.027 0.027 "Ins" "" 0.4] 0.2 0.04 [addbot $UI_botskill]
UIbutton "" [uitext (concatword "Add " $UI_botaddnum " Bots") 0.65] 0.2 0.04 [loop a (UI_botaddnum) [addbot $UI_botskill]]
]
uivlist 0.01 [
UIbutton "" [uitext "Delete Bot" 0.65 ; UI_keyref 1 0.027 0.027 "Del" "" 0.4] 0.2 0.04 [delbot]
UIbutton "" [uitext "Clear Bots" 0.65] 0.2 0.04 [clearbots]
]
]
]
]
] [] [] [] "Bots"
///////////////////////////////////////////////////////////////////////////////
// Display Changes //
///////////////////////////////////////////////////////////////////////////////
UImenu "changes" [
uivlist 0.02 [
uiclamp 1 1
UItitle [uitext "Apply changes for:" 0.6] 0 0.03
uiclamp- 1 1
uivlist 0.01 [
loop i $pendingchanges [
uitext (concatword "^f8" (pendingchanges $i)) 0.6
]
]
uihlist 0 [
UIbutton "hold2" [uitext "Yes" 0.6] 0.18 0.032 [applychanges]
UIbutton "hold2" [uitext "No" 0.6] 0.18 0.032 [hideui "changes"]
]
]
] [if (= $pendingchanges 0) [hideui "changes"]]
///////////////////////////////////////////////////////////////////////////////
// Notepad //
///////////////////////////////////////////////////////////////////////////////
UI_notepadfile = "untitled.txt"
UI_cmc_from = ""
UI_cmc_to = ""
UImenu "notepad" [
uivlist 0.01 [
uihlist 0.01 [
uialign -1 -2
uifield UI_notepadfile -35 [] 0.6 [
uioutline (uifocus? 0xFF0000 $c_line)
uiclamp- 1 1 1 1
]
UIbutton "hold2" [uitext "Load" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textload $UI_notepadfile]
UIbutton "hold2" [uitext "Save" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textsave $UI_notepadfile]
UIbutton "hold2" [uitext "Exec" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textexec]
uispace 0.01 0 [UIbar 0 1]
UIbutton "hold2" [uitext "Copy" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textcopy]
UIbutton "hold2" [uitext "Paste" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textpaste]
UIbutton "hold2" [uitext "Select All" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textselectall]
uispace 0.01 0 [UIbar 0 1]
UIbutton "hold2" [uitext "Clear All" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textclear]
]
uitexteditor $UI_notepadfile -80 20 1 "" 0 [
uioutline (uifocus? 0xFF0000 $c_line)
uiclamp- 1 1 1 1
]
textinit $UI_notepadfile $UI_notepadfile
]
] [] [] [] "Notepad"
notepad = [
if $numargs [UI_notepadfile = $arg1]
showui "notepad"
]
mapnotepad = [
UI_notepadfile = (concatword "media/map/" (? $numargs $arg1 $mapname) ".cfg")
showui "notepad"
]
copymapcfg = [
if $numargs [
UI_cmc_from = $arg1
UI_cmc_to = (? (= $numargs 2) $arg2 $mapname)
if (findfile (concatword "media/map/" $UI_cmc_from ".cfg")) [
if (findfile (concatword "media/map/" $UI_cmc_to ".cfg")) [showui "cmc_confirm"] [
textfocus "#copymapcfg"
textload (concatword "media/map/" $UI_cmc_from ".cfg")
textsave (concatword "media/map/" $UI_cmc_to ".cfg")
]
] [
echo (concatword "^f7Map config "^f8^" $UI_cmc_from "^f7^" does not exist!")
UI_cmc_from = "" ; UI_cmc_to = ""
]
]
]
UImenu "cmc_confirm" [
uivlist 0.02 [
uiclamp 1 1
UItitle [uitext "Copy map config:" 0.6] 0 0.03
uiclamp- 1 1
uivlist 0.01 [
uitext (concatword "^f2" $UI_cmc_from) 0.6
UItriangle 0 0.01 0.01 180
uitext (concatword "^f2" $UI_cmc_to) 0.6
]
uihlist 0 [
UIbutton "hold2" [uitext "Proceed" 0.6] 0.18 0.032 [
textfocus "#copymapcfg"
textload (concatword "media/map/" $UI_cmc_from ".cfg")
textsave (concatword "media/map/" $UI_cmc_to ".cfg")
hideui "cmc_confirm"
]
UIbutton "hold2" [uitext "Cancel" 0.6] 0.18 0.032 [hideui "cmc_confirm"]
]
]
] [
if (|| [=s $UI_cmc_from ""] [=s $UI_cmc_to ""]) [hideui "cmc_confirm"]
] [UI_cmc_from = "" ; UI_cmc_to = ""]

View File

@ -0,0 +1,71 @@
///////////////////////////////////////////////////////////////////////////////
// Edit HUD Elements //
///////////////////////////////////////////////////////////////////////////////
edittoggled = [
if $editing [
showui "editstats"
showui "varicons"
] [
hideallui
]
]
newui "editstats" [
uiallowinput 0
if $hidehud [] [
uialign -1 1
uiabovehud
uicolor $c_menu_a 0 0 [
uispace $UIwindow_padding $UIwindow_padding [
uivlist 0 [
uicontext (
format "%4^f7%5^f7gridsize :^f8 %1 ^f7| worldsize :^f8 %2 ^f7| floatspeed :^f8 %3" $gridpower $mapscale $floatspeed (
if $hmapedit [format "heightmap brush^f8 %1 ^f7:^f8 %2^n" $hbrushindex $hbrushname] [
if $blendpaintmode [
format "blendpaint mode : ^f8%1^f7^nblend brush : ^f8%2^n" (at $blendpaintmodes $blendpaintmode) (getblendbrushname (curblendbrush))
] [if (! (enthavesel)) [
format "index^f8 %1 ^f7:^f8 %2^n" (max 0 (getseltex)) (gettexname (getseltex))
]]
]
) (if (enthavesel) [concat (entget) ":^f8" (enthavesel) "^f7selected^n"])
)
uicontext (format "cube %1%2" $selchildcount (if $showmat [selchildmat ": "]))
uihlist 0 [
uicontextfill 12 0 [uicontext (format "wtr:%1k(%2%%)" $editstatwtr $editstatvtr) ; uialign- -1 0]
uicontextfill 12 0 [uicontext (format "wvt:%1k(%2%%)" $editstatwvt $editstatvvt) ; uialign- -1 0]
uicontextfill 11 0 [uicontext (format "evt:%1k" $editstatevt) ; uialign- -1 0]
uicontextfill 7 0 [uicontext (format "eva:%1k" $editstateva) ; uialign- -1 0]
]
uihlist 0 [
uicontextfill 12 0 [uicontext (concatword "ond:" $editstatocta) ; uialign- -1 0]
uicontextfill 12 0 [uicontext (concatword "va:" $editstatva) ; uialign- -1 0]
uicontextfill 11 0 [uicontext (format "gl:%1(%2)" $editstatglde $editstatgeombatch) ; uialign- -1 0]
uicontextfill 7 0 [uicontext (concatword "oq:" $editstatoq) ; uialign- -1 0]
uicontextfill 7 0 [uicontext (concatword "pvs:" $editstatpvs) ; uialign- -1 0]
]
uialign* -1 0
]
]
uioutline $c_line ; uiclamp- 1 1 1 1
]
]
]
newui "varicons" [
uiallowinput 0
if $hidehud [] [
uialign 1 1
uispace 0.01 0.1 [
uivlist 0 [
looplist i (concatword "allfaces entselsnap entediting fullbright showmat " (? $scoreboardmultiplayer "nompedit")) [
uifont "default_outline" [
uialign 1
if $$i [
uitext (concatword "^f8" $i) 0.47
] [uicolortext $i 0x80FFFFFF 0.47]
]
]
]
]
]
]

1131
config/ui/fkey.cfg 100644

File diff suppressed because it is too large Load Diff

328
config/ui/lib.cfg 100644
View File

@ -0,0 +1,328 @@
// ui* hardcoded ui functions
// UI* aliased ui functions
// UI_* miscellaneous ui stuff
// UImenu 1:"NAME" 2:[children] 3:[on-show] 4:[on-hide] 5:[ui-children] 6:"TITLE"
UImenu = [
newui $arg1 [
@arg5
uivlist 0 [
uiclamp 1 1 1 1
@@(? (>= $numargs 6) [
uivgradient $c_main1 $c_main2 0 0.04 [
uiclamp 1 1
uispace 0.012 0 [
uiclamp 1 1
uitarget 0.039 0.039 [
uihover [uicolor 0xC0C0C0 0.017 0.017] [uicolor 0x909090 0.015 0.015]
uihold [uicolor 0x606060 0.011 0.011] ; uirelease [hideui [@@@@@@arg1]]
]; uialign- -1
uitext [@@@@arg6] 0.8
uitarget 0.039 0.039 [
uihover [uicolor 0xC0C0C0 0.017 0.017] [uicolor 0x909090 0.015 0.015]
uihold [uicolor 0x606060 0.011 0.011] ; uirelease [hideui [@@@@@@arg1]]
]; uialign- 1
]
]
])
uicolor $c_menu 0.01 0.01 [
uiclamp 1 1 1 1
uispace $UIwindow_padding $UIwindow_padding [
uiclamp 1 1 1 1
@@@@arg2
]
]
]
//uioutline $c_line; uiclamp- 1 1 1 1
] $arg3 $arg4
]
// UIbar 1:CLAMP-X 2:CLAMP-Y
UIbar = [
uiline $c_line
uiclamp- $arg1 $arg1 $arg2 $arg2
]
// UItriangle 1:0xCOLOR 2:(SIZE-W) 3:(SIZE-H) 4:(ORIENTATION)
UItriangle = [
if $arg1 [] [arg1 = 0xFFFFFF]
uigroup [
uitriangle $arg1 $arg2 $arg3 $arg4
uitriangleoutline $arg1 $arg2 $arg3 $arg4
]
]
// UIcircle 1:0xCOLOR 2:(SIZE)
UIcircle = [
if $arg1 [] [arg1 = 0xFFFFFF]
uigroup [
uicircle $arg1 $arg2
uicircleoutline $arg1 $arg2
]
]
// UItitle 1:[title children] 2:(SIZE-W) 3:(SIZE-H)
UItitle = [
uivgradient $c_line $c_menu $arg2 $arg3 [
arg1
//uioutline $c_line
uiclamp 1 1 1 1
]
]
// UIbuttonarea 1:(STYLE) 2:(BUTTON-WIDTH) 3:(BUTTON-HEIGHT) 4:[children]
UIbuttonarea = [
uitarget $arg2 $arg3 [
if (=s $arg1 "") [
style_button_default
] [[style_button_@arg1]]
uiclamp* 1 1 1 1
doargs $arg4
]
]
// UIbutton 1:(STYLE) 2:[button-children] 3:(BUTTON-WIDTH) 4:(BUTTON-HEIGHT) 5:[on-release] 6:(ALIGNMENT) 7:[children] 8:(USE-PADDING)
UIbutton = [
uitarget $arg3 $arg4 [
doargs $arg7
if (=s $arg1 "") [
style_button_default
] [[style_button_@arg1]]
uirelease [doargs $arg5]
uiclamp* 1 1 1 1
uispace (? (>= $numargs 8) $arg8 $UIbutton_padding) 0 [
uiclamp 1 1
uihlist 0.01 [
uialign $arg6 0
doargs $arg2
]
]
]
]
// UIcheckbox 1:[condition] 2:(SIZE) 3:0xCOLOR-ON 4:0xCOLOR-OFF 5:[children]
UIcheckbox = [
if $arg4 [] [arg4 = $c_off]
if $arg3 [] [arg3 = $c_on1]
uicolor (? (arg1) $arg3 $arg4) $arg2 $arg2 [
uimodvgradient 0xFFFFFF 0xB0B0B0
doargs $arg5
uioutline $c_line
uiclamp* 1 1 1 1
]
]
// UIradio 1:[condition] 2:(SIZE) 3:0xCOLOR-ON 4:0xCOLOR-OFF 5:[children]
UIradio = [
if $arg4 [] [arg4 = $c_off]
if $arg3 [] [arg3 = $c_on2]
uicircleoutline (? (arg1) $arg3 $arg4) $arg2 [
uicircle (? (arg1) $arg3 $arg4) $arg2 [
doargs $arg5
uiclamp* 1 1 1 1
]
]
]
// UIarrowbutton 1:(SIZE-W) 2:(SIZE-H) 3:(ORIENTATION) 4:[on-release] 5:(ARROW-%-SIZE) 6:[children]
UIarrowbutton = [
local arrowsize
arrowsize = (*f (minf $arg1 $arg2) (minf 1 (maxf 0 $arg5)))
uitarget $arg1 $arg2 [
uicolor $c_menu
doargs $arg6
style_button_default
uirelease [doargs $arg4]
uiclamp* 1 1 1 1
UItriangle 0 $arrowsize $arrowsize $arg3
]
]
// UIhtab 1:(SIZE-W) 2:(SIZE-H) 3:VAR 4:["name" [action] ..] 5:<BUTTON BEHAVIOR: 0=HOVER, 1=PRESS, 2=RELEASE>
UIhtab = [
uifill $arg1 $arg2 [
uihlist 0 [
uiclamp 1 1
looplist3 v n c $arg4 [
if (=s $$arg3 $v) [
uimodvgradient 0xFFFFFF $c_grdmod 0 $arg2 [
UIbar 0 1 ; uialign- -1 0
UIbar 0 1 ; uialign- 1 0
uispace 0.01 0 [uitext (concatword "^f8" $n) 0.7]
]
] [
uitarget 0 $arg2 [
uispace 0.01 0 [uitext $n 0.7]
case $arg5 0 [
uihover [$arg3 = $v]
] 1 [
uipress [$arg3 = $v]
] 2 [uirelease [$arg3 = $v]]
do $c
]
]
]
uiclamp* 1 1
]
UIbar 1 0 ; uialign- 0 1
]
]
// UIvtab 1:(SIZE-W) 2:(SIZE-H) 3:VAR 4:["name" [action] ..] 5:<BUTTON BEHAVIOR: 0=HOVER, 1=PRESS, 2=RELEASE>
UIvtab = [
uifill $arg1 $arg2 [
uivlist 0 [
uiclamp 0 0 1 1
looplist3 v n c $arg4 [
if (=s $$arg3 $v) [
uimodhgradient 0xFFFFFF $c_grdmod $arg1 0 [
UIbar 1 ; uialign- 0 -1
UIbar 1 ; uialign- 0 1
uispace 0.01 0 [uitext (concatword "^f8" $n) 0.7]
]
] [
uitarget $arg1 0 [
uispace 0.01 0 [uitext $n 0.7]
case $arg5 0 [
uihover [$arg3 = $v]
] 1 [
uipress [$arg3 = $v]
] 2 [uirelease [$arg3 = $v]]
do $c
]
]
]
uiclamp* 1 1 1 1
]
UIbar 0 1 ; uialign- 1
]
]
// UIvscroll 1:(SIZE-W) 2:(SIZE-H) 3:(SCROLLSPEED) 4:(ARROW-%-SIZE)
UIvscroll = [
if $arg4 [] [arg4 = 0.5]
uivlist 0 [
uiscrollarrow (-f 0 $arg3) [UIarrowbutton $arg1 $arg1 0 [] $arg4]
uivscrollbar [
uifill $arg1 (-f $arg2 (*f $arg1 2)) [uicolor $c_slider ; uiclamp- 1 1 1 1]
uiscrollbutton [
uicolor $c_menu $arg1
style_button_hold5
uiclamp* 1 1 1 1
style_generic_linesh 3 0.004 (*f $arg1 0.5)
]
]
uiscrollarrow $arg3 [UIarrowbutton $arg1 $arg1 180 [] $arg4]
]
]
// UIhscroll 1:(SIZE-W) 2:(SIZE-H) 3:(SCROLLSPEED) 4:(ARROW-%-SIZE)
UIhscroll = [
if $arg4 [] [arg4 = 0.5]
uihlist 0 [
uiscrollarrow (-f 0 $arg3) [UIarrowbutton $arg2 $arg2 90 [] $arg4]
uihscrollbar [
uifill (-f $arg1 (*f $arg2 2)) $arg2 [uicolor $c_slider ; uiclamp- 1 1 1 1]
uiscrollbutton [
uicolor $c_menu 0 $arg2
style_button_hold1
uiclamp* 1 1 1 1
style_generic_linesv 3 0.004 (*f $arg2 0.5)
]
]
uiscrollarrow $arg3 [UIarrowbutton $arg2 $arg2 270 [] $arg4]
]
]
// UIvslider 1:VAR 2:MIN 3:MAX 4:STEP 5:X 6:Y 7:[children] 8:[on-change] 9:(ARROW-%-SIZE)
UIvslider = [
if $arg9 [] [arg9 = 0.5]
uivlist 0 [
uisliderarrow -1 [UIarrowbutton $arg5 $arg5 0 [] $arg9]
uihslider $arg1 (minf $arg3 $arg2) (maxf $arg2 $arg3) $arg4 $arg8 [
uifill (-f $arg6 (*f $arg5 2)) $arg5 [uicolor $c_slider ; uiclamp- 1 1 1 1]
uisliderbutton [
uicolor $c_menu $arg5
style_button_hold5
uiclamp* 1 1 1 1
uispace (? (>= $numargs 10) $arg11 $UIbutton_padding) 0 [arg7]
]
]
uisliderarrow 1 [UIarrowbutton $arg5 $arg5 180 [] $arg9]
]
]
// UIhslider 1:VAR 2:MIN 3:MAX 4:STEP 5:X 6:Y 7:[children] 8:[on-change] 9:(ARROW-%-SIZE)
UIhslider = [
if $arg9 [] [arg9 = 0.5]
uihlist 0 [
uisliderarrow -1 [UIarrowbutton $arg6 $arg6 90 [] $arg9]
uihslider $arg1 $arg2 $arg3 $arg4 $arg8 [
uifill (-f $arg5 (*f $arg6 2)) $arg6 [uicolor $c_slider ; uiclamp- 1 1 1 1]
uisliderbutton [
uicolor $c_menu 0 $arg6
style_button_hold1
uiclamp* 1 1 1 1
uispace (? (>= $numargs 10) $arg11 $UIbutton_padding) 0 [arg7]
]
]
uisliderarrow 1 [UIarrowbutton $arg6 $arg6 270 [] $arg9]
]
]
// UIvcolorslider 1:VAR 2:MIN 3:MAX 4:0xCOLOR1 5:0xCOLOR2 6:X 7:Y 8:[on-change]
UIvcolorslider = [
uigroup [
uivgradient $arg5 $arg4 (*f 0.85 $arg6) $arg7 [uioutline $c_line ; uiclamp- 1 1 1 1]
uifont "default_outline" [uivlist -0.01 [
loop i (strlen (abs $$arg1)) [
uicolortext (substr $$arg1 $i 1) (? (|| uihover? uihold?) 0x80FFFFFF 0x40FFFFFF) 0.8
]
]]
uivslider $arg1 $arg2 $arg3 1 $arg8 [
uifill $arg6 (*f 0.98 $arg7)
uisliderbutton [uiline 0xFFFFFF $arg6 0]
]
]
]
// UIhcolorslider 1:VAR 2:MIN 3:MAX 4:0xCOLOR1 5:0xCOLOR2 6:X 7:Y 8:[on-change]
UIhcolorslider = [
uigroup [
uihgradient $arg4 $arg5 $arg6 (*f 0.85 $arg7) [uioutline $c_line ; uiclamp- 1 1 1 1]
uihslider $arg1 $arg2 $arg3 1 $arg8 [
uifill (*f 0.98 $arg6) $arg7
uisliderbutton [uiline 0xFFFFFF 0 $arg7]
]
]
]
//UIlistslider 1:VAR 2:COMPARISON 3:[values] 4:X 5:Y 6:[on-change] 7:(ARROW-%-SIZE) 8:[children]
UIlistslider = [
if $arg7 [] [arg7 = 0.5]
uihlist 0 [
UIarrowbutton $arg5 $arg5 90 [
n = ([listfind@arg2] $arg3 $$arg1 1)
if (< $n 0) [n = 0] [
n = (- $n 2)
if (< $n 0) [n = (+ $n (listlen $arg3))]
]
$arg1 = (at $arg3 $n)
arg6
] $arg7
uifill (-f $arg4 (*f $arg5 2)) $arg5 [
uicolor $c_slider
uiclamp* 1 1 1 1
if (=s $arg8 "") [
uitext (|| [[listassoc@arg2] $arg3 $$arg1] [result "custom"]) 0.6
] arg8
]
UIarrowbutton $arg5 $arg5 270 [
n = ([listfind@arg2] $arg3 $$arg1 1)
n = (if (>= $n 0) [mod (+ $n 2) (listlen $arg3)] [- (listlen $arg3) 2])
$arg1 = (at $arg3 $n)
arg6
] $arg7
]
]

View File

@ -0,0 +1,595 @@
///////////////////////////////////////////////////////////////////////////////
// Options //
///////////////////////////////////////////////////////////////////////////////
UI_opttabs = 0
UI_optc1wA = 0.025
UI_optc1wB = 0.270
UI_optc1w = (+f $UI_optc1wA $UI_optc1wB)
UI_optc2w = 0.363
UI_optrowh = 0.032
UI_optbar = [
uitablerow [
uifill $UI_optc1w 0.020 [UIbar 1]
uifill $UI_optc2w 0.020 [UIbar 1]
uialign* -1
]
]
UI_ratio4:3 = [
"640 480"
"800 600"
"1024 768"
"1152 864"
"1280 960"
"1400 1050"
"1600 1200"
"1920 1440"
"2560 1920"
]
UI_ratio5:4 = [
"800 640"
"960 768"
"1280 1024"
"1440 1152"
"1600 1280"
"1920 1536"
"2560 2048"
]
UI_ratio16:9 = [
"800 450"
"1024 600"
"1280 720"
"1366 768"
"1600 900"
"1920 1080"
"2048 1152"
"2560 1440"
]
UI_ratio16:10 = [
"768 480"
"1024 640"
"1280 800"
"1440 900"
"1680 1050"
"1920 1200"
"2560 1600"
]
opt_ratios = [4:3 5:4 16:9 16:10]
opt_ratios_assoc = (concat "custom" "custom" (looplistconcat ratio $opt_ratios [concat $ratio $ratio]))
UI_findratio = [
looplist ratio $opt_ratios [
looplist res $[UI_ratio@ratio] [
if (=s $res $UI_resolution) [UI_aspectratio = $ratio]
]
]
]
UImenu "options" [
hidechanges 1
uihlist 0 [
UIvtab 0.2 (*f 0.048 6) UI_opttabs [
0 "Game" []
1 "Edit" []
2 "Graphics" []
3 "Display" []
4 "Resolution" []
5 "Audio" []
//* "Console" []
] 1
uialign- 0 -1
UIbar 0 1
uifill 0.02
uiscroll 0.67 0.6 [
uifill 0.67 0.6 [
uialign 0 -1
uitable 0 0.005 [
uialign -1 -1
case $UI_opttabs 0 [//Game//////////////////////////////////////////////////////////
UI_optbar//----------------------------------------------------------------------
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "FOV" 0.6]
uihlist 0 [
UIhslider fov 10 150 5 0.3 $UI_optrowh [uitext $fov 0.6]
uifield fov 3 [] 0.65 style_generic_focus
]
uialign* -1 0
]
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Sensitivity" 0.6]
uihlist 0 [
UIhslider sensitivity 0.1 40.0 0.1 0.3 $UI_optrowh [uitext $sensitivity 0.6]
uifield sensitivity 3 [] 0.65 style_generic_focus
]
uialign* -1 0
]
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Zoom FOV" 0.6]
uihlist 0 [
UIhslider zoomfov 10 90 1 0.3 $UI_optrowh [uitext $zoomfov 0.6]
uifield zoomfov 3 [] 0.65 style_generic_focus
]
uialign* -1 0
]
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Zoom Sensitivity" 0.6]
uihlist 0 [
UIhslider zoomsens 0.1 20.0 0.1 0.3 $UI_optrowh [uitext $zoomsens 0.6]
uifield zoomsens 3 [] 0.65 style_generic_focus
]
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $zoomtoggle 0.016
uitext "Zoom Toggle" 0.6
] $UI_optc1wB $UI_optrowh [zoomtoggle (! $zoomtoggle)] -1
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $invmouse 0.016
uitext "Invert Mouse" 0.6
] $UI_optc1wB $UI_optrowh [invmouse (! $invmouse)] -1
uialign* -1 0
]
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "UI Sensitivity" 0.6]
uihlist 0 [
UIhslider uisensitivity 0.1 4.0 0.1 0.3 0.032 [uitext $uisensitivity 0.6]
uifield uisensitivity 3 [] 0.65 style_generic_focus
]
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
uitablerow [
UIbutton "hold2" [
UIcheckbox $showfps 0.016
uitext "Show FPS" 0.6
] $UI_optc1wB $UI_optrowh [showfps (! $showfps)] -1
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $wallclock 0.016
uitext "Show Clock" 0.6
] $UI_optc1wB $UI_optrowh [wallclock (! $wallclock)] -1
uialign* -1 0
uihlist 0 [
UIbutton "hold2" [
UIcheckbox $wallclock24 0.016
uitext (concatword (? (! $wallclock) "^f4") "24 Hour") 0.6
] 0.178 $UI_optrowh [wallclock24 (! $wallclock24)] -1
UIbutton "hold2" [
UIcheckbox $wallclocksecs 0.016
uitext (concatword (? (! $wallclock) "^f4") "Seconds") 0.6
] 0.178 $UI_optrowh [wallclocksecs (! $wallclocksecs)] -1
]
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $hudgun 0.016
uitext "Show Weapon" 0.6
] $UI_optc1wB $UI_optrowh [hudgun (! $hudgun)] -1
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $damagescreen 0.016
uitext "Bloody Screen" 0.6
] $UI_optc1wB $UI_optrowh [damagescreen (! $damagescreen)] -1
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $blood 0.016
uitext "Blood" 0.6
] $UI_optc1wB $UI_optrowh [blood (! $blood)] -1
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
uitablerow [
UIbutton "hold2" [
UIcheckbox (! $hidedead) 0.016
uitext "Show Dead Players" 0.6
] $UI_optc1wB $UI_optrowh [hidedead (! $hidedead)] -1
UIhslider ragdollmillis 0 300000 5000 0.3 $UI_optrowh [uitext (concatword (? $hidedead "^f4") (div $ragdollmillis 1000)) 0.6]
uialign* -1 0
]
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext (concatword (? $hidedead "^f4") "Ragdoll Velocity") 0.6]
UIhslider deadpush 1 20 1 0.3 $UI_optrowh [uitext (concatword (? $hidedead "^f4") $deadpush) 0.6]
uialign* -1 0
]
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Fullbright Models" 0.6]
uihlist 0 [
UIlistslider fullbrightmodels = [0 "^f4off" 60 "^f1subtle" 100 "^f0bright" 150 "^f2overbright" 200 "^f3max"] 0.3 $UI_optrowh
uifield fullbrightmodels 3 [] 0.65 style_generic_focus
]
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Radar" 0.6]
uihlist 0 [
UIbutton "hold2" [
UIcheckbox $radarteammates 0.016
uitext "Teammates" 0.6
] 0.178 $UI_optrowh [radarteammates (! $radarteammates)] -1
UIbutton "hold2" [
UIcheckbox $showminimap 0.016
uitext "Mini-Map" 0.6
] 0.178 $UI_optrowh [showminimap (! $showminimap)] -1
]
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Scoreboard" 0.6]
uivlist 0 [
uihlist 0 [
UIbutton "hold2" [
UIcheckbox $showkills 0.016
uitext "Kills" 0.6
] 0.178 $UI_optrowh [showkills (! $showkills)] -1
UIbutton "hold2" [
UIcheckbox $showdeaths 0.016
uitext "Deaths" 0.6
] 0.178 $UI_optrowh [showdeaths (! $showdeaths)] -1
]
uihlist 0 [
UIbutton "hold2" [
UIcheckbox $showscore 0.016
uitext "Score" 0.6
] 0.178 $UI_optrowh [showscore (! $showscore)] -1
uifill 0.178
]
uihlist 0 [
UIbutton "hold2" [
UIcheckbox $showping 0.016
uitext "Ping" 0.6
] 0.178 $UI_optrowh [showping (! $showping)] -1
UIbutton "hold2" [
UIcheckbox $showclientnum 0.016
uitext "Client#" 0.6
] 0.178 $UI_optrowh [showclientnum (! $showclientnum)] -1
]
uihlist 0 [
UIbutton "hold2" [
UIcheckbox $showip 0.016
uitext "IP:Port" 0.6
] 0.178 $UI_optrowh [showip (! $showip)] -1
UIbutton "hold2" [
UIcheckbox $showspectators 0.016
uitext "Spectators" 0.6
] 0.178 $UI_optrowh [showspectators (! $showspectators)] -1
]
uihlist 0 [
UIbutton "hold2" [
UIcheckbox $sbtransparent 0.016
uitext "Transparent" 0.6
] 0.178 $UI_optrowh [sbtransparent (! $sbtransparent)] -1
uifill 0.178
]
uialign* -1 -1
]
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
] 1 [//Edit/////////////////////////////////////////////////////////////////////////
UI_optbar//----------------------------------------------------------------------
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Shift Floatspeed" 0.6]
uihlist 0 [
UIhslider editfloatspeed 10 10000 10 0.3 $UI_optrowh [uitext $editfloatspeed 0.6]
uifield editfloatspeed 4 [] 0.65 style_generic_focus
]
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
] 2 [//Graphics/////////////////////////////////////////////////////////////////////
UI_optbar//----------------------------------------------------------------------
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Shadow Resolution" 0.6]
UIlistslider smsize = [11 "^f1low" 12 "^f0medium" 13 "^f2high"] 0.3 $UI_optrowh
uialign* -1 0
]
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Shadow Filtering" 0.6]
UIlistslider smfilter = [0 "^f1low" 1 "^f0medium" 2 "^f2high" 3 "^f3ultra"] 0.3 $UI_optrowh
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $gi 0.016
uitext "Global Illumination" 0.6
] $UI_optc1wB $UI_optrowh [gi (! $gi)] -1
UIlistslider rhtaps = [
12 @(concatword (? (! $gi) "^f4" "^f1") "low")
20 @(concatword (? (! $gi) "^f4" "^f0") "medium")
32 @(concatword (? (! $gi) "^f4" "^f2") "high")
] 0.3 $UI_optrowh
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $ao 0.016
uitext "SSAO" 0.6
] $UI_optc1wB $UI_optrowh [ao (! $ao)] -1
UIlistslider aotaps = [
5 @(concatword (? (! $ao) "^f4" "^f1") "low")
8 @(concatword (? (! $ao) "^f4" "^f0") "medium")
12 @(concatword (? (! $ao) "^f4" "^f2") "high")
] 0.3 $UI_optrowh [aobilateral (? (>= $aotaps 8) 4 3)]
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $volumetric 0.016
uitext "Volumetric Lighting" 0.6
] $UI_optc1wB $UI_optrowh [volumetric (! $volumetric)] -1
UIlistslider volsteps = [
12 @(concatword (? (! $volumetric) "^f4" "^f1") "low")
16 @(concatword (? (! $volumetric) "^f4" "^f0") "medium")
24 @(concatword (? (! $volumetric) "^f4" "^f2") "high")
] 0.3 $UI_optrowh [
volbilateral (? (>= $volsteps 16) 2 1)
]
uialign* -1 0
]
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Water" 0.6]
uivlist 0 [
uihlist 0 [
UIbutton "hold2" [
UIcheckbox $waterreflect 0.016
uitext "reflection" 0.6
] 0.178 $UI_optrowh [waterreflect (! $waterreflect)] -1
UIbutton "hold2" [
UIcheckbox $caustics 0.016
uitext "caustics" 0.6
] 0.178 $UI_optrowh [caustics (! $caustics)] -1
]
UIbutton "hold2" [
UIcheckbox $vertwater 0.016
uitext "animation" 0.6
] 0.178 $UI_optrowh [vertwater (! $vertwater)] -1
uialign* -1 -1
]
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $softparticles 0.016
uitext "Soft Particles" 0.6
] $UI_optc1wB $UI_optrowh [softparticles (! $softparticles)] -1
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $stains 0.016
uitext "Stains" 0.6
] $UI_optc1wB $UI_optrowh [stains (! $stains)] -1
uihlist 0 [
UIlistslider stainfade = [
2 @(concatword (? (! $stains) "^f4" "^f1") "instant-fade")
15 @(concatword (? (! $stains) "^f4" "^f0") "quick-fade")
30 @(concatword (? (! $stains) "^f4" "^f2") "moderate-fade")
60 @(concatword (? (! $stains) "^f4" "^f3") "slow-fade")
] 0.3 $UI_optrowh [
maxstaintris (? (> $stainfade 15) 8192 2048)
]
uifield stainfade 4 [
maxstaintris (? (> $stainfade 15) 8192 2048)
] 0.65 style_generic_focus
]
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $grass 0.016
uitext "3D Grass" 0.6
] $UI_optc1wB $UI_optrowh [grass (! $grass)] -1
uihlist 0 [
UIlistslider grassdist = [
128 @(concatword (? (! $grass) "^f4" "^f1") "quick-fade")
256 @(concatword (? (! $grass) "^f4" "^f0") "moderate-fade")
512 @(concatword (? (! $grass) "^f4" "^f2") "slow-fade")
1024 @(concatword (? (! $grass) "^f4" "^f3") "slower-fade")
] 0.3 $UI_optrowh
uifield grassdist 4 [] 0.65 style_generic_focus
]
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
] 3 [//Display//////////////////////////////////////////////////////////////////////
UI_optbar//----------------------------------------------------------------------
uitablerow [
UIbutton "hold2" [
UIcheckbox $fullscreen 0.016
uitext "Fullscreen" 0.6
] $UI_optc1wB $UI_optrowh [fullscreen (! $fullscreen)] -1
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Anisotropic Filtering" 0.6]
UIlistslider aniso = [0 "^f4off" 2 "^f12x" 4 "^f04x" 8 "^f28x" 16 "^f316x"] 0.3 $UI_optrowh
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
uitablerow [
UIbutton "hold2" [
UIcheckbox $smaa 0.016
uitext "Morphological AA" 0.6
] $UI_optc1wB $UI_optrowh [smaa (! $smaa)] -1
UIlistslider smaaquality = [
0 @(concatword (? (! $smaa) "^f4" "^f1") "low")
1 @(concatword (? (! $smaa) "^f4" "^f0") "medium")
2 @(concatword (? (! $smaa) "^f4" "^f2") "high")
3 @(concatword (? (! $smaa) "^f4" "^f3") "ultra")
] 0.3 $UI_optrowh [smaacoloredge (>= $smaaquality 3)]
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $tqaa 0.016
uitext "Temporal AA" 0.6
] $UI_optc1wB $UI_optrowh [tqaa (! $tqaa)] -1
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $fxaa 0.016
uitext "FXAA" 0.6
] $UI_optc1wB $UI_optrowh [fxaa (! $fxaa)] -1
UIlistslider fxaaquality = [
0 @(concatword (? (! $fxaa) "^f4" "^f1") "low")
1 @(concatword (? (! $fxaa) "^f4" "^f0") "medium")
2 @(concatword (? (! $fxaa) "^f4" "^f2") "high")
3 @(concatword (? (! $fxaa) "^f4" "^f3") "ultra")
] 0.3 $UI_optrowh
uialign* -1 0
]
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Multisample AA" 0.6]
UIlistslider msaa = [0 "^f4off" 2 "^f12x" 4 "^f04x" 8 "^f28x" 16 "^f316x"] 0.3 $UI_optrowh
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Gamma" 0.6]
uihlist 0 [
UIhslider gamma 30 300 5 0.3 $UI_optrowh [uitext $gamma 0.6]
uifield gamma 3 [] 0.65 style_generic_focus
]
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox $vsync 0.016
uitext "V-sync" 0.6
] $UI_optc1wB $UI_optrowh [vsync (! $vsync)] -1
UIbutton "hold2" [
UIcheckbox $vsynctear 0.016
uitext (concatword (? (! $vsync) "^f4") "Tear") 0.6
] 0.15 $UI_optrowh [vsynctear (! $vsynctear)] -1
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
] 4 [//Resolution///////////////////////////////////////////////////////////////////
UI_optbar//----------------------------------------------------------------------
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Aspect Ratio" 0.6]
UIlistslider UI_aspectratio =s $opt_ratios_assoc 0.3 $UI_optrowh [
if (=s $UI_aspectratio "custom") [] [
UI_resolution = (at $[UI_ratio@UI_aspectratio] 1)
screenw (at $UI_resolution 0)
screenh (at $UI_resolution 1)
]
]
uialign* -1 0
]
uitablerow [
UIbutton "hold2" [
UIcheckbox (!=s $UI_aspectratio "custom") 0.016
uitext "Preset Resolution" 0.6
] $UI_optc1wB $UI_optrowh [
if (=s $UI_aspectratio "custom") [
UI_findratio
if (=s $UI_aspectratio "custom") [
UI_aspectratio = "16:10"
UI_resolution = (at $[UI_ratio@UI_aspectratio] 1)
screenw (at $UI_resolution 0)
screenh (at $UI_resolution 1)
]
] [
UI_aspectratio = "custom"
]
] -1
if (=s $UI_aspectratio "custom") [
uihlist 0.009 [
uifield screenw 5 [] 0.65 style_generic_focus
uitext "x" 0.6
uifield screenh 5 [] 0.65 style_generic_focus
UIbutton "" [uitext "Native" 0.6] 0.1 $UI_optrowh [
UI_resolution = (concat $desktopw $desktoph)
UI_findratio
screenw (at $UI_resolution 0)
screenh (at $UI_resolution 1)
]
]
] [
UIlistslider UI_resolution = (
looplistconcat i $[UI_ratio@UI_aspectratio] [
result (concat (escape $i) (strreplace $i " " "x"))
]
) 0.3 $UI_optrowh [
screenw (at $UI_resolution 0)
screenh (at $UI_resolution 1)
]
]
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext "Upscaling" 0.6]
UIlistslider gscalecubic = [0 "^f1low" 1 "^f0high"] 0.3 $UI_optrowh
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
] 5 [//Audio////////////////////////////////////////////////////////////////////////
UI_optbar//----------------------------------------------------------------------
uitablerow [
UIbutton "hold2" [
UIcheckbox $sound 0.016
uitext "Enable Audio" 0.6
] $UI_optc1wB $UI_optrowh [sound (! $sound)] -1
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext (concatword (? (! $sound) "^f4") "Sound Volume") 0.6]
uihlist 0 [
UIhslider soundvol 0 255 5 0.3 $UI_optrowh [uitext $soundvol 0.6]
uifield soundvol 3 [] 0.65 style_generic_focus
]
uialign* -1 0
]
uitablerow [
uihlist 0.01 [uifill $UI_optc1wA ; uitext (concatword (? (! $sound) "^f4") "Music Volume") 0.6]
uihlist 0 [
UIhslider musicvol 0 255 5 0.3 $UI_optrowh [uitext $musicvol 0.6]
uifield musicvol 3 [] 0.65 style_generic_focus
]
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
uitablerow [
UIbutton "hold2" [
UIcheckbox $hitsound 0.016
uitext (concatword (? (! $sound) "^f4") "Hit Confirmation") 0.6
] $UI_optc1wB $UI_optrowh [hitsound (! $hitsound)] -1
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
uitablerow [
UIbutton "hold2" [
UIcheckbox $mumble 0.016
uitext "Mumble Positional Audio" 0.6
] $UI_optc1wB $UI_optrowh [mumble (! $mumble)] -1
uialign* -1 0
]
UI_optbar//----------------------------------------------------------------------
]
]
]
]
UIvscroll 0.02 0.6 1.421 0.5
]
] [
UI_aspectratio = "custom"
UI_resolution = (concat $screenw $screenh)
UI_findratio
] [if (pendingchanges) [showui "changes"]] [] "Options"

View File

@ -0,0 +1,222 @@
///////////////////////////////////////////////////////////////////////////////
// Scoreboard //
///////////////////////////////////////////////////////////////////////////////
newui "scoreboard" [
if $mainmenu [hideui "scoreboard"]
uiallowinput 0
refreshscoreboard
uicolor (? $sbtransparent $c_menu_a $c_menu) 0 0 [
uivlist 0 [
UI_sbheader
uifill 0 0.005
if (> $getmode 2) UI_playertableteam UI_playertablesolo
UI_spectatorlist
]
]
] [if $mainmenu [hideui "scoreboard"]]
///////////////////////////////////////////////////////////////////////////////
UI_sbwsolo = 0.68
UI_sbwteam = 1.18
UI_sbheader = [
uifill 0 0.005
uifill (? (> $getmode 2) $UI_sbwteam $UI_sbwsolo) 0.05 [
uifill (-f (? (> $getmode 2) $UI_sbwteam $UI_sbwsolo) (? (= $showip 1) 0.18 0)) 0 [
uialign -1
uiclip (-f (? (> $getmode 2) $UI_sbwteam $UI_sbwsolo) (? (= $showip 1) 0.18 0)) 0 [
uialign -1
uispace 0.01 0 [
uivlist 0 [
if $scoreboardservinfo [
uitext $scoreboardservinfo 0.65
] [
uitext "^f4Tesseract" 0.65
]
uihlist 0.015 [
uifill
uihlist 0.003 [
uitext "^fs[" 0.52
uitext (concatword (at ["^f0" "^f0" "^f2" "^f3"] $getmastermode) (getmastermodename $getmastermode)) 0.52
uitext "^fS]" 0.52
]
UItriangle 0x606060 0.01 0.01 270
uitext (getmodeprettyname $getmode) 0.52
UItriangle 0x606060 0.01 0.01 270
uitext $scoreboardmap 0.52
if (m_timed $getmode) [
UItriangle 0x606060 0.01 0.01 270
uitext (concatword (? (|| $intermission $paused) "^f3" "^f8") $scoreboardtime) 0.52
]
]
uialign* -1
]
]
]
]
if $scoreboardmultiplayer [
if $showip [
uifill 0.18 0 [
uialign 1
UIbar 0 1; uialign- -1
uiclip 0.18 0 [
uialign 1
uispace 0.01 0 [
uivlist 0.004 [
uicolortext $connectedip 0xA0A0A0 0.52
uicolortext $connectedport 0xA0A0A0 0.52
uialign* 1
]
]
uialign- 1
]
]
]
]
]
]
//-------------------------------------------------------------------------------------------------
UI_cw_s = 0.042
UI_cw_k = 0.054
UI_cw_d = 0.054
UI_cw_pj = 0.050
UI_cw_p = 0.050
UI_cw_cn = 0.040
UI_cw_n = [-f (? (> $getmode 2) (*f $UI_sbwteam 0.5) $UI_sbwsolo) (? (> $getmode 2) (? $showscore $UI_cw_s)) (? $showkills $UI_cw_k) (? $showdeaths $UI_cw_d) (? $scoreboardmultiplayer (? $showpj $UI_cw_pj)) (? $scoreboardmultiplayer (? $showping $UI_cw_p)) (? $scoreboardmultiplayer (? $showclientnum $UI_cw_cn)) 0.03]
// ^ blarg
UI_playertablesolo = [
uifill 0 0 [
uitable 0 0 [
uitableheader [
uifill 0.015
uifill (UI_cw_n) 0.022
if $showkills [uifill $UI_cw_k 0.022 [uicolortext "K" 0xBBCC8B 0.45 ; uialign- 1 1]]
if $showdeaths [uifill $UI_cw_d 0.022 [uicolortext "D" 0xE56767 0.45 ; uialign- 1 1]]
if $scoreboardmultiplayer [
if $showpj [uifill $UI_cw_pj 0.022 [uicolortext "PJ" 0x77A1D9 0.45 ; uialign- 1 1]]
if $showping [uifill $UI_cw_p 0.022 [uicolortext "P" 0x77A1D9 0.45 ; uialign- 1 1]]
if $showclientnum [uifill $UI_cw_cn 0.022 [uicolortext "#" 0xA0A0A0 0.45 ; uialign- 1 1]]
]
uifill 0.015
] [uicolor 0x88161616 0 0 [uiclamp 1 1 1 1]]
UI_sbtc = 0
loopscoreboard cn 0 [
UI_sbtc = (! $UI_sbtc)
uitablerow [
uifill 0.015
uifill (UI_cw_n) 0.026 [uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57 ; uialign- -1]
if $showkills [uifill $UI_cw_k 0.026 [uicolortext (getclientfrags $cn) 0xBBCC8B 0.52 ; uialign- 1]]
if $showdeaths [uifill $UI_cw_d 0.026 [uicolortext (getclientdeaths $cn) 0xE56767 0.52 ; uialign- 1]]
if $scoreboardmultiplayer [
if $showpj [uifill $UI_cw_pj 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardpj $cn)) 0x77A1D9 0.52 ; uialign- 1]]
if $showping [uifill $UI_cw_p 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardping $cn)) 0x77A1D9 0.52 ; uialign- 1]]
if $showclientnum [uifill $UI_cw_cn 0.026 [uicolortext (? (isai $cn) "^f4-" $cn) 0xA0A0A0 0.52 ; uialign- 1]]
]
uifill 0.015
] [
uicolor (? $UI_sbtc 0x99323232 0x99262626) 0 0 [uiclamp 1 1 1 1]
pushif highlight (scoreboardhighlight $cn) [uioutline 0xA0A0A0 (-f $UI_sbwsolo 0.002) 0.024]
]
]
]
]
]
UI_playertableteam = [
uifill 0 0 [
uihlist 0 [
uitable 0 0 [
uialign 0 -1
uitableheader [
uifill 0.015
if $scoreboardmultiplayer [
if $showclientnum [uifill $UI_cw_cn 0.042 [uicolortext "#" 0xA0A0A0 0.45 ; uialign- -1 1]]
if $showping [uifill $UI_cw_p 0.042 [uicolortext "P" 0x77A1D9 0.45 ; uialign- -1 1]]
if $showpj [uifill $UI_cw_pj 0.042 [uicolortext "PJ" 0x77A1D9 0.45 ; uialign- -1 1]]
]
if $showdeaths [uifill $UI_cw_d 0.042 [uicolortext "D" 0xE56767 0.45 ; uialign- -1 1]]
if $showkills [uifill $UI_cw_k 0.042 [uicolortext "K" 0xBBCC8B 0.45 ; uialign- -1 1]]
if $showscore [uifill $UI_cw_s 0.042 [uicolortext "Score" 0x62B370 0.45 ; uialign- -1 1]]
uifill (UI_cw_n) 0.042 [uicolortext (getteamscore 1) 0x4060D0 1 ; uialign- 1]
uifill 0.015
] [uicolor 0x99202860 0 0 [uiclamp 1 1 1 1]]
UI_sbtc = 0
loopscoreboard cn 1 [
UI_sbtc = (! $UI_sbtc)
uitablerow [
uifill 0.015
if $scoreboardmultiplayer [
if $showclientnum [uifill $UI_cw_cn 0.026 [uicolortext (? (isai $cn) "^f4-" $cn) 0xA0A0A0 0.52 ; uialign- -1]]
if $showping [uifill $UI_cw_p 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardping $cn)) 0x77A1D9 0.52 ; uialign- -1]]
if $showpj [uifill $UI_cw_pj 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardpj $cn)) 0x77A1D9 0.52 ; uialign- -1]]
]
if $showdeaths [uifill $UI_cw_d 0.026 [uicolortext (getclientdeaths $cn) 0xE56767 0.52 ; uialign- -1]]
if $showkills [uifill $UI_cw_k 0.026 [uicolortext (getclientfrags $cn) 0xBBCC8B 0.52 ; uialign- -1]]
if $showscore [uifill $UI_cw_s 0.026 [uicolortext (getclientflags $cn) 0x62B370 0.52 ; uialign- -1]]
uifill (UI_cw_n) 0.026 [uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57 ; uialign- 1]
uifill 0.015
] [
uicolor (? $UI_sbtc 0x99333b40 0x99262b33) 0 0 [uiclamp 1 1 1 1]
pushif highlight (scoreboardhighlight $cn) [uioutline 0xA0A0A0 (-f (*f $UI_sbwteam 0.5) 0.002) 0.024]
]
]
]
uitable 0 0 [
uialign 0 -1
uitableheader [
uifill 0.015
uifill (UI_cw_n) 0.042 [uicolortext (getteamscore 2) 0xD04040 1 ; uialign- -1]
if $showscore [uifill $UI_cw_s 0.042 [uicolortext "Score" 0x62B370 0.45 ; uialign- 1 1]]
if $showkills [uifill $UI_cw_k 0.042 [uicolortext "K" 0xBBCC8B 0.45 ; uialign- 1 1]]
if $showdeaths [uifill $UI_cw_d 0.042 [uicolortext "D" 0xE56767 0.45 ; uialign- 1 1]]
if $scoreboardmultiplayer [
if $showpj [uifill $UI_cw_pj 0.042 [uicolortext "PJ" 0x77A1D9 0.45 ; uialign- 1 1]]
if $showping [uifill $UI_cw_p 0.042 [uicolortext "P" 0x77A1D9 0.45 ; uialign- 1 1]]
if $showclientnum [uifill $UI_cw_cn 0.042 [uicolortext "#" 0xA0A0A0 0.45 ; uialign- 1 1]]
]
uifill 0.015
] [uicolor 0x99602020 0 0 [uiclamp 1 1 1 1]]
UI_sbtc = 0
loopscoreboard cn 2 [
UI_sbtc = (! $UI_sbtc)
uitablerow [
uifill 0.015
uifill (UI_cw_n) 0.026 [uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57 ; uialign- -1]
if $showscore [uifill $UI_cw_s 0.026 [uicolortext (getclientflags $cn) 0x62B370 0.52 ; uialign- 1]]
if $showkills [uifill $UI_cw_k 0.026 [uicolortext (getclientfrags $cn) 0xBBCC8B 0.52 ; uialign- 1]]
if $showdeaths [uifill $UI_cw_d 0.026 [uicolortext (getclientdeaths $cn) 0xE56767 0.52 ; uialign- 1]]
if $scoreboardmultiplayer [
if $showpj [uifill $UI_cw_pj 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardpj $cn)) 0x77A1D9 0.52 ; uialign- 1]]
if $showping [uifill $UI_cw_p 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardping $cn)) 0x77A1D9 0.52 ; uialign- 1]]
if $showclientnum [uifill $UI_cw_cn 0.026 [uicolortext (? (isai $cn) "^f4-" $cn) 0xA0A0A0 0.52 ; uialign- 1]]
]
uifill 0.015
] [
uicolor (? $UI_sbtc 0x99403333 0x99332626) 0 0 [uiclamp 1 1 1 1]
pushif highlight (scoreboardhighlight $cn) [uioutline 0xA0A0A0 (-f (*f $UI_sbwteam 0.5) 0.002) 0.024]
]
]
]
]
]
]
//-------------------------------------------------------------------------------------------------
UI_spectatorlist = [
uicolor 0x88161616 0 0.022 [
uiclamp 1 1 1 1
if $showspectators [
uigrid (? (> $getmode 2) 3 2) 0 0 [
loopscoreboard cn -1 [
uispace 0.01 0.01 [
pushif sbhigh (scoreboardhighlight $cn) [
uioutline 0xA0A0A0 ; uiclamp- 1 1 1 1
]
uihlist 0.01 [
uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57
if $scoreboardmultiplayer [if $showclientnum [uitext $cn 0.57]]
]
]
]
]
]
]
]

View File

@ -0,0 +1,203 @@
///////////////////////////////////////////////////////////////////////////////
// Server Browser //
///////////////////////////////////////////////////////////////////////////////
_sb_mm = 0
_sb_mode = 0
_sb_ping = 9999
_sb_players = -1
_sb_sort = 1
_sb_showwait = 1
// quickfilterlist ["NAME" [children] [action] ..] <COLUMNS> <X PADDING> <Y PADDING> <BUTTON WIDTH> <BUTTON HEIGHT>
quickfilterlist = [
uigrid $arg2 $arg3 $arg4 [
looplist3 n c a $arg1 [
if (!=s $n "") [
UIbutton "hold2" [
c ; uitext $n 0.6
] $arg5 $arg6 $a -1
] [uifill $arg5 $arg6]
]
]
]
UImenu "sb_filters" [
uigrid 2 0.01 0.02 [
uivlist 0.01 [
UItitle [uitext "Mastermode" 0.7] 0.28 0.03
quickfilterlist [
"Open" [UIcheckbox [& $_sb_mm 1] 0.016] [_sb_mm = (^ $_sb_mm 1)]
"Veto" [UIcheckbox [& $_sb_mm 2] 0.016] [_sb_mm = (^ $_sb_mm 2)]
"Locked" [UIcheckbox [& $_sb_mm 4] 0.016] [_sb_mm = (^ $_sb_mm 4)]
"Private" [UIcheckbox [& $_sb_mm 8] 0.016] [_sb_mm = (^ $_sb_mm 8)]
"Password" [UIcheckbox [& $_sb_mm 16] 0.016] [_sb_mm = (^ $_sb_mm 16)]
"Disable" [UIradio [= $_sb_mm 0] 0.016] [_sb_mm = 0]
] 2 0 0 0.14 0.032
]
uivlist 0.01 [
UItitle [uitext "Ping" 0.7] 0.28 0.03
quickfilterlist [
"50+" [UIradio [= $_sb_ping 55] 0.016] [_sb_ping = 55]
"100+" [UIradio [= $_sb_ping 110] 0.016] [_sb_ping = 110]
"150+" [UIradio [= $_sb_ping 165] 0.016] [_sb_ping = 165]
"250+" [UIradio [= $_sb_ping 270] 0.016] [_sb_ping = 270]
"500+" [UIradio [= $_sb_ping 525] 0.016] [_sb_ping = 525]
"Disable" [UIradio [= $_sb_ping 9999] 0.016] [_sb_ping = 9999]
] 2 0 0 0.14 0.032
]
uivlist 0.01 [
UItitle [uitext "Gamemode" 0.7] 0.28 0.03
quickfilterlist [
"rDM" [UIcheckbox [& $_sb_mode 2] 0.016] [_sb_mode = (^ $_sb_mode 2)]
"pDM" [UIcheckbox [& $_sb_mode 4] 0.016] [_sb_mode = (^ $_sb_mode 4)]
"rTDM" [UIcheckbox [& $_sb_mode 8] 0.016] [_sb_mode = (^ $_sb_mode 8)]
"pTDM" [UIcheckbox [& $_sb_mode 16] 0.016] [_sb_mode = (^ $_sb_mode 16)]
"rCTF" [UIcheckbox [& $_sb_mode 32] 0.016] [_sb_mode = (^ $_sb_mode 32)]
"pCTF" [UIcheckbox [& $_sb_mode 64] 0.016] [_sb_mode = (^ $_sb_mode 64)]
"Edit" [UIcheckbox [& $_sb_mode 1] 0.016] [_sb_mode = (^ $_sb_mode 1)]
"Disable" [UIradio [= $_sb_mode 0] 0.016] [_sb_mode = 0]
] 2 0 0 0.14 0.032
]
uivlist 0.01 [
UItitle [uitext "Players" 0.7] 0.28 0.03
quickfilterlist [
"Empty" [UIradio [= $_sb_players 0] 0.016] [_sb_players = 0]
"Full" [UIradio [= $_sb_players 1] 0.016] [_sb_players = 1]
"" "" ""
"Disable" [UIradio [= $_sb_players -1] 0.016] [_sb_players = -1]
] 2 0 0 0.14 0.032
]
]
] [] [] [] "Server Filters"
UImenu "server_browser" [
refreshservers
uivlist 0.01 [
uihlist 0 [
uiclamp 1 1
UIbutton "" [uitext "Update List" 0.6] 0.2 0.032 [updatefrommaster] 0 [uialign -1 0]
uihlist 0 [
UIbutton "" [
UIcheckbox $searchlan 0.016
uitext "Search LAN" 0.6
] 0.18 0.032 [searchlan (! $searchlan)] -1
UIbutton "" [
UIcheckbox $autoupdateservers 0.016
uitext "Auto-refresh" 0.6
] 0.18 0.032 [autoupdateservers (! $autoupdateservers)] -1
UIbutton "" [
UIcheckbox $autosortservers 0.016
uitext "Auto-sort" 0.6
] 0.18 0.032 [
_sb_sort = (! $_sb_sort)
autosortservers $_sb_sort
] -1
]
UIbutton "" [
UItriangle 0xCCCCCC 0.01 0.01 270
uitext "Filters" 0.6
] 0.2 0.032 [showui "sb_filters"] 0 [uialign 1 0]
]
uihlist 0.01 [
uialign 1 0
uiscroll 1.1 0.65 [
uitarget 1.07 0.65 [
if $_sb_sort [autosortservers (! (uihover?))]
uivlist 0.0035 [
uialign 0 -1
uiclamp 1 1
loop i $numservers [
if (servinfovalid $i) [
if (&& [
<= (servinfoping $i) $_sb_ping
] [
! (& (<< 1 (servinfomastermode $i)) $_sb_mm)
] [
! (& (<< 1 (servinfomode $i)) $_sb_mode)
] [
!= (servinfonumplayers $i) (* $_sb_players (servinfomaxplayers $i))
]) [
_servers_map = (servinfomap $i)
UIbuttonarea "" 0 0.065 [
uirelease [connectservinfo $i]
uispace 0.01 0 [
uiclamp 1 1
uihlist 0.01 [
uialign -1
uifill 0.09 0 [
uivlist 0.002 [
uihlist 0.006 [
uitext (servinfonumplayers $i) 0.8
uitext "/" 0.6
uitext (servinfomaxplayers $i) 0.6
]
uihlist 0.006 [
uitext (servinfoping $i) 0.6
uitext "ms" 0.55
]
]
]
uiimage "media/interface/cube.png" 0.06 0.06 [
uiimage (concatword "media/map/" $_servers_map ".png") 0.06 0.06
]
uifill 0.68 0 [
uiclip 0.68 0 [
uialign -1
uivlist 0.002 [
uispace 0.01 0 [uitext (servinfodesc $i) 0.65]
uialign- -1
uihlist 0.015 [
uialign -1
uifill 0.012
uihlist 0.005 [
uitext "^fs[" 0.6
uitext (servinfomastermodename $i) 0.6
uitext "^fS]" 0.6
]
UItriangle 0x404040 0.01 0.01 270
uitext (servinfomodename $i) 0.6
if (!=s $_servers_map "") [
UItriangle 0x404040 0.01 0.01 270
uitext $_servers_map 0.6
]
if (m_timed (servinfomode $i)) [
UItriangle 0x404040 0.01 0.01 270
uitext (concatword "^f8" (servinfotime $i)) 0.6
]
]
]
]
UIbar 0 1 ; uialign- 1
]
]
uihlist 0.005 [
uialign 1
uivlist 0.004 [
uicolortext (servinfoname $i) 0x808080 0.55
uicolortext (servinfoport $i) 0x808080 0.55
uialign* 1
]
if (&& [=s $connectedip (servinfoname $i)] [= $connectedport (servinfoport $i)]) [
UItriangle 0xCCCCCC 0.04 0.015 90
] [uifill 0.015 0]
]
]
]
]
] [
if $_sb_showwait [
// could offer customised messages one day
UIbutton "" [uitext (servinfodesc $i) 0.6] 0 0.065
]
]
]
uiclamp* 1 1
]
]
]
UIvscroll 0.02 0.65 1.3
]
]
] [initservers] [] [] "Server Browser"

153
config/ui/stats.cfg 100644
View File

@ -0,0 +1,153 @@
///////////////////////////////////////////////////////////////////////////////
// Personal Stats //
///////////////////////////////////////////////////////////////////////////////
stats = [showui player_stats]
UImenu "player_stats" [
uitable 0 0 [
uitablerow [
uifill 0.10 0
uifill 0.13 0 [uitext "^f4Total" 0.57]
uifill 0.13 0 [uitext "^f4rDM" 0.57]
uifill 0.13 0 [uitext "^f4rTDM" 0.57]
uifill 0.13 0 [uitext "^f4rCTF" 0.57]
uifill 0.13 0 [uitext "^f4pDM" 0.57]
uifill 0.13 0 [uitext "^f4pTDM" 0.57]
uifill 0.13 0 [uitext "^f4pCTF" 0.57]
uifill 0.13 0 [uitext "^f4EDIT" 0.57]
] [uicolor 0x99323232 0 0 [uiclamp 1 1 1 1]]
uitablerow [
uitext "^f4Score" 0.57 [uialign 1]
uicolortext $stat_x_total 0x62B370 0.57
uitext "^f4-" 0.57
uitext "^f4-" 0.57
uicolortext $stat_x_rctf 0x62B370 0.57
uitext "^f4-" 0.57
uitext "^f4-" 0.57
uicolortext $stat_x_pctf 0x62B370 0.57
uitext "^f4-" 0.57
] [uicolor 0x99262626 0 0 [uiclamp 1 1 1 1]]
uitablerow [
uitext "^f4Kill" 0.57 [uialign 1]
uicolortext $stat_k_total 0xBBCC8B 0.57
uicolortext $stat_k_rdm 0xBBCC8B 0.57
uicolortext $stat_k_rtdm 0xBBCC8B 0.57
uicolortext $stat_k_rctf 0xBBCC8B 0.57
uicolortext $stat_k_pdm 0xBBCC8B 0.57
uicolortext $stat_k_ptdm 0xBBCC8B 0.57
uicolortext $stat_k_pctf 0xBBCC8B 0.57
uitext "^f4-" 0.57
] [uicolor 0x99323232 0 0 [uiclamp 1 1 1 1]]
uitablerow [
uitext "^f4Death" 0.57 [uialign 1]
uicolortext $stat_d_total 0xE56767 0.57
uicolortext $stat_d_rdm 0xE56767 0.57
uicolortext $stat_d_rtdm 0xE56767 0.57
uicolortext $stat_d_rctf 0xE56767 0.57
uicolortext $stat_d_pdm 0xE56767 0.57
uicolortext $stat_d_ptdm 0xE56767 0.57
uicolortext $stat_d_pctf 0xE56767 0.57
uitext "^f4-" 0.57
] [uicolor 0x99262626 0 0 [uiclamp 1 1 1 1]]
uitablerow [
uitext "^f4Suicide" 0.57 [uialign 1]
uicolortext $stat_s_total 0xE56767 0.57
uicolortext $stat_s_rdm 0xE56767 0.57
uicolortext $stat_s_rtdm 0xE56767 0.57
uicolortext $stat_s_rctf 0xE56767 0.57
uicolortext $stat_s_pdm 0xE56767 0.57
uicolortext $stat_s_ptdm 0xE56767 0.57
uicolortext $stat_s_pctf 0xE56767 0.57
uitext "^f4-" 0.57
] [uicolor 0x99323232 0 0 [uiclamp 1 1 1 1]]
uitablerow [
uitext "^f4TeamKill" 0.57 [uialign 1]
uicolortext $stat_tk_total 0xE56767 0.57
uitext "^f4-" 0.57
uicolortext $stat_tk_rtdm 0xE56767 0.57
uicolortext $stat_tk_rctf 0xE56767 0.57
uitext "^f4-" 0.57
uicolortext $stat_tk_ptdm 0xE56767 0.57
uicolortext $stat_tk_pctf 0xE56767 0.57
uitext "^f4-" 0.57
] [uicolor 0x99262626 0 0 [uiclamp 1 1 1 1]]
uitablerow [
uitext "^f4KD Ratio" 0.57 [uialign 1] // (K-TK)/(D+S)
uicolortext $stat_r_avg 0xBBCC8B 0.57
uicolortext $stat_r_rdm 0xBBCC8B 0.57
uicolortext $stat_r_rtdm 0xBBCC8B 0.57
uicolortext $stat_r_rctf 0xBBCC8B 0.57
uicolortext $stat_r_pdm 0xBBCC8B 0.57
uicolortext $stat_r_ptdm 0xBBCC8B 0.57
uicolortext $stat_r_pctf 0xBBCC8B 0.57
uitext "^f4-" 0.57
] [uicolor 0x99323232 0 0 [uiclamp 1 1 1 1]]
uitablerow [
uitext "^f4Time" 0.57 [uialign 1]
uicolortext "HHHH:MM:SS" 0x77A1D9 0.57
uicolortext $stat_time_rdm 0x77A1D9 0.57
uicolortext $stat_time_rtdm 0x77A1D9 0.57
uicolortext $stat_time_rctf 0x77A1D9 0.57
uicolortext $stat_time_pdm 0x77A1D9 0.57
uicolortext $stat_time_ptdm 0x77A1D9 0.57
uicolortext $stat_time_pctf 0x77A1D9 0.57
uicolortext $stat_time_edit 0x77A1D9 0.57
] [uicolor 0x99262626 0 0 [uiclamp 1 1 1 1]]
]
] [] [] [] "Personal Statistics"
looplist s [
stat_x_rctf
stat_x_pctf
stat_k_rdm
stat_k_rtdm
stat_k_rctf
stat_k_pdm
stat_k_ptdm
stat_k_pctf
stat_d_rdm
stat_d_rtdm
stat_d_rctf
stat_d_pdm
stat_d_ptdm
stat_d_pctf
stat_s_rdm
stat_s_rtdm
stat_s_rctf
stat_s_pdm
stat_s_ptdm
stat_s_pctf
stat_tk_rtdm
stat_tk_rctf
stat_tk_ptdm
stat_tk_pctf
stat_time_edit
stat_time_rdm
stat_time_rtdm
stat_time_rctf
stat_time_pdm
stat_time_ptdm
stat_time_pctf
] [
$s = 0
]
stat_r_rdm = (divf $stat_k_rdm (+f $stat_d_rdm $stat_s_rdm ))
stat_r_rtdm = (divf (-f $stat_k_rtdm $stat_tk_rtdm) (+f $stat_d_rtdm $stat_s_rtdm))
stat_r_rctf = (divf (-f $stat_k_rctf $stat_tk_rctf) (+f $stat_d_rctf $stat_s_rctf))
stat_r_pdm = (divf $stat_k_pdm (+f $stat_d_pctf $stat_s_pdm ))
stat_r_ptdm = (divf (-f $stat_k_ptdm $stat_tk_ptdm) (+f $stat_d_ptdm $stat_s_ptdm))
stat_r_pctf = (divf (-f $stat_k_pctf $stat_tk_pctf) (+f $stat_d_pctf $stat_s_pctf))
stat_x_total = (+ $stat_x_rctf $stat_x_pctf)
stat_k_total = (+ $stat_k_rdm $stat_k_rtdm $stat_k_rctf $stat_k_pdm $stat_k_ptdm $stat_k_pctf)
stat_d_total = (+ $stat_d_rdm $stat_d_rtdm $stat_d_rctf $stat_d_pdm $stat_d_ptdm $stat_d_pctf)
stat_s_total = (+ $stat_s_rdm $stat_s_rtdm $stat_s_rctf $stat_s_pdm $stat_s_ptdm $stat_s_pctf)
stat_tk_total = (+ $stat_tk_rtdm $stat_tk_rctf $stat_tk_ptdm $stat_tk_pctf)
stat_r_avg = (divf (-f $stat_k_total $stat_tk_total) (+f $stat_d_total $stat_s_total))

177
config/ui/style.cfg 100644
View File

@ -0,0 +1,177 @@
// styles used by the elements of stdui.cfg for the game menus
textbright 90
UIwindow_padding = 0.010
UIbutton_padding = 0.008
// preset colors used in styles below
c_menu = 0x1D1D1D // window background
c_menu_a = 0xE61C1C1C // window transparent background
c_line = 0x2B2B2B // all-around line
c_line_a = 0xE6383838 // all-around transparent line
c_slider = 0x131313
c_main1 = 0x292929 // main title gradient top
c_main2 = 0x161616 // main title gradient bottom
c_boxmod = 0xE0E0E0 // box modulate
c_grdmod = 0xC0C0C0 // gradient modulate
c_fill = 0xF0E8E0 // white area
c_focus = 0xFF1008 // focus area
c_off = 0x484848 // checkbox/radio off
c_on1 = 0x48BACE // checkbox on
c_on2 = 0x48BACE // radio on
// generic styles used for combinations below
style_generic_default = [style_generic_box]
style_generic_none = []
style_generic_box = [
uimodcolor $c_boxmod
//uioutline $c_line
]
style_generic_focus = [
uioutline (uifocus? $c_focus $c_line)
uiclamp- 1 1 1 1
]
style_generic_gradient1 = [uimodvgradient $c_grdmod 0xFFFFFF]
style_generic_gradient2 = [uimodvgradient 0xFFFFFF $c_grdmod]
style_generic_gradient3 = [uimodhgradient $c_grdmod 0xFFFFFF]
style_generic_gradient4 = [uimodhgradient 0xFFFFFF $c_grdmod]
style_generic_linesh = [
uivlist $arg2 [
loop i $arg1 [uiline $c_line $arg3]
]
]
style_generic_linesv = [
uihlist $arg2 [
loop i $arg1 [uiline $c_line 0 $arg3]
]
]
// button specific styles below
style_button_default = [style_button_hold1]
style_button_none = []
style_button_hold1 = [// H
style_generic_default
uihold [style_generic_gradient1] [
uihover [
style_generic_gradient2
]
]
]
style_button_hold2 = [// H, HOVER
uihover [
style_generic_default
uihold [style_generic_gradient1] [
style_generic_gradient2
]
]
]
style_button_hold3 = [// H, ESC
style_generic_default
uihold [style_generic_gradient1] [
uieschold [style_generic_gradient1] [
uihover [style_generic_gradient2]
]
]
]
style_button_hold4 = [// H, HOVER, ESC
uihover [
style_generic_default
uihold [style_generic_gradient1] [
uieschold [style_generic_gradient1] [
style_generic_gradient2
]
]
]
]
style_button_hold5 = [// V
style_generic_default
uihold [style_generic_gradient3] [
uihover [style_generic_gradient4]
]
]
style_button_hold6 = [// V, HOVER
uihover [
style_generic_default
uihold [style_generic_gradient3] [
style_generic_gradient4
]
]
]
style_button_hold7 = [// V, ESC
style_generic_default
uihold [style_generic_gradient3] [
uieschold [style_generic_gradient3] [
uihover [style_generic_gradient4]
]
]
]
style_button_hold8 = [// V, HOVER, ESC
uihover [
style_generic_default
uihold [style_generic_gradient3] [
uieschold [style_generic_gradient3] [
style_generic_gradient4
]
]
]
]
// image button specific styles below
style_img_default = [style_img_hold1]
style_img_none = []
style_img_hold1 = [// HOVER
uihold [
uispace 0.003 0.003 [
uialign -1 1
UItriangle $c_on1 0.016 0.008 135
]
] [
uihover [
uispace 0.003 0.003 [
uialign -1 -1
UItriangle 0 0.016 0.008 45
]
]
]
]
style_img_hold2 = [// HOVER, ESC
uihold [
uispace 0.003 0.003 [
uialign -1 1
UItriangle $c_on1 0.016 0.008 135
]
]
uieschold [
uispace 0.003 0.003 [
uialign 1 1
UItriangle $c_on2 0.016 0.008 225
]
]
if (&& uihover? [! (|| uihold? uieschold?)]) [
uispace 0.003 0.003 [
uialign -1 -1
UItriangle 0 0.016 0.008 45
]
]
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 973 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Some files were not shown because too many files have changed in this diff Show More