Browse Source

tesseract: initial import r2181 (minus media)

Daniel Kolesa 8 months ago
parent
commit
9653df4566
100 changed files with 11403 additions and 0 deletions
  1. 83
    0
      README
  2. 101
    0
      bin_unix/readme.txt
  3. 47
    0
      config/blendbrush.cfg
  4. 192
    0
      config/default.cfg
  5. 78
    0
      config/default_map_models.cfg
  6. 181
    0
      config/default_map_settings.cfg
  7. 3
    0
      config/font.cfg
  8. 38
    0
      config/game.cfg
  9. 24
    0
      config/glsl.cfg
  10. 88
    0
      config/glsl/aa.cfg
  11. 285
    0
      config/glsl/ao.cfg
  12. 68
    0
      config/glsl/blur.cfg
  13. 289
    0
      config/glsl/decal.cfg
  14. 688
    0
      config/glsl/deferred.cfg
  15. 61
    0
      config/glsl/edit.cfg
  16. 375
    0
      config/glsl/fxaa.cfg
  17. 313
    0
      config/glsl/gi.cfg
  18. 60
    0
      config/glsl/grass.cfg
  19. 169
    0
      config/glsl/hud.cfg
  20. 490
    0
      config/glsl/material.cfg
  21. 180
    0
      config/glsl/misc.cfg
  22. 374
    0
      config/glsl/model.cfg
  23. 126
    0
      config/glsl/movie.cfg
  24. 176
    0
      config/glsl/particle.cfg
  25. 183
    0
      config/glsl/postfx.cfg
  26. 98
    0
      config/glsl/scale.cfg
  27. 178
    0
      config/glsl/shared.cfg
  28. 163
    0
      config/glsl/sky.cfg
  29. 623
    0
      config/glsl/smaa.cfg
  30. 75
    0
      config/glsl/stain.cfg
  31. 477
    0
      config/glsl/tonemap.cfg
  32. 68
    0
      config/glsl/ui.cfg
  33. 239
    0
      config/glsl/volumetric.cfg
  34. 651
    0
      config/glsl/world.cfg
  35. 140
    0
      config/heightmap.cfg
  36. 133
    0
      config/keymap.cfg
  37. 82
    0
      config/server-init.cfg
  38. 46
    0
      config/sound.cfg
  39. 241
    0
      config/stdedit.cfg
  40. 60
    0
      config/stdlib.cfg
  41. 577
    0
      config/ui.cfg
  42. 71
    0
      config/ui/edithud.cfg
  43. 1131
    0
      config/ui/fkey.cfg
  44. 328
    0
      config/ui/lib.cfg
  45. 595
    0
      config/ui/options.cfg
  46. 222
    0
      config/ui/scoreboard.cfg
  47. 203
    0
      config/ui/serverbrowser.cfg
  48. 153
    0
      config/ui/stats.cfg
  49. 177
    0
      config/ui/style.cfg
  50. BIN
      media/blendbrush/circle_128_hard.png
  51. BIN
      media/blendbrush/circle_128_soft.png
  52. BIN
      media/blendbrush/circle_128_solid.png
  53. BIN
      media/blendbrush/circle_16_hard.png
  54. BIN
      media/blendbrush/circle_16_soft.png
  55. BIN
      media/blendbrush/circle_16_solid.png
  56. BIN
      media/blendbrush/circle_256_hard.png
  57. BIN
      media/blendbrush/circle_256_soft.png
  58. BIN
      media/blendbrush/circle_256_solid.png
  59. BIN
      media/blendbrush/circle_32_hard.png
  60. BIN
      media/blendbrush/circle_32_soft.png
  61. BIN
      media/blendbrush/circle_32_solid.png
  62. BIN
      media/blendbrush/circle_64_hard.png
  63. BIN
      media/blendbrush/circle_64_soft.png
  64. BIN
      media/blendbrush/circle_64_solid.png
  65. BIN
      media/blendbrush/circle_8_hard.png
  66. BIN
      media/blendbrush/circle_8_soft.png
  67. BIN
      media/blendbrush/circle_8_solid.png
  68. BIN
      media/blendbrush/dot_1_hard.png
  69. BIN
      media/blendbrush/dot_1_soft.png
  70. BIN
      media/blendbrush/dot_1_solid.png
  71. BIN
      media/blendbrush/gradient_128.png
  72. BIN
      media/blendbrush/gradient_16.png
  73. BIN
      media/blendbrush/gradient_32.png
  74. BIN
      media/blendbrush/gradient_64.png
  75. BIN
      media/blendbrush/noise_1024_hard.png
  76. BIN
      media/blendbrush/noise_1024_soft.png
  77. BIN
      media/blendbrush/noise_128_hard.png
  78. BIN
      media/blendbrush/noise_128_soft.png
  79. BIN
      media/blendbrush/noise_256_hard.png
  80. BIN
      media/blendbrush/noise_256_soft.png
  81. BIN
      media/blendbrush/noise_512_hard.png
  82. BIN
      media/blendbrush/noise_512_soft.png
  83. BIN
      media/blendbrush/noise_64_hard.png
  84. BIN
      media/blendbrush/noise_64_soft.png
  85. BIN
      media/blendbrush/square_16_hard.png
  86. BIN
      media/blendbrush/square_16_solid.png
  87. BIN
      media/blendbrush/square_32_hard.png
  88. BIN
      media/blendbrush/square_32_solid.png
  89. BIN
      media/blendbrush/square_64_hard.png
  90. BIN
      media/blendbrush/square_64_solid.png
  91. BIN
      media/interface/background.png
  92. BIN
      media/interface/crosshair/circle_dot.png
  93. BIN
      media/interface/crosshair/circle_dot_hit.png
  94. BIN
      media/interface/crosshair/cross_normal.png
  95. BIN
      media/interface/crosshair/cross_normal_hit.png
  96. BIN
      media/interface/crosshair/cross_whole.png
  97. BIN
      media/interface/crosshair/cross_whole_hit.png
  98. BIN
      media/interface/crosshair/default.png
  99. BIN
      media/interface/crosshair/default_hit.png
  100. 0
    0
      media/interface/crosshair/dot.png

+ 83
- 0
README View File

@@ -0,0 +1,83 @@
1
+Tesseract is a fork of the Cube 2: Sauerbraten engine. The goal of Tesseract
2
+is to make mapping more fun by using modern dynamic rendering techniques, so
3
+that you can get instant feedback on lighting changes, not just geometry.
4
+
5
+No more long calclight pauses... just plop down the light, move it, change its
6
+color, or do whatever else with it. It all happens in real-time now.
7
+
8
+Tesseract removes the static lightmapping system of Sauerbraten and replaces
9
+it with completely dynamic lighting system based on deferred shading and
10
+shadowmapping.
11
+
12
+It provides a bunch of new rendering features such as:
13
+
14
+* deferred shading
15
+* omnidirectional point lights using cubemap shadowmaps
16
+* perspective projection spotlight shadowmaps
17
+* orthographic projection sunlight using cascaded shadowmaps
18
+* HDR rendering with tonemapping and bloom
19
+* real-time diffuse global illumination for sunlight (radiance hints)
20
+* volumetric lighting
21
+* screen-space ambient occlusion
22
+* screen-space reflections and refractions for water and glass (use as many water planes as you want now!)
23
+* screen-space refractive alpha cubes
24
+* deferred MSAA, subpixel morphological anti-aliasing (SMAA 1x, T2x, S2x, and 4x), FXAA, and temporal AA
25
+* runs on both OpenGL Core (3.0+) and legacy (2.0+) contexts
26
+
27
+Editing:
28
+
29
+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.
30
+
31
+To make cascaded shadowmapped sunlight, just use the normal sunlight commands:
32
+sunlight
33
+sunlightyaw
34
+sunlightpitch
35
+You can also set sunlightyaw and sunlightpitch from your current direction with the following command:
36
+getsundir
37
+
38
+You can control the diffuse global illumination of sunlight using the following parameters:
39
+giscale - scales the contribution of indirect light
40
+gidist - limits the distance which indirect light travels (smaller values are more intense, but higher values allow farther travel)
41
+giaoscale - controls the contribution of atmospheric light
42
+skylight - controls the color of atmospheric light
43
+
44
+Screen-space ambient occlusion affects mostly ambient light and to a lesser degree sunlight,
45
+but it does not affect point lights. If you want to make use of SSAO in your map, just use 
46
+the ambient command to set an appropriate ambient light color/intensity.
47
+
48
+To make refractive alpha cubes:
49
+First mark the cubes with the alpha material. Use valpha or texalpha to set the transparency level as normal.
50
+Then use either of the following commands:
51
+vrefract K [R G B]
52
+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.
53
+The direction of the distortion is taken from the normal-map of the texture.
54
+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.
55
+
56
+After editing operations your map may be full of small cubes and triangles, and you will notice that your map looks faceted.
57
+To fix this you still need to use the calclight command, however, it no longer generates lightmaps anymore.
58
+It just does a remip optimization pass as well as calculates smoothed normals to make things look better.
59
+Eventually this may be done differently using some sort of background optimization while editing.
60
+
61
+To make decals:
62
+
63
+newent decal SLOT YAW PITCH ROLL SIZE
64
+
65
+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.
66
+The slot refers to a decal slot in the map configuration, starting at offset 0.
67
+The size is specified in cube units.
68
+
69
+To make decal slots:
70
+
71
+decelreset // functions like texture reset, clears all decal texture slots
72
+
73
+setshader bumpspecmapdecal  // shaders work like for world shaders, but with the -decal suffix instead of -world
74
+texture decal "diffuse.png" // all decal slots start with the "decal" sub-slot instead of "0", and this texture must have an alpha-channel
75
+texture n "normals.png"
76
+texture s "spec.png"
77
+
78
+To make volumetric lights:
79
+
80
+Set attribute 5 of a light entity to 4.
81
+
82
+The intensity of the volumetric lighting medium can be controlled by volscale and the color can by controlled by volcolour.
83
+

+ 101
- 0
bin_unix/readme.txt View File

@@ -0,0 +1,101 @@
1
+* Installing and Running Tesseract
2
+
3
+*nix versions of Tesseract clients and standalone servers.
4
+The clients function identical to the win32 client, see config.html for more
5
+information about command-line options if necessary.
6
+
7
+Please run "tesseract_unix" from the root Tesseract dir (NOT from inside the "bin_unix"
8
+directory) to launch these, or set the TESS_DATA variable at the top of the "tesseract_unix" 
9
+script to an absolute path to allow it to be run from any location. Note that the "tesseract_unix" 
10
+script is set up to write any files (saved maps, configs, etc.) into the user's home 
11
+directory at "~/.tesseract".
12
+
13
+Clients will need the following dynamic link libraries present:
14
+* libGL (OpenGL)
15
+* SDL2 (>= 2.0.0)
16
+* SDL2_image
17
+* SDL2_mixer
18
+* libpng
19
+* libjpeg
20
+* zlib
21
+
22
+If native binaries for your platform are not included, then try the following:
23
+1) Ensure you have the DEVELOPMENT VERSIONS of the above libraries installed.
24
+2) Type "make -C src install".
25
+3) Re-run the "tesseract_unix" script if it succeeded.
26
+
27
+The servers (bin_unix/linux_server or bin_unix/native_server) should need no libs 
28
+other than libstdc++ and zlib. Note that for the server to see the "config/server-init.cfg", 
29
+it must be run from the root Tesseract directory. If you run a server with the 
30
+"tesseract_unix -d" command, this happens automatically. However, if you wish to 
31
+run the standalone servers instead, then you may need to write an appropriate wrapper 
32
+script to change to the appropriate data directory before running the standalone
33
+server binary, as described below in the packaging guide.
34
+
35
+
36
+
37
+
38
+
39
+* Packaging Guide for Unix-like Operating System Developers/Maintainers
40
+
41
+If you are packaging Tesseract up for redistribution in a Linux distribution or other 
42
+similar OS, please avoid using the "tesseract_unix" script in its default/unmodified form.
43
+You should at least set the TESS_DATA variable to appropriately find the common Tesseract
44
+data files, or better yet replace it with a more appropriate way of starting Tesseract using
45
+the script as a basis. If the distribution happens to place program binaries in a specific
46
+directory separate from data files, such as "/usr/bin", then much of the lines within the script
47
+that deal with finding an appropriate binary can be removed, as they only exist to help people
48
+running from the original Tesseract tarball. An example run script is shown further
49
+below.
50
+
51
+Also, please note, that if your distribution chooses to package the binaries and game data
52
+as separate packages due to whatever licensing rules or cross-architecture package sharing, 
53
+that client binaries from newer Tesseract editions are NOT compatible with older versions of 
54
+game data, on whole, nor obviously compatible with newer versions of game data. Game data, as a 
55
+whole, and client binaries are only roughly compatible within individual Tesseract editions,
56
+though patches to individual Tesseract editions generally always retain compatibility with
57
+the game data.
58
+
59
+For those writing custom Tesseract run scripts for packaging, they should adhere to the following
60
+guidelines:
61
+
62
+Tesseract finds all game files relative to the current directory from which Tesseract is run, 
63
+so any script running Tesseract should set its current directory to where the Tesseract data 
64
+files are located before it runs the Tesseract client binaries. No silly symlinking tricks should 
65
+be at all necessary.
66
+
67
+When running the Tesseract client, one command-line switch should ALWAYS be supplied to
68
+the client binary. This is "-u${HOME}/.tesseract", which will instruct Tesseract to
69
+write any user private files such as saved maps and configurations to a private ".tesseract" 
70
+directory within each user's home directory. Tesseract will automatically create this
71
+directory and any subdirectories for each user running it, so do not pre-create this directory 
72
+or install any symlinks within it - as some Linux distribution packages have erroneously done. 
73
+All command-line switches supplied to the Tesseract run script should be passed to the 
74
+Tesseract client after the "-u${HOME}/.tesseract" switch.
75
+
76
+A simple script such as the following (with directory/file names set as appropriate) would 
77
+ultimately suffice for the client:
78
+
79
+#!/bin/sh
80
+TESS_DATA=/usr/share/games/tesseract
81
+TESS_BIN=/usr/bin/tesseract_client
82
+TESS_OPTIONS="-u${HOME}/.tesseract"
83
+
84
+cd ${TESS_DATA}
85
+exec ${TESS_BIN} ${TESS_OPTIONS} "$@"
86
+
87
+A simple script for the server, which assumes a global default "config/server-init.cfg" in TESS_DATA,
88
+but allows per-user overriding via the home directory, might be:
89
+
90
+#!/bin/sh
91
+TESS_DATA=/usr/share/games/tesseract
92
+TESS_SERV_BIN=/usr/bin/tesseract_server
93
+TESS_SERV_OPTIONS="-u${HOME}/.tesseract"
94
+
95
+cd ${TESS_DATA}
96
+exec ${TESS_SERV_BIN} ${TESS_SERV_OPTIONS} "$@"
97
+
98
+With respect to libraries, make sure that you do not link Tesseract against any other ENet package
99
+than the one that comes included with the Tesseract, as it may be different from the official ENet
100
+releases and might fail to compile or communicate properly.
101
+

+ 47
- 0
config/blendbrush.cfg View File

@@ -0,0 +1,47 @@
1
+///////////////////////////////////////////////////////////////////////////////
2
+//  Texture-Blending Brush List                                              //
3
+///////////////////////////////////////////////////////////////////////////////
4
+
5
+looplist2 n p [
6
+   "Dot 1px Soft"       dot_1_soft
7
+   "Dot 1px Hard"       dot_1_hard
8
+   "Dot 1px Solid"      dot_1_solid
9
+   "Circle 8px Soft"    circle_8_soft
10
+   "Circle 8px Hard"    circle_8_hard
11
+   "Circle 8px Solid"   circle_8_solid
12
+   "Circle 16px Soft"   circle_16_soft
13
+   "Circle 16px Hard"   circle_16_hard
14
+   "Circle 16px Solid"  circle_16_solid
15
+   "Circle 32px Soft"   circle_32_soft
16
+   "Circle 32px Hard"   circle_32_hard
17
+   "Circle 32px Solid"  circle_32_solid
18
+   "Circle 64px Soft"   circle_64_soft
19
+   "Circle 64px Hard"   circle_64_hard
20
+   "Circle 64px Solid"  circle_64_solid
21
+   "Circle 128px Soft"  circle_128_soft
22
+   "Circle 128px Hard"  circle_128_hard
23
+   "Circle 128px Solid" circle_128_solid
24
+   "Circle 256px Soft"  circle_256_soft
25
+   "Circle 256px Hard"  circle_256_hard
26
+   "Circle 256px Solid" circle_256_solid
27
+   "Noise 64px Soft"    noise_64_soft
28
+   "Noise 64px Hard"    noise_64_hard
29
+   "Noise 128px Soft"   noise_128_soft
30
+   "Noise 128px Hard"   noise_128_hard
31
+   "Noise 256px Soft"   noise_256_soft
32
+   "Noise 256px Hard"   noise_256_hard
33
+   "Noise 512px Soft"   noise_512_soft
34
+   "Noise 512px Hard"   noise_512_hard
35
+   "Noise 1024px Soft"  noise_1024_soft
36
+   "Noise 1024px Hard"  noise_1024_hard
37
+   "Square 16px Hard"   square_16_hard
38
+   "Square 16px Solid"  square_16_solid
39
+   "Square 32px Hard"   square_32_hard
40
+   "Square 32px Solid"  square_32_solid
41
+   "Square 64px Hard"   square_64_hard
42
+   "Square 64px Solid"  square_64_solid
43
+   "Gradient 16px"      gradient_16
44
+   "Gradient 32px"      gradient_32
45
+   "Gradient 64px"      gradient_64
46
+   "Gradient 128px"     gradient_128
47
+] [addblendbrush $n (concatword "media/blendbrush/" $p ".png")]

+ 192
- 0
config/default.cfg View File

@@ -0,0 +1,192 @@
1
+// These default settings are executed whenever "saved.cfg" is not available.
2
+// Do not modify anything below, instead change settings in game, or add to autoexec.cfg
3
+
4
+///////////////////////////////////////////////////////////////////////////////
5
+//  Settings                                                                 //
6
+///////////////////////////////////////////////////////////////////////////////
7
+name "unnamed"
8
+
9
+///////////////////////////////////////////////////////////////////////////////
10
+//  Console                                                                  //
11
+///////////////////////////////////////////////////////////////////////////////
12
+miniconfilter 0x300                 // display chat and team chat in mini-console
13
+confilter (&~ 0xFFF $miniconfilter) // don't display other player frags or mini-console stuff in console
14
+
15
+
16
+///////////////////////////////////////////////////////////////////////////////
17
+//  Universal Mouse Scrollwheel                                              //
18
+///////////////////////////////////////////////////////////////////////////////
19
+ums_modifier    = 0
20
+ums_setmodifier = [ums_modifier = $arg1; onrelease [ums_modifier = 0]]
21
+ums_delta       = [[ums_delta_@(? $editing "edit" "game")_@ums_modifier] $arg1]
22
+
23
+bind "MOUSEWHEELUP"   [ums_delta  1]
24
+bind "MOUSEWHEELDOWN" [ums_delta -1]
25
+
26
+
27
+///////////////////////////////////////////////////////////////////////////////
28
+//  Game Binds                                                               //
29
+///////////////////////////////////////////////////////////////////////////////
30
+bind "MOUSELEFT"    [shoot]
31
+bind "MOUSERIGHT"   [dozoom]
32
+bind "MOUSEMIDDLE"  [melee]
33
+bind "MOUSEBACK"    [melee]
34
+bind "MOUSEFORWARD" [melee]
35
+
36
+// Movement
37
+bind "W"     [forward]
38
+bind "A"     [left]
39
+bind "S"     [backward]
40
+bind "D"     [right]
41
+bind "UP"    [forward]
42
+bind "DOWN"  [backward]
43
+bind "RIGHT" [right]
44
+bind "LEFT"  [left]
45
+
46
+bind    "F6"  [toggleui "map_browser"]
47
+bindvar "F8"  [hidehud]
48
+bind    "F10" [toggleui "gamebind_reference"]
49
+bind    "F11" [toggleconsole; conskip -1000]
50
+bind    "F12" [screenshot]
51
+
52
+bindvarquiet "PAUSE" [paused]
53
+
54
+bind "INSERT"   [addbot]
55
+bind "DELETE"   [delbot]
56
+bind "PAGEUP"   [conskip 5]
57
+bind "PAGEDOWN" [conskip -1000]
58
+
59
+bind "BACKQUOTE" [saycommand /]
60
+bind "SLASH"     [saycommand /]
61
+bind "TAB"       [holdui scoreboard]
62
+bind "LSHIFT"    [crouch]
63
+bind "LCTRL"     [crouch]
64
+bind "SPACE"     [jump]
65
+bind "RETURN"    [saycommand]
66
+
67
+bind "E" [edittoggle]
68
+bind "F" [melee]
69
+bind "J" [taunt]
70
+bind "R" [dropflag]
71
+bind "T" [saycommand]
72
+bind "Y" [sayteamcommand]
73
+
74
+bind    "1" [setweapon rail]
75
+bind    "2" [setweapon pulse]
76
+bindvar "9" [thirdperson]
77
+bind    "0" [menu_master]
78
+
79
+// Console scroll -or- Weapon change
80
+ums_delta_game_0 = [if $fullconsole [conskip (* $arg1 3)] [nextweapon $arg1]]
81
+
82
+
83
+///////////////////////////////////////////////////////////////////////////////
84
+//  Specatator Binds                                                         //
85
+///////////////////////////////////////////////////////////////////////////////
86
+specbind "MOUSELEFT"   [nextfollow]
87
+specbind "MOUSERIGHT"  [nextfollow -1]
88
+specbind "MOUSEMIDDLE" [nextspecmode]
89
+specbind "SPACE"       [nextspecmode]
90
+specbind "LSHIFT"      [floatspeed 1000;onrelease [floatspeed 100]]
91
+specbind "LCTRL"       [floatspeed 25;onrelease [floatspeed 100]]
92
+
93
+
94
+///////////////////////////////////////////////////////////////////////////////
95
+//  Edit Binds                                                               //
96
+///////////////////////////////////////////////////////////////////////////////
97
+editbind "MOUSELEFT"    [if $blendpaintmode [paintblendmap] [editdrag]]
98
+editbind "MOUSEMIDDLE"  [selcorners]
99
+editbind "MOUSERIGHT"   [if $blendpaintmode [rotateblendbrush] [editextend]]
100
+editbind "MOUSEBACK"    [toggleeditmovecut]
101
+editbind "MOUSEFORWARD" [toggleeditmovecut]
102
+
103
+editbind    "LSHIFT" [floatspeed $editfloatspeed; onrelease [floatspeed 100]]
104
+editbind    "COMMA"  [ums_setmodifier 9]  // vSlot: rotate
105
+editbind    "PERIOD" [ums_setmodifier 10] // vSlot: scale
106
+editbindmod "LCTRL"  [passthrough]
107
+editbind    "SPACE"  [cancelsel]
108
+
109
+editbind "DELETE" [editdel]
110
+editbind "HOME"   [gotosel]
111
+editbind "END"    [ums_setmodifier 16; onrelease entautoview] // Hold and scroll to goto selected entities
112
+
113
+editbind    "1"      [ums_setmodifier 11] // Entity attribute modifier 0
114
+editbind    "2"      [ums_setmodifier 12] // Entity attribute modifier 1
115
+editbind    "3"      [ums_setmodifier 13] // Entity attribute modifier 2
116
+editbind    "4"      [ums_setmodifier 14] // Entity attribute modifier 3
117
+editbind    "5"      [ums_setmodifier 15] // Entity attribute modifier 4
118
+editbindvar "6"      [allfaces]
119
+editbindvar "7"      [entselsnap]
120
+editbindvar "8"      [entediting]
121
+editbind    "9"      [selentedit]
122
+editbindvar "MINUS"  [outline]
123
+editbindvar "EQUALS" [wireframe]
124
+
125
+// Editing Menus
126
+editbind "F1"  [menu_entity]                   // Add/Edit Entity
127
+editbind "F2"  [toggleui "texture_browser"]    // Texture List
128
+editbind "F3"  [toggleui "mapmodel"]           // Add Mapmodel
129
+editbind "F4"  [toggleui "material"]           // Edit Material
130
+editbind "F5"  [menu_savemap]                  // Savemap
131
+editbind "F7"  [toggleui "env_settings"]       // Environment Settings
132
+editbind "F8"  [toggleui "geo_prefab"]         // World Geometry Prefab
133
+editbind "F9"  [toggleui "misc_editing"]       // Miscellaneous Editing
134
+editbind "F10" [toggleui "editbind_reference"] // Default Editbind Quick Reference
135
+
136
+// Number Keypad
137
+editbind "KP0"         [blendpaintmode 0]  // Exit paint blendmap mode
138
+editbind "KP1"         [blendpaintmode 1]
139
+editbind "KP2"         [blendpaintmode 2]  // Paint
140
+editbind "KP3"         [blendpaintmode 3]
141
+editbind "KP4"         [blendpaintmode 4]
142
+editbind "KP5"         [blendpaintmode 5]  // Erase
143
+editbind "KP8"         [nextblendbrush -1] // Select brush -
144
+editbind "KP9"         [nextblendbrush  1] // Select brush +
145
+editbind "KP_DIVIDE"   [floatspeed  10; echo [floatspeed @floatspeed]]
146
+editbind "KP_MULTIPLY" [floatspeed  50; echo [floatspeed @floatspeed]]
147
+editbind "KP_MINUS"    [floatspeed 100; echo [floatspeed @floatspeed]]
148
+editbind "KP_PLUS"     [toggleeditmovecut] // Toggle MOUSERIGHT to move selection with or without contents
149
+editbind "KP_ENTER"    [entselect insel]   // Select entities within area selection
150
+
151
+editbind    "B" [ums_setmodifier 6] // Change heightmap brush
152
+editbind    "C" [editcopy]
153
+editbind    "F" [ums_setmodifier 2] // Push face/corners selected
154
+editbind    "G" [ums_setmodifier 1] // Grid size
155
+editbind    "H" [if $hmapedit [editface 1 -1] [hmapedit 1]]
156
+editbind    "I" [redo]
157
+editbind    "K" [calclight]
158
+editbindvar "L" [fullbright]
159
+editbindvar "M" [showmat]
160
+editbind    "N" [selentfindall]
161
+editbind    "O" [ums_setmodifier 7] // vSlot: offset H
162
+editbind    "P" [ums_setmodifier 8] // vSlot: offset V
163
+editbind    "Q" [ums_setmodifier 3] // Push corner pointed at by cursor
164
+editbind    "R" [ums_setmodifier 4] // Geometry rotate -or- blend brush rotate
165
+editbind    "U" [undo; passthroughsel 0]
166
+editbind    "V" [editpaste]
167
+editbind    "X" [editflip]          // Geometry flip
168
+editbind    "Y" [ums_setmodifier 5] // Change textures
169
+editbind    "Z" [history 0]         // Repeat last saycommand
170
+
171
+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
172
+ums_delta_edit_1  = [nodebug [gridpower (+ $arg1 $gridpower)]]                       // Grid size
173
+ums_delta_edit_2  = [editfacewsel $arg1 0]                                           // Push face/corners selected
174
+ums_delta_edit_3  = [editfacewsel $arg1 2]                                           // Push corner pointed at by cursor
175
+ums_delta_edit_4  = [if $blendpaintmode [rotateblendbrush $arg1] [editrotate $arg1]] // Geometry rotate -or- blend brush rotate
176
+ums_delta_edit_5  = [edittex $arg1]                                                  // Change textures
177
+ums_delta_edit_6  = [selecthbrush $arg1]                                             // Change heightmap brush
178
+ums_delta_edit_7  = [vdelta [voffset (* $arg1 $delta_multiplier2) 0]]               // vSlot: offset H
179
+ums_delta_edit_8  = [vdelta [voffset 0 (* $arg1 $delta_multiplier2)]]               // vSlot: offset V
180
+ums_delta_edit_9  = [vdelta [vrotate $arg1]]                                         // vSlot: rotate
181
+ums_delta_edit_10 = [vdelta [vscale (if (< $arg1 0) 0.5 2)]]                         // vSlot: scale
182
+ums_delta_edit_11 = [entproperty 0 (* $arg1 $delta_multiplier1)]
183
+ums_delta_edit_12 = [entproperty 1 (* $arg1 $delta_multiplier1)]
184
+ums_delta_edit_13 = [entproperty 2 (* $arg1 $delta_multiplier1)]
185
+ums_delta_edit_14 = [entproperty 3 (* $arg1 $delta_multiplier1)]
186
+ums_delta_edit_15 = [entproperty 4 (* $arg1 $delta_multiplier1)]
187
+ums_delta_edit_16 = [entautoview $arg1]
188
+
189
+editbind "LALT" [delta_multiplier1 = 10;onrelease [delta_multiplier1 = 1]]  // Entity attribute multiplier
190
+editbind "RALT" [delta_multiplier2 = 32;onrelease [delta_multiplier2 = 16]] // vSlot: offset multiplier
191
+delta_multiplier1 = 1
192
+delta_multiplier2 = 16

+ 78
- 0
config/default_map_models.cfg View File

@@ -0,0 +1,78 @@
1
+// Notice: This list is dynamic and will change with every release.
2
+//         Please use a dedicated map.cfg.
3
+
4
+mapmodelreset
5
+   mapmodel "obj_cube"
6
+   mapmodel "obj_sphere"
7
+
8
+   // Nieb/Complex
9
+   mapmodel "nieb/complex/bench/2"
10
+   mapmodel "nieb/complex/bench/3"
11
+   mapmodel "nieb/complex/box_copy-paper"
12
+   mapmodel "nieb/complex/box_large/label_0"
13
+   mapmodel "nieb/complex/box_large/label_a"
14
+   mapmodel "nieb/complex/box_large/label_b"
15
+   mapmodel "nieb/complex/box_small/label_0"
16
+   mapmodel "nieb/complex/box_small/label_a"
17
+   mapmodel "nieb/complex/box_small/label_b"
18
+   mapmodel "nieb/complex/box_small-open/label_0"
19
+   mapmodel "nieb/complex/box_small-open/label_a"
20
+   mapmodel "nieb/complex/box_small-open/label_b"
21
+   mapmodel "nieb/complex/chair_office"
22
+   mapmodel "nieb/complex/clock_wall"
23
+   mapmodel "nieb/complex/coffee_cup"
24
+   mapmodel "nieb/complex/computer_case_v/off"
25
+   mapmodel "nieb/complex/computer_case_v/on"
26
+   mapmodel "nieb/complex/computer_keyboard"
27
+   mapmodel "nieb/complex/computer_monitor"
28
+   mapmodel "nieb/complex/computer_mouse"
29
+   mapmodel "nieb/complex/cooling_fan"
30
+   mapmodel "nieb/complex/copy-machine"
31
+   mapmodel "nieb/complex/desk"
32
+   mapmodel "nieb/complex/desk/flip"
33
+   mapmodel "nieb/complex/door"
34
+   mapmodel "nieb/complex/door/flip"
35
+   mapmodel "nieb/complex/drinking_fountain"
36
+   mapmodel "nieb/complex/filing_cab1"
37
+   mapmodel "nieb/complex/filing_cab2"
38
+   mapmodel "nieb/complex/fire_alarm"
39
+   mapmodel "nieb/complex/fire_extinguisher"
40
+   mapmodel "nieb/complex/fire_sprinkler"
41
+   mapmodel "nieb/complex/garbage_bin"
42
+   mapmodel "nieb/complex/garbage_can"
43
+   mapmodel "nieb/complex/light_fluorescent/on"
44
+   mapmodel "nieb/complex/light_fluorescent/off"
45
+   mapmodel "nieb/complex/locker01"
46
+   mapmodel "nieb/complex/locker02"
47
+   mapmodel "nieb/complex/mop_bucket"
48
+   mapmodel "nieb/complex/pallet_lift"
49
+   mapmodel "nieb/complex/phone"
50
+   mapmodel "nieb/complex/picture/1"
51
+   mapmodel "nieb/complex/picture/2"
52
+   mapmodel "nieb/complex/picture/3"
53
+   mapmodel "nieb/complex/projector"
54
+   mapmodel "nieb/complex/projector_screen"
55
+   mapmodel "nieb/complex/safety_post"
56
+   mapmodel "nieb/complex/server_rack/1"
57
+   mapmodel "nieb/complex/server_rack/2"
58
+   mapmodel "nieb/complex/server_rack/3"
59
+   mapmodel "nieb/complex/shelf_storage"
60
+   mapmodel "nieb/complex/signage/1"
61
+   mapmodel "nieb/complex/signage/2"
62
+   mapmodel "nieb/complex/signage/3"
63
+   mapmodel "nieb/complex/sign_caution"
64
+   mapmodel "nieb/complex/sign_drinking"
65
+   mapmodel "nieb/complex/sign_exit"
66
+   mapmodel "nieb/complex/sign_fire_extinguisher"
67
+   mapmodel "nieb/complex/sign_restroom/f"
68
+   mapmodel "nieb/complex/sign_restroom/m"
69
+   mapmodel "nieb/complex/sign_room/conference"
70
+   mapmodel "nieb/complex/sign_room/office"
71
+   mapmodel "nieb/complex/sign_room/server"
72
+   mapmodel "nieb/complex/storage_tote"
73
+   mapmodel "nieb/complex/white_board"
74
+
75
+   // Nobiax
76
+   mapmodel "nobiax/cardboardbox1"
77
+   mapmodel "nobiax/gaz_tank"
78
+   mapmodel "nobiax/pallet2"

+ 181
- 0
config/default_map_settings.cfg View File

@@ -0,0 +1,181 @@
1
+// Notice: This list is dynamic and will change with every release.
2
+//         Please use a dedicated map.cfg.
3
+
4
+exec "config/default_map_models.cfg"  // Default Mapmodel List
5
+
6
+// Default Sky/Light Settings
7
+setdefaultenv = [
8
+   skybox ""
9
+   atmo 1
10
+   sunlightpitch 50
11
+   sunlightyaw 30
12
+   sunlight 0xFFF8E0
13
+   skylight 0x7495B8
14
+]
15
+
16
+if $emptymap [setdefaultenv]
17
+
18
+materialreset
19
+loop+ i 1 4 [
20
+   texture [glass@i] "mat_glass/nieb/scratch2.png"          // Glass Normals
21
+   texture [water@i] "mat_water/nieb/water.png"             // Water (Unused)
22
+   texture 1         "mat_water/appleflap/water_normal.png" // Water Normals
23
+   texture 1         "mat_water/nieb/waterfall.png"         // Waterfall Diffuse
24
+   texture 1         "mat_water/nieb/waterfall_normal.png"  // Waterfall Normals
25
+   texture [lava@i]  "mat_lava/nieb/lava.png"               // Lava Diffuse
26
+   texture 1         "mat_lava/nieb/lava_normal.png"        // Lava Normals
27
+   texture 1         "mat_lava/nieb/lava.png"               // Lavafall Diffuse
28
+   texture 1         "mat_lava/nieb/lava_normal.png"        // Lavafall Normals
29
+]
30
+
31
+decalreset
32
+   decalload "nieb/complex/loadingbay"
33
+
34
+texturereset            // Start world texture list
35
+   texsky               // Dummy "sky" texture
36
+   texload "base/base1" // Default geometry texture
37
+   texload "base/base2"
38
+   texload "base/base3"
39
+   texload "base/base4"
40
+   texload "base/white"
41
+   texload "base/glow"
42
+
43
+   // Nieb/Complex
44
+   texload "nieb/complex/door_rail"
45
+   texload "nieb/complex/door_rail"; texrotate 1
46
+   texload "nieb/complex/electrical-outlet"
47
+   texload "nieb/complex/glass_2"
48
+   texload "nieb/complex/glass_subtle"
49
+   texload "nieb/complex/light-switch"
50
+   texload "nieb/complex/light01_off"
51
+   texload "nieb/complex/light01_on"
52
+   texload "nieb/complex/step01"
53
+   texload "nieb/complex/step01"; texrotate 1
54
+   texload "nieb/complex/step02"
55
+   texload "nieb/complex/step02"; texrotate 1
56
+   texload "nieb/complex/step03"
57
+   texload "nieb/complex/step03"; texrotate 1
58
+   texload "nieb/complex/tile01"
59
+   texload "nieb/complex/tile02"
60
+   texload "nieb/complex/vent"
61
+   texload "nieb/complex/wall01"
62
+   texload "nieb/complex/woodfloor01"
63
+   texload "nieb/complex/woodfloor02"
64
+   texload "nieb/complex/woodfloor03"
65
+
66
+   // CGTextures
67
+   texload "cgtextures/buildingshighrise0290"
68
+   texload "cgtextures/buildingshighrise0341"
69
+   texload "cgtextures/buildingshighrise0436"
70
+   texload "cgtextures/carpet01"
71
+   texload "cgtextures/ceilingtile01"
72
+   texload "cgtextures/tilesplain0119"
73
+   texload "cgtextures/tilesplain0119"; texrotate 1
74
+
75
+   // AGF81
76
+   texload "agf81/concrete1"
77
+   texload "agf81/concrete1w"
78
+   texload "agf81/concrete2"
79
+   texload "agf81/concrete2"; texrotate 1
80
+   texload "agf81/concrete3"
81
+   texload "agf81/concrete3"; texrotate 1
82
+   texload "agf81/concrete4"
83
+   texload "agf81/concrete5"
84
+   texload "agf81/door_texture_2"
85
+   texload "agf81/metal_a2"
86
+
87
+   // Nobiax
88
+   texload "nobiax/pattern019"
89
+   texload "nobiax/pattern037"
90
+   texload "nobiax/pattern042"
91
+   texload "nobiax/pattern044"
92
+   texload "nobiax/pattern045"
93
+   texload "nobiax/pattern047"
94
+   texload "nobiax/pattern055"
95
+   texload "nobiax/pattern056"
96
+   texload "nobiax/pattern057"
97
+   texload "nobiax/pattern205"
98
+   texload "nobiax/pattern208"
99
+
100
+   // philipk2
101
+
102
+   texload "philipk2/pk02_ceiling03"
103
+   texload "philipk2/pk02_door01"
104
+   texload "philipk2/pk02_door02"
105
+   texload "philipk2/pk02_door03"
106
+   texload "philipk2/pk02_floor01"
107
+   texload "philipk2/pk02_floor02"
108
+   texload "philipk2/pk02_floor03"
109
+   texload "philipk2/pk02_floor04"
110
+   texload "philipk2/pk02_floor05"
111
+   texload "philipk2/pk02_floor06a"
112
+   texload "philipk2/pk02_floor06b"
113
+   texload "philipk2/pk02_floor07"
114
+   texload "philipk2/pk02_floor08a"
115
+   texload "philipk2/pk02_floor08b"
116
+   texload "philipk2/pk02_floor09a"
117
+   texload "philipk2/pk02_floor09b"
118
+   texload "philipk2/pk02_floor10"
119
+   texload "philipk2/pk02_floor11"
120
+   texload "philipk2/pk02_floor12a"
121
+   texload "philipk2/pk02_floor12b"
122
+   texload "philipk2/pk02_floor13a"
123
+   texload "philipk2/pk02_floor13b"
124
+   texload "philipk2/pk02_floor_cyl01"
125
+   texload "philipk2/pk02_floor_cyl02"
126
+   texload "philipk2/pk02_generic01a"
127
+   texload "philipk2/pk02_generic01b"
128
+   texload "philipk2/pk02_light01a"
129
+   texload "philipk2/pk02_light01b"
130
+   texload "philipk2/pk02_panels01a"
131
+   texload "philipk2/pk02_panels01b"
132
+   texload "philipk2/pk02_panels01c"
133
+   texload "philipk2/pk02_plates01a"
134
+   texload "philipk2/pk02_plates01b"
135
+   texload "philipk2/pk02_rock01"
136
+   texload "philipk2/pk02_sand01"
137
+   texload "philipk2/pk02_switches01a"
138
+   texload "philipk2/pk02_trim01"
139
+   texload "philipk2/pk02_trim02"
140
+   texload "philipk2/pk02_trim03"
141
+   texload "philipk2/pk02_trim04a"
142
+   texload "philipk2/pk02_trim04b"
143
+   texload "philipk2/pk02_trim_set01a"
144
+   texload "philipk2/pk02_trim_set01b"
145
+   texload "philipk2/pk02_trim_set02a"
146
+   texload "philipk2/pk02_trim_set02b"
147
+   texload "philipk2/pk02_wall01"
148
+   texload "philipk2/pk02_wall03a"
149
+   texload "philipk2/pk02_wall03b"
150
+   texload "philipk2/pk02_wall04a"
151
+   texload "philipk2/pk02_wall04b"
152
+   texload "philipk2/pk02_wall05a"
153
+   texload "philipk2/pk02_wall05b"
154
+   texload "philipk2/pk02_wall05c"
155
+   texload "philipk2/pk02_wall06a"
156
+   texload "philipk2/pk02_wall06b"
157
+   texload "philipk2/pk02_wall07a"
158
+   texload "philipk2/pk02_wall07b"
159
+   texload "philipk2/pk02_wall_big01a"
160
+   texload "philipk2/pk02_wall_big01b"
161
+   texload "philipk2/pk02_wall_big02a"
162
+   texload "philipk2/pk02_wall_big02b"
163
+   texload "philipk2/pk02_wall08a"
164
+   texload "philipk2/pk02_wall08b"
165
+   texload "philipk2/pk02_ceiling02"
166
+   texload "philipk2/pk02_computer01a"
167
+   texload "philipk2/pk02_computer01b"
168
+   texload "philipk2/pk02_computer01c"
169
+   texload "philipk2/pk02_light02a"
170
+   texload "philipk2/pk02_light02b"
171
+   texload "philipk2/pk02_light02c"
172
+   texload "philipk2/pk02_light02"
173
+   texload "philipk2/pk02_light03"
174
+   texload "philipk2/pk02_pipes01"
175
+   texload "philipk2/pk02_switches01b"
176
+   texload "philipk2/pk02_switches01c"
177
+   texload "philipk2/pk02_wall02a"
178
+   texload "philipk2/pk02_wall02b"
179
+   texload "philipk2/pk02_wall02c"
180
+
181
+   setshader "stdworld"

+ 3
- 0
config/font.cfg View File

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

+ 38
- 0
config/game.cfg View File

@@ -0,0 +1,38 @@
1
+// Game specific config stuff goes here
2
+
3
+// Scoreboard Options
4
+defvarp showscore     0 1 1
5
+defvarp showkills     0 1 1
6
+defvarp showdeaths    0 0 1
7
+defvarp showip        0 0 1
8
+defvarp sbtransparent 0 1 1
9
+
10
+nextspecmode = [
11
+   if $specmode [
12
+      specmode (mod (+ $specmode 1) 3)
13
+   ] [
14
+      specmode (? (>= (getfollow) 0) 2 1)
15
+   ]
16
+]
17
+
18
+defvarp zoomtoggle 0 0 1
19
+dozoom = [if $zoomtoggle [zoom (? $zoom -1 1)] [zoom 1 ; onrelease [zoom -1]]]
20
+
21
+sayteamcommand = [inputcommand $arg1 [sayteam $commandbuf] "[team]"]
22
+
23
+mapcomplete = [complete $arg1 media/map ogz]
24
+mapcomplete map
25
+
26
+modenames = "edit rdm pdm rtdm ptdm rctf pctf"
27
+
28
+loop i (listlen $modenames) [
29
+   mname = (at $modenames $i)
30
+   alias $mname [if (mode @i) [if (> $numargs 0) [map $arg1] [map]]]
31
+   mapcomplete $mname
32
+]
33
+
34
+demo = [stopdemo; if (mode -1) [map $arg1]]
35
+complete demo . dmo
36
+
37
+allowedittoggle = [result 1]
38
+

+ 24
- 0
config/glsl.cfg View File

@@ -0,0 +1,24 @@
1
+exec "config/glsl/shared.cfg"
2
+exec "config/glsl/misc.cfg"
3
+exec "config/glsl/hud.cfg"
4
+exec "config/glsl/world.cfg"
5
+exec "config/glsl/decal.cfg"
6
+exec "config/glsl/grass.cfg"
7
+exec "config/glsl/model.cfg"
8
+exec "config/glsl/ao.cfg"
9
+exec "config/glsl/gi.cfg"
10
+exec "config/glsl/particle.cfg"
11
+exec "config/glsl/stain.cfg"
12
+exec "config/glsl/material.cfg"
13
+exec "config/glsl/deferred.cfg"
14
+exec "config/glsl/tonemap.cfg"
15
+exec "config/glsl/volumetric.cfg"
16
+exec "config/glsl/sky.cfg"
17
+exec "config/glsl/aa.cfg"
18
+exec "config/glsl/scale.cfg"
19
+exec "config/glsl/blur.cfg"
20
+exec "config/glsl/ui.cfg"
21
+exec "config/glsl/postfx.cfg"
22
+exec "config/glsl/edit.cfg"
23
+exec "config/glsl/movie.cfg"
24
+

+ 88
- 0
config/glsl/aa.cfg View File

@@ -0,0 +1,88 @@
1
+////////////////////////////////////////////////
2
+//
3
+// anti-aliasing
4
+//
5
+////////////////////////////////////////////////
6
+
7
+lazyshader 0 "tqaaresolve" [
8
+    attribute vec4 vvertex;
9
+    @(screentexcoord 0)
10
+    varying vec2 texcoord0;
11
+    @(? $tqaaresolvegather [
12
+        varying vec2 texcoord1;
13
+    ])
14
+    void main(void)
15
+    {
16
+        gl_Position = vvertex;
17
+        texcoord0 = vtexcoord0; 
18
+        @(? $tqaaresolvegather [
19
+            texcoord1 = vtexcoord0 - 0.5;
20
+        ])
21
+    }
22
+] [
23
+    @(gfetchdefs tex2)
24
+    uniform vec4 quincunx;
25
+    uniform sampler2DRect tex0, tex1;
26
+    uniform mat4 reprojectmatrix;
27
+    uniform vec2 maxvelocity;
28
+    uniform vec2 colorweight;
29
+    varying vec2 texcoord0;
30
+    @(? $tqaaresolvegather [
31
+        varying vec2 texcoord1;
32
+    ])
33
+    fragdata(0) vec4 fragcolor;
34
+    void main(void)
35
+    {
36
+        @(gdepthunpack depth [gfetch(tex2, texcoord0)] [
37
+            vec4 prevtc = reprojectmatrix * vec4(depth*texcoord0, depth, 1.0);
38
+        ] [
39
+            vec4 prevtc = reprojectmatrix * vec4(texcoord0, depth, 1.0);
40
+        ])
41
+
42
+        vec2 vel = prevtc.xy/prevtc.w - texcoord0;
43
+        float scale = clamp(maxvelocity.x*inversesqrt(dot(vel, vel) + 1e-6), 0.0, 1.0);
44
+
45
+        float mask = 1.0 - texture2DRect(tex0, texcoord0 + quincunx.xy).a;
46
+        vec4 color = texture2DRect(tex0, texcoord0 + mask*quincunx.xy); 
47
+        vec4 prevcolor = texture2DRect(tex1, texcoord0 + mask*(quincunx.zw + vel*scale));
48
+
49
+        @(? $tqaaresolvegather [
50
+            vec4 l0 = textureGather(tex0, texcoord1, 1);
51
+            vec4 l1 = textureGatherOffset(tex0, texcoord1, ivec2(1, 1), 1);
52
+            float l2 = texture2DRectOffset(tex0, texcoord0, ivec2(1, -1)).g;
53
+            float l3 = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 1)).g;
54
+            vec4 l01min = min(l0, l1), l01max = max(l0, l1);
55
+            l01min.xy = min(l01min.xy, l01min.zw);
56
+            l01max.xy = max(l01max.xy, l01max.zw);
57
+            float lmin = min(min(l01min.x, l01min.y), min(l2, l3));
58
+            float lmax = max(max(l01max.x, l01max.y), max(l2, l3));
59
+        ] [
60
+            float l0 = texture2DRect(tex0, texcoord0 + vec2(-1.0, -0.5)).g;
61
+            float l1 = texture2DRect(tex0, texcoord0 + vec2( 0.5, -1.0)).g;
62
+            float l2 = texture2DRect(tex0, texcoord0 + vec2( 1.0,  0.5)).g;
63
+            float l3 = texture2DRect(tex0, texcoord0 + vec2(-0.5,  1.0)).g;
64
+            float lmin = min(color.g, min(min(l0, l1), min(l2, l3)));
65
+            float lmax = max(color.g, max(max(l0, l1), max(l2, l3)));
66
+        ])
67
+
68
+        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);
69
+        weight *= clamp(1.0 - 2.0*(prevcolor.a - color.a), 0.0, 1.0);
70
+        fragcolor.rgb = mix(color.rgb, prevcolor.rgb, weight);
71
+        fragcolor.a = color.a;
72
+    }
73
+]
74
+
75
+smaaopt = [ >= (strstr $smaaopts $arg1) 0 ]
76
+smaashaders = [
77
+    smaapreset = $arg1   
78
+    smaaopts = $arg2
79
+    exec "config/glsl/smaa.cfg"
80
+]
81
+
82
+fxaaopt = [ >= (strstr $fxaaopts $arg1) 0 ]
83
+fxaashaders = [
84
+    fxaapreset = $arg1
85
+    fxaaopts = $arg2
86
+    exec "config/glsl/fxaa.cfg"
87
+]
88
+

+ 285
- 0
config/glsl/ao.cfg View File

@@ -0,0 +1,285 @@
1
+////////////////////////////////////////////////
2
+//
3
+// ambient obscurance
4
+//
5
+////////////////////////////////////////////////
6
+
7
+aotapoffsets = [
8
+"-0.933103, 0.025116"
9
+"-0.432784, -0.989868"
10
+"0.432416, -0.413800"
11
+"-0.117770, 0.970336"
12
+"0.837276, 0.531114"
13
+"-0.184912, 0.200232"
14
+"-0.955748, 0.815118"
15
+"0.946166, -0.998596"
16
+"-0.897519, -0.581102"
17
+"0.979248, -0.046602"
18
+"-0.155736, -0.488204"
19
+"0.460310, 0.982178"
20
+]
21
+
22
+ambientobscurancevariantshader = [
23
+    lineardepth = (>= (strstr $arg2 "l") 0)
24
+    packeddepth = (>= (strstr $arg2 "p") 0)
25
+    derivnormal = (>= (strstr $arg2 "d") 0)
26
+    maxaotaps = $arg3 
27
+    shader 0 $arg1 [
28
+        attribute vec4 vvertex;
29
+        @(screentexcoord 0)
30
+        @(screentexcoord 1)
31
+        varying vec2 texcoord0, texcoord1;
32
+        void main(void)
33
+        {
34
+            gl_Position = vvertex;
35
+            texcoord0 = vtexcoord0; 
36
+            texcoord1 = vtexcoord1;
37
+        }
38
+    ] [
39
+        @(gfetchdefs tex0 (&& $msaasamples [! $lineardepth]) gdepthfetch)
40
+        @(gfetchdefs tex1 $msaasamples gnormfetch)
41
+        @(gdepthunpackparams)
42
+        uniform sampler2D tex2;
43
+        uniform vec3 tapparams;
44
+        uniform vec2 contrastparams;
45
+        uniform vec4 offsetscale;
46
+        uniform float prefilterdepth;
47
+        @(? (! $derivnormal) [
48
+            uniform mat3 normalmatrix;
49
+        ])
50
+        @(? $lineardepth [
51
+            #define depthtc gl_FragCoord.xy
52
+        ] [
53
+            #define depthtc texcoord0
54
+        ])
55
+        uniform vec3 gdepthpackparams;
56
+        varying vec2 texcoord0, texcoord1;
57
+        fragdata(0) vec4 fragcolor;
58
+        void main(void)
59
+        {
60
+            @(if (&& $derivnormal [= $aodepthformat 1]) [result [
61
+                @(gdepthunpack depth [gnormfetch(tex1, texcoord0)] [
62
+                    vec2 tapscale = tapparams.xy/depth;
63
+                ] [
64
+                    float w = depth*gdepthscale.y + gdepthscale.z;
65
+                    depth = gdepthscale.x/w;
66
+                    vec2 tapscale = tapparams.xy*w;
67
+                ])
68
+            ]] [result [
69
+                @(gdepthunpack depth [gdepthfetch(tex0, depthtc)] [
70
+                    vec2 tapscale = tapparams.xy/depth;
71
+                ] [
72
+                    float w = depth*gdepthscale.y + gdepthscale.z;
73
+                    depth = gdepthscale.x/w;
74
+                    vec2 tapscale = tapparams.xy*w;
75
+                ] $lineardepth (? $lineardepth (! $aodepthformat) (= $gdepthformat 1)) packdepth)
76
+            ]])
77
+            vec2 dpos = depthtc*offsetscale.xy + offsetscale.zw, pos = depth*dpos;
78
+            @(if $derivnormal [result [
79
+                vec2 ddepth = vec2(dFdx(depth), dFdy(depth)); 
80
+                ddepth *= step(abs(ddepth), vec2(4.0));
81
+                vec3 normal;
82
+                normal.xy = (depth+ddepth.yx)*offsetscale.yx;
83
+                normal.z = normal.x*normal.y;
84
+                normal.xy *= -ddepth;
85
+                normal.z -= dot(dpos, normal.xy);
86
+                normal = normalize(normal);
87
+            ]] [result [
88
+                vec3 normal = gnormfetch(tex1, texcoord0).rgb*2.0 - 1.0;
89
+                float normscale = inversesqrt(dot(normal, normal));
90
+                normal *= normscale > 0.75 ? normscale : 0.0;
91
+                normal = normalmatrix * normal;
92
+            ]])
93
+            vec2 noise = texture2D(tex2, texcoord1).rg*2.0-1.0;
94
+            float obscure = 0.0;
95
+            @(loopconcat i $maxaotaps [result [
96
+                vec2 offset@[i] = reflect(vec2(@(at $aotapoffsets $i)), noise);
97
+                offset@[i] = depthtc + tapscale * offset@[i];
98
+                @(gdepthunpack [depth@[i]] [gdepthfetch(tex0, offset@[i])] [] [] $lineardepth (&& $lineardepth (! $aodepthformat)))
99
+                vec3 v@[i] = vec3(depth@[i]*(offset@[i]*offsetscale.xy + offsetscale.zw) - pos, depth@[i] - depth);
100
+                float dist2@[i] = dot(v@[i], v@[i]);
101
+                obscure += step(dist2@[i], tapparams.z) * max(0.0, dot(v@[i], normal) + depth*1.0e-2) / (dist2@[i] + 1.0e-5);
102
+            ]])
103
+            obscure = pow(clamp(1.0 - contrastparams.x*obscure, 0.0, 1.0), contrastparams.y);
104
+            @(if $derivnormal [result [
105
+                vec2 weights = step(abs(ddepth), vec2(prefilterdepth)) * (2.0*fract((gl_FragCoord.xy - 0.5)*0.5) - 0.5);
106
+            ]] [result [
107
+                vec2 weights = step(fwidth(depth), prefilterdepth) * (2.0*fract((gl_FragCoord.xy - 0.5)*0.5) - 0.5);
108
+            ]])
109
+            obscure -= dFdx(obscure) * weights.x;
110
+            obscure -= dFdy(obscure) * weights.y;
111
+            @(if $packeddepth [
112
+                if $aodepthformat [result [
113
+                    fragcolor.rg = vec2(obscure, depth);
114
+                ]] [result [
115
+                    @(if (&& (! $lineardepth) (!= $gdepthformat 1)) [gpackdepth packdepth depth])
116
+                    fragcolor = vec4(packdepth, obscure);
117
+                ]]
118
+            ] [result [
119
+                fragcolor = vec4(obscure, 0.0, 0.0, 1.0);
120
+            ]])
121
+        }
122
+    ]
123
+]
124
+
125
+ambientobscuranceshader = [
126
+    ambientobscurancevariantshader (format "ambientobscurance%1%2" $arg1 $arg2) $arg1 $arg2
127
+]
128
+
129
+shader 0 "linearizedepth" [
130
+    attribute vec4 vvertex;
131
+    @(screentexcoord 0)
132
+    varying vec2 texcoord0;
133
+    void main(void)
134
+    {
135
+        gl_Position = vvertex;
136
+        texcoord0 = vtexcoord0; 
137
+    }
138
+] [
139
+    @(gfetchdefs tex0 $msaasamples)
140
+    uniform vec3 gdepthpackparams;
141
+    varying vec2 texcoord0;
142
+    fragdata(0) vec4 fragcolor;
143
+    void main(void)
144
+    {
145
+        @(if (! $aodepthformat) [
146
+            if (= $gdepthformat 1) [result [
147
+                fragcolor = gfetch(tex0, texcoord0);
148
+            ]] [result [
149
+                @(gdepthunpack depth [gfetch(tex0, texcoord0)])
150
+                @(gpackdepth packdepth depth)
151
+                fragcolor = vec4(packdepth, 1.0);
152
+            ]]
153
+        ] [result [
154
+            @(gdepthunpack depth [gfetch(tex0, texcoord0)])
155
+            fragcolor.r = depth;
156
+        ]])
157
+    }
158
+]
159
+
160
+bilateralvariantshader = [
161
+    linear = (>= (strstr $arg2 "l") 0)
162
+    packed = (>= (strstr $arg2 "p") 0)
163
+    upscaled = (>= (strstr $arg2 "u") 0)
164
+    numtaps = $arg3
165
+    reduced = $arg4
166
+    filterdir = $arg5
167
+    shader 0 $arg1 [
168
+        attribute vec4 vvertex;
169
+        @(if $reduced [result [
170
+            @(screentexcoord 0)
171
+            varying vec2 texcoord0;
172
+        ]])
173
+        @(if $upscaled [result [
174
+            @(screentexcoord 1)
175
+            varying vec2 texcoord1;
176
+        ]])
177
+        void main(void)
178
+        {
179
+            gl_Position = vvertex;
180
+            @(? $reduced [texcoord0 = vtexcoord0;])
181
+            @(? $upscaled [texcoord1 = vtexcoord1;])
182
+        }
183
+    ] [
184
+        @(gfetchdefs tex1 (&& $msaasamples [! $linear]))
185
+        uniform sampler2DRect tex0;
186
+        uniform vec2 bilateralparams;
187
+        uniform vec3 gdepthpackparams;
188
+        @(? $reduced [varying vec2 texcoord0;])
189
+        @(? $upscaled [varying vec2 texcoord1;])
190
+        fragdata(0) vec4 fragcolor;
191
+        void main(void)
192
+        {
193
+            #define tc @(? $upscaled [texcoord1] [gl_FragCoord.xy])
194
+            #define depthtc @(? $reduced [texcoord0] [gl_FragCoord.xy])
195
+            #define tapvec(type, i) @(? (=s $filterdir "x") [type(i, 0.0)] [type(0.0, i)])
196
+            #define texval(i) texture2DRect(tex0, tc + tapvec(vec2, i))
197
+            #define texvaloffset(i) texture2DRectOffset(tex0, tc, tapvec(ivec2, i))
198
+            #define depthval(i) gfetch(tex1, depthtc + tapvec(vec2, i))
199
+            #define depthvaloffset(i) gfetchoffset(tex1, depthtc, tapvec(ivec2, i))
200
+            @(cond [$packed] [
201
+                if $aodepthformat [result [
202
+                    vec2 vals = texture2DRect(tex0, tc).rg;
203
+                    #define color vals.x
204
+                    @(if $upscaled [gdepthunpack depth [gfetch(tex1, depthtc)]] [result [
205
+                        #define depth vals.y
206
+                    ]])
207
+                ]] [result [
208
+                    vec4 vals = texture2DRect(tex0, tc);
209
+                    #define color vals.a
210
+                    @(if $upscaled [gdepthunpack depth [gfetch(tex1, depthtc)]] [result [
211
+                        float depth = dot(vals.rgb, gdepthunpackparams);
212
+                    ]])
213
+                ]]
214
+            ] [$linear] [result [
215
+                float color = gfetch(tex0, tc).r;
216
+                @(if $aodepthformat [result [
217
+                    float depth = gfetch(tex1, depthtc).r;
218
+                ]] [result [
219
+                    float depth = dot(gfetch(tex1, depthtc).rgb, gdepthunpackparams);
220
+                ]])
221
+            ]] [result [
222
+                float color = texture2DRect(tex0, tc).r;
223
+                @(gdepthunpack depth [gfetch(tex1, depthtc)])
224
+            ]])
225
+            float weights = 1.0;
226
+            @(loopconcat i (* 2 $numtaps) [
227
+                curtap = (- $i $numtaps)
228
+                if (>= $curtap 0) [curtap = (+ $curtap 1)]
229
+                curtapoffset = (* $curtap 2)
230
+                curdepthoffset = (<< $curtapoffset $reduced)
231
+                curtexval = [texval@(? (<= $mintexrectoffset $curtapoffset $maxtexrectoffset) "offset")(@(+f $curtapoffset))]
232
+                curdepthval = [depthval@(? (<= $mintexrectoffset $curdepthoffset $maxtexrectoffset) "offset")(@(+f $curdepthoffset))]
233
+                result [
234
+                    @(cond [$packed] [
235
+                        if $aodepthformat [result [
236
+                            vec2 vals@[i] = @[curtexval].rg;
237
+                            #define color@[i] vals@[i].x
238
+                            #define depth@[i] vals@[i].y
239
+                        ]] [result [
240
+                            vec4 vals@[i] = @[curtexval];
241
+                            #define color@[i] vals@[i].a
242
+                            float depth@[i] = dot(vals@[i].rgb, gdepthunpackparams);                 
243
+                        ]]
244
+                    ] [$linear] [
245
+                        result [
246
+                            float color@[i] = @[curtexval].r;
247
+                            @(if $aodepthformat [result [
248
+                                float depth@[i] = @[curdepthval].r;
249
+                            ]] [result [
250
+                                float depth@[i] = dot(@[curdepthval].rgb, gdepthunpackparams);
251
+                            ]])
252
+                        ]
253
+                    ] [
254
+                        result [
255
+                            float color@[i] = @[curtexval].r;
256
+                            @(gdepthunpack [depth@[i]] $curdepthval)
257
+                        ]
258
+                    ])
259
+                    depth@[i] -= depth;
260
+                    float weight@[i] = exp2(@(-f 0 (* $curtap $curtap))*bilateralparams.x - depth@[i]*depth@[i]*bilateralparams.y); 
261
+                    weights += weight@[i];
262
+                    color += weight@[i] * color@[i];
263
+                ]
264
+            ])
265
+            @(if (&& (=s $filterdir "x") $packed) [
266
+                if $aodepthformat [result [
267
+                    fragcolor.rg = vec2(color / weights, depth);
268
+                ]] [result [
269
+                    @(if $upscaled [gpackdepth packdepth depth] [result [
270
+                        #define packdepth vals.rgb
271
+                    ]])
272
+                    fragcolor = vec4(packdepth, color / weights);
273
+                ]]
274
+            ] [result [
275
+                fragcolor = vec4(color / weights, 0.0, 0.0, 1.0);
276
+            ]])
277
+        }
278
+    ]
279
+]
280
+
281
+bilateralshader = [
282
+    bilateralvariantshader (format "bilateralx%1%2" $arg1 $arg2) $arg1 $arg2 $arg3 x
283
+    bilateralvariantshader (format "bilateraly%1%2" $arg1 $arg2) $arg1 $arg2 $arg3 y
284
+]
285
+

+ 68
- 0
config/glsl/blur.cfg View File

@@ -0,0 +1,68 @@
1
+////////////////////////////////////////////////
2
+//
3
+// separable blur with up to 7 taps
4
+//
5
+////////////////////////////////////////////////
6
+
7
+blurshader = [
8
+    shader 0 $arg1 [
9
+        attribute vec4 vvertex;
10
+        @(screentexcoord 0)
11
+        uniform float offsets[8];
12
+        varying vec2 texcoord0, texcoordp1, texcoordn1;
13
+        @(loopconcat+ i 2 (min (- $arg2 1) 2) [result [
14
+            varying vec2 texcoordp@i, texcoordn@i;
15
+        ]])
16
+        void main(void)
17
+        {
18
+            gl_Position = vvertex;
19
+            texcoord0 = vtexcoord0; 
20
+            vec2 tcp = vtexcoord0, tcn = vtexcoord0; 
21
+            tcp.@arg3 += offsets[1];
22
+            tcn.@arg3 -= offsets[1];
23
+            texcoordp1 = tcp;
24
+            texcoordn1 = tcn;
25
+            @(loopconcat+ i 2 (min (- $arg2 1) 2) [result [
26
+                tcp.@arg3 = vtexcoord0.@arg3 + offsets[@@i];
27
+                tcn.@arg3 = vtexcoord0.@arg3 - offsets[@@i];
28
+                texcoordp@i = tcp;
29
+                texcoordn@i = tcn;
30
+            ]])
31
+        }
32
+    ] [
33
+        uniform float weights[8];
34
+        uniform float offsets[8];
35
+        uniform sampler@[arg4] tex0;
36
+        varying vec2 texcoord0, texcoordp1, texcoordn1;
37
+        @(loopconcat+ i 2 (min (- $arg2 1) 2) [result [
38
+            varying vec2 texcoordp@i, texcoordn@i;
39
+        ]])
40
+        fragdata(0) vec4 fragcolor;
41
+        void main(void)
42
+        {
43
+            #define texval(coords) texture@[arg4](tex0, (coords))
44
+            vec4 val = texval(texcoord0) * weights[0];
45
+            @(loopconcat+ i 1 $arg2 [
46
+                if (< $i 4) [result [
47
+                    val += weights[@@i] * (texval(texcoordp@i) + texval(texcoordn@i));
48
+                ]] [result [
49
+                    val += weights[@@i] * 
50
+                    @(if (=s $arg3 "x") [result [
51
+                        (texval(vec2(texcoord0.x + offsets[@@i], texcoord0.y)) + texval(vec2(texcoord0.x - offsets[@@i], texcoord0.y)));
52
+                    ]] [result [
53
+                        (texval(vec2(texcoord0.x, texcoord0.y + offsets[@@i])) + texval(vec2(texcoord0.x, texcoord0.y - offsets[@@i])));
54
+                    ]])
55
+                ]]
56
+            ])
57
+            fragcolor = val;
58
+        }
59
+    ]
60
+]
61
+
62
+loop+ i 1 7 [
63
+    blurshader (format "blurx%1" $i) $i x 2D
64
+    blurshader (format "blury%1" $i) $i y 2D
65
+    blurshader (format "blurx%1rect" $i) $i x 2DRect
66
+    blurshader (format "blury%1rect" $i) $i y 2DRect
67
+]
68
+

+ 289
- 0
config/glsl/decal.cfg View File

@@ -0,0 +1,289 @@
1
+////////////////////////////////////////////////
2
+//
3
+// decals
4
+//
5
+////////////////////////////////////////////////
6
+
7
+// decaltype:
8
+//    e -> reserve envmap texture slot
9
+//    r -> envmap reflection
10
+//    R -> modulate envmap reflection with spec map
11
+//    s -> spec
12
+//    S -> spec map
13
+//    n -> normal map
14
+//    p -> parallax
15
+//    g -> glow
16
+//    G -> pulse glow
17
+//    b -> keep normals
18
+//    0 -> pass 0
19
+//    1 -> pass 1
20
+
21
+dtopt = [ >= (strstr $decaltype $arg1) 0 ]
22
+
23
+decalvariantshader = [
24
+    local decaltype
25
+    decaltype = $arg2
26
+    stype = (? (dtopt "e") 3 1)
27
+    srow = (? (dtopt "1") 0 -1)
28
+    if (dtopt "G") [
29
+        stype = (+ $stype 0x10)
30
+        defuniformparam "glowcolor" 1 1 1 // glow color
31
+        defuniformparam "pulseglowspeed" 1     // pulse frequency (Hz)
32
+        defuniformparam "pulseglowcolor" 0 0 0 // pulse glow color
33
+    ] [if (dtopt "g") [
34
+        defuniformparam "glowcolor" 1 1 1  // glow color
35
+    ]]
36
+    if (dtopt "R") [
37
+        defuniformparam "envscale" 1 1 1 // reflectivity map multiplier
38
+    ] [if (dtopt "r") [
39
+        defuniformparam "envscale" 0.2 0.2 0.2 // reflectivity
40
+    ]]
41
+    reuseuniformparam "gloss" 1 // glossiness
42
+    if (dtopt "S") [
43
+        defuniformparam "specscale" 2 2 2 // spec map multiplier
44
+    ] [if (dtopt "s") [
45
+        defuniformparam "specscale" 1 1 1 // spec multiplier
46
+    ]]
47
+    if (dtopt "p") [
48
+        defuniformparam "parallaxscale" 0.06 -0.03 // parallax scaling
49
+    ]
50
+    if (dtopt "n") [
51
+        defuniformparam "bumpblend" 1 // alpha-blend strength for normals
52
+    ]
53
+    variantshader $stype $arg1 $srow [
54
+        attribute vec4 vvertex;
55
+        @(? (dtopt "n") [
56
+            attribute vec4 vtangent;
57
+            varying mat3 world;
58
+        ] [
59
+            varying vec3 nvec;
60
+        ])
61
+        attribute vec4 vnormal;
62
+        attribute vec3 vtexcoord0;
63
+        uniform mat4 camprojmatrix;
64
+        varying vec4 texcoord0;
65
+        @(? (|| (dtopt "p") (dtopt "r")) [
66
+            uniform vec3 camera;
67
+            varying vec3 camvec;
68
+        ])
69
+        @(? (dtopt "G") [uniform float millis; flat varying float pulse;])
70
+        void main(void)
71
+        {
72
+            gl_Position = camprojmatrix * vvertex;
73
+            texcoord0.xyz = vtexcoord0;
74
+            texcoord0.w = 3.0*vnormal.w;
75
+
76
+            @(? (dtopt "n") [
77
+                vec3 bitangent = cross(vnormal.xyz, vtangent.xyz) * vtangent.w;
78
+                // calculate tangent -> world transform
79
+                world = mat3(vtangent.xyz, bitangent, vnormal.xyz);
80
+            ] [
81
+                nvec = vnormal.xyz;
82
+            ])
83
+
84
+            @(? (|| (dtopt "p") (dtopt "r")) [
85
+                camvec = camera - vvertex.xyz;
86
+            ])
87
+
88
+            @(? (dtopt "G") [
89
+                pulse = abs(fract(millis*pulseglowspeed.x)*2.0 - 1.0);
90
+            ])
91
+        }
92
+    ] [
93
+        @(cond [dtopt "0"] [result [
94
+            fragdata(0) vec4 gcolor;
95
+            fragblend(0) vec4 gcolorblend;
96
+        ]] [dtopt "1"] [
97
+            ? $usepacknorm [
98
+                fragdata(0) vec4 gnormal;
99
+            ] [
100
+                fragdata(0) vec4 gnormal;
101
+                fragblend(0) vec4 gnormalblend;
102
+            ]
103
+        ] [result [
104
+            fragdata(0) vec4 gcolor;
105
+            fragdata(1) vec4 gnormal;
106
+        ]])
107
+        uniform sampler2D diffusemap;
108
+        uniform vec4 colorparams;
109
+        varying vec4 texcoord0;
110
+        @(? (dtopt "n") [
111
+            uniform sampler2D normalmap;
112
+            varying mat3 world;
113
+        ] [
114
+            varying vec3 nvec;
115
+        ])
116
+        @(? (|| (dtopt "p") (dtopt "r")) [varying vec3 camvec;])
117
+        @(? (|| (dtopt "g") (dtopt "S")) [uniform sampler2D glowmap;])
118
+        @(? (dtopt "G") [flat varying float pulse;])
119
+        @(? (dtopt "r") [uniform samplerCube envmap;])
120
+        void main(void)
121
+        {
122
+            @(if (dtopt "n") [result [
123
+                @(? (dtopt "p") [
124
+                    float height = texture2D(normalmap, texcoord0.xy).a;
125
+                    vec3 camvecn = normalize(camvec);
126
+                    vec2 dtc = texcoord0.xy + (camvecn * world).xy*(height*parallaxscale.x + parallaxscale.y);
127
+                ] [
128
+                    #define dtc texcoord0.xy
129
+                ])
130
+
131
+                @(? (|| (! (dtopt "0")) (dtopt "r")) [
132
+                    vec3 bump = texture2D(normalmap, dtc).rgb*2.0 - 1.0;
133
+                    vec3 bumpw = world * bump;
134
+                    #define nvec bumpw
135
+                ])
136
+            ]] [result [
137
+                #define dtc texcoord0.xy
138
+            ]])
139
+
140
+            vec4 diffuse = texture2D(diffusemap, dtc);
141
+
142
+            @(if (dtopt "g") [result [
143
+                vec4 glowspec = texture2D(glowmap, dtc);
144
+                #define glow glowspec.rgb
145
+                #define spec glowspec.a
146
+                glow *= @(? (dtopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]);
147
+                glow *= diffuse.a;
148
+            ]])
149
+
150
+            @(if (dtopt "0") [result [
151
+                @(if (&& (dtopt "S") [! (dtopt "g")]) [result [
152
+                    float spec = @(? (|| (! (dtopt "n")) (dtopt "p")) [texture2D(glowmap, dtc).r] [texture2D(normalmap, dtc).a]);
153
+                ]])
154
+                @(gspecpack [gloss.x] (if (dtopt "s") [? (dtopt "S") [spec * specscale.x] [specscale.x]]))
155
+            ]])
156
+
157
+            @(if (dtopt "1") [
158
+                ? (dtopt "g") [
159
+                   vec3 gcolor = diffuse.rgb*colorparams.rgb;
160
+                ]
161
+            ] [result [
162
+                gcolor.rgb = diffuse.rgb*colorparams.rgb;
163
+
164
+                @(if (dtopt "r") [result [
165
+                    @(? (|| (! (dtopt "n")) (! (dtopt "p"))) [
166
+                        vec3 camvecn = normalize(camvec);
167
+                    ])
168
+                    float invfresnel = dot(camvecn, nvec);
169
+                    vec3 rvec = 2.0*nvec*invfresnel - camvecn;
170
+                    vec3 reflect = textureCube(envmap, rvec).rgb * diffuse.a;
171
+                    @(? (dtopt "R") [
172
+                        vec3 rmod = envscale.xyz*spec;
173
+                    ] [
174
+                        #define rmod envscale.xyz
175
+                    ])
176
+                    reflect *= diffuse.a;
177
+                    gcolor.rgb = mix(gcolor.rgb, reflect, rmod*clamp(1.0 - invfresnel, 0.0, 1.0));
178
+                ]])
179
+            ]])
180
+
181
+            @(if (dtopt "g") [gglowpack glow packnorm])
182
+
183
+            @(if (! (dtopt "0")) [result [
184
+                vec3 normal = normalize(nvec);
185
+                @(gnormpackdef normal packnorm)
186
+            ]])
187
+
188
+            float inside = clamp(texcoord0.z, 0.0, 1.0) * clamp(texcoord0.w, 0.0, 1.0);
189
+            float alpha = inside * diffuse.a;
190
+            @(cond [dtopt "0"] [result [
191
+                gcolor.rgb *= inside;
192
+                gcolor.a *= alpha;
193
+                gcolorblend = vec4(alpha);
194
+            ]] [dtopt "1"] [
195
+                ? $usepacknorm [
196
+                    gnormal.a = alpha * bumpblend.x;
197
+                ] [
198
+                    gnormalblend = vec4(alpha * bumpblend.x);
199
+                ]
200
+            ] [result [
201
+                gcolor.rgb *= inside;
202
+                gcolor.a = alpha;
203
+                @(? (dtopt "b") [
204
+                    gnormal = vec4(0.0);
205
+                ] [
206
+                    gnormal.rgb *= alpha * bumpblend.x;
207
+                    gnormal.a = alpha * bumpblend.x;
208
+                ])
209
+            ]])
210
+        }
211
+    ]
212
+]
213
+
214
+decalshader = [
215
+    decaltype = $arg2
216
+    stype = (? (dtopt "e") 3 1)
217
+    defershader $stype $arg1 [
218
+        if $maxdualdrawbufs [
219
+            decalvariantshader @@arg1 @@(concatword $arg2 "0")
220
+            if @@(! (dtopt "b")) [
221
+                decalvariantshader @@@arg1 @@@(concatword $arg2 "1")
222
+            ]
223
+        ] [
224
+            decalvariantshader @@arg1 @@arg2
225
+        ]
226
+    ]
227
+]
228
+
229
+decalshader "stddecal" "b"
230
+decalshader "specdecal" "bs"
231
+decalshader "specmapdecal" "bsS"
232
+
233
+decalshader "glowdecal" "g"
234
+decalshader "pulseglowdecal" "gG"
235
+
236
+decalshader "envdecal" "ber"
237
+decalshader "envspecdecal" "besr"
238
+decalshader "envspecmapdecal" "besSrR"
239
+decalshader "envglowdecal" "erg"
240
+decalshader "envpulseglowdecal" "ergG"
241
+
242
+decalshader "bumpdecal" "n"
243
+decalshader "bumpspecdecal" "ns"
244
+decalshader "bumpspecmapdecal" "nsS"
245
+
246
+decalshader "bumpglowdecal" "ng"
247
+decalshader "bumpspecglowdecal" "nsg"
248
+decalshader "bumpspecmapglowdecal" "nsSg"
249
+
250
+decalshader "bumppulseglowdecal" "ngG"
251
+decalshader "bumpspecpulseglowdecal" "nsgG"
252
+decalshader "bumpspecmappulseglowdecal" "nsSgG"
253
+
254
+decalshader "bumpparallaxdecal" "np"
255
+decalshader "bumpspecparallaxdecal" "nps"
256
+decalshader "bumpspecmapparallaxdecal" "npsS"
257
+
258
+decalshader "bumpparallaxglowdecal" "npg"
259
+decalshader "bumpspecparallaxglowdecal" "npsg"
260
+decalshader "bumpspecmapparallaxglowdecal" "npsSg"
261
+
262
+decalshader "bumpparallaxpulseglowdecal" "npgG"
263
+decalshader "bumpspecparallaxpulseglowdecal" "npsgG"
264
+decalshader "bumpspecmapparallaxpulseglowdecal" "npsSgG"
265
+
266
+decalshader "bumpenvdecal" "ner"
267
+decalshader "bumpenvspecdecal" "nesr"
268
+decalshader "bumpenvspecmapdecal" "nesSrR"
269
+
270
+decalshader "bumpenvglowdecal" "nerg"
271
+decalshader "bumpenvspecglowdecal" "neosrg"
272
+decalshader "bumpenvspecmapglowdecal" "nesSrRg"
273
+
274
+decalshader "bumpenvpulseglowdecal" "neorgG"
275
+decalshader "bumpenvspecpulseglowdecal" "nesrgG"
276
+decalshader "bumpenvspecmappulseglowdecal" "nesSrRgG"
277
+
278
+decalshader "bumpenvparallaxdecal" "nepr"
279
+decalshader "bumpenvspecparallaxdecal" "nepsr"
280
+decalshader "bumpenvspecmapparallaxdecal" "nepsSrR"
281
+
282
+decalshader "bumpenvparallaxglowdecal" "neprg"
283
+decalshader "bumpenvspecparallaxglowdecal" "nepsrg"
284
+decalshader "bumpenvspecmapparallaxglowdecal" "nepsSrRg"
285
+
286
+decalshader "bumpenvparallaxpulseglowdecal" "neprgG"
287
+decalshader "bumpenvspecparallaxpulseglowdecal" "nepsrgG"
288
+decalshader "bumpenvspecmapparallaxpulseglowdecal" "nepsSrRgG"
289
+

+ 688
- 0
config/glsl/deferred.cfg View File

@@ -0,0 +1,688 @@
1
+////////////////////////////////////////////////
2
+//
3
+// deferred shading
4
+//
5
+////////////////////////////////////////////////
6
+
7
+msaadetectedges = [
8
+    result [{
9
+        @(if (glext "GL_EXT_shader_samples_identical") [result [
10
+            if(textureSamplesIdenticalEXT(tex1, ivec2(gl_FragCoord.xy)))
11
+            {
12
+                @arg1
13
+            }
14
+            else 
15
+        ]])
16
+
17
+        { 
18
+            vec4 e = texelFetch(tex1, ivec2(gl_FragCoord.xy), 0);
19
+            e.xyz -= 0.5;
20
+            float maxdiff = 0.98*0.98*dot(e.xyz, e.xyz); 
21
+
22
+            @(loopconcat+ i 1 (- $msaasamples 1) [result [
23
+                vec4 e@i = texelFetch(tex1, ivec2(gl_FragCoord.xy), @i);
24
+                e@i.xyz -= 0.5;
25
+                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))
26
+                {
27
+            ]])
28
+
29
+            @arg1
30
+
31
+            @(loopconcat+ i 1 (- $msaasamples 1) [result [
32
+                }
33
+            ]])
34
+        }
35
+    }]
36
+]
37
+
38
+lazyshader 0 msaaedgedetect [
39
+    attribute vec4 vvertex;
40
+    void main(void)
41
+    {
42
+        gl_Position = vvertex;
43
+    }
44
+] [
45
+    @(? (glext "GL_EXT_shader_samples_identical") [
46
+        #extension GL_EXT_shader_samples_identical : enable
47
+    ])
48
+    uniform sampler2DMS tex1;
49
+
50
+    void main(void)
51
+    {
52
+        @(msaadetectedges [discard;])
53
+    }
54
+]
55
+
56
+// deferredlighttype:
57
+//    p -> point-light shadow (default cubemap)
58
+//    c -> CSM
59
+//    a -> AO
60
+//    A -> AO sun
61
+//    r -> radiance hints
62
+//    G -> 5x5 weighted gather filter
63
+//    g -> 3x3 weighted gather filter
64
+//    E -> 5x5 weighted bilinear filter
65
+//    F -> 3x3 weighted bilinear filter
66
+//    f -> 4x rotated grid filter
67
+//    m -> minimap
68
+//    M -> multisampled
69
+//    O -> sample 1
70
+//    R -> manual resolve
71
+//    S -> sample shading
72
+//    T -> edge detection
73
+//    n -> tile batching
74
+//    s -> spotlights
75
+//    t -> transparent
76
+//    b -> combined base/light variants
77
+//    d -> avatar shadow dist bias variants
78
+//    D -> disable dist bias
79
+//    z -> spec toggle
80
+dlopt = [ >= (strstr $deferredlighttype $arg1) 0 ]
81
+
82
+unpacknormbias = 0.005
83
+unpacknormscale = (+f 1 (*f 2 $unpacknormbias))
84
+unpacknorm = [
85
+    result [
86
+        @arg1 = clamp(@arg1 * @(divf $unpacknormscale 0.5) - @(+f (*f $unpacknormscale (divf 0.25 0.5)) $unpacknormbias), 0.0, 1.0);
87
+    ]
88
+]
89
+
90
+unpackspec = [
91
+    result [
92
+        vec3 camdir = normalize(camera - pos.xyz);
93
+        float facing = 2.0*dot(normal.xyz, camdir);
94
+        float specscale = min(3.0*(diffuse.a + 0.5/255.0), 2.999), gloss = floor(specscale);
95
+        specscale -= gloss;
96
+        specscale = (0.35 + 0.15*gloss) * specscale / (1.5 - specscale);
97
+        gloss = 5.0 + 17.0*gloss;
98
+    ]
99
+]
100
+
101
+unpackdistbias = [
102
+    cond [$avatar] [result [
103
+        #define distbias -@avatarshadowbias
104
+    ]] [|| $transparent [dlopt "d"] [dlopt "D"] [dlopt "m"]] [result [
105
+        #define distbias 0.0
106
+    ]] [result [
107
+        float distbias = -@avatarshadowbias * @(? (dlopt "a") [avatarmask] [step(fogcoord, @avatarshadowdist) * @(? $msaasamples [step(0.75, normal.a)] [normal.a])]);
108
+    ]]
109
+]
110
+
111
+deferredlightvariantshader = [
112
+    local deferredlighttype
113
+    deferredlighttype = $arg3
114
+    numsplits = (+ $arg4 0)
115
+    numrh = (+ $arg5 0)
116
+    numlights = (+ $arg6 0)
117
+    baselight = (< (mod $arg2 4) 2)
118
+    spotlight = (>= (mod $arg2 8) 4) 
119
+    transparent = (<= 8 $arg2 16)
120
+    avatar = (<= 17 $arg2 31)
121
+    variantshader 0 $arg1 $arg2 (? (< $arg2 0) [
122
+        attribute vec4 vvertex;
123
+        uniform mat4 lightmatrix;
124
+        void main(void)
125
+        {
126
+            gl_Position = lightmatrix * vvertex;
127
+        }
128
+    ]) [
129
+        @(? (&& (dlopt "S") [< $glslversion 400]) [
130
+            #extension GL_ARB_sample_shading : enable
131
+        ])
132
+        @(? (&& (dlopt "T") [glext "GL_EXT_shader_samples_identical"]) [
133
+            #extension GL_EXT_shader_samples_identical : enable
134
+        ])
135
+        @(if (dlopt "M") [result [
136
+            uniform sampler2DMS tex0, tex1, tex3 @(? $transparent [, tex2]);
137
+        ]] [result [
138
+            uniform sampler2DRect tex0, tex1, tex3 @(? $transparent [, tex2]);
139
+        ]])
140
+        @(if (|| (dlopt "p") (dlopt "c")) [
141
+            if (|| (dlopt "g") (dlopt "G")) [if (> $usetexgather 1) [result [
142
+                uniform sampler2DShadow tex4;
143
+            ]] [result [
144
+                uniform sampler2D tex4;
145
+            ]]] [result [
146
+                uniform sampler2DRectShadow tex4;
147
+            ]]
148
+        ])
149
+        @(if $numlights [result [
150
+            uniform vec4 lightpos[@@numlights];
151
+            uniform vec4 lightcolor[@@numlights];
152
+            @(if $spotlight [result [
153
+                uniform vec4 spotparams[@@numlights];
154
+            ]])
155
+            @(if (dlopt "p") [result [
156
+                uniform vec4 shadowparams[@@numlights];
157
+                uniform vec2 shadowoffset[@@numlights];
158
+            ]])
159
+        ]])
160
+        @(if $numsplits [result [
161
+            uniform vec4 csmtc[@@numsplits];
162
+            uniform vec3 csmoffset[@@numsplits];
163
+            uniform vec2 csmz;
164
+        ]])
165
+        @(if (dlopt "c") [result [
166
+            uniform mat3 csmmatrix;
167
+            uniform vec3 sunlightdir;
168
+            uniform vec3 sunlightcolor;
169
+            @(if (dlopt "r") [result [
170
+                uniform vec3 skylightcolor;
171
+                uniform float giscale, rhnudge, rhbounds;
172
+                uniform vec4 rhtc[@@numrh];
173
+                uniform sampler3D tex6, tex7, tex8, tex9;
174
+            ]])
175
+        ]])
176
+        uniform vec3 camera;
177
+        uniform mat4 worldmatrix;
178
+        uniform vec4 fogdir;
179
+        uniform vec3 fogcolor;
180
+        uniform vec2 fogdensity;
181
+        uniform vec4 radialfogscale;
182
+        uniform vec2 shadowatlasscale;
183
+        uniform vec4 lightscale;
184
+        @(? (&& (dlopt "a") [! $avatar] [! $transparent]) [uniform sampler2DRect tex5; uniform vec2 aoscale; uniform vec4 aoparams;])
185
+        @(gdepthunpackparams)
186
+        fragdata(0) vec4 fragcolor;
187
+
188
+        @(if (dlopt "p") [
189
+            ? $spotlight [
190
+                vec3 getspottc(vec3 dir, float spotdist, vec4 spotparams, vec4 shadowparams, vec2 shadowoffset, float distbias)
191
+                {
192
+                    vec2 mparams = shadowparams.xy / max(spotdist + distbias, 1e-5);
193
+                    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);
194
+                }
195
+            ] [
196
+                vec3 getshadowtc(vec3 dir, vec4 shadowparams, vec2 shadowoffset, float distbias)
197
+                {
198
+                    vec3 adir = abs(dir);
199
+                    float m = max(adir.x, adir.y), mz = max(adir.z, m);
200
+                    vec2 mparams = shadowparams.xy / max(mz + distbias, 1e-5);
201
+                    vec4 proj;
202
+                    if(adir.x > adir.y) proj = vec4(dir.zyx, 0.0); else proj = vec4(dir.xzy, 1.0);
203
+                    if(adir.z > m) proj = vec4(dir, 2.0);
204
+                    return vec3(proj.xy * mparams.x + vec2(proj.w, step(0.0, proj.z)) * shadowparams.z + shadowoffset, mparams.y + shadowparams.w);
205
+                }
206
+            ]
207
+        ])
208
+
209
+        @(if (|| (dlopt "p") [dlopt "c"]) [
210
+            cond [dlopt "G"] [result [
211
+                @(? (> $usetexgather 1) [
212
+                #define shadowgather(center, xoff, yoff) textureGatherOffset(tex4, center, shadowtc.z, ivec2(xoff, yoff))
213
+                ] [
214
+                #define shadowgather(center, xoff, yoff) step(shadowtc.z, textureGatherOffset(tex4, center, ivec2(xoff, yoff)))
215
+                ])
216
+                float filtershadow(vec3 shadowtc)
217
+                {
218
+                    vec2 offset = fract(shadowtc.xy - 0.5), center = (shadowtc.xy - offset)*shadowatlasscale;
219
+                    vec4 group1 = shadowgather(center, -2, -2);
220
+                    vec4 group2 = shadowgather(center,  0, -2);
221
+                    vec4 group3 = shadowgather(center,  2, -2);
222
+                    vec4 group4 = shadowgather(center, -2,  0);
223
+                    vec4 group5 = shadowgather(center,  0,  0);
224
+                    vec4 group6 = shadowgather(center,  2,  0);
225
+                    vec4 group7 = shadowgather(center, -2,  2);
226
+                    vec4 group8 = shadowgather(center,  0,  2);
227
+                    vec4 group9 = shadowgather(center,  2,  2);
228
+                    vec4 locols = vec4(group1.ab, group3.ab);
229
+                    vec4 hicols = vec4(group7.rg, group9.rg);
230
+                    locols.yz += group2.ab;
231
+                    hicols.yz += group8.rg;
232
+                    vec4 midcols = vec4(group1.rg, group3.rg) + vec4(group7.ab, group9.ab) +
233
+                                   vec4(group4.rg, group6.rg) + vec4(group4.ab, group6.ab) +
234
+                                   mix(locols, hicols, offset.y);
235
+                    vec4 cols = group5 + vec4(group2.rg, group8.ab);
236
+                    cols.xyz += mix(midcols.xyz, midcols.yzw, offset.x);
237
+                    return dot(cols, vec4(1.0/25.0));
238
+                }
239
+            ]] [dlopt "g"] [result [
240
+                @(? (> $usetexgather 1) [
241
+                #define shadowgather(center, xoff, yoff) textureGatherOffset(tex4, center, shadowtc.z, ivec2(xoff, yoff))
242
+                ] [
243
+                #define shadowgather(center, xoff, yoff) step(shadowtc.z, textureGatherOffset(tex4, center, ivec2(xoff, yoff)))
244
+                ])
245
+                float filtershadow(vec3 shadowtc)
246
+                {
247
+                    vec2 offset = fract(shadowtc.xy - 0.5), center = (shadowtc.xy - offset)*shadowatlasscale;
248
+                    vec4 group1 = shadowgather(center, -1, -1);
249
+                    vec4 group2 = shadowgather(center,  1, -1);
250
+                    vec4 group3 = shadowgather(center, -1,  1);
251
+                    vec4 group4 = shadowgather(center,  1,  1);
252
+                    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);
253
+                    return dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));
254
+                }
255
+            ]] [dlopt "E"] [result [
256
+                #define shadowval(xy, xoff, yoff) float(shadow2DRect(tex4, vec3(xy + vec2(xoff, yoff), shadowtc.z)))
257
+                float filtershadow(vec3 shadowtc)
258
+                {
259
+                    vec2 offset = fract(shadowtc.xy - 0.5);
260
+                    vec4 center = vec4(shadowtc.xy - offset + 0.5, shadowtc.xy - offset*0.5);
261
+                    vec4 size = vec4(offset + 1.0, 2.0 - offset);
262
+                    return (1.0/25.0)*dot(size.zxzx*size.wwyy,
263
+                            vec4(shadowval(center.zw, -1.5, -1.5),
264
+                                 shadowval(center.zw, 2.0, -1.5),
265
+                                 shadowval(center.zw, -1.5, 2.0),
266
+                                 shadowval(center.zw, 2.0, 2.0))) +
267
+                           (2.0/25.0)*dot(size,
268
+                            vec4(shadowval(center.zy, 2.0, 0.0),
269
+                                 shadowval(center.xw, 0.0, 2.0),
270
+                                 shadowval(center.zy, -1.5, 0.0),
271
+                                 shadowval(center.xw, 0.0, -1.5))) +
272
+                           (4.0/25.0)*shadowval(center.xy, 0.0, 0.0);
273
+                }
274
+            ]] [dlopt "F"] [result [
275
+                #define shadowval(center, xoff, yoff) float(shadow2DRect(tex4, center + vec3(xoff, yoff, 0.0)))
276
+                float filtershadow(vec3 shadowtc)
277
+                {
278
+                    vec2 offset = fract(shadowtc.xy - 0.5);
279
+                    vec3 center = shadowtc;
280
+                    //center.xy -= offset;
281
+                    //vec4 size = vec4(offset + 1.0, 2.0 - offset), weight = vec4(2.0 - 1.0 / size.xy, 1.0 / size.zw - 1.0);
282
+                    //return (1.0/9.0)*dot(size.zxzx*size.wwyy,
283
+                    //    vec4(shadowval(center, weight.zw),
284
+                    //         shadowval(center, weight.xw),
285
+                    //         shadowval(center, weight.zy),
286
+                    //         shadowval(center, weight.xy)));
287
+                    center.xy -= offset*0.5;
288
+                    vec4 size = vec4(offset + 1.0, 2.0 - offset);
289
+                    return (1.0/9.0)*dot(size.zxzx*size.wwyy,
290
+                        vec4(shadowval(center, -0.5, -0.5),
291
+                             shadowval(center, 1.0, -0.5),
292
+                             shadowval(center, -0.5, 1.0),
293
+                             shadowval(center, 1.0, 1.0)));
294
+                }
295
+            ]] [dlopt "f"] [result [
296
+                #define shadowval(center, xoff, yoff) float(shadow2DRect(tex4, center + vec3(xoff, yoff, 0.0)))
297
+                float filtershadow(vec3 shadowtc)
298
+                {
299
+                    return dot(vec4(0.25),
300
+                                vec4(shadowval(shadowtc, -0.4, 1.0),
301
+                                    shadowval(shadowtc, -1.0, -0.4),
302
+                                    shadowval(shadowtc, 0.4, -1.0),
303
+                                    shadowval(shadowtc, 1.0, 0.4))); 
304
+                }
305
+            ]] [result [
306
+                #define filtershadow(shadowtc) float(shadow2DRect(tex4, shadowtc))
307
+            ]]
308
+        ])
309
+
310
+        @(if (dlopt "c") [result [
311
+            vec3 getcsmtc(vec3 pos, float distbias)
312
+            {
313
+                vec3 tc, offset;
314
+                pos = csmmatrix * pos;
315
+                pos.z -= distbias;
316
+                tc.z = csmz.x + pos.z*csmz.y; 
317
+                @(loopconcat j $numsplits [result [
318
+                    tc.xy = csmtc[@@j].xy + pos.xy*csmtc[@@j].z;
319
+                    offset = csmoffset[@@j];
320
+                    if(max(abs(tc.x), abs(tc.y)) >= csmtc[@@j].w)
321
+                    {
322
+                ]])
323
+                        offset = vec3(-16384.0);
324
+                @(loopconcat j $numsplits [result [
325
+                    }
326
+                ]])
327
+                return tc + offset;
328
+            }
329
+
330
+            @(if (dlopt "r") [result [
331
+                vec4 getrhlight(vec3 pos, vec3 norm)
332
+                {
333
+                    vec3 tc;
334
+                    float offset;
335
+                    pos += norm*rhnudge;
336
+                    @(loopconcat j $numrh [result [
337
+                        tc = rhtc[@@j].xyz + pos*rhtc[@@j].w;
338
+                        offset = @(divf (+f 0.5 $j) $numrh);
339
+                        if(max(max(abs(tc.x), abs(tc.y)), abs(tc.z)) >= rhbounds)
340
+                        {
341
+                    ]])
342
+                            tc = vec3(4.0);
343
+                    @(loopconcat j $numrh [result [
344
+                        }
345
+                    ]])
346
+                    tc.xy += 0.5;
347
+                    tc.z = tc.z * @(divf 1 $numrh) + offset;
348
+                    vec4 shr = texture3D(tex6, tc), shg = texture3D(tex7, tc), shb = texture3D(tex8, tc), sha = texture3D(tex9, tc);
349
+                    shr.rgb -= 0.5;
350
+                    shg.rgb -= 0.5;
351
+                    shb.rgb -= 0.5;
352
+                    sha.rgb -= 0.5;
353
+                    vec4 basis = vec4(norm*-(1.023326*0.488603/3.14159*2.0), (0.886226*0.282095/3.14159));
354
+                    return clamp(vec4(dot(basis, shr), dot(basis, shg), dot(basis, shb), min(dot(basis, sha), norm.z + 1.0)), 0.0, 1.0);
355
+                }
356
+            ]])
357
+        ]])
358
+
359
+        void main(void)
360
+        {
361
+            @(if (dlopt "M") [
362
+                if (dlopt "R") [result [
363
+                    @(if (dlopt "T") [result [
364
+                        bool shouldresolve = true;
365
+                        @(msaadetectedges [shouldresolve = false;])
366
+                    ]])
367
+
368
+                    #define gfetch(sampler, coords) texelFetch(sampler, ivec2(coords), sampleidx)
369
+
370
+                    vec4 resolved = vec4(0.0);
371
+                    #define accumlight(light) resolved.rgb += light
372
+                    #define accumalpha(alpha) resolved.a += alpha
373
+
374
+                    @(if (&& [dlopt "a"] [! $avatar] [! $transparent]) [result [
375
+                        float ao = texture2DRect(tex5, gl_FragCoord.xy*aoscale).r;
376
+                    ]])
377
+
378
+                    for(int sampleidx = 0; sampleidx < @msaasamples; sampleidx++) 
379
+                    {
380
+                ]] [result [
381
+                    @(if (dlopt "T") [msaadetectedges [discard;]])
382
+
383
+                    #define gfetch(sampler, coords) texelFetch(sampler, ivec2(coords), @(? (dlopt "S") [gl_SampleID] (? (dlopt "O") 1 0)))
384
+
385
+                    #define accumlight(light) fragcolor.rgb = light
386
+                    #define accumalpha(alpha) fragcolor.a = alpha
387
+                ]]
388
+            ] [result [
389
+                #define gfetch(sampler, coords) texture2DRect(sampler, coords)
390
+
391
+                #define accumlight(light) fragcolor.rgb = light
392
+                #define accumalpha(alpha) fragcolor.a = alpha
393
+            ]])
394
+
395
+            @(if (|| $baselight [> $numlights 1]) [result [
396
+                vec4 normal = gfetch(tex1, gl_FragCoord.xy);
397
+
398
+                @(if $transparent [result [
399
+                    @(? (! $ghasstencil) [
400
+                        if(normal.x + normal.y == 0.0) discard;
401
+                    ])
402
+
403
+                    normal.xyz = normal.xyz*2.0 - 1.0;
404
+                    @(if $usepacknorm [result [
405
+                        float alpha = dot(normal.xyz, normal.xyz);
406
+                        normal.xyz *= inversesqrt(alpha);
407
+                        @(if $baselight [unpacknorm alpha])
408
+                    ]] [result [
409
+                        #define alpha normal.a
410
+                    ]])
411
+
412
+                    vec4 diffuse = gfetch(tex0, gl_FragCoord.xy);
413
+                    @(? $baselight [
414
+                        vec3 glow = gfetch(tex2, gl_FragCoord.xy).rgb;
415
+                    ])
416
+                ]] [result [
417
+                    @(? $baselight [
418
+                        float alpha = float(normal.x + normal.y != 0.0);
419
+                    ] [
420
+                        #define alpha 1.0
421
+                    ])
422
+
423
+                    normal.xyz = normal.xyz*2.0 - 1.0;
424
+                    @(if $usepacknorm [result [
425
+                        float glowscale = dot(normal.xyz, normal.xyz);
426
+                        normal.xyz *= inversesqrt(glowscale);
427
+                        @(unpacknorm glowscale)
428
+                    ]] [result [
429
+                        #define glowscale normal.a
430
+                    ]])
431
+
432
+                    vec4 diffuse = gfetch(tex0, gl_FragCoord.xy);
433
+                    @(? $baselight [
434
+                        vec3 glow = diffuse.rgb * (1.0 - glowscale);
435
+                    ])
436
+                    diffuse.rgb *= glowscale;
437
+                ]])
438
+            ]])
439
+
440
+            @(if (dlopt "m") [if (+ $numlights (dlopt "c")) [
441
+                gdepthunpackortho depth [gfetch(tex3, gl_FragCoord.xy)] [
442
+                    vec3 pos = (worldmatrix * vec4(gl_FragCoord.xy, depth, 1.0)).xyz;
443
+                ]
444
+            ]] [if (+ $numlights (dlopt "c")) [result [
445
+                @(gdepthunpack depth [gfetch(tex3, gl_FragCoord.xy)] [
446
+                    vec3 pos = (worldmatrix * vec4(depth*gl_FragCoord.xy, depth, 1.0)).xyz;
447
+                ] [
448
+                    vec4 pos = worldmatrix * vec4(gl_FragCoord.xy, depth, 1.0);
449
+                    pos.xyz /= pos.w;
450
+                ])
451
+                @(? (|| $baselight [> $numlights 1]) [
452
+                    float fogcoord = length(camera - pos.xyz);
453
+                ])
454
+                @(if (> (+ $numlights (dlopt "c")) 1) [unpackspec])
455
+            ]] [result [
456
+                @(gdepthunpack depth [gfetch(tex3, gl_FragCoord.xy)])
457
+                @(? $baselight [
458
+                    float fogcoord = -depth*length(vec3(gl_FragCoord.xy*radialfogscale.xy + radialfogscale.zw, 1.0));
459
+                ])
460
+            ]]])
461
+           
462
+            @(if $baselight [result [
463
+                vec3 light = lightscale.rgb;
464
+                @(? (dlopt "r") [
465
+                    vec4 rhlight = getrhlight(pos.xyz, normal.xyz); 
466
+                    light += rhlight.a * skylightcolor;
467
+                ])
468
+                light *= diffuse.rgb;
469
+
470
+                @(if (&& (dlopt "a") [! $avatar] [! $transparent]) [result [
471
+                    @(? (! (&& (dlopt "M") [dlopt "R"])) [
472
+                        float ao = texture2DRect(tex5, gl_FragCoord.xy*aoscale).r;
473
+                    ])
474
+                    @(if (dlopt "d") [result [
475
+                        #define aomask ao
476
+                    ]] [result [
477
+                        float avatarmask = step(fogcoord, @avatarshadowdist) * @(? $msaasamples [step(0.75, normal.a)] [normal.a]);
478
+                        float aomask = clamp(ao + avatarmask, 0.0, 1.0);
479
+                    ]])
480
+                    light *= aoparams.x + aomask*aoparams.y;
481
+                ]])
482
+                light += glow * lightscale.a;
483
+            ]] [result [
484
+                vec3 light = vec3(0.0);
485
+            ]])
486
+
487
+            @(if (> (+ (? (dlopt "p") $numlights) (dlopt "c")) 1) [unpackdistbias])
488
+
489
+            @(if (dlopt "c") [result [
490
+                @(? (dlopt "r") [
491
+                    vec3 sunlight = rhlight.rgb * giscale * diffuse.rgb;
492
+                ])
493
+                float sunfacing = dot(sunlightdir, normal.xyz);
494
+                if(sunfacing > 0.0)
495
+                {
496
+                    @(if (= (+ (? (dlopt "p") $numlights) (dlopt "c")) 1) [unpackdistbias])
497
+                    vec3 csmtc = getcsmtc(pos.xyz, distbias);
498
+                    float sunoccluded = filtershadow(csmtc);
499
+                    @(if (dlopt "m") [result [
500
+                        light += diffuse.rgb*sunfacing * sunlightcolor * sunoccluded;
501
+                    ]] [result [
502
+                        @(if (= (+ $numlights (dlopt "c")) 1) [unpackspec])
503
+                        float sunspec = pow(clamp(sunfacing*facing - dot(camdir, sunlightdir), 0.0, 1.0), gloss) * specscale;
504
+                        @(if (dlopt "r") [result [
505
+                            sunlight += (diffuse.rgb*sunfacing + sunspec) * sunoccluded;
506
+                        ]] [result [
507
+                            @(? (&& (dlopt "A") [! $avatar] [! $transparent]) [
508
+                                sunoccluded *= aoparams.z + aomask*aoparams.w;
509
+                            ])
510
+                            light += (diffuse.rgb*sunfacing + sunspec) * sunoccluded * sunlightcolor;
511
+                        ]])
512
+                    ]])
513
+                }
514
+                @(if (dlopt "r") [result [
515
+                    @(? (&& (dlopt "A") [! $avatar] [! $transparent]) [
516
+                        sunlight *= aoparams.z + aomask*aoparams.w;
517
+                    ])
518
+                    light += sunlight * sunlightcolor;
519
+                ]])
520
+            ]])
521
+
522
+            @(loopconcat j $numlights [result [
523
+                vec3 light@[j]dir = lightpos[@@j].xyz - pos.xyz * lightpos[@@j].w;
524
+                float light@[j]dist2 = dot(light@[j]dir, light@[j]dir);
525
+                if(light@[j]dist2 < 1.0)
526
+                {
527
+                    @(if (= (+ $numlights $baselight) 1) [result [
528
+                        vec4 normal = gfetch(tex1, gl_FragCoord.xy);
529
+                        @(? (&& $transparent [! $ghasstencil]) [
530
+                            if(normal.x + normal.y == 0.0) discard;
531
+                        ])
532
+                        normal.xyz = normal.xyz*2.0 - 1.0;
533
+                        @(? $usepacknorm [
534
+                            float glowscale = dot(normal.xyz, normal.xyz);
535
+                            normal.xyz *= inversesqrt(glowscale);
536
+                        ] [
537
+                            #define glowscale normal.a
538
+                        ])
539
+                    ]])
540
+                    float light@[j]facing = dot(light@[j]dir, normal.xyz);
541
+                    if(light@[j]facing > 0.0)
542
+                    {
543
+                        float light@[j]invdist = inversesqrt(light@[j]dist2); 
544
+                        @(if $spotlight [result [
545
+                            float spot@[j]dist = dot(light@[j]dir, spotparams[@@j].xyz);
546
+                            float spot@[j]atten = 1.0 - (1.0 - light@[j]invdist * spot@[j]dist) * spotparams[@@j].w;
547
+                            if(spot@[j]atten > 0.0)
548
+                            {
549
+                        ]])
550
+                        float light@[j]atten = 1.0 - light@[j]dist2 * light@[j]invdist;
551
+                        @(? (&& (= (+ $numlights $baselight) 1) [! (dlopt "m")]) [
552
+                            float fogcoord = length(camera - pos.xyz);
553
+                        ])
554
+                        @(if (= (+ (? (dlopt "p") $numlights) (dlopt "c")) 1) [unpackdistbias])
555
+                        @(if $spotlight [
556
+                            if (dlopt "p") [result [
557
+                                vec3 spot@[j]tc = getspottc(light@[j]dir, spot@[j]dist, spotparams[@@j], shadowparams[@@j], shadowoffset[@@j], distbias * lightpos[@@j].w);
558
+                                light@[j]atten *= spot@[j]atten * filtershadow(spot@[j]tc);
559
+                            ]] [result [
560
+                                light@[j]atten *= spot@[j]atten;
561
+                            ]]
562
+                        ] [
563
+                            if (dlopt "p") [result [
564
+                                vec3 shadow@[j]tc = getshadowtc(light@[j]dir, shadowparams[@@j], shadowoffset[@@j], distbias * lightpos[@@j].w);
565
+                                light@[j]atten *= filtershadow(shadow@[j]tc);
566
+                            ]]
567
+                        ])
568
+                        @(if (= (+ $numlights $baselight) 1) [result [
569
+                            vec4 diffuse = gfetch(tex0, gl_FragCoord.xy);
570
+                            @(if (! $transparent) [result [
571
+                                @(if $usepacknorm [unpacknorm glowscale])
572
+                                diffuse.rgb *= glowscale;
573
+                            ]])
574
+                        ]])
575
+                        light@[j]facing *= light@[j]invdist;
576
+                        @(if (dlopt "m") [result [
577
+                            light += diffuse.rgb*light@[j]facing * lightcolor[@@j].rgb * light@[j]atten;
578
+                        ]] [result [
579
+                            @(if (= (+ $numlights (dlopt "c")) 1) [unpackspec])
580
+                            float light@[j]spec = pow(clamp(light@[j]facing*facing - light@[j]invdist*dot(camdir, light@[j]dir), 0.0, 1.0), gloss) * specscale;
581
+                            @(if (dlopt "z") [result [
582
+                                light@[j]spec *= lightcolor[@@j].a;
583
+                            ]]) 
584
+                            light += (diffuse.rgb*light@[j]facing + light@[j]spec) * lightcolor[@@j].rgb * light@[j]atten;
585
+                            @(? (= (+ $numlights $baselight) 1) [
586
+                                float foglerp = clamp(exp2(fogcoord*fogdensity.x)*fogdensity.y, 0.0, 1.0);
587
+                                light *= foglerp;
588
+                            ])
589
+                        ]])
590
+                        @(? $spotlight [}])
591
+                    }
592
+                }
593
+            ]])
594
+            @(if (dlopt "m") [if $baselight [result [
595
+                accumlight(light);
596
+                accumalpha(alpha);
597
+            ]] [result [
598
+                accumlight(light);
599
+                accumalpha(0.0);
600
+            ]]] [if (|| $baselight [> $numlights 1]) [result [
601
+                float foglerp = clamp(exp2(fogcoord*fogdensity.x)*fogdensity.y, 0.0, 1.0);
602
+                @(? $baselight [
603
+                    accumlight(mix(fogcolor*alpha, light, foglerp));
604
+                    accumalpha(alpha);
605
+                ] [
606
+                    accumlight(light*foglerp);
607
+                    accumalpha(0.0);
608
+                ])
609
+            ]] [result [
610
+                accumlight(light);
611
+                accumalpha(0.0);
612
+            ]]])
613
+
614
+            @(if (dlopt "R") [result [
615
+                    @(? (dlopt "T") [if(!shouldresolve) break;])
616
+                }
617
+
618
+                @(? (dlopt "T") [if(shouldresolve)]) resolved *= @(divf 1 $msaasamples);
619
+                fragcolor = resolved;
620
+            ]])
621
+        }
622
+    ] $arg7
623
+]
624
+
625
+deferredlightshader = [
626
+    deferredlighttype = (concatword $arg1 $arg2 $arg3)
627
+    shadername = (concatword "deferredlight" $deferredlighttype)
628
+    basevariants = (* (max $arg6 1) 2 (? (dlopt "b") 2 1) (? (dlopt "s") 2 1))
629
+    maxvariants = $basevariants
630
+    if (dlopt "t") [maxvariants = (+ $maxvariants $basevariants 1)]
631
+    if (dlopt "d") [maxvariants = (+ $maxvariants $basevariants 1)]
632
+    deferredlightvariantshader $shadername -1 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // base shader, no points lights, sunlight
633
+    if (dlopt "t") [
634
+        deferredlightvariantshader $shadername 16 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // row 16, trasparency, base shader, no points lights, sunlight
635
+    ]
636
+    if (dlopt "d") [
637
+        deferredlightvariantshader $shadername 17 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // row 17, avatar, base shader, no points lights, sunlight
638
+    ]
639
+    loop+ i 1 (max $arg6 1) [
640
+        if (dlopt "b") [
641
+            deferredlightvariantshader $shadername 0 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 0, point lights, sunlight
642
+            deferredlightvariantshader $shadername 1 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 1, shadowed point lights, sunlight
643
+        ]
644
+        deferredlightvariantshader $shadername 2 $arg1 $arg4 $arg5 $i $maxvariants // row 2, point lights 
645
+        deferredlightvariantshader $shadername 3 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 3, shadowed point lights
646
+        if (dlopt "s") [
647
+            if (dlopt "b") [
648
+                deferredlightvariantshader $shadername 4 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 4, spot lights, sunlight
649
+                deferredlightvariantshader $shadername 5 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 5, shadowed spot lights, sunlight
650
+            ]
651
+            deferredlightvariantshader $shadername 6 $arg1 $arg4 $arg5 $i $maxvariants // row 6, spot lights 
652
+            deferredlightvariantshader $shadername 7 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 7, shadowed spot lights
653
+        ]
654
+        if (dlopt "t") [
655
+            if (dlopt "b") [
656
+                deferredlightvariantshader $shadername 8 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 8, transparent, point lights, sunlight
657
+                deferredlightvariantshader $shadername 9 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 9, transparent, shadowed point lights, sunlight
658
+            ]
659
+            deferredlightvariantshader $shadername 10 $arg1 $arg4 $arg5 $i $maxvariants // row 10, transparent, point lights 
660
+            deferredlightvariantshader $shadername 11 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 11, transparent, shadowed point lights
661
+            if (dlopt "s") [
662
+                if (dlopt "b") [
663
+                    deferredlightvariantshader $shadername 12 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 12, transparent, spot lights, sunlight
664
+                    deferredlightvariantshader $shadername 13 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 13, transparent, shadowed spot lights, sunlight
665
+                ]
666
+                deferredlightvariantshader $shadername 14 $arg1 $arg4 $arg5 $i $maxvariants // row 14, transparent, spot lights 
667
+                deferredlightvariantshader $shadername 15 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 15, transparent, shadowed spot lights
668
+            ]
669
+        ]
670
+        if (dlopt "d") [
671
+            if (dlopt "b") [
672
+                deferredlightvariantshader $shadername 24 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 24, avatar, point lights, sunlight
673
+                deferredlightvariantshader $shadername 25 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 25, avatar, shadowed point lights, sunlight
674
+            ]
675
+            deferredlightvariantshader $shadername 26 $arg1 $arg4 $arg5 $i $maxvariants // row 26, avatar, point lights 
676
+            deferredlightvariantshader $shadername 27 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 27, avatar, shadowed point lights
677
+            if (dlopt "s") [
678
+                if (dlopt "b") [
679
+                    deferredlightvariantshader $shadername 28 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 28, avatar, spot lights, sunlight
680
+                    deferredlightvariantshader $shadername 29 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 29, avatar, shadowed spot lights, sunlight
681
+                ]
682
+                deferredlightvariantshader $shadername 30 $arg1 $arg4 $arg5 $i $maxvariants // row 30, avatar, spot lights 
683
+                deferredlightvariantshader $shadername 31 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 31, avatar, shadowed spot lights
684
+            ]
685
+        ]
686
+    ]
687
+]
688
+

+ 61
- 0
config/glsl/edit.cfg View File

@@ -0,0 +1,61 @@
1
+////////////////////////////////////////////////
2
+//
3
+// miscellaneous edit shaders
4
+//
5
+////////////////////////////////////////////////
6
+
7
+shader 0 "blendbrush" [
8
+    attribute vec4 vvertex, vcolor;
9
+    uniform mat4 camprojmatrix;
10
+    uniform vec4 texgenS, texgenT;
11
+    uniform float ldrscale;
12
+    varying vec4 color;
13
+    varying vec2 texcoord0;
14
+    void main(void)
15
+    {
16
+        gl_Position = camprojmatrix * vvertex;
17
+        color = vec4(ldrscale * vcolor.rgb, vcolor.a);
18
+        texcoord0 = vec2(dot(texgenS, vvertex), dot(texgenT, vvertex));
19
+    }
20
+] [
21
+    uniform sampler2D tex0;
22
+    varying vec4 color;
23
+    varying vec2 texcoord0;
24
+    fragdata(0) vec4 fragcolor;
25
+    void main(void)
26
+    {
27
+        fragcolor = texture2D(tex0, texcoord0).r * color;
28
+    }
29
+]
30
+
31
+lazyshader 0 "prefab" [
32
+    attribute vec4 vvertex, vcolor;
33
+    attribute vec3 vnormal;
34
+    uniform mat4 prefabmatrix;
35
+    uniform mat3 prefabworld;
36
+    varying vec3 nvec;
37
+    varying vec4 color; 
38
+    @(msaainterpvert)
39
+
40
+    void main(void)
41
+    {
42
+        gl_Position = prefabmatrix * vvertex;
43
+        color = vcolor;
44
+        nvec = prefabworld * vnormal;
45
+        @(msaapackvert)
46
+    }
47
+] [
48
+    varying vec3 nvec;
49
+    varying vec4 color; 
50
+    @(msaainterpfrag)
51
+
52
+    void main(void)
53
+    {
54
+        gcolor.rgb = color.rgb;
55
+        gcolor.a = 0.0;
56
+        vec3 normal = normalize(nvec);
57
+        @(gnormpackdef normal packnorm)
58
+        @(msaapackfrag)
59
+    }
60
+]
61
+

+ 375
- 0
config/glsl/fxaa.cfg View File

@@ -0,0 +1,375 @@
1
+// 
2
+//                     NVIDIA FXAA 3.11 by TIMOTHY LOTTES
3
+//
4
+// ------------------------------------------------------------------------------
5
+// COPYRIGHT (C) 2010, 2011 NVIDIA CORPORATION. ALL RIGHTS RESERVED.
6
+// ------------------------------------------------------------------------------
7
+// TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
8
+// *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
9
+// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
10
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA
11
+// OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR
12
+// CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR
13
+// LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION,
14
+// OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE
15
+// THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16
+// DAMAGES.
17
+
18
+fxaadefs = [
19
+@(if (fxaaopt "g") [result [
20
+    #define FXAA_LUMA(color) (color.g)
21
+]] [result [
22
+    #define FXAA_LUMA(color) (color.a)
23
+]])
24
+
25
+@(case $fxaapreset 0 [result [
26
+    #define FXAA_QUALITY_PRESET 10
27
+    #define fxaaQualityEdgeThreshold 0.250
28
+    #define fxaaQualityEdgeThresholdMin 0.0833
29
+]] 1 [result [
30
+    #define FXAA_QUALITY_PRESET 12
31
+    #define fxaaQualityEdgeThreshold 0.166
32
+    #define fxaaQualityEdgeThresholdMin 0.0833
33
+]] 2 [result [
34
+    #define FXAA_QUALITY_PRESET 24
35
+    #define fxaaQualityEdgeThreshold 0.125 
36
+    #define fxaaQualityEdgeThresholdMin 0.0625
37
+]] 3 [result [
38
+    #define FXAA_QUALITY_PRESET 39
39
+    #define fxaaQualityEdgeThreshold 0.063 
40
+    #define fxaaQualityEdgeThresholdMin 0.0312
41
+]])
42
+    
43
+#define fxaaQualitySubpix 0.75
44
+
45
+#if (FXAA_QUALITY_PRESET == 10)
46
+    #define FXAA_QUALITY_PS 3
47
+    #define FXAA_QUALITY_P0 1.5
48
+    #define FXAA_QUALITY_P1 3.0
49
+    #define FXAA_QUALITY_P2 12.0
50
+#endif
51
+#if (FXAA_QUALITY_PRESET == 11)
52
+    #define FXAA_QUALITY_PS 4
53
+    #define FXAA_QUALITY_P0 1.0
54
+    #define FXAA_QUALITY_P1 1.5
55
+    #define FXAA_QUALITY_P2 3.0
56
+    #define FXAA_QUALITY_P3 12.0
57
+#endif
58
+#if (FXAA_QUALITY_PRESET == 12)
59
+    #define FXAA_QUALITY_PS 5
60
+    #define FXAA_QUALITY_P0 1.0
61
+    #define FXAA_QUALITY_P1 1.5
62
+    #define FXAA_QUALITY_P2 2.0
63
+    #define FXAA_QUALITY_P3 4.0
64
+    #define FXAA_QUALITY_P4 12.0
65
+#endif
66
+#if (FXAA_QUALITY_PRESET == 13)
67
+    #define FXAA_QUALITY_PS 6
68
+    #define FXAA_QUALITY_P0 1.0
69
+    #define FXAA_QUALITY_P1 1.5
70
+    #define FXAA_QUALITY_P2 2.0
71
+    #define FXAA_QUALITY_P3 2.0
72
+    #define FXAA_QUALITY_P4 4.0
73
+    #define FXAA_QUALITY_P5 12.0
74
+#endif
75
+#if (FXAA_QUALITY_PRESET == 14)
76
+    #define FXAA_QUALITY_PS 7
77
+    #define FXAA_QUALITY_P0 1.0
78
+    #define FXAA_QUALITY_P1 1.5
79
+    #define FXAA_QUALITY_P2 2.0
80
+    #define FXAA_QUALITY_P3 2.0
81
+    #define FXAA_QUALITY_P4 2.0
82
+    #define FXAA_QUALITY_P5 4.0
83
+    #define FXAA_QUALITY_P6 12.0
84
+#endif
85
+#if (FXAA_QUALITY_PRESET == 15)
86
+    #define FXAA_QUALITY_PS 8
87
+    #define FXAA_QUALITY_P0 1.0
88
+    #define FXAA_QUALITY_P1 1.5
89
+    #define FXAA_QUALITY_P2 2.0
90
+    #define FXAA_QUALITY_P3 2.0
91
+    #define FXAA_QUALITY_P4 2.0
92
+    #define FXAA_QUALITY_P5 2.0
93
+    #define FXAA_QUALITY_P6 4.0
94
+    #define FXAA_QUALITY_P7 12.0
95
+#endif
96
+#if (FXAA_QUALITY_PRESET == 20)
97
+    #define FXAA_QUALITY_PS 3
98
+    #define FXAA_QUALITY_P0 1.5
99
+    #define FXAA_QUALITY_P1 2.0
100
+    #define FXAA_QUALITY_P2 8.0
101
+#endif
102
+#if (FXAA_QUALITY_PRESET == 21)
103
+    #define FXAA_QUALITY_PS 4
104
+    #define FXAA_QUALITY_P0 1.0
105
+    #define FXAA_QUALITY_P1 1.5
106
+    #define FXAA_QUALITY_P2 2.0
107
+    #define FXAA_QUALITY_P3 8.0
108
+#endif
109
+#if (FXAA_QUALITY_PRESET == 22)
110
+    #define FXAA_QUALITY_PS 5
111
+    #define FXAA_QUALITY_P0 1.0
112
+    #define FXAA_QUALITY_P1 1.5
113
+    #define FXAA_QUALITY_P2 2.0
114
+    #define FXAA_QUALITY_P3 2.0
115
+    #define FXAA_QUALITY_P4 8.0
116
+#endif
117
+#if (FXAA_QUALITY_PRESET == 23)
118
+    #define FXAA_QUALITY_PS 6
119
+    #define FXAA_QUALITY_P0 1.0
120
+    #define FXAA_QUALITY_P1 1.5
121
+    #define FXAA_QUALITY_P2 2.0
122
+    #define FXAA_QUALITY_P3 2.0
123
+    #define FXAA_QUALITY_P4 2.0
124
+    #define FXAA_QUALITY_P5 8.0
125
+#endif
126
+#if (FXAA_QUALITY_PRESET == 24)
127
+    #define FXAA_QUALITY_PS 7
128
+    #define FXAA_QUALITY_P0 1.0
129
+    #define FXAA_QUALITY_P1 1.5
130
+    #define FXAA_QUALITY_P2 2.0
131
+    #define FXAA_QUALITY_P3 2.0
132
+    #define FXAA_QUALITY_P4 2.0
133
+    #define FXAA_QUALITY_P5 3.0
134
+    #define FXAA_QUALITY_P6 8.0
135
+#endif
136
+#if (FXAA_QUALITY_PRESET == 25)
137
+    #define FXAA_QUALITY_PS 8
138
+    #define FXAA_QUALITY_P0 1.0
139
+    #define FXAA_QUALITY_P1 1.5
140
+    #define FXAA_QUALITY_P2 2.0
141
+    #define FXAA_QUALITY_P3 2.0
142
+    #define FXAA_QUALITY_P4 2.0
143
+    #define FXAA_QUALITY_P5 2.0
144
+    #define FXAA_QUALITY_P6 4.0
145
+    #define FXAA_QUALITY_P7 8.0
146
+#endif
147
+#if (FXAA_QUALITY_PRESET == 26)
148
+    #define FXAA_QUALITY_PS 9
149
+    #define FXAA_QUALITY_P0 1.0
150
+    #define FXAA_QUALITY_P1 1.5
151
+    #define FXAA_QUALITY_P2 2.0
152
+    #define FXAA_QUALITY_P3 2.0
153
+    #define FXAA_QUALITY_P4 2.0
154
+    #define FXAA_QUALITY_P5 2.0
155
+    #define FXAA_QUALITY_P6 2.0
156
+    #define FXAA_QUALITY_P7 4.0
157
+    #define FXAA_QUALITY_P8 8.0
158
+#endif
159
+#if (FXAA_QUALITY_PRESET == 27)
160
+    #define FXAA_QUALITY_PS 10
161
+    #define FXAA_QUALITY_P0 1.0
162
+    #define FXAA_QUALITY_P1 1.5
163
+    #define FXAA_QUALITY_P2 2.0
164
+    #define FXAA_QUALITY_P3 2.0
165
+    #define FXAA_QUALITY_P4 2.0
166
+    #define FXAA_QUALITY_P5 2.0
167
+    #define FXAA_QUALITY_P6 2.0
168
+    #define FXAA_QUALITY_P7 2.0
169
+    #define FXAA_QUALITY_P8 4.0
170
+    #define FXAA_QUALITY_P9 8.0
171
+#endif
172
+#if (FXAA_QUALITY_PRESET == 28)
173
+    #define FXAA_QUALITY_PS 11
174
+    #define FXAA_QUALITY_P0 1.0
175
+    #define FXAA_QUALITY_P1 1.5
176
+    #define FXAA_QUALITY_P2 2.0
177
+    #define FXAA_QUALITY_P3 2.0
178
+    #define FXAA_QUALITY_P4 2.0
179
+    #define FXAA_QUALITY_P5 2.0
180
+    #define FXAA_QUALITY_P6 2.0
181
+    #define FXAA_QUALITY_P7 2.0
182
+    #define FXAA_QUALITY_P8 2.0
183
+    #define FXAA_QUALITY_P9 4.0
184
+    #define FXAA_QUALITY_P10 8.0
185
+#endif
186
+#if (FXAA_QUALITY_PRESET == 29)
187
+    #define FXAA_QUALITY_PS 12
188
+    #define FXAA_QUALITY_P0 1.0
189
+    #define FXAA_QUALITY_P1 1.5
190
+    #define FXAA_QUALITY_P2 2.0
191
+    #define FXAA_QUALITY_P3 2.0
192
+    #define FXAA_QUALITY_P4 2.0
193
+    #define FXAA_QUALITY_P5 2.0
194
+    #define FXAA_QUALITY_P6 2.0
195
+    #define FXAA_QUALITY_P7 2.0
196
+    #define FXAA_QUALITY_P8 2.0
197
+    #define FXAA_QUALITY_P9 2.0
198
+    #define FXAA_QUALITY_P10 4.0
199
+    #define FXAA_QUALITY_P11 8.0
200
+#endif
201
+#if (FXAA_QUALITY_PRESET == 39)
202
+    #define FXAA_QUALITY_PS 12
203
+    #define FXAA_QUALITY_P0 1.0
204
+    #define FXAA_QUALITY_P1 1.0
205
+    #define FXAA_QUALITY_P2 1.0
206
+    #define FXAA_QUALITY_P3 1.0
207
+    #define FXAA_QUALITY_P4 1.0
208
+    #define FXAA_QUALITY_P5 1.5
209
+    #define FXAA_QUALITY_P6 2.0
210
+    #define FXAA_QUALITY_P7 2.0
211
+    #define FXAA_QUALITY_P8 2.0
212
+    #define FXAA_QUALITY_P9 2.0
213
+    #define FXAA_QUALITY_P10 4.0
214
+    #define FXAA_QUALITY_P11 8.0
215
+#endif
216
+]
217
+
218
+shader 0 [fxaa@fxaapreset@fxaaopts] [
219
+    attribute vec4 vvertex;
220
+    @(screentexcoord 0)
221
+    varying vec2 texcoord0;
222
+    void main(void)
223
+    {
224
+        gl_Position = vvertex;
225
+        texcoord0 = vtexcoord0;
226
+    }
227
+] [
228
+    @fxaadefs
229
+    varying vec2 texcoord0;
230
+    uniform sampler2DRect tex0;
231
+    fragdata(0) vec4 fragcolor;
232
+    void main(void)
233
+    {
234
+        #define posM texcoord0
235
+        vec4 rgbyM = texture2DRect(tex0, posM);
236
+        float lumaS = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 0,  1)));
237
+        float lumaE = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 1,  0)));
238
+        float lumaN = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 0, -1)));