From 10515f5f631427f54709053d6bcbe660ac270a6a Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 15 Apr 2020 18:39:17 +0200 Subject: [PATCH] initial import: tesseract r2280 --- .gitignore | 2 + README | 83 + bin_unix/readme.txt | 101 + config/blendbrush.cfg | 47 + config/default.cfg | 192 + config/default_map_models.cfg | 78 + config/default_map_settings.cfg | 181 + config/font.cfg | 3 + config/game.cfg | 38 + config/glsl.cfg | 24 + config/glsl/aa.cfg | 88 + config/glsl/ao.cfg | 285 + config/glsl/blur.cfg | 68 + config/glsl/decal.cfg | 290 + config/glsl/deferred.cfg | 688 +++ config/glsl/edit.cfg | 61 + config/glsl/fxaa.cfg | 375 ++ config/glsl/gi.cfg | 313 ++ config/glsl/grass.cfg | 60 + config/glsl/hud.cfg | 169 + config/glsl/material.cfg | 490 ++ config/glsl/misc.cfg | 180 + config/glsl/model.cfg | 374 ++ config/glsl/movie.cfg | 126 + config/glsl/particle.cfg | 176 + config/glsl/postfx.cfg | 183 + config/glsl/scale.cfg | 98 + config/glsl/shared.cfg | 178 + config/glsl/sky.cfg | 163 + config/glsl/smaa.cfg | 623 ++ config/glsl/stain.cfg | 75 + config/glsl/tonemap.cfg | 477 ++ config/glsl/ui.cfg | 68 + config/glsl/volumetric.cfg | 239 + config/glsl/world.cfg | 674 +++ config/heightmap.cfg | 140 + config/keymap.cfg | 133 + config/server-init.cfg | 82 + config/sound.cfg | 46 + config/stdedit.cfg | 241 + config/stdlib.cfg | 60 + config/ui.cfg | 577 ++ config/ui/edithud.cfg | 71 + config/ui/fkey.cfg | 1131 ++++ config/ui/lib.cfg | 328 ++ config/ui/options.cfg | 595 ++ config/ui/scoreboard.cfg | 222 + config/ui/serverbrowser.cfg | 203 + config/ui/stats.cfg | 153 + config/ui/style.cfg | 177 + media/blendbrush/circle_128_hard.png | Bin 0 -> 4088 bytes media/blendbrush/circle_128_soft.png | Bin 0 -> 3477 bytes media/blendbrush/circle_128_solid.png | Bin 0 -> 2364 bytes media/blendbrush/circle_16_hard.png | Bin 0 -> 1122 bytes media/blendbrush/circle_16_soft.png | Bin 0 -> 1091 bytes media/blendbrush/circle_16_solid.png | Bin 0 -> 1113 bytes media/blendbrush/circle_256_hard.png | Bin 0 -> 8825 bytes media/blendbrush/circle_256_soft.png | Bin 0 -> 7251 bytes media/blendbrush/circle_256_solid.png | Bin 0 -> 5296 bytes media/blendbrush/circle_32_hard.png | Bin 0 -> 703 bytes media/blendbrush/circle_32_soft.png | Bin 0 -> 1285 bytes media/blendbrush/circle_32_solid.png | Bin 0 -> 1238 bytes media/blendbrush/circle_64_hard.png | Bin 0 -> 1450 bytes media/blendbrush/circle_64_soft.png | Bin 0 -> 1814 bytes media/blendbrush/circle_64_solid.png | Bin 0 -> 1584 bytes media/blendbrush/circle_8_hard.png | Bin 0 -> 996 bytes media/blendbrush/circle_8_soft.png | Bin 0 -> 992 bytes media/blendbrush/circle_8_solid.png | Bin 0 -> 995 bytes media/blendbrush/dot_1_hard.png | Bin 0 -> 15728 bytes media/blendbrush/dot_1_soft.png | Bin 0 -> 15728 bytes media/blendbrush/dot_1_solid.png | Bin 0 -> 15729 bytes media/blendbrush/gradient_128.png | Bin 0 -> 137 bytes media/blendbrush/gradient_16.png | Bin 0 -> 103 bytes media/blendbrush/gradient_32.png | Bin 0 -> 120 bytes media/blendbrush/gradient_64.png | Bin 0 -> 129 bytes media/blendbrush/noise_1024_hard.png | Bin 0 -> 570609 bytes media/blendbrush/noise_1024_soft.png | Bin 0 -> 577022 bytes media/blendbrush/noise_128_hard.png | Bin 0 -> 9790 bytes media/blendbrush/noise_128_soft.png | Bin 0 -> 8890 bytes media/blendbrush/noise_256_hard.png | Bin 0 -> 48642 bytes media/blendbrush/noise_256_soft.png | Bin 0 -> 42879 bytes media/blendbrush/noise_512_hard.png | Bin 0 -> 129082 bytes media/blendbrush/noise_512_soft.png | Bin 0 -> 160726 bytes media/blendbrush/noise_64_hard.png | Bin 0 -> 3036 bytes media/blendbrush/noise_64_soft.png | Bin 0 -> 2992 bytes media/blendbrush/square_16_hard.png | Bin 0 -> 1082 bytes media/blendbrush/square_16_solid.png | Bin 0 -> 973 bytes media/blendbrush/square_32_hard.png | Bin 0 -> 1183 bytes media/blendbrush/square_32_solid.png | Bin 0 -> 981 bytes media/blendbrush/square_64_hard.png | Bin 0 -> 1207 bytes media/blendbrush/square_64_solid.png | Bin 0 -> 1006 bytes media/interface/background.png | Bin 0 -> 43478 bytes media/interface/crosshair/circle_dot.png | Bin 0 -> 225 bytes media/interface/crosshair/circle_dot_hit.png | Bin 0 -> 279 bytes media/interface/crosshair/cross_normal.png | Bin 0 -> 213 bytes .../interface/crosshair/cross_normal_hit.png | Bin 0 -> 348 bytes media/interface/crosshair/cross_whole.png | Bin 0 -> 175 bytes media/interface/crosshair/cross_whole_hit.png | Bin 0 -> 312 bytes media/interface/crosshair/default.png | Bin 0 -> 336 bytes media/interface/crosshair/default_hit.png | Bin 0 -> 252 bytes media/interface/crosshair/dot.png | Bin 0 -> 297 bytes media/interface/crosshair/dot_hit.png | Bin 0 -> 350 bytes media/interface/crosshair/dot_normal.png | Bin 0 -> 318 bytes media/interface/crosshair/dot_normal_hit.png | Bin 0 -> 382 bytes media/interface/crosshair/dot_whole.png | Bin 0 -> 243 bytes media/interface/crosshair/dot_whole_hit.png | Bin 0 -> 322 bytes media/interface/crosshair/dot_wide.png | Bin 0 -> 352 bytes media/interface/crosshair/dot_wide_hit.png | Bin 0 -> 412 bytes media/interface/crosshair/info.txt | 29 + media/interface/crosshair/o.png | Bin 0 -> 416 bytes media/interface/crosshair/o_dot.png | Bin 0 -> 428 bytes media/interface/crosshair/o_dot_hit.png | Bin 0 -> 422 bytes media/interface/crosshair/o_hit.png | Bin 0 -> 420 bytes media/interface/crosshair/o_x.png | Bin 0 -> 489 bytes media/interface/crosshair/o_x_hit.png | Bin 0 -> 430 bytes media/interface/crosshair/star.png | Bin 0 -> 321 bytes media/interface/crosshair/star_hit.png | Bin 0 -> 363 bytes media/interface/crosshair/teammate.png | Bin 0 -> 599 bytes media/interface/crosshair/wide.png | Bin 0 -> 345 bytes media/interface/crosshair/wide_hit.png | Bin 0 -> 402 bytes media/interface/crosshair/x.png | Bin 0 -> 339 bytes media/interface/crosshair/x_dot.png | Bin 0 -> 347 bytes media/interface/crosshair/x_dot_hit.png | Bin 0 -> 398 bytes media/interface/crosshair/x_hit.png | Bin 0 -> 407 bytes media/interface/cube.png | Bin 0 -> 262892 bytes media/interface/cube2badge.png | Bin 0 -> 10235 bytes media/interface/cursor.png | Bin 0 -> 16540 bytes media/interface/directory.png | Bin 0 -> 1150 bytes media/interface/font/default.cfg | 256 + media/interface/font/default.otf | Bin 0 -> 127448 bytes media/interface/font/default.ttf | Bin 0 -> 643852 bytes media/interface/font/default.txt | 101 + media/interface/font/default0.png | Bin 0 -> 81696 bytes media/interface/font/default_outline.cfg | 3 + media/interface/loading_bar.png | Bin 0 -> 16297 bytes media/interface/loading_frame.png | Bin 0 -> 16412 bytes media/interface/logo.png | Bin 0 -> 92600 bytes media/interface/logo_1024.png | Bin 0 -> 260540 bytes media/interface/radar/blip_blue.png | Bin 0 -> 917 bytes media/interface/radar/blip_blue_alive.png | Bin 0 -> 1445 bytes media/interface/radar/blip_blue_dead.png | Bin 0 -> 1518 bytes media/interface/radar/blip_blue_flag.png | Bin 0 -> 667 bytes media/interface/radar/blip_blue_skull.png | Bin 0 -> 1060 bytes media/interface/radar/blip_grey.png | Bin 0 -> 909 bytes media/interface/radar/blip_neutral.png | Bin 0 -> 909 bytes media/interface/radar/blip_neutral_alive.png | Bin 0 -> 1449 bytes media/interface/radar/blip_neutral_dead.png | Bin 0 -> 1546 bytes media/interface/radar/blip_neutral_flag.png | Bin 0 -> 692 bytes media/interface/radar/blip_red.png | Bin 0 -> 820 bytes media/interface/radar/blip_red_alive.png | Bin 0 -> 1430 bytes media/interface/radar/blip_red_dead.png | Bin 0 -> 1503 bytes media/interface/radar/blip_red_flag.png | Bin 0 -> 737 bytes media/interface/radar/blip_red_skull.png | Bin 0 -> 1010 bytes media/interface/radar/compass.png | Bin 0 -> 2268 bytes media/interface/radar/radar.png | Bin 0 -> 9517 bytes media/interface/shadow.png | Bin 0 -> 141415 bytes media/particle/base.png | Bin 0 -> 4116 bytes media/particle/blood.png | Bin 0 -> 44070 bytes media/particle/explosion.png | Bin 0 -> 173001 bytes media/particle/flames.png | Bin 0 -> 34822 bytes media/particle/flare.png | Bin 0 -> 1613 bytes media/particle/lensflares.png | Bin 0 -> 48275 bytes media/particle/lightning.jpg | Bin 0 -> 8918 bytes media/particle/plasma.png | Bin 0 -> 120255 bytes media/particle/pulse_burst.png | Bin 0 -> 2131 bytes media/particle/pulse_front.png | Bin 0 -> 18123 bytes media/particle/pulse_glow.png | Bin 0 -> 24061 bytes media/particle/pulse_muzzle.png | Bin 0 -> 23544 bytes media/particle/pulse_scorch.png | Bin 0 -> 47765 bytes media/particle/pulse_side.png | Bin 0 -> 20134 bytes media/particle/rail_glow.png | Bin 0 -> 24594 bytes media/particle/rail_hole.png | Bin 0 -> 19659 bytes media/particle/rail_muzzle.png | Bin 0 -> 23589 bytes media/particle/rail_trail.png | Bin 0 -> 16371 bytes media/particle/smoke.png | Bin 0 -> 6715 bytes media/particle/snow.png | Bin 0 -> 2293 bytes media/particle/spark.png | Bin 0 -> 20350 bytes media/particle/steam.png | Bin 0 -> 5027 bytes media/texture/base/base0_normal.png | Bin 0 -> 359527 bytes media/texture/base/base0_spec.png | Bin 0 -> 122021 bytes media/texture/base/base1.png | Bin 0 -> 3052 bytes media/texture/base/base1.tex | 2 + media/texture/base/base2.png | Bin 0 -> 115329 bytes media/texture/base/base2.tex | 5 + media/texture/base/base2_normal.png | Bin 0 -> 413935 bytes media/texture/base/base3.png | Bin 0 -> 211991 bytes media/texture/base/base3.tex | 5 + media/texture/base/base4.png | Bin 0 -> 142307 bytes media/texture/base/base4.tex | 5 + media/texture/base/black.png | Bin 0 -> 944 bytes media/texture/base/black.tex | 2 + media/texture/base/glow.tex | 4 + media/texture/base/info.txt | 20 + media/texture/base/white.png | Bin 0 -> 949 bytes media/texture/base/white.tex | 2 + media/texture/game/info.txt | 20 + media/texture/game/norender.png | Bin 0 -> 1107 bytes media/texture/game/notexture.png | Bin 0 -> 1161 bytes media/texture/game/sky.png | Bin 0 -> 707 bytes media/texture/mat_glass/nieb/cross-noise.png | Bin 0 -> 560477 bytes media/texture/mat_glass/nieb/info.txt | 20 + media/texture/mat_glass/nieb/noise.png | Bin 0 -> 598015 bytes media/texture/mat_glass/nieb/scratch1.png | Bin 0 -> 308495 bytes media/texture/mat_glass/nieb/scratch2.png | Bin 0 -> 302110 bytes media/texture/mat_glass/nieb/subtle.png | Bin 0 -> 46064 bytes .../texture/mat_glass/nieb/vertical-noise.png | Bin 0 -> 327677 bytes media/texture/mat_lava/nieb/info.txt | 20 + media/texture/mat_lava/nieb/lava.png | Bin 0 -> 91485 bytes media/texture/mat_lava/nieb/lava_normal.png | Bin 0 -> 75987 bytes media/texture/mat_water/appleflap/info.txt | 1 + .../mat_water/appleflap/water_normal.png | Bin 0 -> 316521 bytes media/texture/mat_water/caustic/caust00.png | Bin 0 -> 8306 bytes media/texture/mat_water/caustic/caust01.png | Bin 0 -> 8331 bytes media/texture/mat_water/caustic/caust02.png | Bin 0 -> 8292 bytes media/texture/mat_water/caustic/caust03.png | Bin 0 -> 8135 bytes media/texture/mat_water/caustic/caust04.png | Bin 0 -> 8023 bytes media/texture/mat_water/caustic/caust05.png | Bin 0 -> 7913 bytes media/texture/mat_water/caustic/caust06.png | Bin 0 -> 8130 bytes media/texture/mat_water/caustic/caust07.png | Bin 0 -> 8291 bytes media/texture/mat_water/caustic/caust08.png | Bin 0 -> 8296 bytes media/texture/mat_water/caustic/caust09.png | Bin 0 -> 8221 bytes media/texture/mat_water/caustic/caust10.png | Bin 0 -> 8207 bytes media/texture/mat_water/caustic/caust11.png | Bin 0 -> 8256 bytes media/texture/mat_water/caustic/caust12.png | Bin 0 -> 8415 bytes media/texture/mat_water/caustic/caust13.png | Bin 0 -> 8458 bytes media/texture/mat_water/caustic/caust14.png | Bin 0 -> 8452 bytes media/texture/mat_water/caustic/caust15.png | Bin 0 -> 8404 bytes media/texture/mat_water/caustic/caust16.png | Bin 0 -> 8396 bytes media/texture/mat_water/caustic/caust17.png | Bin 0 -> 8389 bytes media/texture/mat_water/caustic/caust18.png | Bin 0 -> 8359 bytes media/texture/mat_water/caustic/caust19.png | Bin 0 -> 8236 bytes media/texture/mat_water/caustic/caust20.png | Bin 0 -> 8290 bytes media/texture/mat_water/caustic/caust21.png | Bin 0 -> 8099 bytes media/texture/mat_water/caustic/caust22.png | Bin 0 -> 8068 bytes media/texture/mat_water/caustic/caust23.png | Bin 0 -> 8020 bytes media/texture/mat_water/caustic/caust24.png | Bin 0 -> 7935 bytes media/texture/mat_water/caustic/caust25.png | Bin 0 -> 7999 bytes media/texture/mat_water/caustic/caust26.png | Bin 0 -> 8241 bytes media/texture/mat_water/caustic/caust27.png | Bin 0 -> 8205 bytes media/texture/mat_water/caustic/caust28.png | Bin 0 -> 8162 bytes media/texture/mat_water/caustic/caust29.png | Bin 0 -> 8230 bytes media/texture/mat_water/caustic/caust30.png | Bin 0 -> 8286 bytes media/texture/mat_water/caustic/caust31.png | Bin 0 -> 8268 bytes media/texture/mat_water/nieb/foam.png | Bin 0 -> 302475 bytes media/texture/mat_water/nieb/info.txt | 20 + .../mat_water/nieb/water-calm_normal.png | Bin 0 -> 187655 bytes .../mat_water/nieb/water-ocean_normal.png | Bin 0 -> 408009 bytes media/texture/mat_water/nieb/water.png | Bin 0 -> 22732 bytes media/texture/mat_water/nieb/waterfall.png | Bin 0 -> 36391 bytes .../mat_water/nieb/waterfall_normal.png | Bin 0 -> 203470 bytes src/enet/ChangeLog | 183 + src/enet/LICENSE | 7 + src/enet/README | 15 + src/enet/callbacks.c | 53 + src/enet/compress.c | 654 +++ src/enet/host.c | 492 ++ src/enet/include/enet/callbacks.h | 27 + src/enet/include/enet/enet.h | 614 ++ src/enet/include/enet/list.h | 43 + src/enet/include/enet/protocol.h | 198 + src/enet/include/enet/time.h | 18 + src/enet/include/enet/types.h | 13 + src/enet/include/enet/unix.h | 48 + src/enet/include/enet/utility.h | 12 + src/enet/include/enet/win32.h | 57 + src/enet/list.c | 75 + src/enet/packet.c | 165 + src/enet/peer.c | 1007 ++++ src/enet/protocol.c | 1950 +++++++ src/enet/unix.c | 615 ++ src/enet/win32.c | 442 ++ src/engine/aa.cpp | 773 +++ src/engine/animmodel.h | 1898 +++++++ src/engine/bih.cpp | 819 +++ src/engine/bih.h | 93 + src/engine/blend.cpp | 1161 ++++ src/engine/client.cpp | 274 + src/engine/command.cpp | 4310 ++++++++++++++ src/engine/console.cpp | 821 +++ src/engine/dynlight.cpp | 186 + src/engine/engine.h | 810 +++ src/engine/explosion.h | 196 + src/engine/grass.cpp | 339 ++ src/engine/hitzone.h | 837 +++ src/engine/iqm.h | 391 ++ src/engine/lensflare.h | 162 + src/engine/light.cpp | 692 +++ src/engine/light.h | 86 + src/engine/lightning.h | 120 + src/engine/main.cpp | 1235 ++++ src/engine/master.cpp | 730 +++ src/engine/material.cpp | 821 +++ src/engine/md2.h | 242 + src/engine/md3.h | 180 + src/engine/md5.h | 415 ++ src/engine/menus.cpp | 78 + src/engine/model.h | 96 + src/engine/movie.cpp | 1170 ++++ src/engine/mpr.h | 569 ++ src/engine/normal.cpp | 281 + src/engine/obj.h | 187 + src/engine/octa.cpp | 1887 +++++++ src/engine/octa.h | 337 ++ src/engine/octaedit.cpp | 2942 ++++++++++ src/engine/octarender.cpp | 1761 ++++++ src/engine/physics.cpp | 2048 +++++++ src/engine/pvs.cpp | 1315 +++++ src/engine/ragdoll.h | 537 ++ src/engine/rendergl.cpp | 2829 ++++++++++ src/engine/renderlights.cpp | 4998 +++++++++++++++++ src/engine/rendermodel.cpp | 1133 ++++ src/engine/renderparticles.cpp | 1442 +++++ src/engine/rendersky.cpp | 579 ++ src/engine/rendertext.cpp | 436 ++ src/engine/renderva.cpp | 2737 +++++++++ src/engine/server.cpp | 1162 ++++ src/engine/serverbrowser.cpp | 753 +++ src/engine/shader.cpp | 1612 ++++++ src/engine/skelmodel.h | 1894 +++++++ src/engine/smd.h | 440 ++ src/engine/sound.cpp | 881 +++ src/engine/stain.cpp | 819 +++ src/engine/textedit.h | 790 +++ src/engine/texture.cpp | 3975 +++++++++++++ src/engine/texture.h | 866 +++ src/engine/ui.cpp | 3585 ++++++++++++ src/engine/vertmodel.h | 520 ++ src/engine/water.cpp | 683 +++ src/engine/world.cpp | 1550 +++++ src/engine/world.h | 53 + src/engine/worldio.cpp | 1123 ++++ src/game/ai.cpp | 1441 +++++ src/game/ai.h | 317 ++ src/game/aiman.h | 276 + src/game/client.cpp | 2167 +++++++ src/game/ctf.h | 983 ++++ src/game/entities.cpp | 407 ++ src/game/extinfo.h | 145 + src/game/game.cpp | 891 +++ src/game/game.h | 633 +++ src/game/render.cpp | 536 ++ src/game/scoreboard.cpp | 221 + src/game/server.cpp | 3605 ++++++++++++ src/game/waypoint.cpp | 806 +++ src/game/weapon.cpp | 784 +++ src/readme_sauerbraten.txt | 96 + src/readme_tesseract.txt | 68 + src/shared/command.h | 410 ++ src/shared/crypto.cpp | 944 ++++ src/shared/cube.h | 70 + src/shared/ents.h | 207 + src/shared/geom.cpp | 290 + src/shared/geom.h | 1942 +++++++ src/shared/glemu.cpp | 347 ++ src/shared/glemu.h | 180 + src/shared/glexts.h | 832 +++ src/shared/iengine.h | 540 ++ src/shared/igame.h | 124 + src/shared/stream.cpp | 1238 ++++ src/shared/tessfont.c | 764 +++ src/shared/tools.cpp | 265 + src/shared/tools.h | 1410 +++++ src/shared/zip.cpp | 588 ++ tesseract_unix | 65 + 364 files changed, 107883 insertions(+) create mode 100644 .gitignore create mode 100644 README create mode 100644 bin_unix/readme.txt create mode 100644 config/blendbrush.cfg create mode 100644 config/default.cfg create mode 100644 config/default_map_models.cfg create mode 100644 config/default_map_settings.cfg create mode 100644 config/font.cfg create mode 100644 config/game.cfg create mode 100644 config/glsl.cfg create mode 100644 config/glsl/aa.cfg create mode 100644 config/glsl/ao.cfg create mode 100644 config/glsl/blur.cfg create mode 100644 config/glsl/decal.cfg create mode 100644 config/glsl/deferred.cfg create mode 100644 config/glsl/edit.cfg create mode 100644 config/glsl/fxaa.cfg create mode 100644 config/glsl/gi.cfg create mode 100644 config/glsl/grass.cfg create mode 100644 config/glsl/hud.cfg create mode 100644 config/glsl/material.cfg create mode 100644 config/glsl/misc.cfg create mode 100644 config/glsl/model.cfg create mode 100644 config/glsl/movie.cfg create mode 100644 config/glsl/particle.cfg create mode 100644 config/glsl/postfx.cfg create mode 100644 config/glsl/scale.cfg create mode 100644 config/glsl/shared.cfg create mode 100644 config/glsl/sky.cfg create mode 100644 config/glsl/smaa.cfg create mode 100644 config/glsl/stain.cfg create mode 100644 config/glsl/tonemap.cfg create mode 100644 config/glsl/ui.cfg create mode 100644 config/glsl/volumetric.cfg create mode 100644 config/glsl/world.cfg create mode 100644 config/heightmap.cfg create mode 100644 config/keymap.cfg create mode 100644 config/server-init.cfg create mode 100644 config/sound.cfg create mode 100644 config/stdedit.cfg create mode 100644 config/stdlib.cfg create mode 100644 config/ui.cfg create mode 100644 config/ui/edithud.cfg create mode 100644 config/ui/fkey.cfg create mode 100644 config/ui/lib.cfg create mode 100644 config/ui/options.cfg create mode 100644 config/ui/scoreboard.cfg create mode 100644 config/ui/serverbrowser.cfg create mode 100644 config/ui/stats.cfg create mode 100644 config/ui/style.cfg create mode 100644 media/blendbrush/circle_128_hard.png create mode 100644 media/blendbrush/circle_128_soft.png create mode 100644 media/blendbrush/circle_128_solid.png create mode 100644 media/blendbrush/circle_16_hard.png create mode 100644 media/blendbrush/circle_16_soft.png create mode 100644 media/blendbrush/circle_16_solid.png create mode 100644 media/blendbrush/circle_256_hard.png create mode 100644 media/blendbrush/circle_256_soft.png create mode 100644 media/blendbrush/circle_256_solid.png create mode 100644 media/blendbrush/circle_32_hard.png create mode 100644 media/blendbrush/circle_32_soft.png create mode 100644 media/blendbrush/circle_32_solid.png create mode 100644 media/blendbrush/circle_64_hard.png create mode 100644 media/blendbrush/circle_64_soft.png create mode 100644 media/blendbrush/circle_64_solid.png create mode 100644 media/blendbrush/circle_8_hard.png create mode 100644 media/blendbrush/circle_8_soft.png create mode 100644 media/blendbrush/circle_8_solid.png create mode 100644 media/blendbrush/dot_1_hard.png create mode 100644 media/blendbrush/dot_1_soft.png create mode 100644 media/blendbrush/dot_1_solid.png create mode 100644 media/blendbrush/gradient_128.png create mode 100644 media/blendbrush/gradient_16.png create mode 100644 media/blendbrush/gradient_32.png create mode 100644 media/blendbrush/gradient_64.png create mode 100644 media/blendbrush/noise_1024_hard.png create mode 100644 media/blendbrush/noise_1024_soft.png create mode 100644 media/blendbrush/noise_128_hard.png create mode 100644 media/blendbrush/noise_128_soft.png create mode 100644 media/blendbrush/noise_256_hard.png create mode 100644 media/blendbrush/noise_256_soft.png create mode 100644 media/blendbrush/noise_512_hard.png create mode 100644 media/blendbrush/noise_512_soft.png create mode 100644 media/blendbrush/noise_64_hard.png create mode 100644 media/blendbrush/noise_64_soft.png create mode 100644 media/blendbrush/square_16_hard.png create mode 100644 media/blendbrush/square_16_solid.png create mode 100644 media/blendbrush/square_32_hard.png create mode 100644 media/blendbrush/square_32_solid.png create mode 100644 media/blendbrush/square_64_hard.png create mode 100644 media/blendbrush/square_64_solid.png create mode 100644 media/interface/background.png create mode 100644 media/interface/crosshair/circle_dot.png create mode 100644 media/interface/crosshair/circle_dot_hit.png create mode 100644 media/interface/crosshair/cross_normal.png create mode 100644 media/interface/crosshair/cross_normal_hit.png create mode 100644 media/interface/crosshair/cross_whole.png create mode 100644 media/interface/crosshair/cross_whole_hit.png create mode 100644 media/interface/crosshair/default.png create mode 100644 media/interface/crosshair/default_hit.png create mode 100644 media/interface/crosshair/dot.png create mode 100644 media/interface/crosshair/dot_hit.png create mode 100644 media/interface/crosshair/dot_normal.png create mode 100644 media/interface/crosshair/dot_normal_hit.png create mode 100644 media/interface/crosshair/dot_whole.png create mode 100644 media/interface/crosshair/dot_whole_hit.png create mode 100644 media/interface/crosshair/dot_wide.png create mode 100644 media/interface/crosshair/dot_wide_hit.png create mode 100644 media/interface/crosshair/info.txt create mode 100644 media/interface/crosshair/o.png create mode 100644 media/interface/crosshair/o_dot.png create mode 100644 media/interface/crosshair/o_dot_hit.png create mode 100644 media/interface/crosshair/o_hit.png create mode 100644 media/interface/crosshair/o_x.png create mode 100644 media/interface/crosshair/o_x_hit.png create mode 100644 media/interface/crosshair/star.png create mode 100644 media/interface/crosshair/star_hit.png create mode 100644 media/interface/crosshair/teammate.png create mode 100644 media/interface/crosshair/wide.png create mode 100644 media/interface/crosshair/wide_hit.png create mode 100644 media/interface/crosshair/x.png create mode 100644 media/interface/crosshair/x_dot.png create mode 100644 media/interface/crosshair/x_dot_hit.png create mode 100644 media/interface/crosshair/x_hit.png create mode 100644 media/interface/cube.png create mode 100644 media/interface/cube2badge.png create mode 100644 media/interface/cursor.png create mode 100644 media/interface/directory.png create mode 100644 media/interface/font/default.cfg create mode 100644 media/interface/font/default.otf create mode 100644 media/interface/font/default.ttf create mode 100644 media/interface/font/default.txt create mode 100644 media/interface/font/default0.png create mode 100644 media/interface/font/default_outline.cfg create mode 100644 media/interface/loading_bar.png create mode 100644 media/interface/loading_frame.png create mode 100644 media/interface/logo.png create mode 100644 media/interface/logo_1024.png create mode 100644 media/interface/radar/blip_blue.png create mode 100644 media/interface/radar/blip_blue_alive.png create mode 100644 media/interface/radar/blip_blue_dead.png create mode 100644 media/interface/radar/blip_blue_flag.png create mode 100644 media/interface/radar/blip_blue_skull.png create mode 100644 media/interface/radar/blip_grey.png create mode 100644 media/interface/radar/blip_neutral.png create mode 100644 media/interface/radar/blip_neutral_alive.png create mode 100644 media/interface/radar/blip_neutral_dead.png create mode 100644 media/interface/radar/blip_neutral_flag.png create mode 100644 media/interface/radar/blip_red.png create mode 100644 media/interface/radar/blip_red_alive.png create mode 100644 media/interface/radar/blip_red_dead.png create mode 100644 media/interface/radar/blip_red_flag.png create mode 100644 media/interface/radar/blip_red_skull.png create mode 100644 media/interface/radar/compass.png create mode 100644 media/interface/radar/radar.png create mode 100644 media/interface/shadow.png create mode 100644 media/particle/base.png create mode 100644 media/particle/blood.png create mode 100644 media/particle/explosion.png create mode 100644 media/particle/flames.png create mode 100644 media/particle/flare.png create mode 100644 media/particle/lensflares.png create mode 100644 media/particle/lightning.jpg create mode 100644 media/particle/plasma.png create mode 100644 media/particle/pulse_burst.png create mode 100644 media/particle/pulse_front.png create mode 100644 media/particle/pulse_glow.png create mode 100644 media/particle/pulse_muzzle.png create mode 100644 media/particle/pulse_scorch.png create mode 100644 media/particle/pulse_side.png create mode 100644 media/particle/rail_glow.png create mode 100644 media/particle/rail_hole.png create mode 100644 media/particle/rail_muzzle.png create mode 100644 media/particle/rail_trail.png create mode 100644 media/particle/smoke.png create mode 100644 media/particle/snow.png create mode 100644 media/particle/spark.png create mode 100644 media/particle/steam.png create mode 100644 media/texture/base/base0_normal.png create mode 100644 media/texture/base/base0_spec.png create mode 100644 media/texture/base/base1.png create mode 100644 media/texture/base/base1.tex create mode 100644 media/texture/base/base2.png create mode 100644 media/texture/base/base2.tex create mode 100644 media/texture/base/base2_normal.png create mode 100644 media/texture/base/base3.png create mode 100644 media/texture/base/base3.tex create mode 100644 media/texture/base/base4.png create mode 100644 media/texture/base/base4.tex create mode 100644 media/texture/base/black.png create mode 100644 media/texture/base/black.tex create mode 100644 media/texture/base/glow.tex create mode 100644 media/texture/base/info.txt create mode 100644 media/texture/base/white.png create mode 100644 media/texture/base/white.tex create mode 100644 media/texture/game/info.txt create mode 100644 media/texture/game/norender.png create mode 100644 media/texture/game/notexture.png create mode 100644 media/texture/game/sky.png create mode 100644 media/texture/mat_glass/nieb/cross-noise.png create mode 100644 media/texture/mat_glass/nieb/info.txt create mode 100644 media/texture/mat_glass/nieb/noise.png create mode 100644 media/texture/mat_glass/nieb/scratch1.png create mode 100644 media/texture/mat_glass/nieb/scratch2.png create mode 100644 media/texture/mat_glass/nieb/subtle.png create mode 100644 media/texture/mat_glass/nieb/vertical-noise.png create mode 100644 media/texture/mat_lava/nieb/info.txt create mode 100644 media/texture/mat_lava/nieb/lava.png create mode 100644 media/texture/mat_lava/nieb/lava_normal.png create mode 100644 media/texture/mat_water/appleflap/info.txt create mode 100644 media/texture/mat_water/appleflap/water_normal.png create mode 100644 media/texture/mat_water/caustic/caust00.png create mode 100644 media/texture/mat_water/caustic/caust01.png create mode 100644 media/texture/mat_water/caustic/caust02.png create mode 100644 media/texture/mat_water/caustic/caust03.png create mode 100644 media/texture/mat_water/caustic/caust04.png create mode 100644 media/texture/mat_water/caustic/caust05.png create mode 100644 media/texture/mat_water/caustic/caust06.png create mode 100644 media/texture/mat_water/caustic/caust07.png create mode 100644 media/texture/mat_water/caustic/caust08.png create mode 100644 media/texture/mat_water/caustic/caust09.png create mode 100644 media/texture/mat_water/caustic/caust10.png create mode 100644 media/texture/mat_water/caustic/caust11.png create mode 100644 media/texture/mat_water/caustic/caust12.png create mode 100644 media/texture/mat_water/caustic/caust13.png create mode 100644 media/texture/mat_water/caustic/caust14.png create mode 100644 media/texture/mat_water/caustic/caust15.png create mode 100644 media/texture/mat_water/caustic/caust16.png create mode 100644 media/texture/mat_water/caustic/caust17.png create mode 100644 media/texture/mat_water/caustic/caust18.png create mode 100644 media/texture/mat_water/caustic/caust19.png create mode 100644 media/texture/mat_water/caustic/caust20.png create mode 100644 media/texture/mat_water/caustic/caust21.png create mode 100644 media/texture/mat_water/caustic/caust22.png create mode 100644 media/texture/mat_water/caustic/caust23.png create mode 100644 media/texture/mat_water/caustic/caust24.png create mode 100644 media/texture/mat_water/caustic/caust25.png create mode 100644 media/texture/mat_water/caustic/caust26.png create mode 100644 media/texture/mat_water/caustic/caust27.png create mode 100644 media/texture/mat_water/caustic/caust28.png create mode 100644 media/texture/mat_water/caustic/caust29.png create mode 100644 media/texture/mat_water/caustic/caust30.png create mode 100644 media/texture/mat_water/caustic/caust31.png create mode 100644 media/texture/mat_water/nieb/foam.png create mode 100644 media/texture/mat_water/nieb/info.txt create mode 100644 media/texture/mat_water/nieb/water-calm_normal.png create mode 100644 media/texture/mat_water/nieb/water-ocean_normal.png create mode 100644 media/texture/mat_water/nieb/water.png create mode 100644 media/texture/mat_water/nieb/waterfall.png create mode 100644 media/texture/mat_water/nieb/waterfall_normal.png create mode 100644 src/enet/ChangeLog create mode 100644 src/enet/LICENSE create mode 100644 src/enet/README create mode 100644 src/enet/callbacks.c create mode 100644 src/enet/compress.c create mode 100644 src/enet/host.c create mode 100644 src/enet/include/enet/callbacks.h create mode 100644 src/enet/include/enet/enet.h create mode 100644 src/enet/include/enet/list.h create mode 100644 src/enet/include/enet/protocol.h create mode 100644 src/enet/include/enet/time.h create mode 100644 src/enet/include/enet/types.h create mode 100644 src/enet/include/enet/unix.h create mode 100644 src/enet/include/enet/utility.h create mode 100644 src/enet/include/enet/win32.h create mode 100644 src/enet/list.c create mode 100644 src/enet/packet.c create mode 100644 src/enet/peer.c create mode 100644 src/enet/protocol.c create mode 100644 src/enet/unix.c create mode 100644 src/enet/win32.c create mode 100644 src/engine/aa.cpp create mode 100644 src/engine/animmodel.h create mode 100644 src/engine/bih.cpp create mode 100644 src/engine/bih.h create mode 100644 src/engine/blend.cpp create mode 100644 src/engine/client.cpp create mode 100644 src/engine/command.cpp create mode 100644 src/engine/console.cpp create mode 100644 src/engine/dynlight.cpp create mode 100644 src/engine/engine.h create mode 100644 src/engine/explosion.h create mode 100644 src/engine/grass.cpp create mode 100644 src/engine/hitzone.h create mode 100644 src/engine/iqm.h create mode 100644 src/engine/lensflare.h create mode 100644 src/engine/light.cpp create mode 100644 src/engine/light.h create mode 100644 src/engine/lightning.h create mode 100644 src/engine/main.cpp create mode 100644 src/engine/master.cpp create mode 100644 src/engine/material.cpp create mode 100644 src/engine/md2.h create mode 100644 src/engine/md3.h create mode 100644 src/engine/md5.h create mode 100644 src/engine/menus.cpp create mode 100644 src/engine/model.h create mode 100644 src/engine/movie.cpp create mode 100644 src/engine/mpr.h create mode 100644 src/engine/normal.cpp create mode 100644 src/engine/obj.h create mode 100644 src/engine/octa.cpp create mode 100644 src/engine/octa.h create mode 100644 src/engine/octaedit.cpp create mode 100644 src/engine/octarender.cpp create mode 100644 src/engine/physics.cpp create mode 100644 src/engine/pvs.cpp create mode 100644 src/engine/ragdoll.h create mode 100644 src/engine/rendergl.cpp create mode 100644 src/engine/renderlights.cpp create mode 100644 src/engine/rendermodel.cpp create mode 100644 src/engine/renderparticles.cpp create mode 100644 src/engine/rendersky.cpp create mode 100644 src/engine/rendertext.cpp create mode 100644 src/engine/renderva.cpp create mode 100644 src/engine/server.cpp create mode 100644 src/engine/serverbrowser.cpp create mode 100644 src/engine/shader.cpp create mode 100644 src/engine/skelmodel.h create mode 100644 src/engine/smd.h create mode 100644 src/engine/sound.cpp create mode 100644 src/engine/stain.cpp create mode 100644 src/engine/textedit.h create mode 100644 src/engine/texture.cpp create mode 100644 src/engine/texture.h create mode 100644 src/engine/ui.cpp create mode 100644 src/engine/vertmodel.h create mode 100644 src/engine/water.cpp create mode 100644 src/engine/world.cpp create mode 100644 src/engine/world.h create mode 100644 src/engine/worldio.cpp create mode 100644 src/game/ai.cpp create mode 100644 src/game/ai.h create mode 100644 src/game/aiman.h create mode 100644 src/game/client.cpp create mode 100644 src/game/ctf.h create mode 100644 src/game/entities.cpp create mode 100644 src/game/extinfo.h create mode 100644 src/game/game.cpp create mode 100644 src/game/game.h create mode 100644 src/game/render.cpp create mode 100644 src/game/scoreboard.cpp create mode 100644 src/game/server.cpp create mode 100644 src/game/waypoint.cpp create mode 100644 src/game/weapon.cpp create mode 100644 src/readme_sauerbraten.txt create mode 100644 src/readme_tesseract.txt create mode 100644 src/shared/command.h create mode 100644 src/shared/crypto.cpp create mode 100644 src/shared/cube.h create mode 100644 src/shared/ents.h create mode 100644 src/shared/geom.cpp create mode 100644 src/shared/geom.h create mode 100644 src/shared/glemu.cpp create mode 100644 src/shared/glemu.h create mode 100644 src/shared/glexts.h create mode 100644 src/shared/iengine.h create mode 100644 src/shared/igame.h create mode 100644 src/shared/stream.cpp create mode 100644 src/shared/tessfont.c create mode 100644 src/shared/tools.cpp create mode 100644 src/shared/tools.h create mode 100644 src/shared/zip.cpp create mode 100755 tesseract_unix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d772625 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.o +src/build \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..05cbae7 --- /dev/null +++ b/README @@ -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. + diff --git a/bin_unix/readme.txt b/bin_unix/readme.txt new file mode 100644 index 0000000..fcf8610 --- /dev/null +++ b/bin_unix/readme.txt @@ -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. + diff --git a/config/blendbrush.cfg b/config/blendbrush.cfg new file mode 100644 index 0000000..9c71b13 --- /dev/null +++ b/config/blendbrush.cfg @@ -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")] diff --git a/config/default.cfg b/config/default.cfg new file mode 100644 index 0000000..0fc7a20 --- /dev/null +++ b/config/default.cfg @@ -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 diff --git a/config/default_map_models.cfg b/config/default_map_models.cfg new file mode 100644 index 0000000..0058030 --- /dev/null +++ b/config/default_map_models.cfg @@ -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" \ No newline at end of file diff --git a/config/default_map_settings.cfg b/config/default_map_settings.cfg new file mode 100644 index 0000000..bc09740 --- /dev/null +++ b/config/default_map_settings.cfg @@ -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" diff --git a/config/font.cfg b/config/font.cfg new file mode 100644 index 0000000..bbfa953 --- /dev/null +++ b/config/font.cfg @@ -0,0 +1,3 @@ +loopfiles f "media/interface/font" cfg [ + exec (concatword "media/interface/font/" $f ".cfg") +] \ No newline at end of file diff --git a/config/game.cfg b/config/game.cfg new file mode 100644 index 0000000..db19558 --- /dev/null +++ b/config/game.cfg @@ -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] + diff --git a/config/glsl.cfg b/config/glsl.cfg new file mode 100644 index 0000000..cbb17b0 --- /dev/null +++ b/config/glsl.cfg @@ -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" + diff --git a/config/glsl/aa.cfg b/config/glsl/aa.cfg new file mode 100644 index 0000000..c6bc12c --- /dev/null +++ b/config/glsl/aa.cfg @@ -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" +] + diff --git a/config/glsl/ao.cfg b/config/glsl/ao.cfg new file mode 100644 index 0000000..a8f17e4 --- /dev/null +++ b/config/glsl/ao.cfg @@ -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 +] + diff --git a/config/glsl/blur.cfg b/config/glsl/blur.cfg new file mode 100644 index 0000000..bf9c68a --- /dev/null +++ b/config/glsl/blur.cfg @@ -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 +] + diff --git a/config/glsl/decal.cfg b/config/glsl/decal.cfg new file mode 100644 index 0000000..e2cab0d --- /dev/null +++ b/config/glsl/decal.cfg @@ -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" + diff --git a/config/glsl/deferred.cfg b/config/glsl/deferred.cfg new file mode 100644 index 0000000..b1d432e --- /dev/null +++ b/config/glsl/deferred.cfg @@ -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 + ] + ] + ] +] + diff --git a/config/glsl/edit.cfg b/config/glsl/edit.cfg new file mode 100644 index 0000000..1278e1b --- /dev/null +++ b/config/glsl/edit.cfg @@ -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) + } +] + diff --git a/config/glsl/fxaa.cfg b/config/glsl/fxaa.cfg new file mode 100644 index 0000000..62b3b72 --- /dev/null +++ b/config/glsl/fxaa.cfg @@ -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); + } +] + diff --git a/config/glsl/gi.cfg b/config/glsl/gi.cfg new file mode 100644 index 0000000..ddb722b --- /dev/null +++ b/config/glsl/gi.cfg @@ -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); + } +] + diff --git a/config/glsl/grass.cfg b/config/glsl/grass.cfg new file mode 100644 index 0000000..1a56b71 --- /dev/null +++ b/config/glsl/grass.cfg @@ -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") +] + diff --git a/config/glsl/hud.cfg b/config/glsl/hud.cfg new file mode 100644 index 0000000..8b920e6 --- /dev/null +++ b/config/glsl/hud.cfg @@ -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); + } +] + diff --git a/config/glsl/material.cfg b/config/glsl/material.cfg new file mode 100644 index 0000000..f1ced84 --- /dev/null +++ b/config/glsl/material.cfg @@ -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) + } +] + diff --git a/config/glsl/misc.cfg b/config/glsl/misc.cfg new file mode 100644 index 0000000..0199eeb --- /dev/null +++ b/config/glsl/misc.cfg @@ -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; + } +] + diff --git a/config/glsl/model.cfg b/config/glsl/model.cfg new file mode 100644 index 0000000..1c9748d --- /dev/null +++ b/config/glsl/model.cfg @@ -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) [] + ] +] + diff --git a/config/glsl/movie.cfg b/config/glsl/movie.cfg new file mode 100644 index 0000000..f1069ff --- /dev/null +++ b/config/glsl/movie.cfg @@ -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); + } +] + diff --git a/config/glsl/particle.cfg b/config/glsl/particle.cfg new file mode 100644 index 0000000..2345e2d --- /dev/null +++ b/config/glsl/particle.cfg @@ -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" + diff --git a/config/glsl/postfx.cfg b/config/glsl/postfx.cfg new file mode 100644 index 0000000..18d61a4 --- /dev/null +++ b/config/glsl/postfx.cfg @@ -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] + ] +] + diff --git a/config/glsl/scale.cfg b/config/glsl/scale.cfg new file mode 100644 index 0000000..8add196 --- /dev/null +++ b/config/glsl/scale.cfg @@ -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); + } +] + + diff --git a/config/glsl/shared.cfg b/config/glsl/shared.cfg new file mode 100644 index 0000000..a8cb610 --- /dev/null +++ b/config/glsl/shared.cfg @@ -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) + ] +] + + diff --git a/config/glsl/sky.cfg b/config/glsl/sky.cfg new file mode 100644 index 0000000..b66a09b --- /dev/null +++ b/config/glsl/sky.cfg @@ -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; + } +] + diff --git a/config/glsl/smaa.cfg b/config/glsl/smaa.cfg new file mode 100644 index 0000000..22ede18 --- /dev/null +++ b/config/glsl/smaa.cfg @@ -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)); + ]) + } +] + diff --git a/config/glsl/stain.cfg b/config/glsl/stain.cfg new file mode 100644 index 0000000..253c88b --- /dev/null +++ b/config/glsl/stain.cfg @@ -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" + diff --git a/config/glsl/tonemap.cfg b/config/glsl/tonemap.cfg new file mode 100644 index 0000000..96c21c5 --- /dev/null +++ b/config/glsl/tonemap.cfg @@ -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);]) +]]) + diff --git a/config/glsl/ui.cfg b/config/glsl/ui.cfg new file mode 100644 index 0000000..4ead341 --- /dev/null +++ b/config/glsl/ui.cfg @@ -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; + } +] + + diff --git a/config/glsl/volumetric.cfg b/config/glsl/volumetric.cfg new file mode 100644 index 0000000..10ec443 --- /dev/null +++ b/config/glsl/volumetric.cfg @@ -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 +] + diff --git a/config/glsl/world.cfg b/config/glsl/world.cfg new file mode 100644 index 0000000..af539dd --- /dev/null +++ b/config/glsl/world.cfg @@ -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; + ]]) + } + ] + ] +] + diff --git a/config/heightmap.cfg b/config/heightmap.cfg new file mode 100644 index 0000000..5f4b171 --- /dev/null +++ b/config/heightmap.cfg @@ -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 : set a point on the brushmap +// hbrushx : the x coordinate of the brushhandle +// hbrushy : 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 diff --git a/config/keymap.cfg b/config/keymap.cfg new file mode 100644 index 0000000..de68306 --- /dev/null +++ b/config/keymap.cfg @@ -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 diff --git a/config/server-init.cfg b/config/server-init.cfg new file mode 100644 index 0000000..fed51e0 --- /dev/null +++ b/config/server-init.cfg @@ -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 + diff --git a/config/sound.cfg b/config/sound.cfg new file mode 100644 index 0000000..e5aa274 --- /dev/null +++ b/config/sound.cfg @@ -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 + diff --git a/config/stdedit.cfg b/config/stdedit.cfg new file mode 100644 index 0000000..e6c19c1 --- /dev/null +++ b/config/stdedit.cfg @@ -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 diff --git a/config/stdlib.cfg b/config/stdlib.cfg new file mode 100644 index 0000000..2a97f2b --- /dev/null +++ b/config/stdlib.cfg @@ -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 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] + ] +] + diff --git a/config/ui.cfg b/config/ui.cfg new file mode 100644 index 0000000..a921335 --- /dev/null +++ b/config/ui.cfg @@ -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 = ""] + diff --git a/config/ui/edithud.cfg b/config/ui/edithud.cfg new file mode 100644 index 0000000..d53b512 --- /dev/null +++ b/config/ui/edithud.cfg @@ -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] + ] + ] + ] + ] + ] +] diff --git a/config/ui/fkey.cfg b/config/ui/fkey.cfg new file mode 100644 index 0000000..29c1638 --- /dev/null +++ b/config/ui/fkey.cfg @@ -0,0 +1,1131 @@ +/////////////////////////////////////////////////////////////////////////////// +// F1 Add/Edit Entity // +/////////////////////////////////////////////////////////////////////////////// +menu_entity = [toggleui "addentity"] +// menu_entity = [if (enthavesel) [toggleui "editentity"] [toggleui "addentity"]] + +UImenu "editentity" [ + uifill 0.5 0.5 [ + UIbutton "" [uitext "ToDo" 0.8] 0.3 0.2 [hidetopui] + ] +] [] [] [] "Edit Entity" + +UImenu "addentity" [ + uispace 0.008 0.015 [ + uivlist 0 [ + uifill 0.5 0.032 [ + uitext (concatword "^f8/newent " $UI_enttype) 0.7 + uialign* -1 0 + uioutline $c_line ; uiclamp- 1 1 1 1 + ] + uifill 0 0.025 + uihlist 0.005 [ + uivlist 0.005 [ + UIbutton "" [uitext "Envmap" 0.6] 0.2 0.04 [hideui "addentity" ; newent envmap] -1 [uihover [UI_enttype = "envmap"]] + UIbutton "" [uitext "Light" 0.6] 0.2 0.04 [hideui "addentity" ; showui "ent_light"] -1 [uihover [UI_enttype = "light ^f4*"]] + UIbutton "" [uitext "Spotlight" 0.6] 0.2 0.04 [hideui "addentity" ; showui "ent_spotlight"] -1 [uihover [UI_enttype = "spotlight ^f4*"]] + ] + uivlist 0.005 [ + UIbutton "" [uitext "Jumppad" 0.6] 0.2 0.04 [hideui "addentity" ; showui "ent_jumppad"] -1 [uihover [UI_enttype = "jumppad ^f4*"]] + UIbutton "" [uitext "Mapmodel" 0.6; UI_keyref 2 0.027 0.027 "F3"] 0.2 0.04 [hideui "addentity"; showui "mapmodel"] -1 [uihover [UI_enttype = "mapmodel ^f4*"]] + UIbutton "" [uitext "Particles" 0.6] 0.2 0.04 [hideui "addentity" ; showui "ent_particles"] -1 [uihover [UI_enttype = "particles ^f4*"]] + UIbutton "" [uitext "Teleport" 0.6] 0.2 0.04 [hideui "addentity" ; showui "ent_teleport"] -1 [uihover [UI_enttype = "teleport ^f4*"]] + UIbutton "" [uitext "Teledest" 0.6] 0.2 0.04 [hideui "addentity" ; showui "ent_teledest"] -1 [uihover [UI_enttype = "teledest ^f4*"]] + ] + uivlist 0.005 [ + UIbutton "" [uitext "Playerstart" 0.6] 0.2 0.04 [hideui "addentity" ; newent playerstart] -1 [uihover [UI_enttype = "playerstart"]] + UIbutton "" [uitext "Playerstart ^f1Azul" 0.6] 0.2 0.04 [hideui "addentity" ; newent playerstart 1] -1 [uihover [UI_enttype = "playerstart 1"]] + UIbutton "" [uitext "Playerstart ^f3Rojo" 0.6] 0.2 0.04 [hideui "addentity" ; newent playerstart 2] -1 [uihover [UI_enttype = "playerstart 2"]] + UIbutton "" [uitext "Flag ^f1Azul" 0.6] 0.2 0.04 [hideui "addentity" ; newent flag 1] -1 [uihover [UI_enttype = "flag 1"]] + UIbutton "" [uitext "Flag ^f3Rojo" 0.6] 0.2 0.04 [hideui "addentity" ; newent flag 2] -1 [uihover [UI_enttype = "flag 2"]] + ] + uialign* -1 -1 + ] + uifill 0 0.01 + UIbutton "hold2" [ + UIcheckbox $entselsnap 0.016 + uitext "Entity Snapping" 0.6 + UI_keyref 2 0.027 0.027 "7" + ] 0.25 0.04 [entselsnap (! $entselsnap)] + ] + ] +] [ + UI_enttype = " " + looplist a ["editentity" "ent_light" "ent_spotlight" "ent_jumppad" "mapmodel" "ent_particles" "ent_teleport" "ent_teledest"] [hideui $a] +] [] [] "Add Entity" + +UI_lts = 128 +UI_ltr = 127 +UI_ltg = 127 +UI_ltb = 127 +UI_ltt = 0 +UImenu "ent_light" [ + uispace 0.008 0.015 [ + uivlist 0 [ + uifill 0.5 0.032 [ + uitext (concatword "^f8/newent light " $UI_lts " " $UI_ltr " " $UI_ltg " " $UI_ltb " " $UI_ltt) 0.7 + uialign* -1 0 + uioutline $c_line ; uiclamp- 1 1 1 1 + ] + uifill 0 0.025 + uitable 0.005 0.005 [ + uitablerow [ + uitext "Radius" 0.6 + UIhslider UI_lts 1 256 1 0.5 0.032 [uitext $UI_lts 0.6] + uialign* -1 0 + ] + uitablerow [ + uitext "Red" 0.6 + UIhslider UI_ltr 0 255 1 0.5 0.032 [uitext $UI_ltr 0.6] + uialign* -1 0 + ] + uitablerow [ + uitext "Green" 0.6 + UIhslider UI_ltg 0 255 1 0.5 0.032 [uitext $UI_ltg 0.6] + uialign* -1 0 + ] + uitablerow [ + uitext "Blue" 0.6 + UIhslider UI_ltb 0 255 1 0.5 0.032 [uitext $UI_ltb 0.6] + uialign* -1 0 + ] + uitablerow [ + uitext "Type" 0.6 + UIhslider UI_ltt 0 2 1 0.5 0.032 [uitext $UI_ltt 0.6] + uialign* -1 0 + ] + ] + uifill 0 0.025 + UIbutton "" [uitext "Add" 0.6] 0.12 0.06 [hideui "ent_light" ; newent light $UI_lts $UI_ltr $UI_ltg $UI_ltb $UI_ltt] + ] + ] +] [] [] [] "Add Entity - Light" + +UI_sla = 45 +UImenu "ent_spotlight" [ + uispace 0.008 0.015 [ + uivlist 0 [ + uifill 0.5 0.032 [ + uitext (concatword "^f8/newent spotlight " $UI_sla) 0.7 + uialign* -1 0 + uioutline $c_line ; uiclamp- 1 1 1 1 + ] + uifill 0 0.025 + uihlist 0.005 [ + uitext "Angle" 0.6 + UIhslider UI_sla 1 90 1 0.5 0.032 [uitext $UI_sla 0.6] + uialign* -1 0 + ] + uifill 0 0.025 + UIbutton "" [uitext "Add" 0.6] 0.12 0.06 [hideui "ent_spotlight" ; newent spotlight $UI_sla] + ] + ] +] [] [] [] "Add Entity - Spotlight" + +UI_jph = 20 +UI_jpx = 0 +UI_jpy = 0 +UImenu "ent_jumppad" [ + uispace 0.008 0.015 [ + uivlist 0 [ + uifill 0.5 0.032 [ + uitext (concatword "^f8/newent jumppad " $UI_jph " " $UI_jpx " " $UI_jpy " ") 0.7 + uialign* -1 0 + uioutline $c_line ; uiclamp- 1 1 1 1 + ] + uifill 0 0.025 + uitable 0.005 0.005 [ + uitablerow [ + uitext "Height" 0.6 + UIhslider UI_jph -128 128 1 0.5 0.032 [uitext $UI_jph 0.6] + uialign* -1 0 + ] + uitablerow [ + uitext "X Lateral" 0.6 + UIhslider UI_jpx -127 127 1 0.5 0.032 [uitext $UI_jpx 0.6] + uialign* -1 0 + ] + uitablerow [ + uitext "Y Lateral" 0.6 + UIhslider UI_jpy -127 127 1 0.5 0.032 [uitext $UI_jpy 0.6] + uialign* -1 0 + ] + ] + uifill 0 0.025 + UIbutton "" [uitext "Add" 0.6] 0.12 0.06 [hideui "ent_jumppad" ; newent jumppad $UI_jph $UI_jpx $UI_jpy] + ] + ] +] [] [] [] "Add Entity - Jumppad" + +UImenu "ent_particles" [ + uispace 0.008 0.015 [ + uivlist 0 [ + uifill 0.5 0.032 [ + uitext (concatword "^f8/newent particles ") 0.7 + uialign* -1 0 + uioutline $c_line ; uiclamp- 1 1 1 1 + ] + uifill 0 0.025 + UIbutton "" [uitext "ToDo" 0.8] 0.3 0.2 [hidetopui] + ] + ] +] [] [] [] "Add Entity - Particles" + +UI_tid = 0 +UImenu "ent_teleport" [ + uispace 0.008 0.015 [ + uivlist 0 [ + uifill 0.5 0.032 [ + uitext (concatword "^f8/newent teleport " $UI_tid) 0.7 + uialign* -1 0 + uioutline $c_line ; uiclamp- 1 1 1 1 + ] + uifill 0 0.025 + uihlist 0.005 [ + uitext "ID#" 0.6 + UIhslider UI_tid 0 127 1 0.5 0.032 [uitext $UI_tid 0.6] + uialign* -1 0 + ] + uifill 0 0.025 + UIbutton "" [uitext "Add" 0.6] 0.12 0.06 [hideui "ent_teleport" ; newent teleport $UI_tid] + ] + ] +] [] [] [] "Add Entity - Teleport" +UImenu "ent_teledest" [ + uispace 0.008 0.015 [ + uivlist 0 [ + uifill 0.5 0.032 [ + uitext (concatword "^f8/newent teledest " $UI_tid) 0.7 + uialign* -1 0 + uioutline $c_line ; uiclamp- 1 1 1 1 + ] + uifill 0 0.025 + uihlist 0.005 [ + uitext "ID#" 0.6 + UIhslider UI_tid 0 127 1 0.5 0.032 [uitext $UI_tid 0.6] + uialign* -1 0 + ] + uifill 0 0.025 + UIbutton "" [uitext "Add" 0.6] 0.12 0.06 [hideui "ent_teledest" ; newent teledest $UI_tid] + ] + ] +] [] [] [] "Add Entity - Teledest" + +/////////////////////////////////////////////////////////////////////////////// +// F2 Texture Browser // +/////////////////////////////////////////////////////////////////////////////// +UI_textabs = 0 + +// uitarget 0 0 [ +// uiimage "media/interface/directory.png" 0.145 0.145 [uispace 0 0.008 [uialign 0 1 ; uiclip 0.145 0 [uitext "directory" 0.55]]] +// uihold [uioutline 0xC0C0C0; uiclamp- 1 1 1 1] [uihover [uioutline 0xFFFFFF; uiclamp- 1 1 1 1]] +// uirelease [hideui "texture_browser"] +// ] + +UImenu "texture_browser" [ + uihlist 0 [ + uifill 0 0 [ + uialign 0 -1 + uiclamp 1 1 1 1 + UIvtab 0.2 (*f 0.048 3) UI_textabs [ + 0 "Listed" [] // Listed Registered Cataloged + 1 "Utilized" [] // Used Utilized + 2 "Replace" [] + ] 1 + uialign- 0 -1 + UIbutton "hold2" [ + UIcheckbox $allfaces 0.016 + uitext "Allfaces" 0.6 + UI_keyref 2 0.027 0.027 "6" + ] 0.2 0.04 [allfaces (! $allfaces)] + uialign- 0 1 + ] + UIbar 0 1 + uifill 0.01 + case $UI_textabs 0 [//Listed///////////////////////////////////////////////////////////////// + uiscroll 1.202875 0.7495 [ + uifill 1.202875 0.7495 [ + uigrid 8 0.006125 0.006125 [ + loop slot (numslots) [ + uislotview $slot 0.145 0.145 [ + uihold [uioutline 0xC0C0C0; uiclamp- 1 1 1 1] [uihover [uioutline 0xFFFFFF; uiclamp- 1 1 1 1]] + uirelease [hideui "texture_browser"; settex (getslottex $slot)] + ] + ] + ] + uialign* -1 -1 + ] + ] + uifill 0.01 + UIvscroll 0.02 0.7495 3.0225 + ] 1 [//Utilized////////////////////////////////////////////////////////////////////////////// + uiscroll 1.202875 0.7495 [ + uifill 1.202875 0.7495 [ + uigrid 8 0.006125 0.006125 [ + looptexmru tex [ + uivslotview $tex 0.145 0.145 [ + uihold [uioutline 0xC0C0C0; uiclamp- 1 1 1 1] [uihover [uioutline 0xFFFFFF; uiclamp- 1 1 1 1]] + uirelease [hideui "texture_browser"; settex $tex] + ] + ] + ] + uialign* -1 -1 + ] + ] + uifill 0.01 + UIvscroll 0.02 0.7495 3.0225 + ] 2 [//Replace/////////////////////////////////////////////////////////////////////////////// + uifill 1.232875 0.7495 [ + UIbutton "" [uitext "ToDo" 0.8] 0.25 0.1 [hidetopui] + ] + ] + ] +] [] [] [] "Texture Browser" + +/////////////////////////////////////////////////////////////////////////////// +// F3 Mapmodel // +/////////////////////////////////////////////////////////////////////////////// +newui "mapmodel" [ + uialign -1 -1 + uieschide 0 + uicolor $c_menu_a 0 0 [ + uispace $UIwindow_padding $UIwindow_padding [ + uiclamp 1 1 1 1 + uihlist 0.01 [ + if 0 [ + UIvscroll 0.02 0.81 (*f (min (+ 1 (div $nummapmodels 100)) 10) 5.4) + ] [ + UIvscroll 0.02 0.81 (*f (min (+ 1 (div $nummapmodels 50)) 5) 2.7) + ] + uiscroll 0 0.81 [ + uivlist 0 [ + uigrid 2 0 0 [// (+ $_res_wide 1) + loop i $nummapmodels [ + uigroup [ + uimodelpreview (mapmodelname $i 1) "mapmodel" 0.12 0.135 [ + uihover [ + uihold [uioutline 0xFFFFFF] [ + uieschold [uioutline 0xFFFFFF] [ + uioutline 0x80FFFFFF + ] + ] + uiclamp* 1 1 1 1 + UI_selmdl = $i + uirelease [ + newent mapmodel $i + _io_mapmodel = 0 + ] + uiescrelease [ + if (enthavesel) [ + entset "mapmodel" $i + _io_mapmodel = 0 + ] + ] + ] [ + if (= $UI_selmdl $i) [ + uioutline 0x40FFFFFF + uiclamp- 1 1 1 1 + ] + ] + ] + uispace 0.01 0.006 [ + uialign -1 -1 + uicolortext $i 0x80FFFFFF 0.6 + ] + ] + ] + ] + ] + ] + ] + ] + uioutline $c_line ; uiclamp- 1 1 1 1 + ] + uiclamp* 1 1 1 1 +] [ + UI_selmdl = -1 + hideui "texture" + hideui "addentity" +] + +/////////////////////////////////////////////////////////////////////////////// +// F4 Material Volume // +/////////////////////////////////////////////////////////////////////////////// +UImenu "material" [ + uispace 0.008 0.015 [ + uivlist 0 [ + uifill 0.5 0.032 [ + uitext (concatword "^f8/" $UI_mattype) 0.7 + uialign* -1 0 + uioutline $c_line ; uiclamp- 1 1 1 1 + ] + uifill 0 0.025 + uihlist 0.005 [ + uivlist 0.005 [ + UIbutton "" [uitext "Air (Clear)" 0.6] 0.15 0.04 [editmat air] -1 [uihover [UI_mattype = "air"]] + UIbutton "" [uitext "Clip" 0.6] 0.15 0.04 [editmat clip] -1 [uihover [UI_mattype = "clip"]] + UIbutton "" [uitext "No-Clip" 0.6] 0.15 0.04 [editmat noclip] -1 [uihover [UI_mattype = "noclip"]] + UIbutton "" [uitext "Gameclip" 0.6] 0.15 0.04 [editmat gameclip] -1 [uihover [UI_mattype = "gameclip"]] + UIbutton "" [uitext "Death" 0.6] 0.15 0.04 [editmat death] -1 [uihover [UI_mattype = "death"]] + UIbutton "" [uitext "Alpha" 0.6] 0.15 0.04 [editmat alpha] -1 [uihover [UI_mattype = "alpha"]] + ] + uivlist 0.005 [ + UIbutton "" [uitext "Glass 1" 0.6] 0.15 0.04 [editmat glass] -1 [uihover [UI_mattype = "glass"]] + UIbutton "" [uitext "Glass 2" 0.6] 0.15 0.04 [editmat glass2] -1 [uihover [UI_mattype = "glass2"]] + UIbutton "" [uitext "Glass 3" 0.6] 0.15 0.04 [editmat glass3] -1 [uihover [UI_mattype = "glass3"]] + UIbutton "" [uitext "Glass 4" 0.6] 0.15 0.04 [editmat glass4] -1 [uihover [UI_mattype = "glass4"]] + ] + uivlist 0.005 [ + UIbutton "" [uitext "Lava 1" 0.6] 0.15 0.04 [editmat lava] -1 [uihover [UI_mattype = "lava"]] + UIbutton "" [uitext "Lava 2" 0.6] 0.15 0.04 [editmat lava2] -1 [uihover [UI_mattype = "lava2"]] + UIbutton "" [uitext "Lava 3" 0.6] 0.15 0.04 [editmat lava3] -1 [uihover [UI_mattype = "lava3"]] + UIbutton "" [uitext "Lava 4" 0.6] 0.15 0.04 [editmat lava4] -1 [uihover [UI_mattype = "lava4"]] + ] + uivlist 0.005 [ + UIbutton "" [uitext "Water 1" 0.6] 0.15 0.04 [editmat water] -1 [uihover [UI_mattype = "water"]] + UIbutton "" [uitext "Water 2" 0.6] 0.15 0.04 [editmat water2] -1 [uihover [UI_mattype = "water2"]] + UIbutton "" [uitext "Water 3" 0.6] 0.15 0.04 [editmat water3] -1 [uihover [UI_mattype = "water3"]] + UIbutton "" [uitext "Water 4" 0.6] 0.15 0.04 [editmat water4] -1 [uihover [UI_mattype = "water4"]] + ] + uialign* -1 -1 + ] + uifill 0 0.01 + UIbutton "hold2" [ + UIcheckbox $showmat 0.016 + uitext "Show Material Volumes" 0.6 + UI_keyref 2 0.027 0.027 "M" + ] 0.33 0.04 [showmat (! $showmat)] + ] + ] +] [UI_mattype = " "] [] [] "Material Volume" + +/////////////////////////////////////////////////////////////////////////////// +// F5 Save Map // +/////////////////////////////////////////////////////////////////////////////// +menu_savemap = [if (! $mapname) [toggleui "savemap"] [savemap]] +UI_mapname = "untitled" + +UImenu "savemap" [ + uispace 0.008 0.015 [ + uivlist 0 [ + uihlist 0.01 [ + uitext "^f8/savemap " 0.7 + uifield UI_mapname 32 [] 0.7 style_generic_focus + ] + uifill 0 0.025 + UIbutton "" [uitext "Save" 0.6] 0.12 0.06 [savemap $UI_mapname] + ] + ] +] [] [] [] "Save Map" + +/////////////////////////////////////////////////////////////////////////////// +// F6 Map Browser // +/////////////////////////////////////////////////////////////////////////////// +UI_mapscale = 10 +UI_maplist = 0 +dmmaps = [ + complex alphacorp ot turbine reflection +] +ctfmaps = [ + alphacorp steelribs test_ctf reflection waterworks +] +tdmmaps = (listunion $dmmaps $ctfmaps) +allmaps = (listunion $dmmaps $ctfmaps) +testmaps = [ + test_anim test_model +] +editmaps = (listunion $dmmaps $ctfmaps $testmaps) + +UImenu "map_browser" [ + uihlist 0.01 [ + uivlist 0 [ + uialign 0 -1 + UItitle [uiclip 0.3 0 [uitext $UI_selmap 0.7]] 0.3 0.03 + uimodcolor $c_boxmod 0.3 0.3 [ + uiclamp 1 1 1 1 + uiimage "media/interface/cube.png" 0.3 0.3 [uiimage (concatword "media/map/" $UI_selmap ".png") 0.3 0.3 [uiclamp 1 1 1 1]] + ] + uifill 0 0.015 + UItitle [uitext "List" 0.7] 0.3 0.03 + UIbutton "" [ + UIradio [= $UI_maplist 0] 0.016 + uitext "Tesseract" 0.6 + ] 0.3 0.03 [UI_maplist = 0 ; UI_selmap = ""] -1 + UIbutton "" [ + UIradio [= $UI_maplist 1] 0.016 + uitext "Custom" 0.6 + ] 0.3 0.03 [UI_maplist = 1 ; UI_selmap = ""] -1 + uifill 0.0 0.015 + UItitle [uitext "Gamemode" 0.7] 0.3 0.03 + uigrid 3 0 0 [ + nextmode = (getnextmode) + looplist2 n i [ + "Edit" 0 "rDM" 1 "pDM" 2 + "" -1 "rTDM" 3 "pTDM" 4 + "" -1 "rCTF" 5 "pCTF" 6 + ] [ + if (< $i 0) [ + uimodcolor $c_boxmod 0.1 0.03 + ] [ + UIbutton "" [ + UIradio [= $nextmode $i] 0.016 + uitext $n 0.6 + ] 0.1 0.03 [mode $i] -1 + ] + ] + ] + uifill 0.0 0.015 + if (issomeoneelsemaster) [ + if (ismaster $getclientnum) [ + UIbutton "" [uitext (concatword (? (= $isconnected 1) (? (! $editing) "^f4")) "New Map") 0.7] 0.3 0.05 [hideui "map_browser" ; showui "newmap"] + ] [ + UIbutton "" [uitext "^f4New Map" 0.65] 0.3 0.05 [] + ] + ] [ + UIbutton "" [uitext (concatword (? (= $isconnected 1) (? (! $editing) "^f4")) "New Map") 0.7] 0.3 0.05 [hideui "map_browser" ; showui "newmap"] + ] + ] + uiscroll 0.4 0.64 [ + uifill 0.37 0.64 + uivlist 0 [ + uialign 0 -1 + uiclamp 1 1 + if $UI_maplist [ + if (=s $custommaps "") [ + custommaps = " " + loopfiles m "media/map" "ogz" [ + if (< (indexof $editmaps $m) 0) [ + custommaps = (concat $custommaps (escape $m)) + ] + ] + ] + looplist m $custommaps [ + UIbutton (? (!=s $UI_selmap $m) "hold2") [ + uitext $m 0.6 + ] 0 0.04 [ + hideui "loadmap" + map $m + ] -1 [uihover [UI_selmap = $m]] + ] + ] [ + looplist m $(? (m_ctf $nextmode) "ctfmaps" (? (m_edit $nextmode) "editmaps" (? (m_teammode $nextmode) "tdmmaps" "dmmaps"))) [ + UIbutton (? (!=s $UI_selmap $m) "hold2") [ + uitext $m 0.6 + ] 0 0.04 [ + hideui "loadmap" + map $m + ] -1 [uihover [UI_selmap = $m]] + ] + ] + uiclamp* 1 1 + ] + ] + UIvscroll 0.02 0.64 1.6 + ] +] [ + UI_selmap = "" + custommaps = "" + hideui "newmap" +] [] [] "Map Browser" + +UImenu "newmap" [ + uispace 0.008 0.015 [ + uivlist 0 [ + uifill 0.5 0.032 [ + uitext (concatword "^f8/newmap " (? (!= $UI_mapscale 10) $UI_mapscale)) 0.7 + uialign* -1 0 + uioutline $c_line ; uiclamp- 1 1 1 1 + ] + uifill 0 0.025 + uihlist 0.01 [ + uitext "MapScale" 0.6 + UIhslider UI_mapscale 10 16 1 0.5 0.032 [uitext $UI_mapscale 0.6] + uialign* -1 0 + ] + uifill 0 0.025 + UIbutton "" [uitext (concatword (? (= $isconnected 1) (? (! $editing) "^f4")) "New") 0.6] 0.12 0.06 [hideui "newmap" ; newmap $UI_mapscale] + ] + ] +] [] [] [] "New Map" + +/////////////////////////////////////////////////////////////////////////////// +// F7 Environment Settings // +/////////////////////////////////////////////////////////////////////////////// +UI_envtabs = 0 + +UImenu "env_settings" [ + uihlist 0 [ + UIvtab 0.2 (*f 0.048 7) UI_envtabs [ + 0 "Lighting" [] + 1 "Sky" [] + 2 [@@(concatword (? (! $atmo) "^f4") "Dynamic-Sky")] [] + 3 "Fog" [] + 4 "Water" [] + 5 "Lava" [] + 6 "Glass" [] + ] 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 [ + uialign -1 -1 + case $UI_envtabs 0 [//Lighting////////////////////////////////////////////////////// + uitablerow [ + UIbutton "" [uitext "Lighting" 0.8] 0.25 0.1 [hidetopui] + ] + ] 1 [//Sky////////////////////////////////////////////////////////////////////////// + uitablerow [ + UIbutton "" [uitext "Sky" 0.8] 0.25 0.1 [hidetopui] + ] + ] 2 [//Dynamic-Sky////////////////////////////////////////////////////////////////// + uitablerow [ + UIbutton "" [uitext "Dynamic-Sky" 0.8] 0.25 0.1 [hidetopui] + ] + ] 3 [//Fog////////////////////////////////////////////////////////////////////////// + uitablerow [ + UIbutton "" [uitext "Fog" 0.8] 0.25 0.1 [hidetopui] + ] + ] 4 [//Water//////////////////////////////////////////////////////////////////////// + uitablerow [ + UIbutton "" [uitext "Water" 0.8] 0.25 0.1 [hidetopui] + ] + ] 5 [//Lava///////////////////////////////////////////////////////////////////////// + uitablerow [ + UIbutton "" [uitext "Lava" 0.8] 0.25 0.1 [hidetopui] + ] + ] 6 [//Glass//////////////////////////////////////////////////////////////////////// + uitablerow [ + UIbutton "" [uitext "Glass" 0.8] 0.25 0.1 [hidetopui] + ] + ] + ] + ] + ] + UIvscroll 0.02 0.6 1.421 0.5 + ] +] [] [] [] "Environment Settings" + +/////////////////////////////////////////////////////////////////////////////// +// F8 World Geometry Prefab // +/////////////////////////////////////////////////////////////////////////////// +UImenu "geo_prefab" [ + uifill 0.5 0.5 [ + UIbutton "" [uitext "ToDo" 0.8] 0.3 0.2 [hidetopui] + ] +] [] [] [] "World Geometry Prefab" + +/////////////////////////////////////////////////////////////////////////////// +// F9 Miscellaneous Editing // +/////////////////////////////////////////////////////////////////////////////// +UImenu "misc_editing" [ + uifill 0.5 0.5 [ + UIbutton "" [uitext "ToDo" 0.8] 0.3 0.2 [hidetopui] + ] +] [] [] [] "Miscellaneous Editing" + +/////////////////////////////////////////////////////////////////////////////// +// F10 Default Keybind Reference // +/////////////////////////////////////////////////////////////////////////////// +// UI_keyref 1:MODE(0=none,1=game,2=edit,3=move) 2:WIDTH(0=default) 3:HEIGHT(0=default) 4:NAME1 5:NAME2 6:TEXTSIZE(0=default) +// UI_keyref * 0.027 0.027 "*" (Key Reference) +UI_keyref = [ + if $arg2 [] [arg2 = 0.04] + if $arg3 [] [arg3 = 0.04] + if $arg6 [] [arg6 = 0.5] + uicolor (at [0x505050 0x496F37 0x2A707B 0x955524] $arg1) $arg2 $arg3 [ + if $arg5 [ + uivlist 0 [uitext $arg4 $arg6 ; uitext $arg5 $arg6] + ] [ + uitext $arg4 $arg6 + ] + ] +] + +UImenu "editbind_reference" [ + uispace 0.005 0.005 [ + uivlist 0 [ + uihlist 0 [ + uigrid 3 0 0 [ + looplist a [ + "^f9ESC" "^f4 = " "^f9Main ^f4(Menu)" + "^f8F1" "^f4 = " "^f8Add/Edit Entity ^f4(Menu)" + "^f8F2" "^f4 = " "^f8Texture List ^f4(Menu)" + "^f8F3" "^f4 = " "^f8Add Mapmodel ^f4(Menu)" + "^f8F4" "^f4 = " "^f8Material Volume ^f4(Menu)" + " " " " " " + "^f8F5" "^f4 = " "^f8Savemap ^f4(Menu)" + "^f9F6" "^f4 = " "^f9Loadmap ^f4(Menu)" + "^f8F7" "^f4 = " "^f8Environment Settings ^f4(Menu)" + "^f8F8" "^f4 = " "^f8World Geometry Prefab ^f4(Menu)" + " " " " " " + "^f8F9" "^f4 = " "^f8Miscellaneous Editing ^f4(Menu)" + "^f8F10" "^f4 = " "^f8Keybind Reference ^f4(Menu)" + "^f9F11" "^f4 = " "^f9Show Console" + "^f9F12" "^f4 = " "^f9Take Screenshot" + " " " " " " + "^f9Pause" "^f4 = " "^f9Pause Game" + " " " " " " + "^f8Delete" "^f4 = " "^f8Editdelete" + "^f8Home" "^f4 = " "^f8Goto selection" + "^f8End" "^f4 = " "^f8Goto selected entities" + " " " " "^f4(Hold & Mousewheel)" + "^f8PageUp" "^f4 = " "^f8Console scroll up" + "^f8PageDown" "^f4 = " "^f8Console scroll to end" + ] [uitext $a 0.42] + ] + uispace 0.01 0 [UIbar 0 1 ; uiclamp 1 1 1 1] + uigrid 3 0 0 [ + looplist a [ + "^f8`" "^f4 = " "^f8Saycommand" + "^f81" "^f4 = " "^f8Edit Entity Attribute 0" + " " " " "^f4(Hold & Mousewheel)" + "^f82" "^f4 = " "^f8Edit Entity Attribute 1" + " " " " "^f4(Hold & Mousewheel)" + "^f83" "^f4 = " "^f8Edit Entity Attribute 2" + " " " " "^f4(Hold & Mousewheel)" + "^f84" "^f4 = " "^f8Edit Entity Attribute 3" + " " " " "^f4(Hold & Mousewheel)" + "^f85" "^f4 = " "^f8Edit Entity Attribute 4" + " " " " "^f4(Hold & Mousewheel)" + "^f86" "^f4 = " "^f8Toggle texture allfaces" + "^f87" "^f4 = " "^f8Toggle entity snapping" + "^f88" "^f4 = " "^f8Toggle entity editing" + "^f89" "^f4 = " "^f8Edit selected entity in console" + "^f90" "^f4 = " "^f9Show Master Menu" + "^f8-" "^f4 = " "^f8Toggle outline" + "^f8=" "^f4 = " "^f8Toggle wireframe" + " " " " " " + "^f8Q" "^f4 = " "^f8Push geometry corner pointed at" + " " " " "^f4(Hold & Mousewheel)" + "^f9E" "^f4 = " "^f9Edittoggle" + "^f8R" "^f4 = " "^f8Rotate geometry/blend-brush" + " " " " "^f4(Hold & Mousewheel)" + "^f9T" "^f4 = " "^f9Chat" + "^f8Y" "^f4 = " "^f8Scroll through textures" + " " " " "^f4(Hold & Mousewheel)" + "^f8U" "^f4 = " "^f8Undo" + "^f8I" "^f4 = " "^f8Redo" + "^f8O" "^f4 = " "^f8Texture offset horizontal ^f4(vslot)" + " " " " "^f4(Hold & Mousewheel)" + "^f8P" "^f4 = " "^f8Texture offset vertical ^f4(vslot)" + " " " " "^f4(Hold & Mousewheel)" + ] [uitext $a 0.42] + ] + uispace 0.01 0 [UIbar 0 1 ; uiclamp 1 1 1 1] + uigrid 3 0 0 [ + looplist a [ + "^f8F" "^f4 = " "^f8Push face/corner selected" + " " " " "^f4(Hold & Mousewheel)" + "^f8G" "^f4 = " "^f8Change gridsize" + " " " " "^f4(Hold & Mousewheel)" + "^f8H" "^f4 = " "^f8Toggle heightmap mode" + "^f8K" "^f4 = " "^f8Calculate Lighting/Remip/Smoothing" + "^f8L" "^f4 = " "^f8Toggle fullbright" + " " " " " " + "^f8Z" "^f4 = " "^f8Repeat last saycommand" + "^f8X" "^f4 = " "^f8Mirror Selection" + "^f8C" "^f4 = " "^f8Copy Selection" + "^f8V" "^f4 = " "^f8Paste Selection" + "^f8B" "^f4 = " "^f8Change heightmap mode brush" + " " " " "^f4(Hold & Mousewheel)" + "^f8N" "^f4 = " "^f8Find all entities of selected type" + "^f8M" "^f4 = " "^f8Toggle show material volumes" + "^f8," "^f4 = " "^f8Rotate texture ^f4(vslot)" + " " " " "^f4(Hold & Mousewheel)" + "^f8." "^f4 = " "^f8Scale texture ^f4(vslot)" + " " " " "^f4(Hold & Mousewheel)" + " " " " " " + "^f9TAB" "^f4 = " "^f9Show scoreboard" + "^f8Left SHIFT" "^f4 = " "^f8Floatspeed 1000" + " " " " "^f4(Hold)" + "^f8Left CTRL" "^f4 = " "^f8Select passthrough" + "^f8Left ALT" "^f4 = " "^f8Edit entity x10" + " " " " "^f4(Hold with 1,2,3,4,5)" + "^f8SPACE" "^f4 = " "^f8Cancel Selection" + "^f8Right ALT" "^f4 = " "^f8Texture offset by 32px" + " " " " "^f4(Default 16px)" + " " " " "^f4(Hold with O or P)" + "^f9ENTER" "^f4 = " "^f9Chat" + ] [uitext $a 0.42] + ] + uispace 0.01 0 [UIbar 0 1 ; uiclamp 1 1 1 1] + uigrid 3 0 0 [ + looplist a [ + "^f8KP 0" "^f4 = " "^f8Exit paint blendmap" + "^f8KP 2" "^f4 = " "^f8Paint" + "^f8KP 5" "^f4 = " "^f8Erase" + "^f8KP 8" "^f4 = " "^f8Select blendbrush -" + "^f8KP 9" "^f4 = " "^f8Select blendbrush +" + "^f8KP +" "^f4 = " "^f8Toggle selection move/cut" + "^f8KP /" "^f4 = " "^f8Floatspeed 10" + "^f8KP *" "^f4 = " "^f8Floatspeed 50" + "^f8KP -" "^f4 = " "^f8Floatspeed 100" + "^f8KP ENTER" "^f4 = " "^f8Select entities within" + " " " " "^f8selection volume" + " " " " " " + "^f8Mouse Left" "^f4 = " "^f8Select geometry/entities" + "^f8Mouse Middle" "^f4 = " "^f8Select corners" + "^f8Mouse Right" "^f4 = " "^f8Select extend/move/cut" + "^f8Mouse Scroll" "^f4 = " "^f8Push Geometry" + "^f8Mouse Back" "^f4 = " "^f8Toggle selection move/cut" + "^f8Mouse Forward" "^f4 = " "^f8Toggle selection move/cut" + ] [uitext $a 0.42] + ] + uialign* -1 -1 + ] + uifill 0 0.01 + uivlist 0.003 [ + uihlist 0.003 [ + UI_keyref 1 0 0 "ESC" + uifill 0.03 0.04 + UI_keyref 2 0 0 "F1" + UI_keyref 2 0 0 "F2" + UI_keyref 2 0 0 "F3" + UI_keyref 2 0 0 "F4" + uifill 0.02 0.04 + UI_keyref 2 0 0 "F5" + UI_keyref 1 0 0 "F6" + UI_keyref 2 0 0 "F7" + UI_keyref 2 0 0 "F8" + uifill 0.02 0.04 + UI_keyref 2 0 0 "F9" + UI_keyref 2 0 0 "F10" + UI_keyref 1 0 0 "F11" + UI_keyref 1 0 0 "F12" + uifill 0.01 0.04 + UI_keyref 0 0 0 "Print" "Screen" 0.32 + UI_keyref 0 0 0 "Scroll" "Lock" 0.32 + UI_keyref 1 0 0 "Pause" "" 0.32 + ] + uifill 0 0.01 + uihlist 0.003 [ + UI_keyref 1 0 0 "`" + UI_keyref 2 0 0 "1" + UI_keyref 2 0 0 "2" + UI_keyref 2 0 0 "3" + UI_keyref 2 0 0 "4" + UI_keyref 2 0 0 "5" + UI_keyref 2 0 0 "6" + UI_keyref 2 0 0 "7" + UI_keyref 2 0 0 "8" + UI_keyref 2 0 0 "9" + UI_keyref 1 0 0 "0" + UI_keyref 2 0 0 "-" + UI_keyref 2 0 0 "=" + UI_keyref 0 0.076 0 "BACK" + uifill 0.01 0.04 + UI_keyref 0 0 0 "Insert" "" 0.32 + UI_keyref 2 0 0 "Home" "" 0.32 + UI_keyref 1 0 0 "Page" "Up" 0.32 + uifill 0.01 0.04 + UI_keyref 0 0 0 "Num" "Lock" 0.32 + UI_keyref 2 0 0 "/" + UI_keyref 2 0 0 "*" + UI_keyref 2 0 0 "-" + ] + uihlist 0.003 [ + UI_keyref 1 0.060 0 "TAB" + UI_keyref 2 0 0 "Q" + UI_keyref 3 0 0 "W" + UI_keyref 1 0 0 "E" + UI_keyref 2 0 0 "R" + UI_keyref 1 0 0 "T" + UI_keyref 2 0 0 "Y" + UI_keyref 2 0 0 "U" + UI_keyref 2 0 0 "I" + UI_keyref 2 0 0 "O" + UI_keyref 2 0 0 "P" + UI_keyref 0 0 0 "[" + UI_keyref 0 0 0 "]" + UI_keyref 0 0.056 0 "\" + uifill 0.01 0.04 + UI_keyref 2 0 0 "Delete" "" 0.32 + UI_keyref 2 0 0 "End" "" 0.32 + UI_keyref 1 0 0 "Page" "Down" 0.32 + uifill 0.01 0.04 + UI_keyref 0 0 0 "7" + UI_keyref 2 0 0 "8" + UI_keyref 2 0 0 "9" + UI_keyref 2 0 0 "+" + ] + uihlist 0.003 [ + UI_keyref 0 0.072 0 "CAPS" + UI_keyref 3 0 0 "A" + UI_keyref 3 0 0 "S" + UI_keyref 3 0 0 "D" + UI_keyref 2 0 0 "F" + UI_keyref 2 0 0 "G" + UI_keyref 2 0 0 "H" + UI_keyref 0 0 0 "J" + UI_keyref 2 0 0 "K" + UI_keyref 2 0 0 "L" + UI_keyref 0 0 0 ";" + UI_keyref 0 0 0 "'" + UI_keyref 1 0.087 0 "ENTER" + uifill 0.152 0.04 + UI_keyref 0 0 0 "4" + UI_keyref 2 0 0 "5" + UI_keyref 0 0 0 "6" + //UI_keyref 2 0 0 "+" + ] + uihlist 0.003 [ + UI_keyref 2 0.100 0 "L SHIFT" + UI_keyref 2 0 0 "Z" + UI_keyref 2 0 0 "X" + UI_keyref 2 0 0 "C" + UI_keyref 2 0 0 "V" + UI_keyref 2 0 0 "B" + UI_keyref 2 0 0 "N" + UI_keyref 2 0 0 "M" + UI_keyref 2 0 0 "," + UI_keyref 2 0 0 "." + UI_keyref 0 0 0 "/" + UI_keyref 0 0.102 0 "R SHIFT" + uifill 0.053 0.04 + uicolor 0x955524 0.04 0.04 [UItriangle 0 0.01 0.01 0] + uifill 0.053 0.04 + UI_keyref 0 0 0 "1" + UI_keyref 2 0 0 "2" + UI_keyref 0 0 0 "3" + UI_keyref 2 0 0 "ENTER" "" 0.32 + ] + uihlist 0.003 [ + UI_keyref 2 0.070 0 "LCTRL" + uifill 0.0585 0.04 + UI_keyref 2 0.060 0 "LALT" + UI_keyref 2 0.240 0 "SPACE" + UI_keyref 2 0.060 0 "RALT" + uifill 0.0585 0.04 + UI_keyref 0 0.070 0 "RCTRL" + uifill 0.01 0.04 + uicolor 0x955524 0.04 0.04 [UItriangle 0 0.01 0.01 90] + uicolor 0x955524 0.04 0.04 [UItriangle 0 0.01 0.01 180] + uicolor 0x955524 0.04 0.04 [UItriangle 0 0.01 0.01 270] + uifill 0.010 0.04 + UI_keyref 2 0.083 0 "0" + UI_keyref 0 0 0 "." + //UI_keyref 2 0 0 "ENTER" "" 0.32 + ] + uialign* -1 -1 + ] + ] + ] +] [] [] [] "Default Editbind Reference" + +UImenu "gamebind_reference" [ + uispace 0.005 0.005 [ + uivlist 0 [ + uihlist 0 [ + uigrid 3 0 0 [ + looplist a [ + "^f9ESC" "^f4 = " "^f9Main ^f4(Menu)" + " " " " " " + "^f9F6" "^f4 = " "^f9Loadmap ^f4(Menu)" + "^f9F10" "^f4 = " "^f9Keybind Reference ^f4(Menu)" + "^f9F11" "^f4 = " "^f9Show Console" + "^f9F12" "^f4 = " "^f9Take Screenshot" + " " " " " " + "^f9Pause" "^f4 = " "^f9Pause Game" + " " " " " " + "^f9PageUp" "^f4 = " "^f9Console scroll up" + "^f9PageDown" "^f4 = " "^f9Console scroll to end" + " " " " " " + "^f9TAB" "^f4 = " "^f9Show scoreboard" + "^f9Left SHIFT" "^f4 = " "^f9Crouch ^f4(Hold)" + "^f9Left CTRL" "^f4 = " "^f9Crouch ^f4(Hold)" + "^f9SPACE" "^f4 = " "^f9Jump" + "^f9ENTER" "^f4 = " "^f9Chat" + ] [uitext $a 0.42] + ] + uispace 0.01 0 [UIbar 0 1 ; uiclamp 1 1 1 1] + uigrid 3 0 0 [ + looplist a [ + "^f9`" "^f4 = " "^f9Saycommand" + "^f91" "^f4 = " "^f9Use Railgun" + "^f92" "^f4 = " "^f9Use Pulse Rifle" + "^f90" "^f4 = " "^f9Show Master Menu" + " " " " " " + "^f9E" "^f4 = " "^f9Edittoggle" + "^f9R" "^f4 = " "^f9Drop Flag" + "^f9T" "^f4 = " "^f9Chat" + "^f9Y" "^f4 = " "^f9Team Chat" + " " " " " " + "^f9F" "^f4 = " "^f9Melee attack" + " " " " " " + "^f9Z" "^f4 = " "^f9Toggle zoom" + ] [uitext $a 0.42] + ] + uispace 0.01 0 [UIbar 0 1 ; uiclamp 1 1 1 1] + uigrid 3 0 0 [ + looplist a [ + "^f9Mouse Left" "^f4 = " "^f9Attack" + "^f9Mouse Middle" "^f4 = " "^f9Melee" + "^f9Mouse Right" "^f4 = " "^f9Zoom" + " " " " " " + "^f9Mouse Scroll-Up" "^f4 = " "^f9Use Rocket" + "^f9Mouse Scroll-Down" "^f4 = " "^f9Use Rifle" + " " " " " " + "^f9Mouse Back" "^f4 = " "^f9Melee" + "^f9Mouse Forward" "^f4 = " "^f9Melee" + ] [uitext $a 0.42] + ] + uialign* -1 -1 + ] + uifill 0 0.01 + uivlist 0.003 [ + uihlist 0.003 [ + UI_keyref 1 0 0 "ESC" + uifill 0.03 0.04 + UI_keyref 1 0 0 "F1" + UI_keyref 0 0 0 "F2" + UI_keyref 0 0 0 "F3" + UI_keyref 0 0 0 "F4" + uifill 0.02 0.04 + UI_keyref 0 0 0 "F5" + UI_keyref 1 0 0 "F6" + UI_keyref 0 0 0 "F7" + UI_keyref 0 0 0 "F8" + uifill 0.02 0.04 + UI_keyref 0 0 0 "F9" + UI_keyref 1 0 0 "F10" + UI_keyref 1 0 0 "F11" + UI_keyref 1 0 0 "F12" + uifill 0.01 0.04 + UI_keyref 0 0 0 "Print" "Screen" 0.32 + UI_keyref 0 0 0 "Scroll" "Lock" 0.32 + UI_keyref 1 0 0 "Pause" "" 0.32 + ] + uifill 0 0.01 + uihlist 0.003 [ + UI_keyref 1 0 0 "`" + UI_keyref 1 0 0 "1" + UI_keyref 1 0 0 "2" + UI_keyref 0 0 0 "3" + UI_keyref 0 0 0 "4" + UI_keyref 0 0 0 "5" + UI_keyref 0 0 0 "6" + UI_keyref 0 0 0 "7" + UI_keyref 0 0 0 "8" + UI_keyref 0 0 0 "9" + UI_keyref 1 0 0 "0" + UI_keyref 0 0 0 "-" + UI_keyref 0 0 0 "=" + UI_keyref 0 0.076 0 "BACK" + uifill 0.01 0.04 + UI_keyref 0 0 0 "Insert" "" 0.32 + UI_keyref 0 0 0 "Home" "" 0.32 + UI_keyref 1 0 0 "Page" "Up" 0.32 + uifill 0.01 0.04 + UI_keyref 0 0 0 "Num" "Lock" 0.32 + UI_keyref 0 0 0 "/" + UI_keyref 0 0 0 "*" + UI_keyref 0 0 0 "-" + ] + uihlist 0.003 [ + UI_keyref 1 0.060 0 "TAB" + UI_keyref 0 0 0 "Q" + UI_keyref 3 0 0 "W" + UI_keyref 1 0 0 "E" + UI_keyref 1 0 0 "R" + UI_keyref 1 0 0 "T" + UI_keyref 1 0 0 "Y" + UI_keyref 0 0 0 "U" + UI_keyref 0 0 0 "I" + UI_keyref 0 0 0 "O" + UI_keyref 0 0 0 "P" + UI_keyref 0 0 0 "[" + UI_keyref 0 0 0 "]" + UI_keyref 0 0.056 0 "\" + uifill 0.01 0.04 + UI_keyref 0 0 0 "Delete" "" 0.32 + UI_keyref 0 0 0 "End" "" 0.32 + UI_keyref 1 0 0 "Page" "Down" 0.32 + uifill 0.01 0.04 + UI_keyref 0 0 0 "7" + UI_keyref 0 0 0 "8" + UI_keyref 0 0 0 "9" + UI_keyref 0 0 0 "+" + ] + uihlist 0.003 [ + UI_keyref 0 0.072 0 "CAPS" + UI_keyref 3 0 0 "A" + UI_keyref 3 0 0 "S" + UI_keyref 3 0 0 "D" + UI_keyref 1 0 0 "F" + UI_keyref 0 0 0 "G" + UI_keyref 0 0 0 "H" + UI_keyref 0 0 0 "J" + UI_keyref 0 0 0 "K" + UI_keyref 0 0 0 "L" + UI_keyref 0 0 0 ";" + UI_keyref 0 0 0 "'" + UI_keyref 1 0.087 0 "ENTER" + uifill 0.152 0.04 + UI_keyref 0 0 0 "4" + UI_keyref 0 0 0 "5" + UI_keyref 0 0 0 "6" + //UI_keyref 0 0 0 "+" + ] + uihlist 0.003 [ + UI_keyref 1 0.100 0 "L SHIFT" + UI_keyref 1 0 0 "Z" + UI_keyref 0 0 0 "X" + UI_keyref 0 0 0 "C" + UI_keyref 0 0 0 "V" + UI_keyref 0 0 0 "B" + UI_keyref 0 0 0 "N" + UI_keyref 0 0 0 "M" + UI_keyref 0 0 0 "," + UI_keyref 0 0 0 "." + UI_keyref 0 0 0 "/" + UI_keyref 0 0.102 0 "R SHIFT" + uifill 0.053 0.04 + uicolor 0x955524 0.04 0.04 [UItriangle 0 0.01 0.01 0] + uifill 0.053 0.04 + UI_keyref 0 0 0 "1" + UI_keyref 0 0 0 "2" + UI_keyref 0 0 0 "3" + UI_keyref 0 0 0 "ENTER" "" 0.32 + ] + uihlist 0.003 [ + UI_keyref 1 0.070 0 "LCTRL" + uifill 0.0585 0.04 + UI_keyref 0 0.060 0 "LALT" + UI_keyref 1 0.240 0 "SPACE" + UI_keyref 0 0.060 0 "RALT" + uifill 0.0585 0.04 + UI_keyref 0 0.070 0 "RCTRL" + uifill 0.01 0.04 + uicolor 0x955524 0.04 0.04 [UItriangle 0 0.01 0.01 90] + uicolor 0x955524 0.04 0.04 [UItriangle 0 0.01 0.01 180] + uicolor 0x955524 0.04 0.04 [UItriangle 0 0.01 0.01 270] + uifill 0.010 0.04 + UI_keyref 0 0.083 0 "0" + UI_keyref 0 0 0 "." + //UI_keyref 0 0 0 "ENTER" "" 0.32 + ] + uialign* -1 -1 + ] + ] + ] +] [] [] [] "Default Gamebind Reference" + +/////////////////////////////////////////////////////////////////////////////// +// F11 Fullscreen Console // +/////////////////////////////////////////////////////////////////////////////// +newui "fullconsole" [ + uiallowinput 0 + uiclamp 1 1 + uialign 0 -1 + uicolor $c_menu_a 0 0 [ + uispace $UIwindow_padding $UIwindow_padding [ + uiclamp 1 1 1 1 + uiconsole 0 (divf $fullconsize 100) [uiclamp 1 1] + ] + uiclamp- 1 1 1 1 + ] + uiclamp* 1 1 1 1 +] diff --git a/config/ui/lib.cfg b/config/ui/lib.cfg new file mode 100644 index 0000000..94faf78 --- /dev/null +++ b/config/ui/lib.cfg @@ -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: