Merge cand's graphical improvements branch!! There are many known issues folks, so don't cry victory just now, this is just the beginning. Especially, shadows do not work correctly at this time
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14590 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
8c17d21282
commit
5899a26aad
@ -9,7 +9,7 @@
|
||||
y="-0.01"
|
||||
z="0.0" />
|
||||
|
||||
<material file="snowflake.png"/>
|
||||
<material file="snowflake.png" clampu="Y" clampv="Y" />
|
||||
|
||||
<!-- Amount of particles emitted per second -->
|
||||
<rate min="400"
|
||||
@ -23,10 +23,13 @@
|
||||
<size min="0.40"
|
||||
max="0.60" />
|
||||
|
||||
<color min="255 255 255"
|
||||
<color min="40 40 255"
|
||||
max="255 255 255" />
|
||||
|
||||
<!-- How much time in milliseconds before the particle is fully faded out -->
|
||||
<fadeout time="100" />
|
||||
|
||||
<wind speed="0.16"
|
||||
flips="Y" />
|
||||
|
||||
</particles>
|
||||
|
@ -1,18 +1,33 @@
|
||||
<stkgui>
|
||||
|
||||
<div x="2%" y="5%" width="96%" height="90%" layout="vertical-row" >
|
||||
<div x="2%" y="5%" width="96%" height="95%" layout="vertical-row" >
|
||||
|
||||
<header id="title" width="100%" height="fit" text_align="center" word_wrap="true" text="Graphics Settings" />
|
||||
|
||||
<spacer height="25" width="10" />
|
||||
<spacer height="20" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<checkbox id="pixelshaders"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Pixel Shaders (requires restart)" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<checkbox id="anim_gfx"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Animated Scenery" I18N="Video settings"/>
|
||||
|
||||
<spacer width="20%" height="10"/>
|
||||
|
||||
<checkbox id="motionblur"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Motion blur" I18N="Video settings"/>
|
||||
|
||||
</div>
|
||||
|
||||
<spacer height="5" width="10" />
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<checkbox id="weather_gfx"/>
|
||||
@ -20,7 +35,7 @@
|
||||
<label text="Weather Effects" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="5" width="10" />
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<label text="Animated Characters" I18N="Video settings" width="40%"/>
|
||||
@ -28,7 +43,7 @@
|
||||
<gauge id="steering_animations" min_value="0" max_value="2" width="50%" />
|
||||
</div>
|
||||
|
||||
<spacer height="5" width="10" />
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<label text="Texture filtering" I18N="Video settings" width="40%"/>
|
||||
@ -36,7 +51,7 @@
|
||||
<gauge id="filtering" min_value="0" max_value="5" width="50%" />
|
||||
</div>
|
||||
|
||||
<spacer height="5" width="10" />
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<label text="Anti-aliasing (requires restart)" I18N="Video settings" width="40%" />
|
||||
@ -44,20 +59,28 @@
|
||||
<gauge id="antialiasing" min_value="0" max_value="3" width="50%"/>
|
||||
</div>
|
||||
|
||||
<spacer height="5" width="10" />
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<checkbox id="postprocessing"/>
|
||||
<checkbox id="mlaa"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Post-processing (motion blur)" I18N="Video settings"/>
|
||||
<label text="MLAA (morphological anti-aliasing)" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="5" width="10" />
|
||||
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<checkbox id="pixelshaders"/>
|
||||
<label text="SSAO (Ambient Occlusion, requires restart)" I18N="Video settings"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Pixel Shaders" I18N="Video settings"/>
|
||||
<gauge id="ssao" min_value="0" max_value="2" width="50%"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<label text="Shadows (requires restart)" I18N="Video settings"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<gauge id="shadows" min_value="0" max_value="2" width="50%"/>
|
||||
</div>
|
||||
|
||||
<spacer proportion="1"/>
|
||||
|
@ -40,16 +40,6 @@
|
||||
<label height="100%" I18N="In the video settings" text="Vertical Sync (requires restart)"/>
|
||||
</div>
|
||||
|
||||
<spacer height="5" width="10"/>
|
||||
|
||||
<!-- ************ FBO ************ -->
|
||||
<div width="75%" height="fit" layout="horizontal-row" >
|
||||
<spacer width="40" height="2" />
|
||||
<checkbox id="fbos"/>
|
||||
<spacer width="20" height="2" />
|
||||
<label height="100%" I18N="In the video settings" text="Use Frame Buffer Objects (requires restart)"/>
|
||||
</div>
|
||||
|
||||
<spacer height="10" width="10"/>
|
||||
|
||||
<!-- ************ RESOLUTION CHOICE ************ -->
|
||||
|
39
data/shaders/MLAA_COPYING
Normal file
39
data/shaders/MLAA_COPYING
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Jorge Jimenez (jorge@iryoku.com)
|
||||
* Copyright (C) 2010 Belen Masia (bmasia@unizar.es)
|
||||
* Copyright (C) 2010 Jose I. Echevarria (joseignacioechevarria@gmail.com)
|
||||
* Copyright (C) 2010 Fernando Navarro (fernandn@microsoft.com)
|
||||
* Copyright (C) 2010 Diego Gutierrez (diegog@unizar.es)
|
||||
* Copyright (C) 2011 Lauri Kasanen (cand@gmx.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the following statement:
|
||||
*
|
||||
* "Uses Jimenez's MLAA. Copyright (C) 2010 by Jorge Jimenez, Belen Masia,
|
||||
* Jose I. Echevarria, Fernando Navarro and Diego Gutierrez."
|
||||
*
|
||||
* Only for use in the Mesa project, this point 2 is filled by naming the
|
||||
* technique Jimenez's MLAA in the Mesa config options.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
||||
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are
|
||||
* those of the authors and should not be interpreted as representing official
|
||||
* policies, either expressed or implied, of the copyright holders.
|
||||
*/
|
13
data/shaders/bloom.frag
Normal file
13
data/shaders/bloom.frag
Normal file
@ -0,0 +1,13 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float low;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 weights = vec3(0.2126, 0.7152, 0.0722); // ITU-R BT. 709
|
||||
vec3 col = texture2D(tex, gl_TexCoord[0].xy).xyz;
|
||||
float luma = dot(weights, col);
|
||||
|
||||
col *= smoothstep(low, 0.9, luma);
|
||||
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
}
|
10
data/shaders/bloomblend.frag
Normal file
10
data/shaders/bloomblend.frag
Normal file
@ -0,0 +1,10 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col = texture2D(tex, gl_TexCoord[0].xy);
|
||||
|
||||
col.xyz *= 10.0 * col.a;
|
||||
|
||||
gl_FragColor = vec4(col.xyz, 1.0);
|
||||
}
|
11
data/shaders/bloompower.frag
Normal file
11
data/shaders/bloompower.frag
Normal file
@ -0,0 +1,11 @@
|
||||
uniform float power;
|
||||
uniform sampler2D tex;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col = texture2D(tex, gl_TexCoord[0].xy);
|
||||
if (col.a < 0.5)
|
||||
discard;
|
||||
|
||||
gl_FragColor = vec4(col.xyz, power);
|
||||
}
|
@ -15,13 +15,12 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
uniform sampler2D main_texture;
|
||||
uniform sampler2D tex;
|
||||
uniform float transparency;
|
||||
varying vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(main_texture, uv);
|
||||
gl_FragColor.a *= transparency;
|
||||
gl_FragColor = texture2D(tex, uv);
|
||||
gl_FragColor.a *= transparency;
|
||||
}
|
||||
|
17
data/shaders/caustics.frag
Normal file
17
data/shaders/caustics.frag
Normal file
@ -0,0 +1,17 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D caustictex;
|
||||
uniform vec2 dir;
|
||||
uniform vec2 dir2;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 tc = gl_TexCoord[0].xy;
|
||||
|
||||
vec3 col = texture2D(tex, tc).xyz;
|
||||
float caustic = texture2D(caustictex, tc + dir).x;
|
||||
float caustic2 = texture2D(caustictex, (tc.yx + dir2 * vec2(-0.6, 0.3)) * vec2(0.6)).x;
|
||||
|
||||
col += caustic * caustic2 * 10.0;
|
||||
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
}
|
25
data/shaders/collapse.frag
Normal file
25
data/shaders/collapse.frag
Normal file
@ -0,0 +1,25 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D oldtex;
|
||||
uniform vec2 pixel;
|
||||
uniform vec2 multi;
|
||||
uniform int size;
|
||||
|
||||
void main()
|
||||
{
|
||||
float res = 0.0;
|
||||
vec2 tc = gl_TexCoord[0].xy;
|
||||
// tc.y = 1.0 - tc.y;
|
||||
tc *= multi;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
float col = texture2D(tex, tc).x;
|
||||
res = max(col, res);
|
||||
|
||||
tc += pixel;
|
||||
}
|
||||
|
||||
float old = texture2D(oldtex, gl_TexCoord[0].xy).x;
|
||||
|
||||
gl_FragColor = vec4(mix(old, res, 0.7));
|
||||
}
|
6
data/shaders/colorize.frag
Normal file
6
data/shaders/colorize.frag
Normal file
@ -0,0 +1,6 @@
|
||||
uniform vec3 col;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
}
|
11
data/shaders/colorize_ref.frag
Normal file
11
data/shaders/colorize_ref.frag
Normal file
@ -0,0 +1,11 @@
|
||||
uniform vec3 col;
|
||||
uniform sampler2D tex;
|
||||
|
||||
void main()
|
||||
{
|
||||
float alpha = texture2D(tex, gl_TexCoord[0].xy).a;
|
||||
if (alpha < 0.5)
|
||||
discard;
|
||||
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
}
|
40
data/shaders/displace.frag
Normal file
40
data/shaders/displace.frag
Normal file
@ -0,0 +1,40 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 screen;
|
||||
uniform vec2 dir;
|
||||
uniform vec2 dir2;
|
||||
|
||||
varying float camdist;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 tc = gl_TexCoord[0].xy;
|
||||
|
||||
vec4 col = vec4(0.0);
|
||||
const float maxlen = 0.02;
|
||||
|
||||
float horiz = texture2D(tex, tc + dir).x;
|
||||
float vert = texture2D(tex, (tc.yx + dir2) * vec2(0.9)).x;
|
||||
|
||||
vec2 offset = vec2(horiz, vert);
|
||||
offset *= 2.0;
|
||||
offset -= 1.0;
|
||||
|
||||
// Fade according to distance to cam
|
||||
float fade = 1.0 - smoothstep(1.0, 40.0, camdist);
|
||||
|
||||
// Fade according to distance from the edges
|
||||
vec2 edger = gl_TexCoord[1].xy;
|
||||
const float mindist = 0.1;
|
||||
fade *= smoothstep(0.0, mindist, edger.x) * smoothstep(0.0, mindist, edger.y) *
|
||||
(1.0 - smoothstep(1.0 - mindist, 1.0, edger.x)) *
|
||||
(1.0 - smoothstep(1.0 - mindist, 1.0, edger.y));
|
||||
|
||||
offset *= 50.0 * fade * maxlen;
|
||||
|
||||
col.r = step(offset.x, 0.0) * -offset.x;
|
||||
col.g = step(0.0, offset.x) * offset.x;
|
||||
col.b = step(offset.y, 0.0) * -offset.y;
|
||||
col.a = step(0.0, offset.y) * offset.y;
|
||||
|
||||
gl_FragColor = col;
|
||||
}
|
9
data/shaders/displace.vert
Normal file
9
data/shaders/displace.vert
Normal file
@ -0,0 +1,9 @@
|
||||
varying float camdist;
|
||||
|
||||
void main() {
|
||||
gl_Position = ftransform();
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_TexCoord[1] = gl_MultiTexCoord1;
|
||||
|
||||
camdist = length((gl_ModelViewMatrix * gl_Vertex).xyz);
|
||||
}
|
6
data/shaders/farplane.vert
Normal file
6
data/shaders/farplane.vert
Normal file
@ -0,0 +1,6 @@
|
||||
void main() {
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_TexCoord[1] = gl_MultiTexCoord1;
|
||||
gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex).xyww;
|
||||
gl_FrontColor = gl_Color;
|
||||
}
|
9
data/shaders/flip.frag
Normal file
9
data/shaders/flip.frag
Normal file
@ -0,0 +1,9 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texc = gl_TexCoord[0].xy;
|
||||
texc.y = 1.0 - texc.y;
|
||||
|
||||
gl_FragColor = texture2D(tex, texc);
|
||||
}
|
34
data/shaders/fog.frag
Normal file
34
data/shaders/fog.frag
Normal file
@ -0,0 +1,34 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
uniform float fogmax;
|
||||
uniform float startH;
|
||||
uniform float endH;
|
||||
uniform float start;
|
||||
uniform float end;
|
||||
uniform vec3 col;
|
||||
uniform vec3 campos;
|
||||
uniform mat4 ipvmat;
|
||||
|
||||
float decdepth(vec4 rgba) {
|
||||
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0));
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
float z = decdepth(vec4(texture2D(tex, gl_TexCoord[0].xy).xyz, 0.0));
|
||||
|
||||
vec3 tmp = vec3(gl_TexCoord[0].xy, z);
|
||||
tmp = tmp * 2.0 - 1.0;
|
||||
|
||||
vec4 xpos = vec4(tmp, 1.0);
|
||||
xpos = ipvmat * xpos;
|
||||
xpos.xyz /= xpos.w;
|
||||
|
||||
float dist = distance(campos, xpos.xyz);
|
||||
float fog = smoothstep(start, end, dist);
|
||||
fog *= 1.0 - smoothstep(startH, endH, xpos.y);
|
||||
|
||||
fog = min(fog, fogmax);
|
||||
|
||||
gl_FragColor = vec4(col, fog);
|
||||
}
|
19
data/shaders/gaussian3h.frag
Normal file
19
data/shaders/gaussian3h.frag
Normal file
@ -0,0 +1,19 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
// Gaussian separated blur with radius 3.
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sum = vec4(0.0);
|
||||
float X = gl_TexCoord[0].x;
|
||||
float Y = gl_TexCoord[0].y;
|
||||
|
||||
sum += texture2D(tex, vec2(X - 3.0 * pixel.x, Y)) * 0.03125;
|
||||
sum += texture2D(tex, vec2(X - 1.3333 * pixel.x, Y)) * 0.328125;
|
||||
sum += texture2D(tex, vec2(X, Y)) * 0.273438;
|
||||
sum += texture2D(tex, vec2(X + 1.3333 * pixel.x, Y)) * 0.328125;
|
||||
sum += texture2D(tex, vec2(X + 3.0 * pixel.x, Y)) * 0.03125;
|
||||
|
||||
gl_FragColor = sum;
|
||||
}
|
19
data/shaders/gaussian3v.frag
Normal file
19
data/shaders/gaussian3v.frag
Normal file
@ -0,0 +1,19 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
// Gaussian separated blur with radius 3.
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sum = vec4(0.0);
|
||||
float X = gl_TexCoord[0].x;
|
||||
float Y = gl_TexCoord[0].y;
|
||||
|
||||
sum += texture2D(tex, vec2(X, Y - 3.0 * pixel.y)) * 0.03125;
|
||||
sum += texture2D(tex, vec2(X, Y - 1.3333 * pixel.y)) * 0.328125;
|
||||
sum += texture2D(tex, vec2(X, Y)) * 0.273438;
|
||||
sum += texture2D(tex, vec2(X, Y + 1.3333 * pixel.y)) * 0.328125;
|
||||
sum += texture2D(tex, vec2(X, Y + 3.0 * pixel.y)) * 0.03125;
|
||||
|
||||
gl_FragColor = sum;
|
||||
}
|
21
data/shaders/gaussian6h.frag
Normal file
21
data/shaders/gaussian6h.frag
Normal file
@ -0,0 +1,21 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
// Gaussian separated blur with radius 6.
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sum = vec4(0.0);
|
||||
float X = gl_TexCoord[0].x;
|
||||
float Y = gl_TexCoord[0].y;
|
||||
|
||||
sum += texture2D(tex, vec2(X - 5.13333 * pixel.x, Y)) * 0.00640869;
|
||||
sum += texture2D(tex, vec2(X - 3.26667 * pixel.x, Y)) * 0.083313;
|
||||
sum += texture2D(tex, vec2(X - 1.4 * pixel.x, Y)) * 0.305481;
|
||||
sum += texture2D(tex, vec2(X, Y)) * 0.209473;
|
||||
sum += texture2D(tex, vec2(X + 1.4 * pixel.x, Y)) * 0.305481;
|
||||
sum += texture2D(tex, vec2(X + 3.26667 * pixel.x, Y)) * 0.083313;
|
||||
sum += texture2D(tex, vec2(X + 5.13333 * pixel.x, Y)) * 0.00640869;
|
||||
|
||||
gl_FragColor = sum;
|
||||
}
|
21
data/shaders/gaussian6v.frag
Normal file
21
data/shaders/gaussian6v.frag
Normal file
@ -0,0 +1,21 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
// Gaussian separated blur with radius 6.
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sum = vec4(0.0);
|
||||
float X = gl_TexCoord[0].x;
|
||||
float Y = gl_TexCoord[0].y;
|
||||
|
||||
sum += texture2D(tex, vec2(X, Y - 5.13333 * pixel.y)) * 0.00640869;
|
||||
sum += texture2D(tex, vec2(X, Y - 3.26667 * pixel.y)) * 0.083313;
|
||||
sum += texture2D(tex, vec2(X, Y - 1.4 * pixel.y)) * 0.305481;
|
||||
sum += texture2D(tex, vec2(X, Y)) * 0.209473;
|
||||
sum += texture2D(tex, vec2(X, Y + 1.4 * pixel.y)) * 0.305481;
|
||||
sum += texture2D(tex, vec2(X, Y + 3.26667 * pixel.y)) * 0.083313;
|
||||
sum += texture2D(tex, vec2(X, Y + 5.13333 * pixel.y)) * 0.00640869;
|
||||
|
||||
gl_FragColor = sum;
|
||||
}
|
16
data/shaders/glow.frag
Normal file
16
data/shaders/glow.frag
Normal file
@ -0,0 +1,16 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 res;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 coords = gl_FragCoord.xy / res;
|
||||
|
||||
vec4 col = texture2D(tex, coords);
|
||||
float alpha = col.a;
|
||||
|
||||
if (alpha < 0.04) discard;
|
||||
|
||||
col *= vec4(vec3(4.0), 1.5);
|
||||
|
||||
gl_FragColor = col;
|
||||
}
|
16
data/shaders/godfade.frag
Normal file
16
data/shaders/godfade.frag
Normal file
@ -0,0 +1,16 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec3 col;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 res = texture2D(tex, gl_TexCoord[0].xy);
|
||||
|
||||
// Keep the sun fully bright, but fade the sky
|
||||
float mul = distance(res.xyz, col);
|
||||
mul = step(mul, 0.02);
|
||||
mul *= 0.97;
|
||||
|
||||
res = res * vec4(mul);
|
||||
|
||||
gl_FragColor = res;
|
||||
}
|
29
data/shaders/godray.frag
Normal file
29
data/shaders/godray.frag
Normal file
@ -0,0 +1,29 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 sunpos;
|
||||
|
||||
#define SAMPLES 12
|
||||
|
||||
const float decaystep = 0.88;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texc = gl_TexCoord[0].xy;
|
||||
vec2 tosun = sunpos - texc;
|
||||
|
||||
if (dot(tosun, tosun) > 0.49) discard;
|
||||
|
||||
vec2 dist = tosun * 1.0/(float(SAMPLES) * 1.12);
|
||||
|
||||
vec3 col = texture2D(tex, texc).xyz;
|
||||
float decay = 1.0;
|
||||
|
||||
for (int i = 0; i < SAMPLES; i++) {
|
||||
texc += dist;
|
||||
vec3 here = texture2D(tex, texc).xyz;
|
||||
here *= decay;
|
||||
col += here;
|
||||
decay *= decaystep;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(col, 1.0) * 0.8;
|
||||
}
|
@ -1,54 +1,8 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2013 the SuperTuxKart team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
uniform vec4 fogColor;
|
||||
uniform float fogFrom;
|
||||
uniform float fogTo;
|
||||
uniform int fog;
|
||||
uniform sampler2D tex;
|
||||
varying vec4 coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture2D(tex, gl_TexCoord[0].st);
|
||||
vec4 solidColor = vec4(color.r, color.g, color.b, 1);
|
||||
vec4 color = texture2D(tex, gl_TexCoord[0].st);
|
||||
|
||||
if (fog == 1)
|
||||
{
|
||||
if (coord.z > fogTo)
|
||||
{
|
||||
gl_FragColor = fogColor;
|
||||
gl_FragColor.a = color.a;
|
||||
}
|
||||
else if (coord.z > fogFrom)
|
||||
{
|
||||
float fogIntensity = (coord.z - fogFrom) / (fogTo - fogFrom);
|
||||
vec4 color2 = fogIntensity*fogColor + (1.0 - fogIntensity)*solidColor;
|
||||
color2.a = color.a;
|
||||
gl_FragColor = color2;
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
||||
gl_FragColor = color;
|
||||
}
|
||||
|
@ -1,33 +1,11 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2013 the SuperTuxKart team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
uniform float angle;
|
||||
uniform float amplitude;
|
||||
varying vec4 coord;
|
||||
|
||||
uniform vec3 windDir;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
vec4 vertexPosition = ftransform(); //gl_ModelViewMatrix * gl_Vertex;
|
||||
vertexPosition += vec4(1,0,0,0) * amplitude * gl_Color.r * sin(angle);
|
||||
gl_Position = vertexPosition;
|
||||
gl_FrontColor = vec4(1,1,1,1);
|
||||
gl_BackColor = vec4(1,1,1,1);
|
||||
coord = vertexPosition;
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
vec4 vertexPosition = gl_Vertex;
|
||||
vertexPosition.xyz += windDir * gl_Color.r;
|
||||
|
||||
gl_Position = gl_ModelViewProjectionMatrix * vertexPosition;
|
||||
}
|
||||
|
19
data/shaders/lightblend.frag
Normal file
19
data/shaders/lightblend.frag
Normal file
@ -0,0 +1,19 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec3 ambient;
|
||||
uniform sampler2D spectex;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texc = gl_TexCoord[0].xy;
|
||||
|
||||
vec4 col = texture2D(tex, texc);
|
||||
vec4 specular = texture2D(spectex, texc);
|
||||
|
||||
col.xyz += ambient;
|
||||
float spec = col.a - 0.05;
|
||||
spec *= specular.a;
|
||||
col.xyz += spec;
|
||||
col.a = 1.0;
|
||||
|
||||
gl_FragColor = col;
|
||||
}
|
52
data/shaders/mipviz.frag
Normal file
52
data/shaders/mipviz.frag
Normal file
@ -0,0 +1,52 @@
|
||||
#version 120
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 texsize;
|
||||
uniform int notex;
|
||||
|
||||
float miplevel(in vec2 texture_coordinate)
|
||||
{
|
||||
// The OpenGL Graphics System: A Specification 4.2
|
||||
// - chapter 3.9.11, equation 3.21
|
||||
|
||||
vec2 dx_vtc = dFdx(texture_coordinate);
|
||||
vec2 dy_vtc = dFdy(texture_coordinate);
|
||||
float delta_max_sqr = max(dot(dx_vtc, dx_vtc), dot(dy_vtc, dy_vtc));
|
||||
|
||||
return 0.5 * log2(delta_max_sqr); // == log2(sqrt(delta_max_sqr));
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
if (notex != 0) {
|
||||
gl_FragColor = gl_Color;
|
||||
return;
|
||||
}
|
||||
|
||||
// Buggy Intel windows driver workaround
|
||||
vec4 levels[6] = vec4[](
|
||||
vec4(0.0, 0.0, 1.0, 0.8),
|
||||
vec4(0.0, 0.5, 1.0, 0.4),
|
||||
vec4(1.0, 1.0, 1.0, 0.0),
|
||||
vec4(1.0, 0.7, 0.0, 0.2),
|
||||
vec4(1.0, 0.3, 0.0, 0.6),
|
||||
vec4(1.0, 0.0, 0.0, 0.8)
|
||||
);
|
||||
|
||||
float mip = miplevel(texsize * gl_TexCoord[0].xy) + 2.0;
|
||||
mip = clamp(mip, 0.0, 5.0);
|
||||
|
||||
int lowmip = int(mip);
|
||||
int highmip = lowmip + 1;
|
||||
if (highmip > 5)
|
||||
highmip = 5;
|
||||
|
||||
float mixer = fract(mip);
|
||||
|
||||
vec4 mixcol = mix(levels[lowmip], levels[highmip], mixer);
|
||||
vec4 tcol = texture2D(tex, gl_TexCoord[0].xy);
|
||||
|
||||
vec3 col = mix(tcol.xyz, mixcol.xyz, mixcol.a);
|
||||
|
||||
gl_FragColor = vec4(col, tcol.a);
|
||||
}
|
112
data/shaders/mlaa_blend2.frag
Normal file
112
data/shaders/mlaa_blend2.frag
Normal file
@ -0,0 +1,112 @@
|
||||
#define MAX_SEARCH_STEPS 8.0
|
||||
#define MAX_DISTANCE 33.0
|
||||
|
||||
#extension GL_ARB_shader_texture_lod: enable
|
||||
|
||||
uniform sampler2D edgesMap;
|
||||
uniform sampler2D areaMap;
|
||||
|
||||
uniform vec2 PIXEL_SIZE;
|
||||
|
||||
/**
|
||||
* This one just returns the first level of a mip map chain, which allow us to
|
||||
* avoid the nasty ddx/ddy warnings, even improving the performance a little
|
||||
* bit.
|
||||
*/
|
||||
vec4 tex2Doffset(sampler2D map, vec2 texcoord, vec2 offset) {
|
||||
return texture2DLod(map, texcoord + PIXEL_SIZE * offset, 0.0);
|
||||
}
|
||||
|
||||
float SearchXLeft(vec2 texcoord) {
|
||||
// We compare with 0.9 to prevent bilinear access precision problems.
|
||||
float i;
|
||||
float e = 0.0;
|
||||
for (i = -1.5; i > -2.0 * MAX_SEARCH_STEPS; i -= 2.0) {
|
||||
e = tex2Doffset(edgesMap, texcoord, vec2(i, 0.0)).g;
|
||||
if (e < 0.9) break;
|
||||
}
|
||||
return max(i + 1.5 - 2.0 * e, -2.0 * MAX_SEARCH_STEPS);
|
||||
}
|
||||
|
||||
float SearchXRight(vec2 texcoord) {
|
||||
float i;
|
||||
float e = 0.0;
|
||||
for (i = 1.5; i < 2.0 * MAX_SEARCH_STEPS; i += 2.0) {
|
||||
e = tex2Doffset(edgesMap, texcoord, vec2(i, 0.0)).g;
|
||||
if (e < 0.9) break;
|
||||
}
|
||||
return min(i - 1.5 + 2.0 * e, 2.0 * MAX_SEARCH_STEPS);
|
||||
}
|
||||
|
||||
float SearchYDown(vec2 texcoord) {
|
||||
float i;
|
||||
float e = 0.0;
|
||||
for (i = -1.5; i > -2.0 * MAX_SEARCH_STEPS; i -= 2.0) {
|
||||
e = tex2Doffset(edgesMap, texcoord, vec2(i, 0.0).yx).r;
|
||||
if (e < 0.9) break;
|
||||
}
|
||||
return max(i + 1.5 - 2.0 * e, -2.0 * MAX_SEARCH_STEPS);
|
||||
}
|
||||
|
||||
float SearchYUp(vec2 texcoord) {
|
||||
float i;
|
||||
float e = 0.0;
|
||||
for (i = 1.5; i < 2.0 * MAX_SEARCH_STEPS; i += 2.0) {
|
||||
e = tex2Doffset(edgesMap, texcoord, vec2(i, 0.0).yx).r;
|
||||
if (e < 0.9) break;
|
||||
}
|
||||
return min(i - 1.5 + 2.0 * e, 2.0 * MAX_SEARCH_STEPS);
|
||||
}
|
||||
|
||||
|
||||
vec2 round(vec2 invec) {
|
||||
return vec2(floor(abs(invec) + vec2(0.5)) * sign(invec));
|
||||
}
|
||||
|
||||
vec2 Area(vec2 distance, float e1, float e2) {
|
||||
// * By dividing by areaSize - 1.0 below we are implicitely offsetting to
|
||||
// always fall inside of a pixel
|
||||
// * Rounding prevents bilinear access precision problems
|
||||
float areaSize = MAX_DISTANCE * 5.0;
|
||||
vec2 pixcoord = MAX_DISTANCE * round(4.0 * vec2(e1, e2)) + distance;
|
||||
vec2 texcoord = pixcoord / (areaSize - 1.0);
|
||||
return texture2DLod(areaMap, texcoord, 0.0).ra;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 areas = vec4(0.0);
|
||||
|
||||
vec2 e = texture2D(edgesMap, gl_TexCoord[0].xy).rg;
|
||||
|
||||
if (e.g != 0.0) { // Edge at north
|
||||
|
||||
// Search distances to the left and to the right:
|
||||
vec2 d = vec2(SearchXLeft(gl_TexCoord[0].xy), SearchXRight(gl_TexCoord[0].xy));
|
||||
|
||||
// Now fetch the crossing edges. Instead of sampling between edgels, we
|
||||
// sample at 0.25, to be able to discern what value has each edgel:
|
||||
vec4 coords = vec4(d.x, 0.25, d.y + 1.0, 0.25) * PIXEL_SIZE.xyxy + gl_TexCoord[0].xyxy;
|
||||
float e1 = texture2DLod(edgesMap, coords.xy, 0.0).r;
|
||||
float e2 = texture2DLod(edgesMap, coords.zw, 0.0).r;
|
||||
|
||||
// Ok, we know how this pattern looks like, now it is time for getting
|
||||
// the actual area:
|
||||
areas.rg = Area(abs(d), e1, e2);
|
||||
}
|
||||
|
||||
if (e.r != 0.0) { // Edge at west
|
||||
|
||||
// Search distances to the top and to the bottom:
|
||||
vec2 d = vec2(SearchYUp(gl_TexCoord[0].xy), SearchYDown(gl_TexCoord[0].xy));
|
||||
|
||||
// Now fetch the crossing edges (yet again):
|
||||
vec4 coords = vec4(-0.25, d.x, -0.25, d.y - 1.0) * PIXEL_SIZE.xyxy + gl_TexCoord[0].xyxy;
|
||||
float e1 = texture2DLod(edgesMap, coords.xy, 0.0).g;
|
||||
float e2 = texture2DLod(edgesMap, coords.zw, 0.0).g;
|
||||
|
||||
// Get the area for this direction:
|
||||
areas.ba = Area(abs(d), e1, e2);
|
||||
}
|
||||
|
||||
gl_FragColor = areas;
|
||||
}
|
25
data/shaders/mlaa_color1.frag
Normal file
25
data/shaders/mlaa_color1.frag
Normal file
@ -0,0 +1,25 @@
|
||||
varying vec4 offset[2];
|
||||
|
||||
uniform sampler2D colorMapG;
|
||||
const float threshold = 0.1f;
|
||||
|
||||
void main() {
|
||||
vec3 weights = vec3(0.2126,0.7152, 0.0722); // ITU-R BT. 709
|
||||
|
||||
/**
|
||||
* Luma calculation requires gamma-corrected colors:
|
||||
*/
|
||||
float L = dot(texture2D(colorMapG, gl_TexCoord[0].xy).rgb, weights);
|
||||
float Lleft = dot(texture2D(colorMapG, offset[0].xy).rgb, weights);
|
||||
float Ltop = dot(texture2D(colorMapG, offset[0].zw).rgb, weights);
|
||||
float Lright = dot(texture2D(colorMapG, offset[1].xy).rgb, weights);
|
||||
float Lbottom = dot(texture2D(colorMapG, offset[1].zw).rgb, weights);
|
||||
|
||||
vec4 delta = abs(vec4(L) - vec4(Lleft, Ltop, Lright, Lbottom));
|
||||
vec4 edges = step(vec4(threshold), delta);
|
||||
|
||||
if (dot(edges, vec4(1.0)) == 0.0)
|
||||
discard;
|
||||
|
||||
gl_FragColor = edges;
|
||||
}
|
38
data/shaders/mlaa_neigh3.frag
Normal file
38
data/shaders/mlaa_neigh3.frag
Normal file
@ -0,0 +1,38 @@
|
||||
varying vec4 offset[2];
|
||||
|
||||
uniform sampler2D blendMap;
|
||||
uniform sampler2D colorMap;
|
||||
|
||||
void main() {
|
||||
// Fetch the blending weights for current pixel:
|
||||
vec4 topLeft = texture2D(blendMap, gl_TexCoord[0].xy);
|
||||
float bottom = texture2D(blendMap, offset[1].zw).g;
|
||||
float right = texture2D(blendMap, offset[1].xy).a;
|
||||
vec4 a = vec4(topLeft.r, bottom, topLeft.b, right);
|
||||
|
||||
// Up to 4 lines can be crossing a pixel (one in each edge). So, we perform
|
||||
// a weighted average, where the weight of each line is 'a' cubed, which
|
||||
// favors blending and works well in practice.
|
||||
vec4 w = a * a * a;
|
||||
|
||||
// There is some blending weight with a value greater than 0.0?
|
||||
float sum = dot(w, vec4(1.0));
|
||||
if (sum < 1e-5)
|
||||
discard;
|
||||
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
// Add the contributions of the possible 4 lines that can cross this pixel:
|
||||
vec4 C = texture2D(colorMap, gl_TexCoord[0].xy);
|
||||
vec4 Cleft = texture2D(colorMap, offset[0].xy);
|
||||
vec4 Ctop = texture2D(colorMap, offset[0].zw);
|
||||
vec4 Cright = texture2D(colorMap, offset[1].xy);
|
||||
vec4 Cbottom = texture2D(colorMap, offset[1].zw);
|
||||
color = mix(C, Ctop, a.r) * w.r + color;
|
||||
color = mix(C, Cbottom, a.g) * w.g + color;
|
||||
color = mix(C, Cleft, a.b) * w.b + color;
|
||||
color = mix(C, Cright, a.a) * w.a + color;
|
||||
|
||||
// Normalize the resulting color and we are finished!
|
||||
gl_FragColor = color / sum;
|
||||
}
|
12
data/shaders/mlaa_offset.vert
Normal file
12
data/shaders/mlaa_offset.vert
Normal file
@ -0,0 +1,12 @@
|
||||
varying vec4 offset[2];
|
||||
uniform vec2 PIXEL_SIZE;
|
||||
|
||||
void main() {
|
||||
gl_Position = ftransform();
|
||||
vec4 invy = gl_MultiTexCoord0;
|
||||
// invy.y = 1.0 - invy.y;
|
||||
gl_TexCoord[0] = invy;
|
||||
|
||||
offset[0] = invy.xyxy + PIXEL_SIZE.xyxy * vec4(-1.0, 0.0, 0.0, 1.0);
|
||||
offset[1] = invy.xyxy + PIXEL_SIZE.xyxy * vec4( 1.0, 0.0, 0.0, -1.0);
|
||||
}
|
@ -41,7 +41,7 @@ uniform float mask_radius;
|
||||
uniform float max_tex_height;
|
||||
|
||||
// Number of samples used for blurring
|
||||
#define NB_SAMPLES 12
|
||||
#define NB_SAMPLES 8
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -50,14 +50,6 @@ void main()
|
||||
// Sample the color buffer
|
||||
vec3 color = texture2D(color_buffer, texcoords).rgb;
|
||||
|
||||
// If no motion blur is needed, don't do any of the blur computation,
|
||||
// just return the color from the texture.
|
||||
if(boost_amount==0.0)
|
||||
{
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute the blur direction.
|
||||
// IMPORTANT: we don't normalize it so that it avoids a glitch around 'center',
|
||||
// plus it naturally scales the motion blur in a cool way :)
|
||||
|
10
data/shaders/multiply.frag
Normal file
10
data/shaders/multiply.frag
Normal file
@ -0,0 +1,10 @@
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col1 = texture2D(tex1, gl_TexCoord[0].xy);
|
||||
vec4 col2 = vec4(vec3(texture2D(tex2, gl_TexCoord[0].xy).x), 1.0);
|
||||
|
||||
gl_FragColor = col1 * col2;
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
uniform sampler2D BumpTex; //The bump-map
|
||||
uniform sampler2D DecalTex; //The texture
|
||||
uniform sampler2D LightMapTex;
|
||||
int HasLightMap;
|
||||
uniform int HasLightMap;
|
||||
|
||||
// New bumpmapping
|
||||
varying vec3 lightVec;
|
||||
@ -19,18 +19,18 @@ void main()
|
||||
normal = normalize (normal);
|
||||
|
||||
// compute diffuse lighting
|
||||
float lamberFactor = max (dot (lightVec, normal), 0.0) ;
|
||||
float lamberFactor = max (dot (lightVec, normal), 0.0);
|
||||
vec4 diffuseMaterial;
|
||||
|
||||
diffuseMaterial = texture2D (DecalTex, gl_TexCoord[0].st);
|
||||
diffuseMaterial = texture2D (DecalTex, gl_TexCoord[0].st);
|
||||
|
||||
if (HasLightMap < 1)
|
||||
{
|
||||
// 0.5 is the ambient light
|
||||
gl_FragColor = diffuseMaterial * (0.5 + lamberFactor*0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_FragColor = diffuseMaterial * (0.5 + lamberFactor*0.5) * texture2D(LightMapTex, gl_TexCoord[0].st);
|
||||
}
|
||||
if (HasLightMap < 1)
|
||||
{
|
||||
// 0.5 is the ambient light
|
||||
gl_FragColor = diffuseMaterial * (0.5 + lamberFactor*0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_FragColor = diffuseMaterial * (0.5 + lamberFactor*0.5) * texture2D(LightMapTex, gl_TexCoord[0].st);
|
||||
}
|
||||
}
|
||||
|
40
data/shaders/objectpass.frag
Normal file
40
data/shaders/objectpass.frag
Normal file
@ -0,0 +1,40 @@
|
||||
varying vec3 nor;
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D lighttex;
|
||||
uniform float far;
|
||||
uniform int hastex;
|
||||
uniform int haslightmap;
|
||||
uniform float objectid;
|
||||
|
||||
const float near = 1.0;
|
||||
|
||||
vec4 encdepth(float v) {
|
||||
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
|
||||
enc = fract(enc);
|
||||
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
|
||||
return enc;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
|
||||
|
||||
// Tune for better inside range without losing outdoors
|
||||
linear_z *= 2.0;
|
||||
|
||||
vec4 light = vec4(1.0);
|
||||
|
||||
if (haslightmap != 0) {
|
||||
light = texture2D(lighttex, gl_TexCoord[1].xy);
|
||||
}
|
||||
|
||||
if (hastex != 0)
|
||||
gl_FragData[0] = texture2D(tex, gl_TexCoord[0].xy) * light;
|
||||
else
|
||||
gl_FragData[0] = gl_Color;
|
||||
|
||||
gl_FragData[1] = vec4(nor, linear_z);
|
||||
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
|
||||
}
|
||||
|
14
data/shaders/objectpass.vert
Normal file
14
data/shaders/objectpass.vert
Normal file
@ -0,0 +1,14 @@
|
||||
varying vec3 nor;
|
||||
uniform mat4 invtworldm;
|
||||
|
||||
void main() {
|
||||
|
||||
nor = (invtworldm * vec4(gl_Normal, 0.0)).xyz;
|
||||
nor = normalize(nor);
|
||||
nor = nor * 0.5 + 0.5;
|
||||
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_TexCoord[1] = gl_MultiTexCoord1;
|
||||
gl_Position = ftransform();
|
||||
gl_FrontColor = gl_Color;
|
||||
}
|
37
data/shaders/objectpass_ref.frag
Normal file
37
data/shaders/objectpass_ref.frag
Normal file
@ -0,0 +1,37 @@
|
||||
varying vec3 nor;
|
||||
uniform sampler2D tex;
|
||||
uniform float far;
|
||||
uniform int hastex;
|
||||
uniform float objectid;
|
||||
|
||||
const float near = 1.0;
|
||||
|
||||
vec4 encdepth(float v) {
|
||||
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
|
||||
enc = fract(enc);
|
||||
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
|
||||
return enc;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
|
||||
|
||||
// Tune for better inside range without losing outdoors
|
||||
linear_z *= 2.0;
|
||||
|
||||
if (hastex != 0) {
|
||||
vec4 col = texture2D(tex, gl_TexCoord[0].xy);
|
||||
|
||||
if (col.a < 0.5)
|
||||
discard;
|
||||
|
||||
gl_FragData[0] = col;
|
||||
} else {
|
||||
gl_FragData[0] = gl_Color;
|
||||
}
|
||||
|
||||
gl_FragData[1] = vec4(nor, linear_z);
|
||||
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
|
||||
}
|
||||
|
45
data/shaders/objectpass_rimlit.frag
Normal file
45
data/shaders/objectpass_rimlit.frag
Normal file
@ -0,0 +1,45 @@
|
||||
varying vec3 nor;
|
||||
uniform sampler2D tex;
|
||||
uniform float far;
|
||||
uniform int hastex;
|
||||
uniform float objectid;
|
||||
|
||||
varying vec3 eyenor;
|
||||
varying vec3 viewpos;
|
||||
|
||||
const float near = 1.0;
|
||||
|
||||
vec4 encdepth(float v) {
|
||||
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
|
||||
enc = fract(enc);
|
||||
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
|
||||
return enc;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
|
||||
|
||||
// Tune for better inside range without losing outdoors
|
||||
linear_z *= 2.0;
|
||||
|
||||
float rim = 1.0 - dot(eyenor, viewpos);
|
||||
rim = smoothstep(0.5, 1.5, rim) * 0.35;
|
||||
|
||||
if (hastex != 0) {
|
||||
vec4 col = texture2D(tex, gl_TexCoord[0].xy);
|
||||
|
||||
if (col.a < 0.5)
|
||||
discard;
|
||||
|
||||
col.xyz += rim;
|
||||
|
||||
gl_FragData[0] = col;
|
||||
} else {
|
||||
gl_FragData[0] = gl_Color + vec4(vec3(rim), 0.0);
|
||||
}
|
||||
|
||||
gl_FragData[1] = vec4(nor, linear_z);
|
||||
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
|
||||
}
|
||||
|
19
data/shaders/objectpass_rimlit.vert
Normal file
19
data/shaders/objectpass_rimlit.vert
Normal file
@ -0,0 +1,19 @@
|
||||
varying vec3 nor;
|
||||
uniform mat4 invtworldm;
|
||||
|
||||
varying vec3 eyenor;
|
||||
varying vec3 viewpos;
|
||||
|
||||
void main() {
|
||||
|
||||
nor = (invtworldm * vec4(gl_Normal, 0.0)).xyz;
|
||||
nor = normalize(nor);
|
||||
nor = nor * 0.5 + 0.5;
|
||||
|
||||
eyenor = gl_NormalMatrix * gl_Normal;
|
||||
viewpos = -normalize((gl_ModelViewMatrix * gl_Vertex).xyz);
|
||||
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
gl_FrontColor = gl_Color;
|
||||
}
|
42
data/shaders/objectpass_spheremap.frag
Normal file
42
data/shaders/objectpass_spheremap.frag
Normal file
@ -0,0 +1,42 @@
|
||||
varying vec3 nor;
|
||||
uniform sampler2D tex;
|
||||
uniform float far;
|
||||
uniform float objectid;
|
||||
|
||||
varying vec3 eyenor;
|
||||
varying vec3 viewpos;
|
||||
|
||||
const float near = 1.0;
|
||||
|
||||
vec4 encdepth(float v) {
|
||||
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
|
||||
enc = fract(enc);
|
||||
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
|
||||
return enc;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
|
||||
|
||||
// Tune for better inside range without losing outdoors
|
||||
linear_z *= 2.0;
|
||||
|
||||
// Calculate the spherical UV
|
||||
const vec3 forward = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
// get the angle between the forward vector and the horizontal portion of the normal
|
||||
vec3 normal_x = normalize(vec3(eyenor.x, 0.0, eyenor.z));
|
||||
float sin_theta_x = length(cross( forward, normal_x )) * eyenor.x/abs(eyenor.x);
|
||||
|
||||
// get the angle between the forward vector and the vertical portion of the normal
|
||||
vec3 normal_y = normalize(vec3(0.0, eyenor.y, eyenor.z));
|
||||
float sin_theta_y = length(cross( forward, normal_y )) * eyenor.y/abs(eyenor.y);
|
||||
|
||||
vec4 detail0 = texture2D(tex, vec2(0.5 + sin_theta_x*0.5, 0.5 + sin_theta_y*0.5));
|
||||
|
||||
gl_FragData[0] = detail0 * gl_Color;
|
||||
|
||||
gl_FragData[1] = vec4(nor, linear_z);
|
||||
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
|
||||
}
|
6
data/shaders/pass.frag
Normal file
6
data/shaders/pass.frag
Normal file
@ -0,0 +1,6 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(tex, gl_TexCoord[0].xy);
|
||||
}
|
6
data/shaders/pass.vert
Normal file
6
data/shaders/pass.vert
Normal file
@ -0,0 +1,6 @@
|
||||
void main() {
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_TexCoord[1] = gl_MultiTexCoord1;
|
||||
gl_Position = ftransform();
|
||||
gl_FrontColor = gl_Color;
|
||||
}
|
52
data/shaders/penumbrah.frag
Normal file
52
data/shaders/penumbrah.frag
Normal file
@ -0,0 +1,52 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
// Separated penumbra, horizontal
|
||||
|
||||
void main()
|
||||
{
|
||||
float sum = 0.0;
|
||||
vec4 tmp;
|
||||
float X = gl_TexCoord[0].x;
|
||||
float Y = gl_TexCoord[0].y;
|
||||
float width = 0.0;
|
||||
float zsum = 0.00001;
|
||||
|
||||
tmp = texture2D(tex, vec2(X - 5.13333 * pixel.x, Y));
|
||||
sum += tmp.x * 0.00640869;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture2D(tex, vec2(X - 3.26667 * pixel.x, Y));
|
||||
sum += tmp.x * 0.083313;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture2D(tex, vec2(X - 1.4 * pixel.x, Y));
|
||||
sum += tmp.x * 0.305481;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture2D(tex, vec2(X, Y));
|
||||
sum += tmp.x * 0.209473;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture2D(tex, vec2(X + 1.4 * pixel.x, Y));
|
||||
sum += tmp.x * 0.305481;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture2D(tex, vec2(X + 3.26667 * pixel.x, Y));
|
||||
sum += tmp.x * 0.083313;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture2D(tex, vec2(X + 5.13333 * pixel.x, Y));
|
||||
sum += tmp.x * 0.00640869;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
float hasz = step(0.7, zsum);
|
||||
gl_FragColor = vec4(sum, (width / zsum) * hasz, hasz, 1.0);
|
||||
}
|
52
data/shaders/penumbrav.frag
Normal file
52
data/shaders/penumbrav.frag
Normal file
@ -0,0 +1,52 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
// Separated penumbra, vertical
|
||||
|
||||
void main()
|
||||
{
|
||||
float sum = 0.0;
|
||||
vec4 tmp;
|
||||
float X = gl_TexCoord[0].x;
|
||||
float Y = gl_TexCoord[0].y;
|
||||
float width = 0.0;
|
||||
float zsum = 0.00001;
|
||||
|
||||
tmp = texture2D(tex, vec2(X, Y - 5.13333 * pixel.y));
|
||||
sum += tmp.x * 0.00640869;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture2D(tex, vec2(X, Y - 3.26667 * pixel.y));
|
||||
sum += tmp.x * 0.083313;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture2D(tex, vec2(X, Y - 1.4 * pixel.y));
|
||||
sum += tmp.x * 0.305481;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture2D(tex, vec2(X, Y));
|
||||
sum += tmp.x * 0.209473;
|
||||
zsum += tmp.z;
|
||||