Merge branch 'master' of https://github.com/supertuxkart/stk-code
This commit is contained in:
@@ -3,14 +3,15 @@ uniform sampler2D tex;
|
||||
uniform float low;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 weights = vec3(0.2126, 0.7152, 0.0722); // ITU-R BT. 709
|
||||
vec3 col = texture2D(tex, uv).xyz;
|
||||
vec3 col = texture(tex, uv).xyz;
|
||||
float luma = dot(weights, col);
|
||||
|
||||
col *= smoothstep(low, 0.9, luma);
|
||||
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
FragColor = vec4(col, 1.0);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col = texture2D(tex, uv);
|
||||
vec4 col = texture(tex, uv);
|
||||
|
||||
col.xyz *= 10.0 * col.a;
|
||||
|
||||
gl_FragColor = vec4(col.xyz, 1.);
|
||||
FragColor = vec4(col.xyz, 1.);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
uniform float power;
|
||||
uniform sampler2D tex;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col = texture2D(tex, gl_TexCoord[0].xy);
|
||||
vec4 col = texture(tex, gl_TexCoord[0].xy);
|
||||
if (col.a < 0.5)
|
||||
discard;
|
||||
|
||||
gl_FragColor = vec4(col.xyz, power);
|
||||
FragColor = vec4(col.xyz, power);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float transparency;
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(tex, uv);
|
||||
gl_FragColor.a *= transparency;
|
||||
FragColor = texture(tex, uv);
|
||||
FragColor.a *= transparency;
|
||||
}
|
||||
|
||||
@@ -4,15 +4,17 @@ uniform sampler2D caustictex;
|
||||
uniform vec2 dir;
|
||||
uniform vec2 dir2;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
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;
|
||||
vec3 col = texture(tex, tc).xyz;
|
||||
float caustic = texture(caustictex, tc + dir).x;
|
||||
float caustic2 = texture(caustictex, (tc.yx + dir2 * vec2(-0.6, 0.3)) * vec2(0.6)).x;
|
||||
|
||||
col += caustic * caustic2 * 10.0;
|
||||
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
FragColor = vec4(col, 1.0);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ uniform vec2 pixel;
|
||||
uniform vec2 multi;
|
||||
uniform int size;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float res = 0.0;
|
||||
@@ -14,13 +16,13 @@ void main()
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
float col = texture2D(tex, tc).x;
|
||||
float col = texture(tex, tc).x;
|
||||
res = max(col, res);
|
||||
|
||||
tc += pixel;
|
||||
}
|
||||
|
||||
float old = texture2D(oldtex, gl_TexCoord[0].xy).x;
|
||||
float old = texture(oldtex, gl_TexCoord[0].xy).x;
|
||||
|
||||
gl_FragColor = vec4(mix(old, res, 0.7));
|
||||
FragColor = vec4(mix(old, res, 0.7));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ uniform vec3 inlevel;
|
||||
uniform vec2 outlevel;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -11,7 +12,7 @@ void main()
|
||||
//texc.y = 1.0 - texc.y;
|
||||
|
||||
|
||||
vec4 col = texture2D(tex, texc);
|
||||
vec4 col = texture(tex, texc);
|
||||
|
||||
//col = col / (1 - col);
|
||||
|
||||
@@ -25,5 +26,5 @@ void main()
|
||||
col.rgb = (pow(((col.rgb * 255.0) - inBlack) / (inWhite - inBlack),
|
||||
vec3(1.0 / inGamma)) * (outWhite - outBlack) + outBlack) / 255.0;
|
||||
|
||||
gl_FragColor = vec4(col.rgb, 1.0);
|
||||
FragColor = vec4(col.rgb, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#version 130
|
||||
uniform ivec4 color;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(color) / 255.;
|
||||
FragColor = vec4(color) / 255.;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#version 130
|
||||
uniform vec3 col;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
FragColor = vec4(col, 1.0);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
uniform vec3 col;
|
||||
uniform sampler2D tex;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float alpha = texture2D(tex, gl_TexCoord[0].xy).a;
|
||||
float alpha = texture(tex, gl_TexCoord[0].xy).a;
|
||||
if (alpha < 0.5)
|
||||
discard;
|
||||
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
FragColor = vec4(col, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#version 130
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 uv;
|
||||
in vec4 col;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 res = texture2D(texture, uv);
|
||||
gl_FragColor = vec4(res.xyz * col.xyz, res.a);
|
||||
vec4 res = texture(tex, uv);
|
||||
FragColor = vec4(res.xyz * col.xyz, res.a);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ in vec2 uv;
|
||||
in vec2 edger_uv;
|
||||
in float camdist;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 tc = uv;
|
||||
@@ -15,8 +17,8 @@ void main()
|
||||
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;
|
||||
float horiz = texture(tex, tc + dir).x;
|
||||
float vert = texture(tex, (tc.yx + dir2) * vec2(0.9)).x;
|
||||
|
||||
vec2 offset = vec2(horiz, vert);
|
||||
offset *= 2.0;
|
||||
@@ -39,5 +41,5 @@ void main()
|
||||
col.b = step(offset.y, 0.0) * -offset.y;
|
||||
col.a = step(0.0, offset.y) * offset.y;
|
||||
|
||||
gl_FragColor = col;
|
||||
FragColor = col;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ uniform vec3 campos;
|
||||
uniform mat4 ipvmat;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float z = texture2D(tex, uv).a;
|
||||
float z = texture(tex, uv).a;
|
||||
|
||||
vec3 tmp = vec3(gl_TexCoord[0].xy, z);
|
||||
tmp = tmp * 2.0 - 1.0;
|
||||
@@ -29,5 +30,5 @@ void main()
|
||||
|
||||
fog = min(fog, fogmax);
|
||||
|
||||
gl_FragColor = vec4(col, fog);
|
||||
FragColor = vec4(col, fog);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ uniform vec2 pixel;
|
||||
// Gaussian separated blur with radius 3.
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -12,11 +13,11 @@ void main()
|
||||
float X = uv.x;
|
||||
float Y = uv.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;
|
||||
sum += texture(tex, vec2(X - 3.0 * pixel.x, Y)) * 0.03125;
|
||||
sum += texture(tex, vec2(X - 1.3333 * pixel.x, Y)) * 0.328125;
|
||||
sum += texture(tex, vec2(X, Y)) * 0.273438;
|
||||
sum += texture(tex, vec2(X + 1.3333 * pixel.x, Y)) * 0.328125;
|
||||
sum += texture(tex, vec2(X + 3.0 * pixel.x, Y)) * 0.03125;
|
||||
|
||||
gl_FragColor = sum;
|
||||
FragColor = sum;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ uniform vec2 pixel;
|
||||
// Gaussian separated blur with radius 3.
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -12,11 +13,11 @@ void main()
|
||||
float X = uv.x;
|
||||
float Y = uv.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;
|
||||
sum += texture(tex, vec2(X, Y - 3.0 * pixel.y)) * 0.03125;
|
||||
sum += texture(tex, vec2(X, Y - 1.3333 * pixel.y)) * 0.328125;
|
||||
sum += texture(tex, vec2(X, Y)) * 0.273438;
|
||||
sum += texture(tex, vec2(X, Y + 1.3333 * pixel.y)) * 0.328125;
|
||||
sum += texture(tex, vec2(X, Y + 3.0 * pixel.y)) * 0.03125;
|
||||
|
||||
gl_FragColor = sum;
|
||||
FragColor = sum;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ uniform vec2 pixel;
|
||||
// Gaussian separated blur with radius 6.
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -12,13 +13,13 @@ void main()
|
||||
float X = uv.x;
|
||||
float Y = uv.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;
|
||||
sum += texture(tex, vec2(X - 5.13333 * pixel.x, Y)) * 0.00640869;
|
||||
sum += texture(tex, vec2(X - 3.26667 * pixel.x, Y)) * 0.083313;
|
||||
sum += texture(tex, vec2(X - 1.4 * pixel.x, Y)) * 0.305481;
|
||||
sum += texture(tex, vec2(X, Y)) * 0.209473;
|
||||
sum += texture(tex, vec2(X + 1.4 * pixel.x, Y)) * 0.305481;
|
||||
sum += texture(tex, vec2(X + 3.26667 * pixel.x, Y)) * 0.083313;
|
||||
sum += texture(tex, vec2(X + 5.13333 * pixel.x, Y)) * 0.00640869;
|
||||
|
||||
gl_FragColor = sum;
|
||||
FragColor = sum;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ uniform vec2 pixel;
|
||||
// Gaussian separated blur with radius 6.
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -12,13 +13,13 @@ void main()
|
||||
float X = uv.x;
|
||||
float Y = uv.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;
|
||||
sum += texture(tex, vec2(X, Y - 5.13333 * pixel.y)) * 0.00640869;
|
||||
sum += texture(tex, vec2(X, Y - 3.26667 * pixel.y)) * 0.083313;
|
||||
sum += texture(tex, vec2(X, Y - 1.4 * pixel.y)) * 0.305481;
|
||||
sum += texture(tex, vec2(X, Y)) * 0.209473;
|
||||
sum += texture(tex, vec2(X, Y + 1.4 * pixel.y)) * 0.305481;
|
||||
sum += texture(tex, vec2(X, Y + 3.26667 * pixel.y)) * 0.083313;
|
||||
sum += texture(tex, vec2(X, Y + 5.13333 * pixel.y)) * 0.00640869;
|
||||
|
||||
gl_FragColor = sum;
|
||||
FragColor = sum;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 coords = uv;
|
||||
|
||||
vec4 col = texture2D(tex, coords);
|
||||
vec4 col = texture(tex, coords);
|
||||
float alpha = col.a;
|
||||
|
||||
if (alpha < 0.04 || length(col.xyz) < 0.2) discard;
|
||||
@@ -15,5 +16,5 @@ void main()
|
||||
col *= vec4(vec3(4.0), 1.5);
|
||||
col.a *= 0.6;
|
||||
|
||||
gl_FragColor = col;
|
||||
FragColor = col;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#version 130
|
||||
uniform sampler2D tex;
|
||||
uniform vec3 col;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 res = texture2D(tex, gl_TexCoord[0].xy);
|
||||
vec4 res = texture(tex, gl_TexCoord[0].xy);
|
||||
|
||||
// Keep the sun fully bright, but fade the sky
|
||||
float mul = distance(res.xyz, col);
|
||||
@@ -13,5 +14,5 @@ void main()
|
||||
|
||||
res = res * vec4(mul);
|
||||
|
||||
gl_FragColor = res;
|
||||
FragColor = res;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ uniform vec2 sunpos;
|
||||
|
||||
const float decaystep = 0.88;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texc = gl_TexCoord[0].xy;
|
||||
@@ -15,16 +17,16 @@ void main()
|
||||
|
||||
vec2 dist = tosun * 1.0/(float(SAMPLES) * 1.12);
|
||||
|
||||
vec3 col = texture2D(tex, texc).xyz;
|
||||
vec3 col = texture(tex, texc).xyz;
|
||||
float decay = 1.0;
|
||||
|
||||
for (int i = 0; i < SAMPLES; i++) {
|
||||
texc += dist;
|
||||
vec3 here = texture2D(tex, texc).xyz;
|
||||
vec3 here = texture(tex, texc).xyz;
|
||||
here *= decay;
|
||||
col += here;
|
||||
decay *= decaystep;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(col, 1.0) * 0.8;
|
||||
FragColor = vec4(col, 1.0) * 0.8;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,13 @@ uniform sampler2D tex;
|
||||
|
||||
noperspective in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec4 Albedo;
|
||||
out vec4 NormalDepth;
|
||||
out vec4 Specular;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragData[0] = texture2D(tex, uv);
|
||||
gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
gl_FragData[2] = vec4(0.);
|
||||
Albedo = texture(tex, uv);
|
||||
NormalDepth = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
Specular = vec4(0.);
|
||||
}
|
||||
|
||||
18
data/shaders/grass_pass1.vert
Normal file
18
data/shaders/grass_pass1.vert
Normal file
@@ -0,0 +1,18 @@
|
||||
#version 130
|
||||
uniform vec3 windDir;
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec2 Texcoord;
|
||||
in vec4 Color;
|
||||
noperspective out vec3 nor;
|
||||
out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
uv = Texcoord;
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 1.)).xyz;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position + windDir * Color.r, 1.);
|
||||
}
|
||||
14
data/shaders/grass_pass2.vert
Normal file
14
data/shaders/grass_pass2.vert
Normal file
@@ -0,0 +1,14 @@
|
||||
#version 130
|
||||
uniform vec3 windDir;
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
in vec4 Color;
|
||||
out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
uv = Texcoord;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position + windDir * Color.r, 1.);
|
||||
}
|
||||
@@ -26,13 +26,14 @@ uniform float transparency;
|
||||
in vec2 uv;
|
||||
noperspective in vec3 eyeVec;
|
||||
noperspective in vec3 normal;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float inter = dot(normal, eyeVec);
|
||||
float m = texture2D(tex, vec2(0.5, uv.y)).r;
|
||||
float m = texture(tex, vec2(0.5, uv.y)).r;
|
||||
inter = 1.0 - inter;
|
||||
float alpha = inter + 1.0;// * m;
|
||||
|
||||
gl_FragColor = vec4(0.8, 0.16, 0.48, alpha);
|
||||
FragColor = vec4(0.8, 0.16, 0.48, alpha);
|
||||
}
|
||||
|
||||
@@ -28,12 +28,13 @@ uniform float transparency;
|
||||
in vec2 uv;
|
||||
noperspective in vec3 eyeVec;
|
||||
noperspective in vec3 normal;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float inter = dot(normal, eyeVec);
|
||||
float m = texture2D(tex, vec2(0.5, uv.y)).r;
|
||||
float m = texture(tex, vec2(0.5, uv.y)).r;
|
||||
float alpha = inter * inter * inter * inter * m;
|
||||
|
||||
gl_FragColor = vec4(1.0, 1.0, 0.8, alpha);
|
||||
FragColor = vec4(1.0, 1.0, 0.8, alpha);
|
||||
}
|
||||
|
||||
@@ -6,15 +6,16 @@ uniform sampler2D specular_map;
|
||||
uniform vec3 ambient;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texc = uv;
|
||||
|
||||
vec3 diffuse = texture2D(diffuse, texc).xyz;
|
||||
vec3 spec = texture2D(specular, texc).xyz;
|
||||
float specmap = texture2D(specular_map, texc).x;
|
||||
float ao = texture2D(ambient_occlusion, texc).x;
|
||||
vec3 diffuse = texture(diffuse, texc).xyz;
|
||||
vec3 spec = texture(specular, texc).xyz;
|
||||
float specmap = texture(specular_map, texc).x;
|
||||
float ao = texture(ambient_occlusion, texc).x;
|
||||
|
||||
gl_FragColor = vec4(diffuse + spec * specmap + ao * ambient, 1.0);
|
||||
FragColor = vec4(diffuse + spec * specmap + ao * ambient, 1.0);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 texsize;
|
||||
uniform int notex;
|
||||
out vec4 FragColor;
|
||||
|
||||
float miplevel(in vec2 texture_coordinate)
|
||||
{
|
||||
@@ -19,7 +20,7 @@ float miplevel(in vec2 texture_coordinate)
|
||||
void main() {
|
||||
|
||||
if (notex != 0) {
|
||||
gl_FragColor = gl_Color;
|
||||
FragColor = gl_Color;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,9 +45,9 @@ void main() {
|
||||
float mixer = fract(mip);
|
||||
|
||||
vec4 mixcol = mix(levels[lowmip], levels[highmip], mixer);
|
||||
vec4 tcol = texture2D(tex, gl_TexCoord[0].xy);
|
||||
vec4 tcol = texture(tex, gl_TexCoord[0].xy);
|
||||
|
||||
vec3 col = mix(tcol.xyz, mixcol.xyz, mixcol.a);
|
||||
|
||||
gl_FragColor = vec4(col, tcol.a);
|
||||
FragColor = vec4(col, tcol.a);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ uniform sampler2D areaMap;
|
||||
|
||||
uniform vec2 PIXEL_SIZE;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -77,7 +79,7 @@ vec2 Area(vec2 distance, float e1, float e2) {
|
||||
void main() {
|
||||
vec4 areas = vec4(0.0);
|
||||
|
||||
vec2 e = texture2D(edgesMap, gl_TexCoord[0].xy).rg;
|
||||
vec2 e = texture(edgesMap, gl_TexCoord[0].xy).rg;
|
||||
|
||||
if (e.g != 0.0) { // Edge at north
|
||||
|
||||
@@ -109,5 +111,5 @@ void main() {
|
||||
areas.ba = Area(abs(d), e1, e2);
|
||||
}
|
||||
|
||||
gl_FragColor = areas;
|
||||
FragColor = areas;
|
||||
}
|
||||
|
||||
@@ -5,17 +5,19 @@ in vec2 uv;
|
||||
uniform sampler2D colorMapG;
|
||||
const float threshold = 0.1;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
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, uv).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);
|
||||
float L = dot(texture(colorMapG, uv).rgb, weights);
|
||||
float Lleft = dot(texture(colorMapG, offset[0].xy).rgb, weights);
|
||||
float Ltop = dot(texture(colorMapG, offset[0].zw).rgb, weights);
|
||||
float Lright = dot(texture(colorMapG, offset[1].xy).rgb, weights);
|
||||
float Lbottom = dot(texture(colorMapG, offset[1].zw).rgb, weights);
|
||||
|
||||
vec4 delta = abs(vec4(L) - vec4(Lleft, Ltop, Lright, Lbottom));
|
||||
vec4 edges = step(vec4(threshold), delta);
|
||||
@@ -23,5 +25,5 @@ void main() {
|
||||
if (dot(edges, vec4(1.0)) == 0.0)
|
||||
discard;
|
||||
|
||||
gl_FragColor = edges;
|
||||
FragColor = edges;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#version 130
|
||||
in vec4 offset[2];
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform sampler2D blendMap;
|
||||
uniform sampler2D colorMap;
|
||||
|
||||
void main() {
|
||||
// Fetch the blending weights for current pixel:
|
||||
vec4 topLeft = texture2D(blendMap, uv);
|
||||
float bottom = texture2D(blendMap, offset[1].zw).g;
|
||||
float right = texture2D(blendMap, offset[1].xy).a;
|
||||
vec4 topLeft = texture(blendMap, uv);
|
||||
float bottom = texture(blendMap, offset[1].zw).g;
|
||||
float right = texture(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
|
||||
@@ -25,16 +26,16 @@ void main() {
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
// Add the contributions of the possible 4 lines that can cross this pixel:
|
||||
vec4 C = texture2D(colorMap, uv);
|
||||
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);
|
||||
vec4 C = texture(colorMap, uv);
|
||||
vec4 Cleft = texture(colorMap, offset[0].xy);
|
||||
vec4 Ctop = texture(colorMap, offset[0].zw);
|
||||
vec4 Cright = texture(colorMap, offset[1].xy);
|
||||
vec4 Cbottom = texture(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;
|
||||
FragColor = color / sum;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ uniform float mask_radius;
|
||||
// Maximum height of texture used
|
||||
uniform float max_tex_height;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Number of samples used for blurring
|
||||
#define NB_SAMPLES 8
|
||||
|
||||
@@ -49,7 +51,7 @@ void main()
|
||||
vec2 texcoords = gl_TexCoord[0].st;
|
||||
|
||||
// Sample the color buffer
|
||||
vec3 color = texture2D(color_buffer, texcoords).rgb;
|
||||
vec3 color = texture(color_buffer, texcoords).rgb;
|
||||
|
||||
// Compute the blur direction.
|
||||
// IMPORTANT: we don't normalize it so that it avoids a glitch around 'center',
|
||||
@@ -74,12 +76,12 @@ void main()
|
||||
vec2 blur_texcoords = texcoords + inc_vec;
|
||||
for(int i=1 ; i < NB_SAMPLES ; i++)
|
||||
{
|
||||
color += texture2D(color_buffer, blur_texcoords).rgb;
|
||||
color += texture(color_buffer, blur_texcoords).rgb;
|
||||
blur_texcoords += inc_vec;
|
||||
}
|
||||
color /= vec3(NB_SAMPLES);
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
FragColor = vec4(color, 1.0);
|
||||
|
||||
// Keep this commented line for debugging:
|
||||
//gl_FragColor = vec4(blur_factor, blur_factor, blur_factor, 0.0);
|
||||
//FragColor = vec4(blur_factor, blur_factor, blur_factor, 0.0);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col1 = texture2D(tex1, gl_TexCoord[0].xy);
|
||||
vec4 col2 = vec4(vec3(texture2D(tex2, gl_TexCoord[0].xy).x), 1.0);
|
||||
vec4 col1 = texture(tex1, gl_TexCoord[0].xy);
|
||||
vec4 col2 = vec4(vec3(texture(tex2, gl_TexCoord[0].xy).x), 1.0);
|
||||
|
||||
gl_FragColor = col1 * col2;
|
||||
FragColor = col1 * col2;
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@ uniform sampler2D normalMap;
|
||||
noperspective in vec3 tangent;
|
||||
noperspective in vec3 bitangent;
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
// normal in Tangent Space
|
||||
vec3 TS_normal = 2.0 * texture2D (normalMap, uv).rgb - 1.0;
|
||||
vec3 TS_normal = 2.0 * texture (normalMap, uv).rgb - 1.0;
|
||||
// Because of interpolation, we need to renormalize
|
||||
vec3 Frag_tangent = normalize(tangent);
|
||||
vec3 Frag_normal = normalize(cross(Frag_tangent, bitangent));
|
||||
@@ -17,5 +18,5 @@ void main()
|
||||
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
|
||||
FragmentNormal = normalize(FragmentNormal);
|
||||
|
||||
gl_FragColor = vec4(0.5 * FragmentNormal + 0.5, gl_FragCoord.z);
|
||||
FragColor = vec4(0.5 * FragmentNormal + 0.5, gl_FragCoord.z);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#version 130
|
||||
noperspective in vec3 nor;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_FragColor = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
FragColor = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
}
|
||||
|
||||
@@ -6,14 +6,15 @@ uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
vec4 color = texture2D(Albedo, uv);
|
||||
vec3 DiffuseComponent = texture2D(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture2D(SpecularMap, tc).xyz;
|
||||
float ao = texture2D(SSAO, tc).x;
|
||||
vec4 color = texture(Albedo, uv);
|
||||
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
||||
float ao = texture(SSAO, tc).x;
|
||||
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent * (1. - color.a);
|
||||
gl_FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
}
|
||||
|
||||
@@ -8,22 +8,25 @@ noperspective in vec3 nor;
|
||||
in vec4 color;
|
||||
in vec2 uv0;
|
||||
in vec2 uv1;
|
||||
out vec4 Albedo;
|
||||
out vec4 NormalDepth;
|
||||
out vec4 Specular;
|
||||
|
||||
void main() {
|
||||
vec4 light = vec4(1.0);
|
||||
vec4 col;
|
||||
|
||||
if (haslightmap != 0) {
|
||||
light = texture2D(lighttex, uv1);
|
||||
light = texture(lighttex, uv1);
|
||||
}
|
||||
|
||||
if (hastex != 0)
|
||||
col = texture2D(tex, uv0) * light;
|
||||
col = texture(tex, uv0) * light;
|
||||
else
|
||||
col = color;
|
||||
|
||||
gl_FragData[0] = vec4(col.xyz, 1.);
|
||||
gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
gl_FragData[2] = vec4(1. - col.a);
|
||||
Albedo = vec4(col.xyz, 1.);
|
||||
NormalDepth = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
Specular = vec4(1. - col.a);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,21 +6,24 @@ uniform float objectid;
|
||||
noperspective in vec3 nor;
|
||||
in vec2 uv0;
|
||||
in vec2 uv1;
|
||||
out vec4 Albedo;
|
||||
out vec4 NormalDepth;
|
||||
out vec4 Specular;
|
||||
|
||||
void main() {
|
||||
|
||||
//if (hastex != 0) {
|
||||
vec4 col = texture2D(tex, uv0);
|
||||
vec4 col = texture(tex, uv0);
|
||||
|
||||
if (col.a < 0.5)
|
||||
discard;
|
||||
|
||||
gl_FragData[0] = vec4(col.xyz, 1.);
|
||||
Albedo = vec4(col.xyz, 1.);
|
||||
//} else {
|
||||
// gl_FragData[0] = gl_Color;
|
||||
// Albedo = gl_Color;
|
||||
//}
|
||||
|
||||
gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
gl_FragData[2] = vec4(1. - col.a);
|
||||
NormalDepth = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
Specular = vec4(1. - col.a);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ uniform float objectid;
|
||||
noperspective in vec3 nor;
|
||||
noperspective in vec3 eyenor;
|
||||
noperspective in vec3 viewpos;
|
||||
out vec4 Albedo;
|
||||
out vec4 NormalDepth;
|
||||
out vec4 Specular;
|
||||
|
||||
void main() {
|
||||
float rim = 1.0 - dot(eyenor, viewpos);
|
||||
@@ -13,7 +16,7 @@ void main() {
|
||||
vec4 color;
|
||||
|
||||
if (hastex != 0) {
|
||||
vec4 col = texture2D(tex, gl_TexCoord[0].xy);
|
||||
vec4 col = texture(tex, gl_TexCoord[0].xy);
|
||||
|
||||
if (col.a < 0.1)
|
||||
discard;
|
||||
@@ -25,8 +28,8 @@ void main() {
|
||||
color = gl_Color + vec4(vec3(rim), 0.0);
|
||||
}
|
||||
|
||||
gl_FragData[0] = vec4(color.xyz, 1.);
|
||||
gl_FragData[1] = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
gl_FragData[2] = vec4(1. - color.a);
|
||||
Albedo = vec4(color.xyz, 1.);
|
||||
NormalDepth = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
Specular = vec4(1. - color.a);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
noperspective in vec3 nor;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main() {
|
||||
// Calculate the spherical UV
|
||||
@@ -15,7 +16,7 @@ void main() {
|
||||
vec3 normal_y = normalize(vec3(0.0, nor.y, nor.z));
|
||||
float sin_theta_y = length(cross( forward, normal_y )) * nor.y / abs(nor.y);
|
||||
|
||||
vec4 detail0 = texture2D(tex, 0.5 * vec2(sin_theta_x, sin_theta_y) + 0.5);
|
||||
vec4 detail0 = texture(tex, 0.5 * vec2(sin_theta_x, sin_theta_y) + 0.5);
|
||||
|
||||
gl_FragColor = vec4(detail0.xyz, 1.);
|
||||
FragColor = vec4(detail0.xyz, 1.);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@ uniform sampler2D tex;
|
||||
|
||||
noperspective in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec4 NormalDepth;
|
||||
|
||||
void main() {
|
||||
vec4 col = texture2D(tex, uv);
|
||||
vec4 col = texture(tex, uv);
|
||||
if (col.a < 0.5)
|
||||
discard;
|
||||
gl_FragColor = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
NormalDepth = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,15 +6,16 @@ uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color = texture2D(Albedo, uv);
|
||||
vec4 color = texture(Albedo, uv);
|
||||
if (color.a < 0.5) discard;
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
vec3 DiffuseComponent = texture2D(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture2D(SpecularMap, tc).xyz;
|
||||
float ao = texture2D(SSAO, tc).x;
|
||||
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
||||
float ao = texture(SSAO, tc).x;
|
||||
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent;
|
||||
gl_FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#version 130
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D normals_and_depth;
|
||||
uniform mat4 invproj;
|
||||
uniform vec2 screen;
|
||||
@@ -13,13 +13,13 @@ void main(void)
|
||||
{
|
||||
vec2 xy = gl_FragCoord.xy / screen;
|
||||
float FragZ = gl_FragCoord.z;
|
||||
float EnvZ = texture2D(normals_and_depth, xy).a;
|
||||
float EnvZ = texture(normals_and_depth, xy).a;
|
||||
vec4 FragmentPos = invproj * (2. * vec4(xy, FragZ, 1.0) - 1.);
|
||||
FragmentPos /= FragmentPos.w;
|
||||
vec4 EnvPos = invproj * (2. * vec4(xy, EnvZ, 1.0) - 1.);
|
||||
EnvPos /= EnvPos.w;
|
||||
float len = dot(vec3(1.0), abs(texture2D(normals_and_depth, xy).xyz));
|
||||
float len = dot(vec3(1.0), abs(texture(normals_and_depth, xy).xyz));
|
||||
float alpha = (len < 0.2) ? 1. : clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
|
||||
color = texture2D(texture, tc);
|
||||
color = texture(tex, tc);
|
||||
color.a *= alpha * smoothstep(1., 0.8, lf);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#version 130
|
||||
uniform sampler2D tex;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(tex, gl_TexCoord[0].xy);
|
||||
FragColor = texture(tex, gl_TexCoord[0].xy);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
out vec4 FragColor;
|
||||
// Separated penumbra, horizontal
|
||||
|
||||
void main()
|
||||
@@ -13,41 +14,41 @@ void main()
|
||||
float width = 0.0;
|
||||
float zsum = 0.00001;
|
||||
|
||||
tmp = texture2D(tex, vec2(X - 5.13333 * pixel.x, Y));
|
||||
tmp = texture(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));
|
||||
tmp = texture(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));
|
||||
tmp = texture(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));
|
||||
tmp = texture(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));
|
||||
tmp = texture(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));
|
||||
tmp = texture(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));
|
||||
tmp = texture(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);
|
||||
FragColor = vec4(sum, (width / zsum) * hasz, hasz, 1.0);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Separated penumbra, vertical
|
||||
|
||||
void main()
|
||||
@@ -13,41 +15,41 @@ void main()
|
||||
float width = 0.0;
|
||||
float zsum = 0.00001;
|
||||
|
||||
tmp = texture2D(tex, vec2(X, Y - 5.13333 * pixel.y));
|
||||
tmp = texture(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));
|
||||
tmp = texture(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));
|
||||
tmp = texture(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));
|
||||
tmp = texture(tex, vec2(X, Y));
|
||||
sum += tmp.x * 0.209473;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture2D(tex, vec2(X, Y + 1.4 * pixel.y));
|
||||
tmp = texture(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 + 3.26667 * pixel.y));
|
||||
tmp = texture(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 + 5.13333 * pixel.y));
|
||||
tmp = texture(tex, vec2(X, Y + 5.13333 * pixel.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);
|
||||
FragColor = vec4(sum, (width / zsum) * hasz, hasz, 1.0);
|
||||
}
|
||||
|
||||
@@ -9,10 +9,12 @@ uniform mat4 invproj;
|
||||
uniform mat4 viewm;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 Diffuse;
|
||||
out vec4 Specular;
|
||||
|
||||
void main() {
|
||||
vec2 texc = uv;
|
||||
float z = texture2D(ntex, texc).a;
|
||||
float z = texture(ntex, texc).a;
|
||||
|
||||
vec4 xpos = 2.0 * vec4(texc, z, 1.0) - 1.0f;
|
||||
xpos = invproj * xpos;
|
||||
@@ -29,7 +31,7 @@ void main() {
|
||||
float att = energy[i] * 200. / (4. * 3.14 * d * d);
|
||||
float spec_att = (energy[i] + 10.) * 200. / (4. * 3.14 * d * d);
|
||||
|
||||
vec3 norm = texture2D(ntex, texc).xyz;
|
||||
vec3 norm = texture(ntex, texc).xyz;
|
||||
norm = (norm - 0.5) * 2.0;
|
||||
|
||||
// Light Direction
|
||||
@@ -44,6 +46,6 @@ void main() {
|
||||
specular += Specular * light_col * spec_att;
|
||||
}
|
||||
|
||||
gl_FragData[0] = vec4(diffuse, 1.);
|
||||
gl_FragData[1] = vec4(specular , 1.);
|
||||
Diffuse = vec4(diffuse, 1.);
|
||||
Specular = vec4(specular , 1.);
|
||||
}
|
||||
|
||||
@@ -5,25 +5,26 @@ uniform sampler2D dtex;
|
||||
uniform int viz;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 tc = uv;
|
||||
|
||||
vec4 shiftval = texture2D(dtex, tc) / vec4(50.0);
|
||||
vec4 shiftval = texture(dtex, tc) / vec4(50.0);
|
||||
vec2 shift;
|
||||
shift.x = -shiftval.x + shiftval.y;
|
||||
shift.y = -shiftval.z + shiftval.w;
|
||||
|
||||
tc += shift;
|
||||
|
||||
vec4 newcol = texture2D(tex, tc);
|
||||
vec4 newcol = texture(tex, tc);
|
||||
|
||||
if (viz < 1)
|
||||
{
|
||||
gl_FragColor = newcol;
|
||||
FragColor = newcol;
|
||||
} else
|
||||
{
|
||||
gl_FragColor = shiftval * vec4(50.0);
|
||||
FragColor = shiftval * vec4(50.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,17 +4,19 @@ uniform sampler2D normals_and_depth;
|
||||
uniform mat4 invproj;
|
||||
uniform vec2 screen;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 xy = gl_FragCoord.xy / screen;
|
||||
float FragZ = gl_FragCoord.z;
|
||||
float EnvZ = texture2D(normals_and_depth, xy).a;
|
||||
float EnvZ = texture(normals_and_depth, xy).a;
|
||||
vec4 FragmentPos = invproj * (2. * vec4(xy, FragZ, 1.0) - 1.);
|
||||
FragmentPos /= FragmentPos.w;
|
||||
vec4 EnvPos = invproj * (2. * vec4(xy, EnvZ, 1.0) - 1.);
|
||||
EnvPos /= EnvPos.w;
|
||||
float len = dot(vec3(1.0), abs(texture2D(normals_and_depth, xy).xyz));
|
||||
float len = dot(vec3(1.0), abs(texture(normals_and_depth, xy).xyz));
|
||||
float alpha = (len < 0.2) ? 1. : clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
|
||||
gl_FragColor = texture2D(tex, gl_PointCoord.xy);
|
||||
gl_FragColor.a *= alpha;
|
||||
FragColor = texture(tex, gl_PointCoord.xy);
|
||||
FragColor.a *= alpha;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
uniform sampler2D halft; // half is a reserved word
|
||||
uniform sampler2D quarter;
|
||||
uniform sampler2D eighth;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 val[3];
|
||||
val[0] = texture2D(halft, gl_TexCoord[0].xy).xyz;
|
||||
val[1] = texture2D(quarter, gl_TexCoord[0].xy).xyz;
|
||||
val[2] = texture2D(eighth, gl_TexCoord[0].xy).xyz;
|
||||
val[0] = texture(halft, gl_TexCoord[0].xy).xyz;
|
||||
val[1] = texture(quarter, gl_TexCoord[0].xy).xyz;
|
||||
val[2] = texture(eighth, gl_TexCoord[0].xy).xyz;
|
||||
|
||||
// Find the first level with a penumbra value
|
||||
int i;
|
||||
@@ -41,5 +42,5 @@ void main()
|
||||
outval = 1.0 - mix(val[down].x, val[up].x, interp);
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(vec3(outval), 1.0);
|
||||
FragColor = vec4(vec3(outval), 1.0);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ uniform int low;
|
||||
|
||||
in vec3 wpos;
|
||||
in vec2 texc;
|
||||
out vec4 FragColor;
|
||||
|
||||
float luminanceImp()
|
||||
{
|
||||
@@ -13,7 +14,7 @@ float luminanceImp()
|
||||
if (low > 0) return 1.0;
|
||||
|
||||
const vec3 weights = vec3(0.2126, 0.7152, 0.0722); // ITU-R BT. 709
|
||||
vec3 col = texture2D(ctex, texc).xyz;
|
||||
vec3 col = texture(ctex, texc).xyz;
|
||||
|
||||
float luma = dot(weights, col);
|
||||
|
||||
@@ -51,7 +52,7 @@ float depthImp(float linearz)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 ntmp = texture2D(ntex, texc);
|
||||
vec4 ntmp = texture(ntex, texc);
|
||||
vec3 normal = ntmp.xyz * 2.0 - 1.0;
|
||||
float linearz = ntmp.a;
|
||||
|
||||
@@ -66,6 +67,6 @@ void main()
|
||||
importance = ceil(importance) * low;
|
||||
importance /= steps;
|
||||
|
||||
gl_FragColor = vec4(importance);
|
||||
FragColor = vec4(importance);
|
||||
gl_FragDepth = 1.0 - importance;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ float decdepth(vec4 rgba) {
|
||||
void main()
|
||||
{
|
||||
texc = gl_Vertex.xy / vec2(32767.0);
|
||||
float z = decdepth(vec4(texture2D(dtex, texc).xyz, 0.0));
|
||||
float z = decdepth(vec4(texture(dtex, texc).xyz, 0.0));
|
||||
|
||||
vec3 tmp = vec3(texc, z);
|
||||
tmp = tmp * 2.0 - 1.0;
|
||||
|
||||
@@ -6,6 +6,7 @@ uniform int wireframe;
|
||||
uniform float objectid;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
vec4 encdepth(float v) {
|
||||
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
|
||||
@@ -17,7 +18,7 @@ vec4 encdepth(float v) {
|
||||
void main() {
|
||||
|
||||
if (hastex != 0) {
|
||||
float alpha = texture2D(tex, uv).a;
|
||||
float alpha = texture(tex, uv).a;
|
||||
|
||||
if (alpha < 0.5)
|
||||
discard;
|
||||
@@ -25,13 +26,13 @@ void main() {
|
||||
|
||||
if (viz < 1)
|
||||
{
|
||||
gl_FragColor = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
|
||||
FragColor = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
|
||||
}
|
||||
else {
|
||||
if (wireframe > 0)
|
||||
gl_FragColor = vec4(1.0);
|
||||
FragColor = vec4(1.0);
|
||||
else
|
||||
gl_FragColor = texture2D(tex, uv);
|
||||
FragColor = texture(tex, uv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ void main()
|
||||
|
||||
vec2 tc = pos.xy * vec2(0.5) + vec2(0.5);
|
||||
|
||||
float movex = decdepth(texture2D(warpx, tc));
|
||||
float movey = decdepth(texture2D(warpy, tc));
|
||||
float movex = decdepth(texture(warpx, tc));
|
||||
float movey = decdepth(texture(warpy, tc));
|
||||
|
||||
float dx = movex * 2.0 - 1.0;
|
||||
float dy = movey * 2.0 - 1.0;
|
||||
|
||||
@@ -3,6 +3,8 @@ uniform sampler2D tex;
|
||||
uniform int size;
|
||||
uniform vec2 pixel;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
vec4 encdepth(float v) {
|
||||
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
|
||||
enc = fract(enc);
|
||||
@@ -22,7 +24,7 @@ void main()
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
float col = texture2D(tex, tc).x;
|
||||
float col = texture(tex, tc).x;
|
||||
|
||||
lower += col * step(tc.x, origtc.x);
|
||||
total += col;
|
||||
@@ -51,5 +53,5 @@ void main()
|
||||
res = res * 0.5 + 0.5;
|
||||
res = clamp(res, 0.01, 0.99);
|
||||
|
||||
gl_FragColor = encdepth(res);
|
||||
FragColor = encdepth(res);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ uniform sampler2D tex;
|
||||
uniform int size;
|
||||
uniform vec2 pixel;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
vec4 encdepth(float v) {
|
||||
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
|
||||
enc = fract(enc);
|
||||
@@ -22,7 +24,7 @@ void main()
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
float col = texture2D(tex, tc).x;
|
||||
float col = texture(tex, tc).x;
|
||||
|
||||
lower += col * step(tc.y, origtc.y);
|
||||
total += col;
|
||||
@@ -51,5 +53,5 @@ void main()
|
||||
res = res * 0.5 + 0.5;
|
||||
res = clamp(res, 0.01, 0.99);
|
||||
|
||||
gl_FragColor = encdepth(res);
|
||||
FragColor = encdepth(res);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ in vec2 uv;
|
||||
in vec2 uv_cl;
|
||||
in vec3 vertex;
|
||||
in vec2 uv_fast;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -32,26 +33,26 @@ void main()
|
||||
vec3 V = normalize(vertex);
|
||||
vec3 L = normalize(vec3(sun_pos));
|
||||
|
||||
vec3 col = texture2D(tex, vec2((L.y + 1.0) / 2.0, V.y)).xyz;
|
||||
vec3 col = texture(tex, vec2((L.y + 1.0) / 2.0, V.y)).xyz;
|
||||
|
||||
float vl = clamp(dot(V, L), 0., 1.);
|
||||
|
||||
float paint = texture2D(tex, uv_temp * 3).a;
|
||||
float paint = texture(tex, uv_temp * 3).a;
|
||||
|
||||
uv_temp += 20;
|
||||
//float paint2 = texture2D(tex, uv_temp * 5).a;
|
||||
//float paint2 = texture(tex, uv_temp * 5).a;
|
||||
|
||||
float paint2 = texture2D(tex, uv * 5.).a;
|
||||
float paint2 = texture(tex, uv * 5.).a;
|
||||
|
||||
// Get the general cloud mask
|
||||
|
||||
|
||||
float hello = texture2D(glow_tex, (uv_cl + paint2 * 0.07) *2.).g;
|
||||
float hello = texture(glow_tex, (uv_cl + paint2 * 0.07) *2.).g;
|
||||
|
||||
float cld_mask = texture2D(glow_tex, (uv_anim + hello * 0.007 )).r;
|
||||
float cld_mask = texture(glow_tex, (uv_anim + hello * 0.007 )).r;
|
||||
|
||||
vec2 fast = vec2(-uv_fast.x, uv_fast.y);// + (hello * 0.007);
|
||||
float cld_fast = texture2D(glow_tex, fast ).r;
|
||||
float cld_fast = texture(glow_tex, fast ).r;
|
||||
|
||||
|
||||
|
||||
@@ -62,8 +63,8 @@ void main()
|
||||
col = cld_mask + col*(1. - cld_mask);
|
||||
col = cld_fast + col*(1. - cld_fast);
|
||||
|
||||
gl_FragColor = vec4( vec3(col * paint * paint2), 1.0);
|
||||
FragColor = vec4( vec3(col * paint * paint2), 1.0);
|
||||
|
||||
|
||||
//gl_FragColor = vec4(vec3(ou), 1.0);
|
||||
//FragColor = vec4(vec3(ou), 1.0);
|
||||
}
|
||||
|
||||
@@ -12,14 +12,15 @@ uniform vec3 ambient;
|
||||
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main() {
|
||||
// Splatting part
|
||||
vec4 splatting = texture2D(tex_layout, uv_bis);
|
||||
vec4 detail0 = texture2D(tex_detail0, uv);
|
||||
vec4 detail1 = texture2D(tex_detail1, uv);
|
||||
vec4 detail2 = texture2D(tex_detail2, uv);
|
||||
vec4 detail3 = texture2D(tex_detail3, uv);
|
||||
vec4 splatting = texture(tex_layout, uv_bis);
|
||||
vec4 detail0 = texture(tex_detail0, uv);
|
||||
vec4 detail1 = texture(tex_detail1, uv);
|
||||
vec4 detail2 = texture(tex_detail2, uv);
|
||||
vec4 detail3 = texture(tex_detail3, uv);
|
||||
vec4 detail4 = vec4(0.0);
|
||||
|
||||
vec4 splatted = splatting.r * detail0 +
|
||||
@@ -28,12 +29,10 @@ void main() {
|
||||
(1.0 - splatting.r - splatting.g - splatting.b) * detail3;
|
||||
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
vec3 DiffuseComponent = texture2D(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture2D(SpecularMap, tc).xyz;
|
||||
float ao = texture2D(SSAO, tc).x;
|
||||
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
||||
float ao = texture(SSAO, tc).x;
|
||||
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent;
|
||||
|
||||
gl_FragColor = vec4(splatted.xyz * LightFactor, 1.);
|
||||
|
||||
// gl_FragData[2] = vec4(1. - splatted.a);
|
||||
FragColor = vec4(splatted.xyz * LightFactor, 1.);
|
||||
}
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
#version 130
|
||||
uniform sampler2D normals_and_depth;
|
||||
uniform sampler2D noise_texture;
|
||||
uniform mat4 invprojm;
|
||||
uniform mat4 projm;
|
||||
uniform vec4 samplePoints[16];
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
const float strengh = 4.;
|
||||
const float radius = .4f;
|
||||
|
||||
#define SAMPLES 16
|
||||
#define SAMPLES 8
|
||||
|
||||
const float invSamples = strengh / SAMPLES;
|
||||
|
||||
// Found here : http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
|
||||
float rand(vec2 co)
|
||||
{
|
||||
return fract(sin(dot(co.xy,vec2(12.9898,78.233))) * 43758.5453);
|
||||
return texture(noise_texture, co).x;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 cur = texture2D(normals_and_depth, uv);
|
||||
float curdepth = texture2D(normals_and_depth, uv).a;
|
||||
vec4 cur = texture(normals_and_depth, uv);
|
||||
float curdepth = texture(normals_and_depth, uv).a;
|
||||
vec4 FragPos = invprojm * (2.0f * vec4(uv, curdepth, 1.0f) - 1.0f);
|
||||
FragPos /= FragPos.w;
|
||||
|
||||
@@ -50,7 +51,7 @@ void main(void)
|
||||
|
||||
bool isInsideTexture = (sampleProj.x > -1.) && (sampleProj.x < 1.) && (sampleProj.y > -1.) && (sampleProj.y < 1.);
|
||||
// get the depth of the occluder fragment
|
||||
float occluderFragmentDepth = texture2D(normals_and_depth, (sampleProj.xy * 0.5) + 0.5).a;
|
||||
float occluderFragmentDepth = texture(normals_and_depth, (sampleProj.xy * 0.5) + 0.5).a;
|
||||
// Position of the occluder fragment in worldSpace
|
||||
vec4 occluderPos = invprojm * vec4(sampleProj.xy, 2.0 * occluderFragmentDepth - 1.0, 1.0f);
|
||||
occluderPos /= occluderPos.w;
|
||||
@@ -62,5 +63,5 @@ void main(void)
|
||||
// output the result
|
||||
float ao = 1.0 - bl * invSamples;
|
||||
|
||||
gl_FragColor = vec4(ao);
|
||||
FragColor = vec4(ao);
|
||||
}
|
||||
|
||||
@@ -9,10 +9,14 @@ uniform mat4 invproj;
|
||||
uniform int hasclouds;
|
||||
uniform vec2 wind;
|
||||
|
||||
out vec4 Diff;
|
||||
out vec4 Spec;
|
||||
out vec4 SpecularMap;
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 texc = gl_FragCoord.xy / screen;
|
||||
float z = texture2D(ntex, texc).a;
|
||||
float z = texture(ntex, texc).a;
|
||||
vec4 xpos = 2.0 * vec4(texc, z, 1.0) - 1.0;
|
||||
xpos = invproj * xpos;
|
||||
xpos.xyz /= xpos.w;
|
||||
@@ -20,12 +24,12 @@ void main() {
|
||||
if (z < 0.03)
|
||||
{
|
||||
// Skyboxes are fully lit
|
||||
gl_FragData[0] = vec4(1.0);
|
||||
gl_FragData[1] = vec4(1.0);
|
||||
Diff = vec4(1.0);
|
||||
Spec = vec4(1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 norm = texture2D(ntex, texc).xyz;
|
||||
vec3 norm = texture(ntex, texc).xyz;
|
||||
norm = (norm - 0.5) * 2.0;
|
||||
|
||||
// Normalized on the cpu
|
||||
@@ -41,13 +45,13 @@ void main() {
|
||||
if (hasclouds == 1)
|
||||
{
|
||||
vec2 cloudcoord = (xpos.xz * 0.00833333) + wind;
|
||||
float cloud = texture2D(cloudtex, cloudcoord).x;
|
||||
float cloud = texture(cloudtex, cloudcoord).x;
|
||||
//float cloud = step(0.5, cloudcoord.x) * step(0.5, cloudcoord.y);
|
||||
|
||||
outcol *= cloud;
|
||||
}
|
||||
|
||||
gl_FragData[0] = vec4(NdotL * col, 1.);
|
||||
gl_FragData[1] = vec4(Specular * col, 1.);
|
||||
gl_FragData[2] = vec4(1.0);
|
||||
Diff = vec4(NdotL * col, 1.);
|
||||
Spec = vec4(Specular * col, 1.);
|
||||
SpecularMap = vec4(1.0);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ uniform int hasclouds;
|
||||
uniform vec2 wind;
|
||||
uniform float shadowoffset;
|
||||
|
||||
out vec4 FragColor;
|
||||
out vec4 OtherOutput;
|
||||
|
||||
float decdepth(vec4 rgba) {
|
||||
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0));
|
||||
}
|
||||
@@ -22,18 +25,18 @@ float decdepth(vec4 rgba) {
|
||||
void main() {
|
||||
|
||||
vec2 texc = gl_FragCoord.xy / screen;
|
||||
vec4 depthread = texture2D(dtex, texc);
|
||||
vec4 depthread = texture(dtex, texc);
|
||||
float z = decdepth(vec4(depthread.xyz, 0.0));
|
||||
|
||||
if (z < 0.03)
|
||||
{
|
||||
// Skyboxes are fully lit
|
||||
gl_FragData[0] = vec4(1.0);
|
||||
gl_FragData[1] = vec4(0.0);
|
||||
FragColor = vec4(1.0);
|
||||
OtherOutput = vec4(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 norm = texture2D(ntex, texc).xyz;
|
||||
vec3 norm = texture(ntex, texc).xyz;
|
||||
norm = (norm - 0.5) * 2.0;
|
||||
|
||||
// Normalized on the cpu
|
||||
@@ -55,7 +58,7 @@ void main() {
|
||||
if (hasclouds == 1)
|
||||
{
|
||||
vec2 cloudcoord = (xpos.xz * 0.00833333) + wind;
|
||||
float cloud = texture2D(cloudtex, cloudcoord).x;
|
||||
float cloud = texture(cloudtex, cloudcoord).x;
|
||||
//float cloud = step(0.5, cloudcoord.x) * step(0.5, cloudcoord.y);
|
||||
|
||||
outcol *= cloud;
|
||||
@@ -65,13 +68,13 @@ void main() {
|
||||
vec3 shadowcoord = (shadowmat * vec4(xpos.xyz, 1.0)).xyz;
|
||||
shadowcoord = (shadowcoord * 0.5) + vec3(0.5);
|
||||
|
||||
float movex = decdepth(texture2D(warpx, shadowcoord.xy));
|
||||
float movey = decdepth(texture2D(warpy, shadowcoord.xy));
|
||||
float movex = decdepth(texture(warpx, shadowcoord.xy));
|
||||
float movey = decdepth(texture(warpy, shadowcoord.xy));
|
||||
float dx = movex * 2.0 - 1.0;
|
||||
float dy = movey * 2.0 - 1.0;
|
||||
shadowcoord.xy += vec2(dx, dy);
|
||||
|
||||
vec4 shadowread = texture2D(shadowtex, shadowcoord.xy);
|
||||
vec4 shadowread = texture(shadowtex, shadowcoord.xy);
|
||||
float shadowmapz = decdepth(vec4(shadowread.xyz, 0.0));
|
||||
|
||||
float moved = (abs(dx) + abs(dy)) * 0.5;
|
||||
@@ -94,10 +97,10 @@ void main() {
|
||||
bias = clamp(bias, 0.001, abi);
|
||||
|
||||
// This ID, and four IDs around this must match for a shadow pixel
|
||||
float right = texture2D(shadowtex, shadowcoord.xy + vec2(shadowoffset, 0.0)).a;
|
||||
float left = texture2D(shadowtex, shadowcoord.xy + vec2(-shadowoffset, 0.0)).a;
|
||||
float up = texture2D(shadowtex, shadowcoord.xy + vec2(0.0, shadowoffset)).a;
|
||||
float down = texture2D(shadowtex, shadowcoord.xy + vec2(0.0, -shadowoffset)).a;
|
||||
float right = texture(shadowtex, shadowcoord.xy + vec2(shadowoffset, 0.0)).a;
|
||||
float left = texture(shadowtex, shadowcoord.xy + vec2(-shadowoffset, 0.0)).a;
|
||||
float up = texture(shadowtex, shadowcoord.xy + vec2(0.0, shadowoffset)).a;
|
||||
float down = texture(shadowtex, shadowcoord.xy + vec2(0.0, -shadowoffset)).a;
|
||||
|
||||
float matching = ((right + left + up + down) * 0.25) - shadowread.a;
|
||||
matching = abs(matching) * 400.0;
|
||||
@@ -115,6 +118,6 @@ void main() {
|
||||
/* outcol.r = (shadowcoord.z - shadowmapz) * 50.0;
|
||||
outcol.g = moved;*/
|
||||
|
||||
gl_FragData[0] = vec4(outcol, 0.05);
|
||||
gl_FragData[1] = vec4(shadowed, penumbra, shadowed, shadowed);
|
||||
FragColor = vec4(outcol, 0.05);
|
||||
OtherOutput = vec4(shadowed, penumbra, shadowed, shadowed);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#version 130
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(texture, uv);
|
||||
FragColor = texture(tex, uv);
|
||||
}
|
||||
@@ -12,12 +12,13 @@ noperspective in vec3 lightVec;
|
||||
noperspective in vec3 halfVec;
|
||||
noperspective in vec3 eyeVec;
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
// lookup normal from normal map, move from [0,1] to [-1, 1] range, normalize
|
||||
vec3 normal = 2.0 * texture2D (BumpTex1, uv + delta1).rgb - 1.0;
|
||||
vec3 normal2 = 2.0 * texture2D (BumpTex2, uv + delta2).rgb - 1.0;
|
||||
vec3 normal = 2.0 * texture (BumpTex1, uv + delta1).rgb - 1.0;
|
||||
vec3 normal2 = 2.0 * texture (BumpTex2, uv + delta2).rgb - 1.0;
|
||||
|
||||
// scale normals
|
||||
normal.y = 4.0*normal.y;
|
||||
@@ -30,7 +31,7 @@ void main()
|
||||
vec4 diffuseMaterial;
|
||||
vec4 diffuseLight;
|
||||
|
||||
diffuseMaterial = texture2D (DecalTex, uv + vec2(delta1.x, 0.0));
|
||||
diffuseMaterial = texture (DecalTex, uv + vec2(delta1.x, 0.0));
|
||||
diffuseLight = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
vec3 col = diffuseMaterial.xyz * (0.3 + lamberFactor*0.7);
|
||||
@@ -53,5 +54,5 @@ void main()
|
||||
float summed = dot(vec3(1.0), col) / 3.0;
|
||||
float alpha = 0.9 + 0.1 * smoothstep(0.0, 1.0, summed);
|
||||
|
||||
gl_FragColor = vec4(col, alpha);
|
||||
FragColor = vec4(col, alpha);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#version 130
|
||||
out vec4 FragColor;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0);
|
||||
FragColor = vec4(1.0);
|
||||
}
|
||||
|
||||
@@ -29,37 +29,6 @@ using namespace core;
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
void NormalMapProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
{
|
||||
core::matrix4 ModelViewProjectionMatrix = srv->getVideoDriver()->getTransform(ETS_PROJECTION);
|
||||
ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_VIEW);
|
||||
ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_WORLD);
|
||||
core::matrix4 TransposeInverseModelView = srv->getVideoDriver()->getTransform(ETS_VIEW);
|
||||
TransposeInverseModelView *= srv->getVideoDriver()->getTransform(ETS_WORLD);
|
||||
TransposeInverseModelView.makeInverse();
|
||||
TransposeInverseModelView = TransposeInverseModelView.getTransposed();
|
||||
|
||||
srv->setVertexShaderConstant("ModelViewProjectionMatrix", ModelViewProjectionMatrix.pointer(), 16);
|
||||
srv->setVertexShaderConstant("TransposeInverseModelView", TransposeInverseModelView.pointer(), 16);
|
||||
|
||||
if (!firstdone)
|
||||
{
|
||||
s32 texture = 0;
|
||||
srv->setPixelShaderConstant("texture", &texture, 1);
|
||||
|
||||
s32 normaltex = 1;
|
||||
srv->setPixelShaderConstant("normalMap", &normaltex, 1);
|
||||
|
||||
// We could calculate light direction as coming from the sun (then we'd need to
|
||||
// transform it into camera space). But I find that pretending light
|
||||
// comes from the camera gives good results
|
||||
|
||||
firstdone = true;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
void WaterShaderProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
{
|
||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||
@@ -179,42 +148,6 @@ void SkyboxProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
void SplattingProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
{
|
||||
core::matrix4 ModelViewProjectionMatrix = srv->getVideoDriver()->getTransform(ETS_PROJECTION);
|
||||
ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_VIEW);
|
||||
ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_WORLD);
|
||||
core::matrix4 TransposeInverseModelView = srv->getVideoDriver()->getTransform(ETS_VIEW);
|
||||
TransposeInverseModelView *= srv->getVideoDriver()->getTransform(ETS_WORLD);
|
||||
TransposeInverseModelView.makeInverse();
|
||||
TransposeInverseModelView = TransposeInverseModelView.getTransposed();
|
||||
|
||||
srv->setVertexShaderConstant("ModelViewProjectionMatrix", ModelViewProjectionMatrix.pointer(), 16);
|
||||
srv->setVertexShaderConstant("TransposeInverseModelView", TransposeInverseModelView.pointer(), 16);
|
||||
|
||||
if (!firstdone)
|
||||
{
|
||||
s32 tex_layout = 1;
|
||||
srv->setPixelShaderConstant("tex_layout", &tex_layout, 1);
|
||||
|
||||
s32 tex_detail0 = 2;
|
||||
srv->setPixelShaderConstant("tex_detail0", &tex_detail0, 1);
|
||||
|
||||
s32 tex_detail1 = 3;
|
||||
srv->setPixelShaderConstant("tex_detail1", &tex_detail1, 1);
|
||||
|
||||
s32 tex_detail2 = 4;
|
||||
srv->setPixelShaderConstant("tex_detail2", &tex_detail2, 1);
|
||||
|
||||
s32 tex_detail3 = 5;
|
||||
srv->setPixelShaderConstant("tex_detail3", &tex_detail3, 1);
|
||||
|
||||
firstdone = true;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
void BubbleEffectProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
{
|
||||
const float start = fabsf(mat.MaterialTypeParam2);
|
||||
|
||||
@@ -50,22 +50,6 @@ protected:
|
||||
|
||||
//
|
||||
|
||||
class NormalMapProvider: public CallBase
|
||||
{
|
||||
public:
|
||||
virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
|
||||
|
||||
NormalMapProvider(bool withLightmap)
|
||||
{
|
||||
m_with_lightmap = withLightmap;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_with_lightmap;
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
class WaterShaderProvider: public CallBase
|
||||
{
|
||||
public:
|
||||
@@ -133,6 +117,16 @@ public:
|
||||
m_amplitude = amp;
|
||||
}
|
||||
|
||||
float getSpeed() const
|
||||
{
|
||||
return m_speed;
|
||||
}
|
||||
|
||||
float getAmplitude() const
|
||||
{
|
||||
return m_amplitude;
|
||||
}
|
||||
|
||||
private:
|
||||
float m_amplitude, m_speed;
|
||||
};
|
||||
@@ -156,14 +150,6 @@ private:
|
||||
|
||||
//
|
||||
|
||||
class SplattingProvider: public CallBase
|
||||
{
|
||||
public:
|
||||
virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
class BubbleEffectProvider: public CallBase
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -299,7 +299,7 @@ void bindUniformToTextureUnit(GLuint location, GLuint texid, unsigned textureUni
|
||||
static GLuint TexturedQuadShader;
|
||||
static GLuint TexturedQuadAttribPosition;
|
||||
static GLuint TexturedQuadAttribTexCoord;
|
||||
static GLuint TexturedQuadUniformTexture;
|
||||
static GLuint TexturedQuadUniformTex;
|
||||
static GLuint TexturedQuadUniformCenter;
|
||||
static GLuint TexturedQuadUniformSize;
|
||||
static GLuint TexturedQuadUniformTexcenter;
|
||||
@@ -311,7 +311,7 @@ static GLuint ColorTexturedQuadShader;
|
||||
static GLuint ColorTexturedQuadAttribPosition;
|
||||
static GLuint ColorTexturedQuadAttribTexCoord;
|
||||
static GLuint ColorTexturedQuadAttribColor;
|
||||
static GLuint ColorTexturedQuadUniformTexture;
|
||||
static GLuint ColorTexturedQuadUniformTex;
|
||||
static GLuint ColorTexturedQuadUniformCenter;
|
||||
static GLuint ColorTexturedQuadUniformSize;
|
||||
static GLuint ColorTexturedQuadUniformTexcenter;
|
||||
@@ -336,7 +336,7 @@ static void drawTexColoredQuad(const video::ITexture *texture, const video::SCol
|
||||
ColorTexturedQuadAttribPosition = glGetAttribLocation(ColorTexturedQuadShader, "position");
|
||||
ColorTexturedQuadAttribTexCoord = glGetAttribLocation(ColorTexturedQuadShader, "texcoord");
|
||||
ColorTexturedQuadAttribColor = glGetAttribLocation(ColorTexturedQuadShader, "color");
|
||||
ColorTexturedQuadUniformTexture = glGetUniformLocation(ColorTexturedQuadShader, "texture");
|
||||
ColorTexturedQuadUniformTex = glGetUniformLocation(ColorTexturedQuadShader, "tex");
|
||||
ColorTexturedQuadUniformCenter = glGetUniformLocation(ColorTexturedQuadShader, "center");
|
||||
ColorTexturedQuadUniformSize = glGetUniformLocation(ColorTexturedQuadShader, "size");
|
||||
ColorTexturedQuadUniformTexcenter = glGetUniformLocation(ColorTexturedQuadShader, "texcenter");
|
||||
@@ -359,7 +359,7 @@ static void drawTexColoredQuad(const video::ITexture *texture, const video::SCol
|
||||
glBindVertexArray(CTQvao);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName());
|
||||
glUniform1i(ColorTexturedQuadUniformTexture, 0);
|
||||
glUniform1i(ColorTexturedQuadUniformTex, 0);
|
||||
glUniform2f(ColorTexturedQuadUniformCenter, center_pos_x, center_pos_y);
|
||||
glUniform2f(ColorTexturedQuadUniformSize, width, height);
|
||||
glUniform2f(ColorTexturedQuadUniformTexcenter, tex_center_pos_x, tex_center_pos_y);
|
||||
@@ -378,7 +378,7 @@ void drawTexQuad(const video::ITexture *texture, float width, float height,
|
||||
|
||||
TexturedQuadAttribPosition = glGetAttribLocation(TexturedQuadShader, "position");
|
||||
TexturedQuadAttribTexCoord = glGetAttribLocation(TexturedQuadShader, "texcoord");
|
||||
TexturedQuadUniformTexture = glGetUniformLocation(TexturedQuadShader, "texture");
|
||||
TexturedQuadUniformTex = glGetUniformLocation(TexturedQuadShader, "tex");
|
||||
TexturedQuadUniformCenter = glGetUniformLocation(TexturedQuadShader, "center");
|
||||
TexturedQuadUniformSize = glGetUniformLocation(TexturedQuadShader, "size");
|
||||
TexturedQuadUniformTexcenter = glGetUniformLocation(TexturedQuadShader, "texcenter");
|
||||
@@ -396,7 +396,7 @@ void drawTexQuad(const video::ITexture *texture, float width, float height,
|
||||
glBindVertexArray(TQvao);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName());
|
||||
glUniform1i(TexturedQuadUniformTexture, 0);
|
||||
glUniform1i(TexturedQuadUniformTex, 0);
|
||||
glUniform2f(TexturedQuadUniformCenter, center_pos_x, center_pos_y);
|
||||
glUniform2f(TexturedQuadUniformSize, width, height);
|
||||
glUniform2f(TexturedQuadUniformTexcenter, tex_center_pos_x, tex_center_pos_y);
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace SimpleParticleRender
|
||||
{
|
||||
GLuint Program;
|
||||
GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
|
||||
GLuint uniform_matrix, uniform_viewmatrix, uniform_texture, uniform_normal_and_depths, uniform_screen, uniform_invproj;
|
||||
GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_normal_and_depths, uniform_screen, uniform_invproj;
|
||||
|
||||
void init()
|
||||
{
|
||||
@@ -105,7 +105,7 @@ namespace SimpleParticleRender
|
||||
|
||||
uniform_matrix = glGetUniformLocation(Program, "ProjectionMatrix");
|
||||
uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix");
|
||||
uniform_texture = glGetUniformLocation(Program, "texture");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_invproj = glGetUniformLocation(Program, "invproj");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_normal_and_depths = glGetUniformLocation(Program, "normals_and_depth");
|
||||
@@ -116,7 +116,7 @@ namespace FlipParticleRender
|
||||
{
|
||||
GLuint Program;
|
||||
GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz, attrib_rotationvec, attrib_anglespeed;
|
||||
GLuint uniform_matrix, uniform_viewmatrix, uniform_texture, uniform_normal_and_depths, uniform_screen, uniform_invproj;
|
||||
GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_normal_and_depths, uniform_screen, uniform_invproj;
|
||||
|
||||
void init()
|
||||
{
|
||||
@@ -132,7 +132,7 @@ namespace FlipParticleRender
|
||||
|
||||
uniform_matrix = glGetUniformLocation(Program, "ProjectionMatrix");
|
||||
uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix");
|
||||
uniform_texture = glGetUniformLocation(Program, "texture");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_invproj = glGetUniformLocation(Program, "invproj");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_normal_and_depths = glGetUniformLocation(Program, "normals_and_depth");
|
||||
@@ -471,12 +471,12 @@ void ParticleSystemProxy::simulateHeightmap()
|
||||
glEnableVertexAttribArray(HeightmapSimulationShader::attrib_position);
|
||||
glEnableVertexAttribArray(HeightmapSimulationShader::attrib_lifetime);
|
||||
glEnableVertexAttribArray(HeightmapSimulationShader::attrib_velocity);
|
||||
glEnableVertexAttribArray(HeightmapSimulationShader::attrib_size);
|
||||
// glEnableVertexAttribArray(HeightmapSimulationShader::attrib_size);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]);
|
||||
glVertexAttribPointer(HeightmapSimulationShader::attrib_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0);
|
||||
glVertexAttribPointer(HeightmapSimulationShader::attrib_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float)));
|
||||
glVertexAttribPointer(HeightmapSimulationShader::attrib_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float)));
|
||||
glVertexAttribPointer(HeightmapSimulationShader::attrib_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(7 * sizeof(float)));
|
||||
//glVertexAttribPointer(HeightmapSimulationShader::attrib_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(7 * sizeof(float)));
|
||||
glEnableVertexAttribArray(HeightmapSimulationShader::attrib_initial_position);
|
||||
glEnableVertexAttribArray(HeightmapSimulationShader::attrib_initial_lifetime);
|
||||
glEnableVertexAttribArray(HeightmapSimulationShader::attrib_initial_velocity);
|
||||
@@ -506,7 +506,7 @@ void ParticleSystemProxy::simulateHeightmap()
|
||||
glDisableVertexAttribArray(HeightmapSimulationShader::attrib_position);
|
||||
glDisableVertexAttribArray(HeightmapSimulationShader::attrib_lifetime);
|
||||
glDisableVertexAttribArray(HeightmapSimulationShader::attrib_velocity);
|
||||
glDisableVertexAttribArray(HeightmapSimulationShader::attrib_size);
|
||||
// glDisableVertexAttribArray(HeightmapSimulationShader::attrib_size);
|
||||
glDisableVertexAttribArray(HeightmapSimulationShader::attrib_initial_position);
|
||||
glDisableVertexAttribArray(HeightmapSimulationShader::attrib_initial_lifetime);
|
||||
glDisableVertexAttribArray(HeightmapSimulationShader::attrib_initial_velocity);
|
||||
@@ -592,7 +592,7 @@ void ParticleSystemProxy::drawFlip()
|
||||
(float)UserConfigParams::m_height
|
||||
};
|
||||
|
||||
bindUniformToTextureUnit(FlipParticleRender::uniform_texture, texture, 0);
|
||||
bindUniformToTextureUnit(FlipParticleRender::uniform_tex, texture, 0);
|
||||
bindUniformToTextureUnit(FlipParticleRender::uniform_normal_and_depths, normal_and_depth, 1);
|
||||
|
||||
glUniformMatrix4fv(FlipParticleRender::uniform_invproj, 1, GL_FALSE, irr_driver->getInvProjMatrix().pointer());
|
||||
@@ -661,7 +661,7 @@ void ParticleSystemProxy::drawNotFlip()
|
||||
(float)UserConfigParams::m_height
|
||||
};
|
||||
|
||||
bindUniformToTextureUnit(SimpleParticleRender::uniform_texture, texture, 0);
|
||||
bindUniformToTextureUnit(SimpleParticleRender::uniform_tex, texture, 0);
|
||||
bindUniformToTextureUnit(SimpleParticleRender::uniform_normal_and_depths, normal_and_depth, 1);
|
||||
|
||||
glUniformMatrix4fv(SimpleParticleRender::uniform_invproj, 1, GL_FALSE, irr_driver->getInvProjMatrix().pointer());
|
||||
|
||||
@@ -490,8 +490,8 @@ void PostProcessing::renderGlow(ITexture *tex)
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(tex)->getOpenGLTextureName());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glUniform1i(FullScreenShader::GlowShader::uniform_tex, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
@@ -502,6 +502,7 @@ void PostProcessing::renderGlow(ITexture *tex)
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
ITexture *noise_tex = 0;
|
||||
|
||||
void PostProcessing::renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm)
|
||||
{
|
||||
@@ -522,6 +523,16 @@ void PostProcessing::renderSSAO(const core::matrix4 &invprojm, const core::matri
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glUniform1i(FullScreenShader::SSAOShader::uniform_normals_and_depth, 0);
|
||||
|
||||
if (!noise_tex)
|
||||
noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/tarmac.jpg").c_str());
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(noise_tex)->getOpenGLTextureName());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glUniform1i(FullScreenShader::SSAOShader::uniform_noise_texture, 1);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
@@ -32,10 +32,7 @@ Shaders::Shaders()
|
||||
// Callbacks
|
||||
memset(m_callbacks, 0, sizeof(m_callbacks));
|
||||
|
||||
m_callbacks[ES_NORMAL_MAP_LIGHTMAP] = new NormalMapProvider(true);
|
||||
m_callbacks[ES_NORMAL_MAP] = new NormalMapProvider(false);
|
||||
m_callbacks[ES_SKYBOX] = new SkyboxProvider();
|
||||
m_callbacks[ES_SPLATTING] = new SplattingProvider();
|
||||
m_callbacks[ES_WATER] = new WaterShaderProvider();
|
||||
m_callbacks[ES_GRASS] = new GrassShaderProvider();
|
||||
m_callbacks[ES_BUBBLES] = new BubbleEffectProvider();
|
||||
@@ -116,9 +113,9 @@ void Shaders::loadShaders()
|
||||
m_shaders[ES_SPHERE_MAP] = glslmat(dir + "objectpass.vert", dir + "objectpass_spheremap.frag",
|
||||
m_callbacks[ES_OBJECTPASS], EMT_SOLID);
|
||||
|
||||
m_shaders[ES_GRASS] = glslmat(dir + "grass.vert", dir + "grass.frag",
|
||||
m_shaders[ES_GRASS] = glslmat(dir + "grass.vert", dir + "grass.frag",
|
||||
m_callbacks[ES_GRASS], EMT_TRANSPARENT_ALPHA_CHANNEL);
|
||||
m_shaders[ES_GRASS_REF] = glslmat(dir + "grass.vert", dir + "grass.frag",
|
||||
m_shaders[ES_GRASS_REF] = glslmat(dir + "grass.vert", dir + "grass.frag",
|
||||
m_callbacks[ES_GRASS], EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
|
||||
|
||||
m_shaders[ES_BUBBLES] = glslmat(dir + "bubble.vert", dir + "bubble.frag",
|
||||
@@ -247,6 +244,8 @@ void Shaders::loadShaders()
|
||||
MeshShader::ObjectRefPass2Shader::init();
|
||||
MeshShader::SphereMapShader::init();
|
||||
MeshShader::SplattingShader::init();
|
||||
MeshShader::GrassPass1Shader::init();
|
||||
MeshShader::GrassPass2Shader::init();
|
||||
}
|
||||
|
||||
Shaders::~Shaders()
|
||||
@@ -285,7 +284,6 @@ namespace MeshShader
|
||||
|
||||
void ObjectPass1Shader::init()
|
||||
{
|
||||
initGL();
|
||||
Program = LoadProgram(file_manager->getAsset("shaders/object_pass1.vert").c_str(), file_manager->getAsset("shaders/object_pass1.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
attrib_normal = glGetAttribLocation(Program, "Normal");
|
||||
@@ -309,7 +307,6 @@ namespace MeshShader
|
||||
|
||||
void ObjectRefPass1Shader::init()
|
||||
{
|
||||
initGL();
|
||||
Program = LoadProgram(file_manager->getAsset("shaders/objectref_pass1.vert").c_str(), file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
attrib_normal = glGetAttribLocation(Program, "Normal");
|
||||
@@ -330,7 +327,6 @@ namespace MeshShader
|
||||
GLuint ObjectPass2Shader::attrib_position;
|
||||
GLuint ObjectPass2Shader::attrib_texcoord;
|
||||
GLuint ObjectPass2Shader::uniform_MVP;
|
||||
GLuint ObjectPass2Shader::uniform_TIMV;
|
||||
GLuint ObjectPass2Shader::uniform_Albedo;
|
||||
GLuint ObjectPass2Shader::uniform_DiffuseMap;
|
||||
GLuint ObjectPass2Shader::uniform_SpecularMap;
|
||||
@@ -340,7 +336,6 @@ namespace MeshShader
|
||||
|
||||
void ObjectPass2Shader::init()
|
||||
{
|
||||
initGL();
|
||||
Program = LoadProgram(file_manager->getAsset("shaders/object_pass2.vert").c_str(), file_manager->getAsset("shaders/object_pass2.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||
@@ -369,7 +364,6 @@ namespace MeshShader
|
||||
GLuint ObjectRefPass2Shader::attrib_position;
|
||||
GLuint ObjectRefPass2Shader::attrib_texcoord;
|
||||
GLuint ObjectRefPass2Shader::uniform_MVP;
|
||||
GLuint ObjectRefPass2Shader::uniform_TIMV;
|
||||
GLuint ObjectRefPass2Shader::uniform_Albedo;
|
||||
GLuint ObjectRefPass2Shader::uniform_DiffuseMap;
|
||||
GLuint ObjectRefPass2Shader::uniform_SpecularMap;
|
||||
@@ -404,6 +398,79 @@ namespace MeshShader
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
|
||||
GLuint GrassPass1Shader::Program;
|
||||
GLuint GrassPass1Shader::attrib_position;
|
||||
GLuint GrassPass1Shader::attrib_texcoord;
|
||||
GLuint GrassPass1Shader::attrib_normal;
|
||||
GLuint GrassPass1Shader::attrib_color;
|
||||
GLuint GrassPass1Shader::uniform_MVP;
|
||||
GLuint GrassPass1Shader::uniform_TIMV;
|
||||
GLuint GrassPass1Shader::uniform_tex;
|
||||
GLuint GrassPass1Shader::uniform_windDir;
|
||||
|
||||
void GrassPass1Shader::init()
|
||||
{
|
||||
Program = LoadProgram(file_manager->getAsset("shaders/grass_pass1.vert").c_str(), file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||
attrib_normal = glGetAttribLocation(Program, "Normal");
|
||||
attrib_color = glGetAttribLocation(Program, "Color");
|
||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_windDir = glGetUniformLocation(Program, "windDir");
|
||||
}
|
||||
|
||||
void GrassPass1Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::vector3df &windDirection, unsigned TU_tex)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer());
|
||||
glUniform3f(uniform_windDir, windDirection.X, windDirection.Y, windDirection.Z);
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
}
|
||||
|
||||
GLuint GrassPass2Shader::Program;
|
||||
GLuint GrassPass2Shader::attrib_position;
|
||||
GLuint GrassPass2Shader::attrib_texcoord;
|
||||
GLuint GrassPass2Shader::attrib_color;
|
||||
GLuint GrassPass2Shader::uniform_MVP;
|
||||
GLuint GrassPass2Shader::uniform_Albedo;
|
||||
GLuint GrassPass2Shader::uniform_DiffuseMap;
|
||||
GLuint GrassPass2Shader::uniform_SpecularMap;
|
||||
GLuint GrassPass2Shader::uniform_SSAO;
|
||||
GLuint GrassPass2Shader::uniform_screen;
|
||||
GLuint GrassPass2Shader::uniform_ambient;
|
||||
GLuint GrassPass2Shader::uniform_windDir;
|
||||
|
||||
void GrassPass2Shader::init()
|
||||
{
|
||||
Program = LoadProgram(file_manager->getAsset("shaders/grass_pass2.vert").c_str(), file_manager->getAsset("shaders/objectref_pass2.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||
attrib_color = glGetAttribLocation(Program, "Color");
|
||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||
uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
||||
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
uniform_windDir = glGetUniformLocation(Program, "windDir");
|
||||
}
|
||||
|
||||
void GrassPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||
glUniform1i(uniform_Albedo, TU_Albedo);
|
||||
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
|
||||
glUniform1i(uniform_SpecularMap, TU_SpecularMap);
|
||||
glUniform1i(uniform_SSAO, TU_SSAO);
|
||||
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
glUniform3f(uniform_windDir, windDirection.X, windDirection.Y, windDirection.Z);
|
||||
}
|
||||
|
||||
GLuint NormalMapShader::Program;
|
||||
GLuint NormalMapShader::attrib_position;
|
||||
GLuint NormalMapShader::attrib_texcoord;
|
||||
@@ -415,7 +482,6 @@ namespace MeshShader
|
||||
|
||||
void NormalMapShader::init()
|
||||
{
|
||||
initGL();
|
||||
Program = LoadProgram(file_manager->getAsset("shaders/normalmap.vert").c_str(), file_manager->getAsset("shaders/normalmap.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||
@@ -442,7 +508,6 @@ namespace MeshShader
|
||||
|
||||
void SphereMapShader::init()
|
||||
{
|
||||
initGL();
|
||||
Program = LoadProgram(file_manager->getAsset("shaders/object_pass1.vert").c_str(), file_manager->getAsset("shaders/objectpass_spheremap.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
attrib_normal = glGetAttribLocation(Program, "Normal");
|
||||
@@ -476,7 +541,6 @@ namespace MeshShader
|
||||
|
||||
void SplattingShader::init()
|
||||
{
|
||||
initGL();
|
||||
Program = LoadProgram(file_manager->getAsset("shaders/splatting.vert").c_str(), file_manager->getAsset("shaders/splatting.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||
@@ -517,7 +581,6 @@ namespace MeshShader
|
||||
|
||||
void ColorizeShader::init()
|
||||
{
|
||||
initGL();
|
||||
Program = LoadProgram(file_manager->getAsset("shaders/object_pass2.vert").c_str(), file_manager->getAsset("shaders/colorize.frag").c_str());
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||
@@ -710,6 +773,7 @@ namespace FullScreenShader
|
||||
|
||||
GLuint SSAOShader::Program;
|
||||
GLuint SSAOShader::uniform_normals_and_depth;
|
||||
GLuint SSAOShader::uniform_noise_texture;
|
||||
GLuint SSAOShader::uniform_invprojm;
|
||||
GLuint SSAOShader::uniform_projm;
|
||||
GLuint SSAOShader::uniform_samplePoints;
|
||||
@@ -719,6 +783,7 @@ namespace FullScreenShader
|
||||
{
|
||||
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/ssao.frag").c_str());
|
||||
uniform_normals_and_depth = glGetUniformLocation(Program, "normals_and_depth");
|
||||
uniform_noise_texture = glGetUniformLocation(Program, "noise_texture");
|
||||
uniform_invprojm = glGetUniformLocation(Program, "invprojm");
|
||||
uniform_projm = glGetUniformLocation(Program, "projm");
|
||||
uniform_samplePoints = glGetUniformLocation(Program, "samplePoints[0]");
|
||||
|
||||
@@ -53,7 +53,7 @@ class ObjectPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MVP, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
||||
@@ -64,12 +64,34 @@ class ObjectRefPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MVP, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
||||
};
|
||||
|
||||
class GrassPass1Shader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_normal, attrib_color;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_tex, uniform_windDir;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::vector3df &windDirection, unsigned TU_tex);
|
||||
};
|
||||
|
||||
class GrassPass2Shader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||
static GLuint uniform_MVP, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient, uniform_windDir;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
||||
};
|
||||
|
||||
class NormalMapShader
|
||||
{
|
||||
public:
|
||||
@@ -243,7 +265,7 @@ class SSAOShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_normals_and_depth, uniform_invprojm, uniform_projm, uniform_samplePoints;
|
||||
static GLuint uniform_normals_and_depth, uniform_noise_texture, uniform_invprojm, uniform_projm, uniform_samplePoints;
|
||||
static GLuint vao;
|
||||
static float SSAOSamples[64];
|
||||
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
#include <IMaterialRenderer.h>
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/callbacks.hpp"
|
||||
#include "utils/helpers.hpp"
|
||||
|
||||
static
|
||||
GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_texcoord, GLuint attrib_second_texcoord, GLuint attrib_normal, GLuint attrib_tangent, GLuint attrib_bitangent, size_t stride)
|
||||
GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_texcoord, GLuint attrib_second_texcoord, GLuint attrib_normal, GLuint attrib_tangent, GLuint attrib_bitangent, GLuint attrib_color, size_t stride)
|
||||
{
|
||||
GLuint vao;
|
||||
glGenVertexArrays(1, &vao);
|
||||
@@ -23,6 +24,8 @@ GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_t
|
||||
glEnableVertexAttribArray(attrib_tangent);
|
||||
if ((GLint)attrib_bitangent != -1)
|
||||
glEnableVertexAttribArray(attrib_bitangent);
|
||||
if ((GLint)attrib_color != -1)
|
||||
glEnableVertexAttribArray(attrib_color);
|
||||
glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, stride, 0);
|
||||
if ((GLint)attrib_texcoord != -1)
|
||||
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 28);
|
||||
@@ -47,6 +50,8 @@ GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_t
|
||||
Log::error("material", "Bitangents not present in VBO");
|
||||
glVertexAttribPointer(attrib_bitangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)48);
|
||||
}
|
||||
if ((GLint)attrib_color != -1)
|
||||
glVertexAttribPointer(attrib_color, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, (GLvoid*)24);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idx);
|
||||
glBindVertexArray(0);
|
||||
@@ -166,15 +171,8 @@ STKMesh::~STKMesh()
|
||||
}
|
||||
}
|
||||
|
||||
void STKMesh::drawFirstPass(const GLMesh &mesh)
|
||||
void STKMesh::drawObjectPass1(const GLMesh &mesh)
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||
|
||||
glStencilFunc(GL_ALWAYS, 0, ~0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
@@ -192,21 +190,10 @@ void STKMesh::drawFirstPass(const GLMesh &mesh)
|
||||
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glStencilFunc(GL_ALWAYS, 1, ~0);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getMainSetup(), false, false);
|
||||
}
|
||||
|
||||
void STKMesh::drawObjectRefPass1(const GLMesh &mesh)
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||
|
||||
glStencilFunc(GL_ALWAYS, 0, ~0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
@@ -231,21 +218,54 @@ void STKMesh::drawObjectRefPass1(const GLMesh &mesh)
|
||||
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glStencilFunc(GL_ALWAYS, 1, ~0);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getMainSetup(), false, false);
|
||||
}
|
||||
|
||||
static
|
||||
core::vector3df getWind()
|
||||
{
|
||||
const core::vector3df pos = irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD).getTranslation();
|
||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||
GrassShaderProvider *gsp = (GrassShaderProvider *)irr_driver->getCallback(ES_GRASS);
|
||||
float m_speed = gsp->getSpeed(), m_amplitude = gsp->getAmplitude();
|
||||
|
||||
float strength = (pos.X + pos.Y + pos.Z) * 1.2f + time * m_speed;
|
||||
strength = noise2d(strength / 10.0f) * m_amplitude * 5;
|
||||
// * 5 is to work with the existing amplitude values.
|
||||
|
||||
// Pre-multiply on the cpu
|
||||
return irr_driver->getWind() * strength;
|
||||
}
|
||||
|
||||
void STKMesh::drawGrassPass1(const GLMesh &mesh)
|
||||
{
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
ModelViewProjectionMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION);
|
||||
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||
TransposeInverseModelView = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
TransposeInverseModelView *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||
TransposeInverseModelView.makeInverse();
|
||||
TransposeInverseModelView = TransposeInverseModelView.getTransposed();
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, mesh.textures[0]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
glUseProgram(MeshShader::GrassPass1Shader::Program);
|
||||
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, getWind(), 0);
|
||||
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void STKMesh::drawNormalPass(const GLMesh &mesh)
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||
|
||||
glStencilFunc(GL_ALWAYS, 0, ~0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
@@ -271,20 +291,10 @@ void STKMesh::drawNormalPass(const GLMesh &mesh)
|
||||
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glStencilFunc(GL_ALWAYS, 1, ~0);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getMainSetup(), false, false);
|
||||
}
|
||||
|
||||
void STKMesh::drawSphereMap(const GLMesh &mesh)
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
@@ -301,19 +311,10 @@ void STKMesh::drawSphereMap(const GLMesh &mesh)
|
||||
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
}
|
||||
|
||||
void STKMesh::drawSplatting(const GLMesh &mesh)
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
@@ -379,19 +380,10 @@ void STKMesh::drawSplatting(const GLMesh &mesh)
|
||||
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
}
|
||||
|
||||
void STKMesh::drawObjectRefPass2(const GLMesh &mesh)
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
@@ -421,19 +413,43 @@ void STKMesh::drawObjectRefPass2(const GLMesh &mesh)
|
||||
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
}
|
||||
|
||||
void STKMesh::drawSecondPass(const GLMesh &mesh)
|
||||
void STKMesh::drawGrassPass2(const GLMesh &mesh)
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, mesh.textures[0]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP1))->getOpenGLTextureName());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP2))->getOpenGLTextureName());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_SSAO))->getOpenGLTextureName());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glUseProgram(MeshShader::GrassPass2Shader::Program);
|
||||
MeshShader::GrassPass2Shader::setUniforms(ModelViewProjectionMatrix, getWind(), 0, 1, 2, 3);
|
||||
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void STKMesh::drawObjectPass2(const GLMesh &mesh)
|
||||
{
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
@@ -463,9 +479,6 @@ void STKMesh::drawSecondPass(const GLMesh &mesh)
|
||||
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
}
|
||||
|
||||
void STKMesh::drawGlow(const GLMesh &mesh, float r, float g, float b)
|
||||
@@ -494,23 +507,54 @@ void STKMesh::draw(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
||||
switch (irr_driver->getPhase())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||
|
||||
glStencilFunc(GL_ALWAYS, 0, ~0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
if (type == irr_driver->getShader(ES_NORMAL_MAP))
|
||||
drawNormalPass(mesh);
|
||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||
drawObjectRefPass1(mesh);
|
||||
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
||||
drawGrassPass1(mesh);
|
||||
else
|
||||
drawFirstPass(mesh);
|
||||
drawObjectPass1(mesh);
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glStencilFunc(GL_ALWAYS, 1, ~0);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getMainSetup(), false, false);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
if (type == irr_driver->getShader(ES_SPHERE_MAP))
|
||||
drawSphereMap(mesh);
|
||||
else if (type == irr_driver->getShader(ES_SPLATTING))
|
||||
drawSplatting(mesh);
|
||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||
drawObjectRefPass2(mesh);
|
||||
else
|
||||
drawSecondPass(mesh);
|
||||
break;
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
if (type == irr_driver->getShader(ES_SPHERE_MAP))
|
||||
drawSphereMap(mesh);
|
||||
else if (type == irr_driver->getShader(ES_SPLATTING))
|
||||
drawSplatting(mesh);
|
||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||
drawObjectRefPass2(mesh);
|
||||
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
||||
drawGrassPass2(mesh);
|
||||
else
|
||||
drawObjectPass2(mesh);
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
ColorizeProvider * const cb = (ColorizeProvider *)irr_driver->getCallback(ES_COLORIZE);
|
||||
@@ -541,6 +585,10 @@ static bool isObject(video::E_MATERIAL_TYPE type)
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_SPLATTING))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_GRASS))
|
||||
return true;
|
||||
if (type == irr_driver->getShader(ES_GRASS_REF))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -551,41 +599,50 @@ static void initvaostate(GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
||||
if (type == irr_driver->getShader(ES_NORMAL_MAP))
|
||||
{
|
||||
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
MeshShader::NormalMapShader::attrib_position, MeshShader::NormalMapShader::attrib_texcoord, -1, -1, MeshShader::NormalMapShader::attrib_tangent, MeshShader::NormalMapShader::attrib_bitangent, mesh.Stride);
|
||||
MeshShader::NormalMapShader::attrib_position, MeshShader::NormalMapShader::attrib_texcoord, -1, -1, MeshShader::NormalMapShader::attrib_tangent, MeshShader::NormalMapShader::attrib_bitangent, -1, mesh.Stride);
|
||||
}
|
||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||
{
|
||||
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
MeshShader::ObjectPass1Shader::attrib_position, MeshShader::ObjectRefPass1Shader::attrib_texcoord, -1, MeshShader::ObjectPass1Shader::attrib_normal, -1, -1, mesh.Stride);
|
||||
MeshShader::ObjectPass1Shader::attrib_position, MeshShader::ObjectRefPass1Shader::attrib_texcoord, -1, MeshShader::ObjectPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
|
||||
}
|
||||
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
||||
{
|
||||
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
MeshShader::GrassPass1Shader::attrib_position, MeshShader::GrassPass1Shader::attrib_texcoord, -1, MeshShader::GrassPass1Shader::attrib_normal, -1, -1, MeshShader::GrassPass1Shader::attrib_color, mesh.Stride);
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
MeshShader::ObjectPass1Shader::attrib_position, -1, -1, MeshShader::ObjectPass1Shader::attrib_normal, -1, -1, mesh.Stride);
|
||||
MeshShader::ObjectPass1Shader::attrib_position, -1, -1, MeshShader::ObjectPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
|
||||
}
|
||||
|
||||
if (type == irr_driver->getShader(ES_SPHERE_MAP))
|
||||
{
|
||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
MeshShader::SphereMapShader::attrib_position, -1, -1, MeshShader::SphereMapShader::attrib_normal, -1, -1, mesh.Stride);
|
||||
MeshShader::SphereMapShader::attrib_position, -1, -1, MeshShader::SphereMapShader::attrib_normal, -1, -1, -1, mesh.Stride);
|
||||
}
|
||||
else if (type == irr_driver->getShader(ES_SPLATTING))
|
||||
{
|
||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
MeshShader::SplattingShader::attrib_position, MeshShader::SplattingShader::attrib_texcoord, MeshShader::SplattingShader::attrib_second_texcoord, -1, -1, -1, mesh.Stride);
|
||||
MeshShader::SplattingShader::attrib_position, MeshShader::SplattingShader::attrib_texcoord, MeshShader::SplattingShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
|
||||
}
|
||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||
{
|
||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
MeshShader::ObjectRefPass2Shader::attrib_position, MeshShader::ObjectRefPass2Shader::attrib_texcoord, -1, -1, -1, -1, mesh.Stride);
|
||||
|
||||
MeshShader::ObjectRefPass2Shader::attrib_position, MeshShader::ObjectRefPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
||||
}
|
||||
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
||||
{
|
||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
MeshShader::GrassPass2Shader::attrib_position, MeshShader::GrassPass2Shader::attrib_texcoord, -1, -1, -1, -1, MeshShader::GrassPass2Shader::attrib_color, mesh.Stride);
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
|
||||
MeshShader::ObjectPass2Shader::attrib_position, MeshShader::ObjectPass2Shader::attrib_texcoord, -1, -1, -1, -1, mesh.Stride);
|
||||
MeshShader::ObjectPass2Shader::attrib_position, MeshShader::ObjectPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
|
||||
}
|
||||
mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, mesh.Stride);
|
||||
mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
|
||||
}
|
||||
|
||||
void STKMesh::render()
|
||||
|
||||
@@ -29,15 +29,17 @@ protected:
|
||||
void draw(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
|
||||
|
||||
// Pass 1 shader (ie shaders that outputs normals and depth)
|
||||
void drawFirstPass(const GLMesh &mesh);
|
||||
void drawObjectPass1(const GLMesh &mesh);
|
||||
void drawNormalPass(const GLMesh &mesh);
|
||||
void drawObjectRefPass1(const GLMesh &mesh);
|
||||
void drawGrassPass1(const GLMesh &mesh);
|
||||
|
||||
// Pass 2 shader (ie shaders that outputs final color)
|
||||
void drawSphereMap(const GLMesh &mesh);
|
||||
void drawSplatting(const GLMesh &mesh);
|
||||
void drawSecondPass(const GLMesh &mesh);
|
||||
void drawObjectPass2(const GLMesh &mesh);
|
||||
void drawObjectRefPass2(const GLMesh &mesh);
|
||||
void drawGrassPass2(const GLMesh &mesh);
|
||||
|
||||
// Pass 3 shader (glow)
|
||||
void drawGlow(const GLMesh &mesh, float r, float g, float b);
|
||||
|
||||
Reference in New Issue
Block a user