+
-
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
diff --git a/data/gui/tracks.stkgui b/data/gui/tracks.stkgui
index a3f40d7a8..07b29ff48 100644
--- a/data/gui/tracks.stkgui
+++ b/data/gui/tracks.stkgui
@@ -1,31 +1,30 @@
+
+
-
+
-
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
+
+
+
-
\ No newline at end of file
+
+
+
+
+
+
diff --git a/data/gui/tutorial.stkgui b/data/gui/tutorial.stkgui
index 08c7def60..a8b92bc03 100644
--- a/data/gui/tutorial.stkgui
+++ b/data/gui/tutorial.stkgui
@@ -1,21 +1,19 @@
+
-
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
\ No newline at end of file
+
diff --git a/data/gui/tutorial_message_dialog.stkgui b/data/gui/tutorial_message_dialog.stkgui
index 68f2d0586..532fec307 100644
--- a/data/gui/tutorial_message_dialog.stkgui
+++ b/data/gui/tutorial_message_dialog.stkgui
@@ -1,12 +1,10 @@
+
+
diff --git a/data/gui/user_screen.stkgui b/data/gui/user_screen.stkgui
index d4a285dbd..da38ed107 100644
--- a/data/gui/user_screen.stkgui
+++ b/data/gui/user_screen.stkgui
@@ -1,3 +1,4 @@
+
@@ -61,6 +62,6 @@
-
+
diff --git a/data/gui/user_screen_tab.stkgui b/data/gui/user_screen_tab.stkgui
index 1b6000daa..37f0fe980 100644
--- a/data/gui/user_screen_tab.stkgui
+++ b/data/gui/user_screen_tab.stkgui
@@ -1,3 +1,4 @@
+
@@ -13,7 +14,7 @@
-
+
@@ -55,7 +56,7 @@
-
+
-
-
+
diff --git a/data/shaders/gaussian.comp b/data/shaders/bilateralH.comp
similarity index 53%
rename from data/shaders/gaussian.comp
rename to data/shaders/bilateralH.comp
index a5c1a3d22..1611b5d55 100644
--- a/data/shaders/gaussian.comp
+++ b/data/shaders/bilateralH.comp
@@ -1,20 +1,25 @@
// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html
uniform layout(size1x16) restrict readonly image2D source;
+uniform layout(size1x32) restrict readonly image2D depth;
uniform layout(size1x16) volatile restrict writeonly image2D dest;
uniform float sigma = 5.;
layout (local_size_x = 8, local_size_y = 8) in;
shared float local_src[8 + 2 * 8][8];
+shared float local_depth[8 + 2 * 8][8];
void main()
{
int x = int(gl_LocalInvocationID.x), y = int(gl_LocalInvocationID.y);
ivec2 uv = ivec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y);
local_src[x][y] = imageLoad(source, ivec2(uv) - ivec2(8, 0)).x;
+ local_depth[x][y] = imageLoad(depth, ivec2(uv) - ivec2(8, 0)).x;
local_src[x + 8][y] = imageLoad(source, ivec2(uv)).x;
+ local_depth[x + 8][y] = imageLoad(depth, ivec2(uv)).x;
local_src[x + 16][y] = imageLoad(source, ivec2(uv) + ivec2(8, 0)).x;
+ local_depth[x + 16][y] = imageLoad(depth, ivec2(uv) + ivec2(8, 0)).x;
barrier();
@@ -23,14 +28,20 @@ void main()
g1 = exp(-0.5 / (sigma * sigma));
g2 = g1 * g1;
float sum = local_src[x + 8][y] * g0;
+ float pixel_depth = local_depth[x + 8][y];
g0 *= g1;
g1 *= g2;
+ float tmp_weight, total_weight = g0;
for (int j = 1; j < 8; j++) {
- sum += local_src[8 + x - j][y] * g0;
- sum += local_src[8 + x + j][y] * g0;
+ tmp_weight = max(0.0, 1.0 - .001 * abs(local_depth[8 + x - j][y] - pixel_depth));
+ total_weight += g0 * tmp_weight;
+ sum += local_src[8 + x - j][y] * g0 * tmp_weight;
+ tmp_weight = max(0.0, 1.0 - .001 * abs(local_depth[8 + x + j][y] - pixel_depth));
+ total_weight += g0 * tmp_weight;
+ sum += local_src[8 + x + j][y] * g0 * tmp_weight;
g0 *= g1;
g1 *= g2;
}
- imageStore(dest, ivec2(uv), vec4(sum));
+ imageStore(dest, ivec2(uv), vec4(sum / total_weight));
}
diff --git a/data/shaders/bilateralH.frag b/data/shaders/bilateralH.frag
new file mode 100644
index 000000000..283578d28
--- /dev/null
+++ b/data/shaders/bilateralH.frag
@@ -0,0 +1,37 @@
+// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html
+
+uniform sampler2D tex;
+uniform sampler2D depth;
+uniform vec2 pixel;
+uniform float sigma = 5.;
+
+out vec4 FragColor;
+
+void main()
+{
+ vec2 uv = gl_FragCoord.xy * pixel;
+ float X = uv.x;
+ float Y = uv.y;
+
+ float g0, g1, g2;
+ g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
+ g1 = exp(-0.5 / (sigma * sigma));
+ g2 = g1 * g1;
+ vec4 sum = texture(tex, vec2(X, Y)) * g0;
+ float pixel_depth = texture(depth, vec2(X, Y)).x;
+ g0 *= g1;
+ g1 *= g2;
+ float tmp_weight, total_weight = g0;
+ for (int i = 1; i < 9; i++) {
+ tmp_weight = max(0.0, 1.0 - .001 * abs(texture(depth, vec2(X - i * pixel.x, Y)).x - pixel_depth));
+ sum += texture(tex, vec2(X - i * pixel.x, Y)) * g0 * tmp_weight;
+ total_weight += g0 * tmp_weight;
+ tmp_weight = max(0.0, 1.0 - .001 * abs(texture(depth, vec2(X + i * pixel.x, Y)).x - pixel_depth));
+ sum += texture(tex, vec2(X + i * pixel.x, Y)) * g0 * tmp_weight;
+ total_weight += g0 * tmp_weight;
+ g0 *= g1;
+ g1 *= g2;
+ }
+
+ FragColor = sum / total_weight;
+}
diff --git a/data/shaders/gaussianv.comp b/data/shaders/bilateralV.comp
similarity index 53%
rename from data/shaders/gaussianv.comp
rename to data/shaders/bilateralV.comp
index 38674a61d..42338305f 100644
--- a/data/shaders/gaussianv.comp
+++ b/data/shaders/bilateralV.comp
@@ -1,20 +1,25 @@
// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html
uniform layout(size1x16) restrict readonly image2D source;
+uniform layout(size1x32) restrict readonly image2D depth;
uniform layout(size1x16) volatile restrict writeonly image2D dest;
uniform float sigma = 5.;
layout (local_size_x = 8, local_size_y = 8) in;
shared float local_src[8][8 + 2 * 8];
+shared float local_depth[8][8 + 2 * 8];
void main()
{
int x = int(gl_LocalInvocationID.x), y = int(gl_LocalInvocationID.y);
ivec2 uv = ivec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y);
local_src[x][y] = imageLoad(source, ivec2(uv) - ivec2(0, 8)).x;
+ local_depth[x][y] = imageLoad(depth, ivec2(uv) - ivec2(0, 8)).x;
local_src[x][y + 8] = imageLoad(source, ivec2(uv)).x;
+ local_depth[x][y + 8] = imageLoad(depth, ivec2(uv)).x;
local_src[x][y + 16] = imageLoad(source, ivec2(uv) + ivec2(0, 8)).x;
+ local_depth[x][y + 16] = imageLoad(depth, ivec2(uv) + ivec2(0, 8)).x;
barrier();
@@ -23,14 +28,21 @@ void main()
g1 = exp(-0.5 / (sigma * sigma));
g2 = g1 * g1;
float sum = local_src[x][y + 8] * g0;
+ float pixel_depth = local_depth[x][y + 8];
g0 *= g1;
g1 *= g2;
+ float tmp_weight, total_weight = g0;
for (int j = 1; j < 8; j++) {
- sum += local_src[x][y + 8 + j] * g0;
- sum += local_src[x][y + 8 - j] * g0;
+ tmp_weight = max(0.0, 1.0 - .001 * abs(local_depth[x][y + 8 + j] - pixel_depth));
+ sum += local_src[x][y + 8 + j] * g0 * tmp_weight;
+ total_weight += g0 * tmp_weight;
+ tmp_weight = max(0.0, 1.0 - .001 * abs(local_depth[x][y + 8 - j] - pixel_depth));
+ sum += local_src[x][y + 8 - j] * g0 * tmp_weight;
+ total_weight += g0 * tmp_weight;
g0 *= g1;
g1 *= g2;
+
}
- imageStore(dest, ivec2(uv), vec4(sum));
+ imageStore(dest, ivec2(uv), vec4(sum / total_weight));
}
diff --git a/data/shaders/bilateralV.frag b/data/shaders/bilateralV.frag
new file mode 100644
index 000000000..c34218844
--- /dev/null
+++ b/data/shaders/bilateralV.frag
@@ -0,0 +1,38 @@
+// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html
+
+uniform sampler2D tex;
+uniform sampler2D depth;
+uniform vec2 pixel;
+uniform float sigma = 5.;
+
+out vec4 FragColor;
+
+void main()
+{
+ vec2 uv = gl_FragCoord.xy * pixel;
+ float X = uv.x;
+ float Y = uv.y;
+
+ float g0, g1, g2;
+ g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
+ g1 = exp(-0.5 / (sigma * sigma));
+ g2 = g1 * g1;
+ vec4 sum = texture(tex, vec2(X, Y)) * g0;
+ float pixel_depth = texture(depth, vec2(X, Y)).x;
+ g0 *= g1;
+ g1 *= g2;
+ float tmp_weight, total_weight = g0;
+ for (int i = 1; i < 9; i++) {
+ tmp_weight = max(0.0, 1.0 - .001 * abs(texture(depth, vec2(X, Y - i * pixel.y)).x - pixel_depth));
+ sum += texture(tex, vec2(X, Y - i * pixel.y)) * g0 * tmp_weight;
+ total_weight += g0 * tmp_weight;
+ tmp_weight = max(0.0, 1.0 - .001 * abs(texture(depth, vec2(X, Y + i * pixel.y)).x - pixel_depth));
+ sum += texture(tex, vec2(X, Y + i * pixel.y)) * g0 * tmp_weight;
+ total_weight += g0 * tmp_weight;
+ g0 *= g1;
+ g1 *= g2;
+ }
+
+ FragColor = sum / total_weight;
+}
+
diff --git a/data/shaders/bubble.vert b/data/shaders/bubble.vert
index 0d61b7d33..fb2962e6a 100644
--- a/data/shaders/bubble.vert
+++ b/data/shaders/bubble.vert
@@ -21,17 +21,9 @@
uniform mat4 ModelViewProjectionMatrix;
uniform float time;
-#if __VERSION__ >= 130
-in vec3 Position;
-in vec2 Texcoord;
+layout(location = 0) in vec3 Position;
+layout(location = 3) in vec2 Texcoord;
out vec2 uv;
-#else
-attribute vec3 Position;
-attribute vec2 Texcoord;
-varying vec2 uv;
-#endif
-
-
void main()
{
diff --git a/data/shaders/displace.vert b/data/shaders/displace.vert
index 48b052077..6d1f04893 100644
--- a/data/shaders/displace.vert
+++ b/data/shaders/displace.vert
@@ -1,27 +1,39 @@
-uniform mat4 ModelViewProjectionMatrix;
-uniform mat4 ModelViewMatrix;
+#ifdef UBO_DISABLED
+uniform mat4 ViewMatrix;
+uniform mat4 ProjectionMatrix;
+uniform mat4 InverseViewMatrix;
+uniform mat4 InverseProjectionMatrix;
+#else
+layout (std140) uniform MatrixesData
+{
+ mat4 ViewMatrix;
+ mat4 ProjectionMatrix;
+ mat4 InverseViewMatrix;
+ mat4 InverseProjectionMatrix;
+ mat4 ShadowViewProjMatrixes[4];
+ vec2 screen;
+};
+#endif
-#if __VERSION__ >= 130
+uniform mat4 ModelMatrix;
+
+#if __VERSION__ >= 330
+layout(location = 0) in vec3 Position;
+layout(location = 3) in vec2 Texcoord;
+layout(location = 4) in vec2 SecondTexcoord;
+#else
in vec3 Position;
in vec2 Texcoord;
in vec2 SecondTexcoord;
+#endif
+
out vec2 uv;
out vec2 uv_bis;
out float camdist;
-#else
-attribute vec3 Position;
-attribute vec2 Texcoord;
-attribute vec2 SecondTexcoord;
-varying vec2 uv;
-varying vec2 uv_bis;
-varying float camdist;
-#endif
-
-
void main() {
- gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
+ gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * vec4(Position, 1.);
uv = Texcoord;
uv_bis = SecondTexcoord;
- camdist = length(ModelViewMatrix * vec4(Position, 1.));
+ camdist = length(ViewMatrix * ModelMatrix * vec4(Position, 1.));
}
diff --git a/data/shaders/frustrum.vert b/data/shaders/frustrum.vert
new file mode 100644
index 000000000..489241b4d
--- /dev/null
+++ b/data/shaders/frustrum.vert
@@ -0,0 +1,18 @@
+layout (std140) uniform MatrixesData
+{
+ mat4 ViewMatrix;
+ mat4 ProjectionMatrix;
+ mat4 InverseViewMatrix;
+ mat4 InverseProjectionMatrix;
+ mat4 ShadowViewProjMatrixes[4];
+ vec2 screen;
+};
+
+uniform int idx;
+
+in vec3 Position;
+
+void main(void)
+{
+ gl_Position = ShadowViewProjMatrixes[idx] * vec4(Position, 1.);
+}
diff --git a/data/shaders/gaussian17taph.frag b/data/shaders/gaussian17taph.frag
deleted file mode 100644
index 6ac30cd54..000000000
--- a/data/shaders/gaussian17taph.frag
+++ /dev/null
@@ -1,30 +0,0 @@
-// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html
-
-uniform sampler2D tex;
-uniform vec2 pixel;
-uniform float sigma = 5.;
-
-out vec4 FragColor;
-
-void main()
-{
- vec2 uv = gl_FragCoord.xy * pixel;
- float X = uv.x;
- float Y = uv.y;
-
- float g0, g1, g2;
- g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
- g1 = exp(-0.5 / (sigma * sigma));
- g2 = g1 * g1;
- vec4 sum = texture(tex, vec2(X, Y)) * g0;
- g0 *= g1;
- g1 *= g2;
- for (int i = 1; i < 9; i++) {
- sum += texture(tex, vec2(X - i * pixel.x, Y)) * g0;
- sum += texture(tex, vec2(X + i * pixel.x, Y)) * g0;
- g0 *= g1;
- g1 *= g2;
- }
-
- FragColor = sum;
-}
diff --git a/data/shaders/gaussian17tapv.frag b/data/shaders/gaussian17tapv.frag
deleted file mode 100644
index 59c2c05ab..000000000
--- a/data/shaders/gaussian17tapv.frag
+++ /dev/null
@@ -1,31 +0,0 @@
-// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html
-
-uniform sampler2D tex;
-uniform vec2 pixel;
-uniform float sigma = 5.;
-
-out vec4 FragColor;
-
-void main()
-{
- vec2 uv = gl_FragCoord.xy * pixel;
- float X = uv.x;
- float Y = uv.y;
-
- float g0, g1, g2;
- g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
- g1 = exp(-0.5 / (sigma * sigma));
- g2 = g1 * g1;
- vec4 sum = texture(tex, vec2(X, Y)) * g0;
- g0 *= g1;
- g1 *= g2;
- for (int i = 1; i < 9; i++) {
- sum += texture(tex, vec2(X, Y - i * pixel.y)) * g0;
- sum += texture(tex, vec2(X, Y + i * pixel.y)) * g0;
- g0 *= g1;
- g1 *= g2;
- }
-
- FragColor = sum;
-}
-
diff --git a/data/shaders/gi.frag b/data/shaders/gi.frag
index 92f9e0804..b6983b4f2 100644
--- a/data/shaders/gi.frag
+++ b/data/shaders/gi.frag
@@ -12,6 +12,7 @@ uniform sampler3D SHB;
uniform float R_wcs = 10.;
uniform vec3 extents;
uniform mat4 RHMatrix;
+uniform mat4 InvRHMatrix;
layout (std140) uniform MatrixesData
{
@@ -55,7 +56,7 @@ void main()
if (depth==1.0) discard;
vec4 pos_screen_space = getPosFromUVDepth(vec3(uv, depth), InverseProjectionMatrix);
- vec4 tmp = (inverse(RHMatrix) * InverseViewMatrix * pos_screen_space);
+ vec4 tmp = (InvRHMatrix * InverseViewMatrix * pos_screen_space);
vec3 pos = tmp.xyz / tmp.w;
vec3 normal_screen_space = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
vec3 normal = (transpose(ViewMatrix) * vec4(normal_screen_space, 0.)).xyz;
diff --git a/data/shaders/grass_pass.vert b/data/shaders/grass_pass.vert
index 647697da3..fa52d4c7f 100644
--- a/data/shaders/grass_pass.vert
+++ b/data/shaders/grass_pass.vert
@@ -3,22 +3,20 @@ uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView;
-#if __VERSION__ >= 130
+#if __VERSION__ >= 330
+layout(location = 0) in vec3 Position;
+layout(location = 1) in vec3 Normal;
+layout(location = 2) in vec4 Color;
+layout(location = 3) in vec2 Texcoord;
+#else
in vec3 Position;
in vec3 Normal;
-in vec2 Texcoord;
in vec4 Color;
-out vec3 nor;
-out vec2 uv;
-#else
-attribute vec3 Position;
-attribute vec3 Normal;
-attribute vec2 Texcoord;
-attribute vec4 Color;
-varying vec3 nor;
-varying vec2 uv;
+in vec2 Texcoord;
#endif
+out vec3 nor;
+out vec2 uv;
void main()
{
diff --git a/data/shaders/instanced_grass.vert b/data/shaders/instanced_grass.vert
index 90e56c00c..0c1978cf4 100644
--- a/data/shaders/instanced_grass.vert
+++ b/data/shaders/instanced_grass.vert
@@ -10,15 +10,25 @@ layout (std140) uniform MatrixesData
uniform vec3 windDir;
+#if __VERSION__ >= 330
+layout(location = 0) in vec3 Position;
+layout(location = 1) in vec3 Normal;
+layout(location = 2) in vec4 Color;
+layout(location = 3) in vec2 Texcoord;
+
+layout(location = 7) in vec3 Origin;
+layout(location = 8) in vec3 Orientation;
+layout(location = 9) in vec3 Scale;
+#else
+in vec3 Position;
+in vec3 Normal;
+in vec4 Color;
+in vec2 Texcoord;
in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
-
-in vec3 Position;
-in vec3 Normal;
-in vec2 Texcoord;
-in vec4 Color;
+#endif
out vec3 nor;
out vec2 uv;
diff --git a/data/shaders/instanced_object_pass.vert b/data/shaders/instanced_object_pass.vert
index 493fa9139..57a2668f9 100644
--- a/data/shaders/instanced_object_pass.vert
+++ b/data/shaders/instanced_object_pass.vert
@@ -15,14 +15,24 @@ layout (std140) uniform MatrixesData
};
#endif
-in vec3 Origin;
-in vec3 Orientation;
-in vec3 Scale;
+#if __VERSION__ >= 330
+layout(location = 0) in vec3 Position;
+layout(location = 1) in vec3 Normal;
+layout(location = 3) in vec2 Texcoord;
+layout(location = 7) in vec3 Origin;
+layout(location = 8) in vec3 Orientation;
+layout(location = 9) in vec3 Scale;
+#else
in vec3 Position;
in vec3 Normal;
in vec2 Texcoord;
+in vec3 Origin;
+in vec3 Orientation;
+in vec3 Scale;
+#endif
+
out vec3 nor;
out vec2 uv;
diff --git a/data/shaders/instanciedshadow.vert b/data/shaders/instanciedshadow.vert
index e421aef03..845d07c6e 100644
--- a/data/shaders/instanciedshadow.vert
+++ b/data/shaders/instanciedshadow.vert
@@ -7,12 +7,21 @@ layout (std140) uniform MatrixesData
mat4 ShadowViewProjMatrixes[4];
};
+#if __VERSION__ >= 330
+layout(location = 0) in vec3 Position;
+layout(location = 3) in vec2 Texcoord;
+
+layout(location = 7) in vec3 Origin;
+layout(location = 8) in vec3 Orientation;
+layout(location = 9) in vec3 Scale;
+#else
+in vec3 Position;
+in vec2 Texcoord;
+
in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
-
-in vec3 Position;
-in vec2 Texcoord;
+#endif
#ifdef VSLayer
out vec2 uv;
diff --git a/data/shaders/layertexturequad.frag b/data/shaders/layertexturequad.frag
new file mode 100644
index 000000000..d9be4690b
--- /dev/null
+++ b/data/shaders/layertexturequad.frag
@@ -0,0 +1,10 @@
+uniform sampler2DArray tex;
+uniform int layer;
+
+in vec2 uv;
+out vec4 FragColor;
+
+void main()
+{
+ FragColor = texture(tex, vec3(uv, float(layer)));
+}
\ No newline at end of file
diff --git a/data/shaders/normalmap.vert b/data/shaders/normalmap.vert
index eb5570ddd..2104372a4 100644
--- a/data/shaders/normalmap.vert
+++ b/data/shaders/normalmap.vert
@@ -10,24 +10,21 @@ layout (std140) uniform MatrixesData
uniform mat4 ModelMatrix;
uniform mat4 InverseModelMatrix;
-#if __VERSION__ >= 130
+#if __VERSION__ >= 330
+layout(location = 0) in vec3 Position;
+layout(location = 3) in vec2 Texcoord;
+layout(location = 5) in vec3 Tangent;
+layout(location = 6) in vec3 Bitangent;
+#else
in vec3 Position;
in vec2 Texcoord;
in vec3 Tangent;
in vec3 Bitangent;
+#endif
+
out vec3 tangent;
out vec3 bitangent;
out vec2 uv;
-#else
-attribute vec3 Position;
-attribute vec2 Texcoord;
-attribute vec3 Tangent;
-attribute vec3 Bitangent;
-varying vec3 tangent;
-varying vec3 bitangent;
-varying vec2 uv;
-#endif
-
void main()
{
diff --git a/data/shaders/object_pass.vert b/data/shaders/object_pass.vert
index 3bd585e93..1adea5425 100644
--- a/data/shaders/object_pass.vert
+++ b/data/shaders/object_pass.vert
@@ -24,25 +24,24 @@ uniform mat4 TextureMatrix =
0., 0., 1., 0.,
0., 0., 0., 1.);
-#if __VERSION__ >= 130
+#if __VERSION__ >= 330
+layout(location = 0) in vec3 Position;
+layout(location = 1) in vec3 Normal;
+layout(location = 2) in vec4 Color;
+layout(location = 3) in vec2 Texcoord;
+layout(location = 4) in vec2 SecondTexcoord;
+#else
in vec3 Position;
-in vec2 Texcoord;
-in vec2 SecondTexcoord;
in vec3 Normal;
in vec4 Color;
+in vec2 Texcoord;
+in vec2 SecondTexcoord;
+#endif
+
out vec3 nor;
out vec2 uv;
out vec2 uv_bis;
out vec4 color;
-#else
-attribute vec3 Position;
-attribute vec3 Normal;
-attribute vec2 Texcoord;
-attribute vec2 SecondTexcoord;
-varying vec3 nor;
-varying vec2 uv;
-varying vec2 uv_bis;
-#endif
void main(void)
diff --git a/data/shaders/rsm.vert b/data/shaders/rsm.vert
index d5d08d48b..4b44144b2 100644
--- a/data/shaders/rsm.vert
+++ b/data/shaders/rsm.vert
@@ -9,9 +9,10 @@ uniform mat4 TextureMatrix =
0., 0., 0., 1.);
-in vec3 Position;
-in vec2 Texcoord;
-in vec3 Normal;
+layout(location = 0) in vec3 Position;
+layout(location = 1) in vec3 Normal;
+layout(location = 3) in vec2 Texcoord;
+
out vec3 nor;
out vec2 uv;
diff --git a/data/shaders/shadow.vert b/data/shaders/shadow.vert
index d7c389b2f..d1212e7ea 100644
--- a/data/shaders/shadow.vert
+++ b/data/shaders/shadow.vert
@@ -9,8 +9,8 @@ layout (std140) uniform MatrixesData
uniform mat4 ModelMatrix;
-in vec3 Position;
-in vec2 Texcoord;
+layout(location = 0) in vec3 Position;
+layout(location = 3) in vec2 Texcoord;
#ifdef VSLayer
out vec2 uv;
diff --git a/data/shaders/ssao.frag b/data/shaders/ssao.frag
index 5241ff764..445de5388 100644
--- a/data/shaders/ssao.frag
+++ b/data/shaders/ssao.frag
@@ -56,7 +56,7 @@ void main(void)
vec3 norm = -normalize(cross(ddy, ddx));
float r = radius / FragPos.z;
- float phi = 30. * (x ^ y) + 10. * x * y;
+ float phi = 3. * (x ^ y) + x * y;
float bl = 0.0;
float m = log2(r) + 6 + log2(invSamples);
diff --git a/data/shaders/transparent.vert b/data/shaders/transparent.vert
deleted file mode 100644
index e6c6b13fe..000000000
--- a/data/shaders/transparent.vert
+++ /dev/null
@@ -1,22 +0,0 @@
-uniform mat4 ModelViewProjectionMatrix;
-uniform mat4 TextureMatrix;
-
-#if __VERSION__ >= 130
-in vec3 Position;
-in vec2 Texcoord;
-in vec4 Color;
-out vec2 uv;
-out vec4 color;
-#else
-attribute vec3 Position;
-attribute vec2 Texcoord;
-varying vec2 uv;
-#endif
-
-
-void main()
-{
- uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
- gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
- color = Color;
-}
diff --git a/data/skins/Ocean.stkskin b/data/skins/Ocean.stkskin
index 890138cc0..4318a6083 100644
--- a/data/skins/Ocean.stkskin
+++ b/data/skins/Ocean.stkskin
@@ -68,6 +68,14 @@ when the border that intersect at this corner are enabled.
+
+
+
+
diff --git a/data/skins/Peach.stkskin b/data/skins/Peach.stkskin
index 5951a560c..e9594353f 100644
--- a/data/skins/Peach.stkskin
+++ b/data/skins/Peach.stkskin
@@ -68,6 +68,14 @@ when the border that intersect at this corner are enabled.
+
+
+
+
diff --git a/data/skins/peach/achievement.png b/data/skins/peach/achievement.png
new file mode 100644
index 000000000..cd06f0260
Binary files /dev/null and b/data/skins/peach/achievement.png differ
diff --git a/data/skins/peach/friend.png b/data/skins/peach/friend.png
new file mode 100644
index 000000000..3b02dd339
Binary files /dev/null and b/data/skins/peach/friend.png differ
diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp
index 5825c2830..b9cd2505c 100644
--- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp
+++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp
@@ -264,7 +264,7 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
// enumerate video modes
s32 modeCount;
XF86VidModeModeInfo** modes;
- float refresh_rate;
+ float refresh_rate, refresh_rate_old;
XF86VidModeGetAllModeLines(display, screennr, &modeCount, &modes);
@@ -273,22 +273,17 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
{
if (bestMode==-1 && modes[i]->hdisplay >= Width && modes[i]->vdisplay >= Height)
{
- float pixels_per_second = modes[i]->dotclock * 1000.0;
- float pixels_per_frame = modes[i]->htotal * modes[i]->vtotal;
- refresh_rate = pixels_per_second / pixels_per_frame;
bestMode = i;
}
else if (bestMode!=-1 &&
modes[i]->hdisplay == modes[bestMode]->hdisplay &&
modes[i]->vdisplay == modes[bestMode]->vdisplay)
{
- float pixels_per_second = modes[i]->dotclock * 1000.0;
- float pixels_per_frame = modes[i]->htotal * modes[i]->vtotal;
- float refresh_rate_tmp = pixels_per_second / pixels_per_frame;
+ refresh_rate_old = (modes[bestMode]->dotclock * 1000.0) / (modes[bestMode]->htotal * modes[bestMode]->vtotal);
+ refresh_rate = (modes[i]->dotclock * 1000.0) / (modes[i]->htotal * modes[i]->vtotal);
- if (refresh_rate_tmp > refresh_rate)
+ if (refresh_rate > refresh_rate_old)
{
- refresh_rate = refresh_rate_tmp;
bestMode = i;
}
}
@@ -298,9 +293,6 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
modes[i]->hdisplay <= modes[bestMode]->hdisplay &&
modes[i]->vdisplay <= modes[bestMode]->vdisplay)
{
- float pixels_per_second = modes[i]->dotclock * 1000.0;
- float pixels_per_frame = modes[i]->htotal * modes[i]->vtotal;
- refresh_rate = pixels_per_second / pixels_per_frame;
bestMode = i;
}
}
diff --git a/src/achievements/achievement.cpp b/src/achievements/achievement.cpp
index bdc33591d..29f9bc2d8 100644
--- a/src/achievements/achievement.cpp
+++ b/src/achievements/achievement.cpp
@@ -21,7 +21,7 @@
#include "achievements/achievement.hpp"
#include "achievements/achievement_info.hpp"
-#include "guiengine/dialog_queue.hpp"
+#include "guiengine/message_queue.hpp"
#include "io/utf_writer.hpp"
#include "config/player_manager.hpp"
#include "states_screens/dialogs/notification_dialog.hpp"
@@ -202,8 +202,7 @@ void Achievement::check()
//show achievement
core::stringw s = StringUtils::insertValues(_("Completed achievement \"%s\"."),
m_achievement_info->getTitle());
- GUIEngine::DialogQueue::get()->pushDialog(
- new NotificationDialog(NotificationDialog::T_Achievements, s));
+ MessageQueue::add(MessageQueue::MT_ACHIEVEMENT, s);
// Sends a confirmation to the server that an achievement has been
// completed, if a user is signed in.
diff --git a/src/animations/animation_base.cpp b/src/animations/animation_base.cpp
index cd51bf3c1..784068288 100644
--- a/src/animations/animation_base.cpp
+++ b/src/animations/animation_base.cpp
@@ -33,6 +33,8 @@ AnimationBase::AnimationBase(const XMLNode &node)
node.get("fps", &fps);
for(unsigned int i=0; i
getName() == "animated-texture")
+ continue;
Ipo *ipo = new Ipo(*node.getNode(i), fps);
m_all_ipos.push_back(ipo);
}
diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp
index 516be8203..6d4b84b80 100644
--- a/src/graphics/glwrap.cpp
+++ b/src/graphics/glwrap.cpp
@@ -1,5 +1,4 @@
#include "graphics/glwrap.hpp"
-#include "irr_driver.hpp"
#include
#include
#include "config/user_config.hpp"
@@ -44,6 +43,7 @@ PFNGLUNIFORM4FVPROC glUniform4fv;
PFNGLGETPROGRAMIVPROC glGetProgramiv;
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
+PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
PFNGLBLENDEQUATIONPROC glBlendEquation;
PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor;
PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
@@ -197,6 +197,7 @@ void initGL()
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramInfoLog");
glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)IRR_OGL_LOAD_EXTENSION("glTransformFeedbackVaryings");
glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetAttribLocation");
+ glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glBindAttribLocation");
glBlendEquation = (PFNGLBLENDEQUATIONPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquation");
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribDivisor");
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)IRR_OGL_LOAD_EXTENSION("glDrawArraysInstanced");
diff --git a/src/graphics/glwrap.hpp b/src/graphics/glwrap.hpp
index bb5a5cbf9..f06844f1a 100644
--- a/src/graphics/glwrap.hpp
+++ b/src/graphics/glwrap.hpp
@@ -25,6 +25,7 @@
#endif
#include
+#include "irr_driver.hpp"
#include "utils/log.hpp"
// already includes glext.h, which defines useful GL constants.
@@ -68,6 +69,7 @@ extern PFNGLUNIFORM4IPROC glUniform4i;
extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
+extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
extern PFNGLBLENDEQUATIONPROC glBlendEquation;
extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor;
extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
@@ -143,6 +145,19 @@ GLint LoadProgram(Types ... args)
{
GLint ProgramID = glCreateProgram();
loadAndAttach(ProgramID, args...);
+ if (irr_driver->getGLSLVersion() < 330)
+ {
+ glBindAttribLocation(ProgramID, 0, "Position");
+ glBindAttribLocation(ProgramID, 1, "Normal");
+ glBindAttribLocation(ProgramID, 2, "Color");
+ glBindAttribLocation(ProgramID, 3, "Texcoord");
+ glBindAttribLocation(ProgramID, 4, "SecondTexcoord");
+ glBindAttribLocation(ProgramID, 5, "Tangent");
+ glBindAttribLocation(ProgramID, 6, "Bitangent");
+ glBindAttribLocation(ProgramID, 7, "Origin");
+ glBindAttribLocation(ProgramID, 8, "Orientation");
+ glBindAttribLocation(ProgramID, 9, "Scale");
+ }
glLinkProgram(ProgramID);
GLint Result = GL_FALSE;
diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp
index 2f4291056..0bf9aa5e3 100644
--- a/src/graphics/irr_driver.cpp
+++ b/src/graphics/irr_driver.cpp
@@ -443,7 +443,10 @@ void IrrDriver::initDevice()
glGetIntegerv(GL_MAJOR_VERSION, &GLMajorVersion);
glGetIntegerv(GL_MINOR_VERSION, &GLMinorVersion);
}
- Log::info("IrrDriver", "OPENGL VERSION IS %d.%d", GLMajorVersion, GLMinorVersion);
+ Log::info("IrrDriver", "OpenGL version: %d.%d", GLMajorVersion, GLMinorVersion);
+ Log::info("IrrDriver", "OpenGL vendor: %s", glGetString(GL_VENDOR));
+ Log::info("IrrDriver", "OpenGL renderer: %s", glGetString(GL_RENDERER));
+ Log::info("IrrDriver", "OpenGL version string: %s", glGetString(GL_VERSION));
m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1));
// Parse extensions
diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp
index bfffa6c3c..48ceb741d 100644
--- a/src/graphics/irr_driver.hpp
+++ b/src/graphics/irr_driver.hpp
@@ -345,6 +345,7 @@ private:
class STKMeshSceneNode *m_sun_interposer;
scene::CLensFlareSceneNode *m_lensflare;
scene::ICameraSceneNode *m_suncam;
+ float m_shadows_cam[4][24];
std::vector m_glowing;
@@ -380,6 +381,7 @@ private:
void renderSSAO();
void renderLights(unsigned pointlightCount);
void renderDisplacement();
+ void renderShadowsDebug();
void doScreenShot();
public:
IrrDriver();
diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp
index fd4fc0eed..90686a395 100644
--- a/src/graphics/post_processing.cpp
+++ b/src/graphics/post_processing.cpp
@@ -244,6 +244,8 @@ void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSH
void PostProcessing::renderGI(const core::matrix4 &RHMatrix, const core::vector3df &rh_extend, GLuint shr, GLuint shg, GLuint shb)
{
+ core::matrix4 InvRHMatrix;
+ RHMatrix.getInverse(InvRHMatrix);
glDisable(GL_DEPTH_TEST);
glUseProgram(FullScreenShader::GlobalIlluminationReconstructionShader::Program);
glBindVertexArray(FullScreenShader::GlobalIlluminationReconstructionShader::vao);
@@ -267,7 +269,7 @@ void PostProcessing::renderGI(const core::matrix4 &RHMatrix, const core::vector3
}
setTexture(3, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
setTexture(4, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
- FullScreenShader::GlobalIlluminationReconstructionShader::setUniforms(RHMatrix, rh_extend, 3, 4, 0, 1, 2);
+ FullScreenShader::GlobalIlluminationReconstructionShader::setUniforms(RHMatrix, InvRHMatrix, rh_extend, 3, 4, 0, 1, 2);
glDrawArrays(GL_TRIANGLES, 0, 3);
}
@@ -413,7 +415,11 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
setTexture(0, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ setTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glUniform1i(FullScreenShader::Gaussian17TapHShader::uniform_tex, 0);
+ glUniform1i(FullScreenShader::Gaussian17TapHShader::uniform_depth, 1);
glDrawArrays(GL_TRIANGLES, 0, 3);
}
@@ -423,9 +429,11 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
glUseProgram(FullScreenShader::ComputeGaussian17TapHShader::Program);
glBindImageTexture(0, in_fbo.getRTT()[0], 0, false, 0, GL_READ_ONLY, GL_R16F);
- glBindImageTexture(1, auxiliary.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
+ glBindImageTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], 1, false, 0, GL_READ_ONLY, GL_R32F);
+ glBindImageTexture(2, auxiliary.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
glUniform1i(FullScreenShader::ComputeGaussian17TapHShader::uniform_source, 0);
- glUniform1i(FullScreenShader::ComputeGaussian17TapHShader::uniform_dest, 1);
+ glUniform1i(FullScreenShader::ComputeGaussian17TapHShader::uniform_depth, 1);
+ glUniform1i(FullScreenShader::ComputeGaussian17TapHShader::uniform_dest, 2);
glDispatchCompute(in_fbo.getWidth() / 8, in_fbo.getHeight() / 8, 1);
}
#endif
@@ -444,7 +452,11 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
setTexture(0, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ setTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glUniform1i(FullScreenShader::Gaussian17TapVShader::uniform_tex, 0);
+ glUniform1i(FullScreenShader::Gaussian17TapVShader::uniform_depth, 1);
glDrawArrays(GL_TRIANGLES, 0, 3);
}
@@ -453,9 +465,11 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
{
glUseProgram(FullScreenShader::ComputeGaussian17TapVShader::Program);
glBindImageTexture(0, auxiliary.getRTT()[0], 0, false, 0, GL_READ_ONLY, GL_R16F);
- glBindImageTexture(1, in_fbo.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
+ glBindImageTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], 1, false, 0, GL_READ_ONLY, GL_R32F);
+ glBindImageTexture(2, in_fbo.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
glUniform1i(FullScreenShader::ComputeGaussian17TapVShader::uniform_source, 0);
- glUniform1i(FullScreenShader::ComputeGaussian17TapVShader::uniform_dest, 1);
+ glUniform1i(FullScreenShader::ComputeGaussian17TapVShader::uniform_depth, 1);
+ glUniform1i(FullScreenShader::ComputeGaussian17TapVShader::uniform_dest, 2);
glDispatchCompute(in_fbo.getWidth() / 8, in_fbo.getHeight() / 8, 1);
}
#endif
@@ -477,6 +491,21 @@ void PostProcessing::renderPassThrough(GLuint tex)
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
+void PostProcessing::renderTextureLayer(unsigned tex, unsigned layer)
+{
+ glUseProgram(FullScreenShader::LayerPassThroughShader::Program);
+ glBindVertexArray(FullScreenShader::LayerPassThroughShader::vao);
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
+ glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glUniform1i(FullScreenShader::LayerPassThroughShader::uniform_texture, 0);
+ glUniform1i(FullScreenShader::LayerPassThroughShader::uniform_layer, layer);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+}
+
void PostProcessing::renderGlow(unsigned tex)
{
diff --git a/src/graphics/post_processing.hpp b/src/graphics/post_processing.hpp
index edf314700..a0e6c4484 100644
--- a/src/graphics/post_processing.hpp
+++ b/src/graphics/post_processing.hpp
@@ -90,6 +90,7 @@ public:
/** Render tex. Used for blit/texture resize */
void renderPassThrough(unsigned tex);
+ void renderTextureLayer(unsigned tex, unsigned layer);
void applyMLAA();
void renderMotionBlur(unsigned cam, FrameBuffer &in_fbo, FrameBuffer &out_fbo);
diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp
index b7647a38c..6cbb9e3e2 100644
--- a/src/graphics/render.cpp
+++ b/src/graphics/render.cpp
@@ -48,6 +48,7 @@
#include "utils/profiler.hpp"
#include
+#include
#define MAX2(a, b) ((a) > (b) ? (a) : (b))
#define MIN2(a, b) ((a) > (b) ? (b) : (a))
@@ -197,6 +198,10 @@ void IrrDriver::renderGLSL(float dt)
glViewport(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
m_post_processing->renderPassThrough(m_rtts->getRSM().getRTT()[0]);
}
+ else if (irr_driver->getShadowViz())
+ {
+ renderShadowsDebug();
+ }
else
fbo->BlitToDefault(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
}
@@ -535,7 +540,7 @@ void IrrDriver::renderSolidFirstPass()
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
- draw(mesh, mesh.vao_first_pass, GroupedFPSM::MVPSet[i], GroupedFPSM::TIMVSet[i], 0);
+ draw(mesh, mesh.vao, GroupedFPSM::MVPSet[i], GroupedFPSM::TIMVSet[i], 0);
if (!mesh.textures[0])
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
@@ -549,7 +554,7 @@ void IrrDriver::renderSolidFirstPass()
const GLMesh &mesh = *GroupedFPSM::MeshSet[i];
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
- draw(mesh, mesh.vao_first_pass, GroupedFPSM::MVPSet[i], GroupedFPSM::TIMVSet[i], GroupedFPSM::MeshSet[i]->TextureMatrix, 0);
+ draw(mesh, mesh.vao, GroupedFPSM::MVPSet[i], GroupedFPSM::TIMVSet[i], GroupedFPSM::MeshSet[i]->TextureMatrix, 0);
}
glUseProgram(MeshShader::NormalMapShader::Program);
for (unsigned i = 0; i < GroupedFPSM::MeshSet.size(); ++i)
@@ -560,7 +565,7 @@ void IrrDriver::renderSolidFirstPass()
setTexture(0, getTextureGLuint(mesh.textures[1]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
compressTexture(mesh.textures[0], true);
setTexture(1, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
- draw(mesh, mesh.vao_first_pass, GroupedFPSM::MVPSet[i], GroupedFPSM::TIMVSet[i], 0, 1);
+ draw(mesh, mesh.vao, GroupedFPSM::MVPSet[i], GroupedFPSM::TIMVSet[i], 0, 1);
}
}
}
@@ -648,7 +653,30 @@ void IrrDriver::renderTransparent()
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glDisable(GL_CULL_FACE);
+ TransparentMeshes::reset();
+ TransparentMeshes::reset();
m_scene_manager->drawAll(scene::ESNRP_TRANSPARENT);
+
+ if (World::getWorld() && World::getWorld()->isFogEnabled())
+ {
+ glUseProgram(MeshShader::TransparentFogShader::Program);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ for (unsigned i = 0; i < TransparentMeshes::MeshSet.size(); i++)
+ drawTransparentFogObject(*TransparentMeshes::MeshSet[i], TransparentMeshes::MVPSet[i], TransparentMeshes::MeshSet[i]->TextureMatrix);
+ glBlendFunc(GL_ONE, GL_ONE);
+ for (unsigned i = 0; i < TransparentMeshes::MeshSet.size(); i++)
+ drawTransparentFogObject(*TransparentMeshes::MeshSet[i], TransparentMeshes::MVPSet[i], TransparentMeshes::MeshSet[i]->TextureMatrix);
+ }
+ else
+ {
+ glUseProgram(MeshShader::TransparentShader::Program);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ for (unsigned i = 0; i < TransparentMeshes::MeshSet.size(); i++)
+ drawTransparentObject(*TransparentMeshes::MeshSet[i], TransparentMeshes::MVPSet[i], TransparentMeshes::MeshSet[i]->TextureMatrix);
+ glBlendFunc(GL_ONE, GL_ONE);
+ for (unsigned i = 0; i < TransparentMeshes::MeshSet.size(); i++)
+ drawTransparentObject(*TransparentMeshes::MeshSet[i], TransparentMeshes::MVPSet[i], TransparentMeshes::MeshSet[i]->TextureMatrix);
+ }
}
void IrrDriver::renderParticles()
@@ -662,8 +690,6 @@ void IrrDriver::renderParticles()
void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, size_t width, size_t height)
{
- static int tick = 0;
- tick++;
m_scene_manager->drawAll(scene::ESNRP_CAMERA);
irr_driver->setProjMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION));
irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW));
@@ -707,6 +733,34 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
camnode->setFarValue(FarValues[i]);
camnode->setNearValue(NearValues[i]);
camnode->render();
+ const scene::SViewFrustum *frustrum = camnode->getViewFrustum();
+ float tmp[24] = {
+ frustrum->getFarLeftDown().X,
+ frustrum->getFarLeftDown().Y,
+ frustrum->getFarLeftDown().Z,
+ frustrum->getFarLeftUp().X,
+ frustrum->getFarLeftUp().Y,
+ frustrum->getFarLeftUp().Z,
+ frustrum->getFarRightDown().X,
+ frustrum->getFarRightDown().Y,
+ frustrum->getFarRightDown().Z,
+ frustrum->getFarRightUp().X,
+ frustrum->getFarRightUp().Y,
+ frustrum->getFarRightUp().Z,
+ frustrum->getNearLeftDown().X,
+ frustrum->getNearLeftDown().Y,
+ frustrum->getNearLeftDown().Z,
+ frustrum->getNearLeftUp().X,
+ frustrum->getNearLeftUp().Y,
+ frustrum->getNearLeftUp().Z,
+ frustrum->getNearRightDown().X,
+ frustrum->getNearRightDown().Y,
+ frustrum->getNearRightDown().Z,
+ frustrum->getNearRightUp().X,
+ frustrum->getNearRightUp().Y,
+ frustrum->getNearRightUp().Z,
+ };
+ memcpy(m_shadows_cam[i], tmp, 24 * sizeof(float));
const core::aabbox3df smallcambox = camnode->
getViewFrustum()->getBoundingBox();
core::aabbox3df trackbox(vmin->toIrrVector(), vmax->toIrrVector() -
@@ -716,8 +770,35 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
core::aabbox3df box = smallcambox;
box = box.intersect(trackbox);
-
- SunCamViewMatrix.transformBoxEx(trackbox);
+ float xmin = std::numeric_limits::infinity();
+ float xmax = -std::numeric_limits::infinity();
+ float ymin = std::numeric_limits::infinity();
+ float ymax = -std::numeric_limits::infinity();
+ float zmin = std::numeric_limits::infinity();
+ float zmax = -std::numeric_limits::infinity();
+ const vector3df vectors[] =
+ {
+ frustrum->getFarLeftDown(),
+ frustrum->getFarLeftUp(),
+ frustrum->getFarRightDown(),
+ frustrum->getFarRightUp(),
+ frustrum->getNearLeftDown(),
+ frustrum->getNearLeftUp(),
+ frustrum->getNearRightDown(),
+ frustrum->getNearRightUp()
+ };
+ for (unsigned j = 0; j < 8; j++)
+ {
+ vector3df vector;
+ SunCamViewMatrix.transformVect(vector, vectors[j]);
+ xmin = MIN2(xmin, vector.X);
+ xmax = MAX2(xmax, vector.X);
+ ymin = MIN2(ymin, vector.Y);
+ ymax = MAX2(ymax, vector.Y);
+ zmin = MIN2(zmin, vector.Z);
+ zmax = MAX2(zmax, vector.Z);
+ }
+/* SunCamViewMatrix.transformBoxEx(trackbox);
SunCamViewMatrix.transformBoxEx(box);
core::vector3df extent = box.getExtent();
@@ -727,12 +808,12 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
// Snap to texels
const float units_per_w = w / 1024;
- const float units_per_h = h / 1024;
+ const float units_per_h = h / 1024;*/
- float left = box.MinEdge.X;
- float right = box.MaxEdge.X;
- float up = box.MaxEdge.Y;
- float down = box.MinEdge.Y;
+ float left = xmin;
+ float right = xmax;
+ float up = ymin;
+ float down = ymax;
core::matrix4 tmp_matrix;
@@ -745,15 +826,26 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
}
tmp_matrix.buildProjectionMatrixOrthoLH(left, right,
- up, down,
- 30, z);
+ down, up,
+ 30, zmax);
m_suncam->setProjectionMatrix(tmp_matrix, true);
m_suncam->render();
sun_ortho_matrix.push_back(getVideoDriver()->getTransform(video::ETS_PROJECTION) * getVideoDriver()->getTransform(video::ETS_VIEW));
}
- if ((tick % 100) == 2)
- rsm_matrix = sun_ortho_matrix[3];
+
+ {
+ core::aabbox3df trackbox(vmin->toIrrVector(), vmax->toIrrVector() -
+ core::vector3df(0, 30, 0));
+ SunCamViewMatrix.transformBoxEx(trackbox);
+ core::matrix4 tmp_matrix;
+ tmp_matrix.buildProjectionMatrixOrthoLH(trackbox.MinEdge.X, trackbox.MaxEdge.X,
+ trackbox.MaxEdge.Y, trackbox.MinEdge.Y,
+ 30, trackbox.MaxEdge.Z);
+ m_suncam->setProjectionMatrix(tmp_matrix, true);
+ m_suncam->render();
+ rsm_matrix = getVideoDriver()->getTransform(video::ETS_PROJECTION) * getVideoDriver()->getTransform(video::ETS_VIEW);
+ }
rh_extend = core::vector3df(128, 64, 128);
core::vector3df campos = camnode->getAbsolutePosition();
core::vector3df translation(8 * floor(campos.X / 8), 8 * floor(campos.Y / 8), 8 * floor(campos.Z / 8));
@@ -820,10 +912,40 @@ void IrrDriver::renderShadows()
continue;
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
- draw(mesh, mesh.vao_rsm_pass, rsm_matrix, GroupedFPSM::MVPSet[i], 0);
+ draw(mesh, mesh.vao, rsm_matrix, GroupedFPSM::MVPSet[i], 0);
}
}
+static void renderWireFrameFrustrum(float *tmp, unsigned i)
+{
+ glUseProgram(MeshShader::ViewFrustrumShader::Program);
+ glBindVertexArray(MeshShader::ViewFrustrumShader::frustrumvao);
+ glBindBuffer(GL_ARRAY_BUFFER, SharedObject::frustrumvbo);
+
+ glBufferSubData(GL_ARRAY_BUFFER, 0, 8 * 3 * sizeof(float), (void *)tmp);
+ MeshShader::ViewFrustrumShader::setUniforms(video::SColor(255, 0, 255, 0), i);
+ glDrawElements(GL_LINES, 24, GL_UNSIGNED_INT, 0);
+}
+
+
+void IrrDriver::renderShadowsDebug()
+{
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glViewport(0, UserConfigParams::m_height / 2, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
+ m_post_processing->renderTextureLayer(m_rtts->getShadowDepthTex(), 0);
+ renderWireFrameFrustrum(m_shadows_cam[0], 0);
+ glViewport(UserConfigParams::m_width / 2, UserConfigParams::m_height / 2, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
+ m_post_processing->renderTextureLayer(m_rtts->getShadowDepthTex(), 1);
+ renderWireFrameFrustrum(m_shadows_cam[1], 1);
+ glViewport(0, 0, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
+ m_post_processing->renderTextureLayer(m_rtts->getShadowDepthTex(), 2);
+ renderWireFrameFrustrum(m_shadows_cam[2], 2);
+ glViewport(UserConfigParams::m_width / 2, 0, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2);
+ m_post_processing->renderTextureLayer(m_rtts->getShadowDepthTex(), 3);
+ renderWireFrameFrustrum(m_shadows_cam[3], 3);
+ glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
+}
+
// ----------------------------------------------------------------------------
void IrrDriver::renderGlow(std::vector& glows)
diff --git a/src/graphics/rtts.cpp b/src/graphics/rtts.cpp
index 907394453..4f4a4627d 100644
--- a/src/graphics/rtts.cpp
+++ b/src/graphics/rtts.cpp
@@ -42,7 +42,7 @@ static GLuint generateRTT(const core::dimension2du &res, GLint internalFormat, G
glGenTextures(1, &result);
glBindTexture(GL_TEXTURE_2D, result);
#if WIN32
- if (irr_driver->getGLSLVersion() < 420)
+ if (irr_driver->getGLSLVersion() >= 420)
glTexStorage2D(GL_TEXTURE_2D, mipmaplevel, internalFormat, res.Width, res.Height);
else
#endif
@@ -265,20 +265,19 @@ RTT::~RTT()
glDeleteTextures(1, &DepthStencilTexture);
if (UserConfigParams::m_shadows)
{
+ delete m_shadow_FBO;
glDeleteTextures(1, &shadowColorTex);
glDeleteTextures(1, &shadowDepthTex);
}
if (UserConfigParams::m_gi)
{
+ delete m_RH_FBO;
+ delete m_RSM;
glDeleteTextures(1, &RSM_Color);
glDeleteTextures(1, &RSM_Normal);
glDeleteTextures(1, &RSM_Depth);
glDeleteTextures(1, &RH_Red);
glDeleteTextures(1, &RH_Green);
glDeleteTextures(1, &RH_Blue);
-
- delete m_shadow_FBO;
- delete m_RH_FBO;
- delete m_RSM;
}
}
diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp
index 14cd9035d..65361166d 100644
--- a/src/graphics/shaders.cpp
+++ b/src/graphics/shaders.cpp
@@ -169,6 +169,26 @@ static void initCubeVBO()
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6 * 6 * sizeof(int), indices, GL_STATIC_DRAW);
}
+GLuint SharedObject::frustrumvbo = 0;
+GLuint SharedObject::frustrumindexes = 0;
+
+static void initFrustrumVBO()
+{
+ glGenBuffers(1, &SharedObject::frustrumvbo);
+ glBindBuffer(GL_ARRAY_BUFFER, SharedObject::frustrumvbo);
+ glBufferData(GL_ARRAY_BUFFER, 8 * 3 * sizeof(float), 0, GL_DYNAMIC_DRAW);
+
+ int indices[24] = {
+ 0, 1, 1, 3, 3, 2, 2, 0,
+ 4, 5, 5, 7, 7, 6, 6, 4,
+ 0, 4, 1, 5, 2, 6, 3, 7,
+ };
+
+ glGenBuffers(1, &SharedObject::frustrumindexes);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, SharedObject::frustrumindexes);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, 12 * 2 * sizeof(int), indices, GL_STATIC_DRAW);
+}
+
GLuint SharedObject::ViewProjectionMatrixesUBO;
static void initShadowVPMUBO()
@@ -271,6 +291,7 @@ void Shaders::loadShaders()
initQuadBuffer();
initBillboardVBO();
initCubeVBO();
+ initFrustrumVBO();
initShadowVPMUBO();
FullScreenShader::BloomBlendShader::init();
FullScreenShader::BloomShader::init();
@@ -286,6 +307,7 @@ void Shaders::loadShaders()
FullScreenShader::Gaussian6VBlurShader::init();
FullScreenShader::GlowShader::init();
FullScreenShader::PassThroughShader::init();
+ FullScreenShader::LayerPassThroughShader::init();
FullScreenShader::LinearizeDepthShader::init();
FullScreenShader::SSAOShader::init();
FullScreenShader::SunLightShader::init();
@@ -336,6 +358,7 @@ void Shaders::loadShaders()
MeshShader::InstancedRefShadowShader::init();
MeshShader::GrassShadowShader::init();
MeshShader::SkyboxShader::init();
+ MeshShader::ViewFrustrumShader::init();
ParticleShader::FlipParticleRender::init();
ParticleShader::HeightmapSimulationShader::init();
ParticleShader::SimpleParticleRender::init();
@@ -427,9 +450,6 @@ namespace MeshShader
// Solid Normal and depth pass shaders
GLuint ObjectPass1Shader::Program;
- GLuint ObjectPass1Shader::attrib_position;
- GLuint ObjectPass1Shader::attrib_normal;
- GLuint ObjectPass1Shader::attrib_texcoord;
GLuint ObjectPass1Shader::uniform_MM;
GLuint ObjectPass1Shader::uniform_IMM;
GLuint ObjectPass1Shader::uniform_tex;
@@ -440,9 +460,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_normal = glGetAttribLocation(Program, "Normal");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
@@ -463,9 +480,6 @@ namespace MeshShader
}
GLuint ObjectRefPass1Shader::Program;
- GLuint ObjectRefPass1Shader::attrib_position;
- GLuint ObjectRefPass1Shader::attrib_normal;
- GLuint ObjectRefPass1Shader::attrib_texcoord;
GLuint ObjectRefPass1Shader::uniform_MM;
GLuint ObjectRefPass1Shader::uniform_IMM;
GLuint ObjectRefPass1Shader::uniform_TM;
@@ -477,9 +491,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_normal = glGetAttribLocation(Program, "Normal");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
@@ -502,10 +513,6 @@ namespace MeshShader
}
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;
@@ -517,10 +524,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
GL_FRAGMENT_SHADER, 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");
@@ -536,10 +539,6 @@ namespace MeshShader
}
GLuint NormalMapShader::Program;
- GLuint NormalMapShader::attrib_position;
- GLuint NormalMapShader::attrib_texcoord;
- GLuint NormalMapShader::attrib_tangent;
- GLuint NormalMapShader::attrib_bitangent;
GLuint NormalMapShader::uniform_MM;
GLuint NormalMapShader::uniform_IMM;
GLuint NormalMapShader::uniform_normalMap;
@@ -551,10 +550,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/normalmap.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/normalmap.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_tangent = glGetAttribLocation(Program, "Tangent");
- attrib_bitangent = glGetAttribLocation(Program, "Bitangent");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_normalMap = glGetUniformLocation(Program, "normalMap");
@@ -577,12 +572,6 @@ namespace MeshShader
}
GLuint InstancedObjectPass1Shader::Program;
- GLuint InstancedObjectPass1Shader::attrib_position;
- GLuint InstancedObjectPass1Shader::attrib_normal;
- GLuint InstancedObjectPass1Shader::attrib_texcoord;
- GLuint InstancedObjectPass1Shader::attrib_orientation;
- GLuint InstancedObjectPass1Shader::attrib_origin;
- GLuint InstancedObjectPass1Shader::attrib_scale;
GLuint InstancedObjectPass1Shader::uniform_tex;
void InstancedObjectPass1Shader::init()
@@ -592,12 +581,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str());
- attrib_origin = glGetAttribLocation(Program, "Origin");
- attrib_orientation = glGetAttribLocation(Program, "Orientation");
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_scale = glGetAttribLocation(Program, "Scale");
- attrib_normal = glGetAttribLocation(Program, "Normal");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
{
@@ -614,12 +597,6 @@ namespace MeshShader
}
GLuint InstancedObjectRefPass1Shader::Program;
- GLuint InstancedObjectRefPass1Shader::attrib_position;
- GLuint InstancedObjectRefPass1Shader::attrib_normal;
- GLuint InstancedObjectRefPass1Shader::attrib_texcoord;
- GLuint InstancedObjectRefPass1Shader::attrib_orientation;
- GLuint InstancedObjectRefPass1Shader::attrib_origin;
- GLuint InstancedObjectRefPass1Shader::attrib_scale;
GLuint InstancedObjectRefPass1Shader::uniform_tex;
void InstancedObjectRefPass1Shader::init()
@@ -629,12 +606,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
- attrib_origin = glGetAttribLocation(Program, "Origin");
- attrib_orientation = glGetAttribLocation(Program, "Orientation");
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_scale = glGetAttribLocation(Program, "Scale");
- attrib_normal = glGetAttribLocation(Program, "Normal");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
{
@@ -651,13 +622,6 @@ namespace MeshShader
}
GLuint InstancedGrassPass1Shader::Program;
- GLuint InstancedGrassPass1Shader::attrib_position;
- GLuint InstancedGrassPass1Shader::attrib_normal;
- GLuint InstancedGrassPass1Shader::attrib_origin;
- GLuint InstancedGrassPass1Shader::attrib_orientation;
- GLuint InstancedGrassPass1Shader::attrib_scale;
- GLuint InstancedGrassPass1Shader::attrib_texcoord;
- GLuint InstancedGrassPass1Shader::attrib_color;
GLuint InstancedGrassPass1Shader::uniform_windDir;
GLuint InstancedGrassPass1Shader::uniform_tex;
@@ -668,13 +632,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_grass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
- attrib_origin = glGetAttribLocation(Program, "Origin");
- attrib_orientation = glGetAttribLocation(Program, "Orientation");
- attrib_scale = glGetAttribLocation(Program, "Scale");
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_normal = glGetAttribLocation(Program, "Normal");
- attrib_color = glGetAttribLocation(Program, "Color");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_windDir = glGetUniformLocation(Program, "windDir");
uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
@@ -695,8 +652,6 @@ namespace MeshShader
// Solid Lit pass shaders
GLuint ObjectPass2Shader::Program;
- GLuint ObjectPass2Shader::attrib_position;
- GLuint ObjectPass2Shader::attrib_texcoord;
GLuint ObjectPass2Shader::uniform_MM;
GLuint ObjectPass2Shader::uniform_TM;
GLuint ObjectPass2Shader::uniform_ambient;
@@ -708,8 +663,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
@@ -743,11 +696,6 @@ namespace MeshShader
}
GLuint InstancedObjectPass2Shader::Program;
- GLuint InstancedObjectPass2Shader::attrib_position;
- GLuint InstancedObjectPass2Shader::attrib_texcoord;
- GLuint InstancedObjectPass2Shader::attrib_origin;
- GLuint InstancedObjectPass2Shader::attrib_orientation;
- GLuint InstancedObjectPass2Shader::attrib_scale;
GLuint InstancedObjectPass2Shader::uniform_VP;
GLuint InstancedObjectPass2Shader::uniform_TM;
GLuint InstancedObjectPass2Shader::uniform_ambient;
@@ -760,11 +708,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_origin = glGetAttribLocation(Program, "Origin");
- attrib_orientation = glGetAttribLocation(Program, "Orientation");
- attrib_scale = glGetAttribLocation(Program, "Scale");
uniform_VP = glGetUniformLocation(Program, "ViewProjectionMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
@@ -799,11 +742,6 @@ namespace MeshShader
}
GLuint InstancedObjectRefPass2Shader::Program;
- GLuint InstancedObjectRefPass2Shader::attrib_position;
- GLuint InstancedObjectRefPass2Shader::attrib_texcoord;
- GLuint InstancedObjectRefPass2Shader::attrib_origin;
- GLuint InstancedObjectRefPass2Shader::attrib_orientation;
- GLuint InstancedObjectRefPass2Shader::attrib_scale;
GLuint InstancedObjectRefPass2Shader::uniform_VP;
GLuint InstancedObjectRefPass2Shader::uniform_TM;
GLuint InstancedObjectRefPass2Shader::uniform_ambient;
@@ -816,11 +754,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_origin = glGetAttribLocation(Program, "Origin");
- attrib_orientation = glGetAttribLocation(Program, "Orientation");
- attrib_scale = glGetAttribLocation(Program, "Scale");
uniform_VP = glGetUniformLocation(Program, "ViewProjectionMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
@@ -852,9 +785,6 @@ namespace MeshShader
}
GLuint DetailledObjectPass2Shader::Program;
- GLuint DetailledObjectPass2Shader::attrib_position;
- GLuint DetailledObjectPass2Shader::attrib_texcoord;
- GLuint DetailledObjectPass2Shader::attrib_second_texcoord;
GLuint DetailledObjectPass2Shader::uniform_MM;
GLuint DetailledObjectPass2Shader::uniform_ambient;
GLuint DetailledObjectPass2Shader::TU_Albedo;
@@ -866,9 +796,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/detailledobject_pass2.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
GLuint uniform_Detail = glGetUniformLocation(Program, "Detail");
@@ -900,8 +827,6 @@ namespace MeshShader
}
GLuint ObjectUnlitShader::Program;
- GLuint ObjectUnlitShader::attrib_position;
- GLuint ObjectUnlitShader::attrib_texcoord;
GLuint ObjectUnlitShader::uniform_MM;
GLuint ObjectUnlitShader::TU_tex;
@@ -910,8 +835,6 @@ namespace MeshShader
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
@@ -934,9 +857,6 @@ namespace MeshShader
}
GLuint ObjectRimLimitShader::Program;
- GLuint ObjectRimLimitShader::attrib_position;
- GLuint ObjectRimLimitShader::attrib_texcoord;
- GLuint ObjectRimLimitShader::attrib_normal;
GLuint ObjectRimLimitShader::uniform_MM;
GLuint ObjectRimLimitShader::uniform_IMM;
GLuint ObjectRimLimitShader::uniform_TM;
@@ -948,9 +868,6 @@ namespace MeshShader
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_rimlit.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_normal = glGetAttribLocation(Program, "Normal");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
@@ -989,8 +906,6 @@ namespace MeshShader
}
GLuint UntexturedObjectShader::Program;
- GLuint UntexturedObjectShader::attrib_position;
- GLuint UntexturedObjectShader::attrib_color;
GLuint UntexturedObjectShader::uniform_MM;
GLuint UntexturedObjectShader::uniform_ambient;
@@ -1000,8 +915,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/untextured_object.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_color = glGetAttribLocation(Program, "Color");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
@@ -1031,8 +944,6 @@ namespace MeshShader
GLuint ObjectRefPass2Shader::Program;
- GLuint ObjectRefPass2Shader::attrib_position;
- GLuint ObjectRefPass2Shader::attrib_texcoord;
GLuint ObjectRefPass2Shader::uniform_MM;
GLuint ObjectRefPass2Shader::uniform_TM;
GLuint ObjectRefPass2Shader::uniform_ambient;
@@ -1045,8 +956,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
@@ -1081,9 +990,6 @@ namespace MeshShader
}
GLuint GrassPass2Shader::Program;
- GLuint GrassPass2Shader::attrib_position;
- GLuint GrassPass2Shader::attrib_texcoord;
- GLuint GrassPass2Shader::attrib_color;
GLuint GrassPass2Shader::uniform_MVP;
GLuint GrassPass2Shader::uniform_ambient;
GLuint GrassPass2Shader::uniform_windDir;
@@ -1095,9 +1001,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_color = glGetAttribLocation(Program, "Color");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
@@ -1125,13 +1028,6 @@ namespace MeshShader
}
GLuint InstancedGrassPass2Shader::Program;
- GLuint InstancedGrassPass2Shader::attrib_position;
- GLuint InstancedGrassPass2Shader::attrib_texcoord;
- GLuint InstancedGrassPass2Shader::attrib_color;
- GLuint InstancedGrassPass2Shader::attrib_normal;
- GLuint InstancedGrassPass2Shader::attrib_origin;
- GLuint InstancedGrassPass2Shader::attrib_orientation;
- GLuint InstancedGrassPass2Shader::attrib_scale;
GLuint InstancedGrassPass2Shader::uniform_VP;
GLuint InstancedGrassPass2Shader::uniform_ambient;
GLuint InstancedGrassPass2Shader::uniform_windDir;
@@ -1148,13 +1044,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_grass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_color = glGetAttribLocation(Program, "Color");
- attrib_normal = glGetAttribLocation(Program, "Normal");
- attrib_origin = glGetAttribLocation(Program, "Origin");
- attrib_orientation = glGetAttribLocation(Program, "Orientation");
- attrib_scale = glGetAttribLocation(Program, "Scale");
uniform_VP = glGetUniformLocation(Program, "ViewProjectionMatrix");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
@@ -1195,8 +1084,6 @@ namespace MeshShader
}
GLuint SphereMapShader::Program;
- GLuint SphereMapShader::attrib_position;
- GLuint SphereMapShader::attrib_normal;
GLuint SphereMapShader::uniform_MM;
GLuint SphereMapShader::uniform_IMM;
GLuint SphereMapShader::uniform_ambient;
@@ -1209,8 +1096,6 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_spheremap.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_normal = glGetAttribLocation(Program, "Normal");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_ambient = glGetUniformLocation(Program, "ambient");
@@ -1244,9 +1129,6 @@ namespace MeshShader
}
GLuint SplattingShader::Program;
- GLuint SplattingShader::attrib_position;
- GLuint SplattingShader::attrib_texcoord;
- GLuint SplattingShader::attrib_second_texcoord;
GLuint SplattingShader::uniform_MM;
GLuint SplattingShader::uniform_ambient;
GLuint SplattingShader::TU_tex_layout;
@@ -1260,9 +1142,6 @@ namespace MeshShader
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/splatting.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_tex_layout = glGetUniformLocation(Program, "tex_layout");
GLuint uniform_tex_detail0 = glGetUniformLocation(Program, "tex_detail0");
@@ -1299,8 +1178,6 @@ namespace MeshShader
}
GLuint BubbleShader::Program;
- GLuint BubbleShader::attrib_position;
- GLuint BubbleShader::attrib_texcoord;
GLuint BubbleShader::uniform_MVP;
GLuint BubbleShader::uniform_tex;
GLuint BubbleShader::uniform_time;
@@ -1311,8 +1188,6 @@ namespace MeshShader
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/bubble.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bubble.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_time = glGetUniformLocation(Program, "time");
@@ -1327,9 +1202,6 @@ namespace MeshShader
}
GLuint TransparentShader::Program;
- GLuint TransparentShader::attrib_position;
- GLuint TransparentShader::attrib_texcoord;
- GLuint TransparentShader::attrib_color;
GLuint TransparentShader::uniform_MVP;
GLuint TransparentShader::uniform_TM;
GLuint TransparentShader::uniform_tex;
@@ -1337,27 +1209,26 @@ namespace MeshShader
void TransparentShader::init()
{
Program = LoadProgram(
- GL_VERTEX_SHADER, file_manager->getAsset("shaders/transparent.vert").c_str(),
+ GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparent.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_color = glGetAttribLocation(Program, "Color");
- uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
+ uniform_MVP = glGetUniformLocation(Program, "ModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
+ if (!UserConfigParams::m_ubo_disabled)
+ {
+ GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
+ glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
+ }
}
- void TransparentShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex)
+ void TransparentShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex)
{
- glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
+ glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelMatrix.pointer());
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
glUniform1i(uniform_tex, TU_tex);
}
GLuint TransparentFogShader::Program;
- GLuint TransparentFogShader::attrib_position;
- GLuint TransparentFogShader::attrib_texcoord;
- GLuint TransparentFogShader::attrib_color;
GLuint TransparentFogShader::uniform_MVP;
GLuint TransparentFogShader::uniform_TM;
GLuint TransparentFogShader::uniform_tex;
@@ -1371,12 +1242,9 @@ namespace MeshShader
void TransparentFogShader::init()
{
Program = LoadProgram(
- GL_VERTEX_SHADER, file_manager->getAsset("shaders/transparent.vert").c_str(),
+ GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparentfog.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_color = glGetAttribLocation(Program, "Color");
- uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
+ uniform_MVP = glGetUniformLocation(Program, "ModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_fogmax = glGetUniformLocation(Program, "fogmax");
@@ -1392,9 +1260,9 @@ namespace MeshShader
}
}
- void TransparentFogShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex)
+ void TransparentFogShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex)
{
- glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
+ glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelMatrix.pointer());
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
glUniform1f(uniform_fogmax, fogmax);
glUniform1f(uniform_startH, startH);
@@ -1442,7 +1310,6 @@ namespace MeshShader
}
GLuint ColorizeShader::Program;
- GLuint ColorizeShader::attrib_position;
GLuint ColorizeShader::uniform_MM;
GLuint ColorizeShader::uniform_col;
@@ -1451,7 +1318,6 @@ namespace MeshShader
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/colorize.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_col = glGetUniformLocation(Program, "col");
if (!UserConfigParams::m_ubo_disabled)
@@ -1470,17 +1336,13 @@ namespace MeshShader
}
GLuint ShadowShader::Program;
- GLuint ShadowShader::attrib_position;
GLuint ShadowShader::uniform_MM;
void ShadowShader::init()
{
// Geometry shader needed
if (irr_driver->getGLSLVersion() < 150)
- {
- attrib_position = -1;
return;
- }
if (irr_driver->hasVSLayerExtension())
{
Program = LoadProgram(
@@ -1494,7 +1356,6 @@ namespace MeshShader
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/shadow.geom").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str());
}
- attrib_position = glGetAttribLocation(Program, "Position");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@@ -1507,22 +1368,18 @@ namespace MeshShader
}
GLuint RSMShader::Program;
- GLuint RSMShader::attrib_position;
- GLuint RSMShader::attrib_texcoord;
- GLuint RSMShader::attrib_normal;
GLuint RSMShader::uniform_MM;
GLuint RSMShader::uniform_tex;
GLuint RSMShader::uniform_RSMMatrix;
void RSMShader::init()
{
+ if (irr_driver->getGLSLVersion() < 150)
+ return;
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/rsm.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rsm.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_normal = glGetAttribLocation(Program, "Normal");
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_RSMMatrix = glGetUniformLocation(Program, "RSMMatrix");
}
@@ -1535,19 +1392,12 @@ namespace MeshShader
}
GLuint InstancedShadowShader::Program;
- GLuint InstancedShadowShader::attrib_position;
- GLuint InstancedShadowShader::attrib_origin;
- GLuint InstancedShadowShader::attrib_orientation;
- GLuint InstancedShadowShader::attrib_scale;
void InstancedShadowShader::init()
{
// Geometry shader needed
if (irr_driver->getGLSLVersion() < 150)
- {
- attrib_position = -1;
return;
- }
if (irr_driver->hasVSLayerExtension())
{
Program = LoadProgram(
@@ -1563,10 +1413,6 @@ namespace MeshShader
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/shadow.geom").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str());
}
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_origin = glGetAttribLocation(Program, "Origin");
- attrib_orientation = glGetAttribLocation(Program, "Orientation");
- attrib_scale = glGetAttribLocation(Program, "Scale");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
@@ -1576,8 +1422,6 @@ namespace MeshShader
}
GLuint RefShadowShader::Program;
- GLuint RefShadowShader::attrib_position;
- GLuint RefShadowShader::attrib_texcoord;
GLuint RefShadowShader::uniform_MM;
GLuint RefShadowShader::uniform_tex;
@@ -1585,11 +1429,7 @@ namespace MeshShader
{
// Geometry shader needed
if (irr_driver->getGLSLVersion() < 150)
- {
- attrib_position = -1;
- attrib_texcoord = -1;
return;
- }
if (irr_driver->hasVSLayerExtension())
{
Program = LoadProgram(
@@ -1603,8 +1443,6 @@ namespace MeshShader
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/shadow.geom").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
}
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
@@ -1618,22 +1456,13 @@ namespace MeshShader
}
GLuint InstancedRefShadowShader::Program;
- GLuint InstancedRefShadowShader::attrib_position;
- GLuint InstancedRefShadowShader::attrib_texcoord;
- GLuint InstancedRefShadowShader::attrib_origin;
- GLuint InstancedRefShadowShader::attrib_orientation;
- GLuint InstancedRefShadowShader::attrib_scale;
GLuint InstancedRefShadowShader::uniform_tex;
void InstancedRefShadowShader::init()
{
// Geometry shader needed
if (irr_driver->getGLSLVersion() < 150)
- {
- attrib_position = -1;
- attrib_texcoord = -1;
return;
- }
if (irr_driver->hasVSLayerExtension())
{
Program = LoadProgram(
@@ -1649,11 +1478,6 @@ namespace MeshShader
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/shadow.geom").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
}
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_origin = glGetAttribLocation(Program, "Origin");
- attrib_orientation = glGetAttribLocation(Program, "Orientation");
- attrib_scale = glGetAttribLocation(Program, "Scale");
uniform_tex = glGetUniformLocation(Program, "tex");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@@ -1665,9 +1489,6 @@ namespace MeshShader
}
GLuint GrassShadowShader::Program;
- GLuint GrassShadowShader::attrib_position;
- GLuint GrassShadowShader::attrib_texcoord;
- GLuint GrassShadowShader::attrib_color;
GLuint GrassShadowShader::uniform_MVP;
GLuint GrassShadowShader::uniform_tex;
GLuint GrassShadowShader::uniform_windDir;
@@ -1678,11 +1499,8 @@ namespace MeshShader
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
- attrib_color = glGetAttribLocation(Program, "Color");
uniform_windDir = glGetUniformLocation(Program, "windDir");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@@ -1696,7 +1514,6 @@ namespace MeshShader
}
GLuint DisplaceMaskShader::Program;
- GLuint DisplaceMaskShader::attrib_position;
GLuint DisplaceMaskShader::uniform_MVP;
void DisplaceMaskShader::init()
@@ -1704,21 +1521,21 @@ namespace MeshShader
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/displace.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
+ uniform_MVP = glGetUniformLocation(Program, "ModelMatrix");
+ if (!UserConfigParams::m_ubo_disabled)
+ {
+ GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
+ glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
+ }
}
- void DisplaceMaskShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix)
+ void DisplaceMaskShader::setUniforms(const core::matrix4 &ModelMatrix)
{
- glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
+ glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelMatrix.pointer());
}
GLuint DisplaceShader::Program;
- GLuint DisplaceShader::attrib_position;
- GLuint DisplaceShader::attrib_texcoord;
- GLuint DisplaceShader::attrib_second_texcoord;
GLuint DisplaceShader::uniform_MVP;
- GLuint DisplaceShader::uniform_MV;
GLuint DisplaceShader::uniform_displacement_tex;
GLuint DisplaceShader::uniform_mask_tex;
GLuint DisplaceShader::uniform_color_tex;
@@ -1730,11 +1547,7 @@ namespace MeshShader
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/displace.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/displace.frag").c_str());
- attrib_position = glGetAttribLocation(Program, "Position");
- attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
- attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord");
- uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
- uniform_MV = glGetUniformLocation(Program, "ModelViewMatrix");
+ uniform_MVP = glGetUniformLocation(Program, "ModelMatrix");
uniform_displacement_tex = glGetUniformLocation(Program, "displacement_tex");
uniform_color_tex = glGetUniformLocation(Program, "color_tex");
uniform_mask_tex = glGetUniformLocation(Program, "mask_tex");
@@ -1744,10 +1557,9 @@ namespace MeshShader
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
- void DisplaceShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex)
+ void DisplaceShader::setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex)
{
- glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
- glUniformMatrix4fv(uniform_MV, 1, GL_FALSE, ModelViewMatrix.pointer());
+ glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelMatrix.pointer());
glUniform2f(uniform_dir, dir.X, dir.Y);
glUniform2f(uniform_dir2, dir2.X, dir2.Y);
glUniform1i(uniform_displacement_tex, TU_displacement_tex);
@@ -1791,6 +1603,41 @@ namespace MeshShader
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
glUniform1i(uniform_tex, TU_tex);
}
+
+ GLuint ViewFrustrumShader::Program;
+ GLuint ViewFrustrumShader::attrib_position;
+ GLuint ViewFrustrumShader::uniform_color;
+ GLuint ViewFrustrumShader::uniform_idx;
+ GLuint ViewFrustrumShader::frustrumvao;
+
+ void ViewFrustrumShader::init()
+ {
+ Program = LoadProgram(
+ GL_VERTEX_SHADER, file_manager->getAsset("shaders/frustrum.vert").c_str(),
+ GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/coloredquad.frag").c_str());
+ attrib_position = glGetAttribLocation(Program, "Position");
+ if (!UserConfigParams::m_ubo_disabled)
+ {
+ GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
+ glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
+ }
+ uniform_color = glGetUniformLocation(Program, "color");
+ uniform_idx = glGetUniformLocation(Program, "idx");
+
+ glGenVertexArrays(1, &frustrumvao);
+ glBindVertexArray(frustrumvao);
+ glBindBuffer(GL_ARRAY_BUFFER, SharedObject::frustrumvbo);
+ glEnableVertexAttribArray(attrib_position);
+ glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, SharedObject::frustrumindexes);
+ glBindVertexArray(0);
+ }
+
+ void ViewFrustrumShader::setUniforms(const video::SColor &color, unsigned idx)
+ {
+ glUniform4i(uniform_color, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
+ glUniform1i(uniform_idx, idx);
+ }
}
namespace LightShader
@@ -2329,6 +2176,8 @@ namespace FullScreenShader
void RadianceHintsConstructionShader::init()
{
+ if (irr_driver->getGLSLVersion() < 150)
+ return;
if (irr_driver->hasVSLayerExtension())
{
Program = LoadProgram(
@@ -2400,6 +2249,7 @@ namespace FullScreenShader
GLuint GlobalIlluminationReconstructionShader::uniform_SHB;
GLuint GlobalIlluminationReconstructionShader::uniform_extents;
GLuint GlobalIlluminationReconstructionShader::uniform_RHMatrix;
+ GLuint GlobalIlluminationReconstructionShader::uniform_InvRHMatrix;
GLuint GlobalIlluminationReconstructionShader::vao;
void GlobalIlluminationReconstructionShader::init()
@@ -2415,15 +2265,17 @@ namespace FullScreenShader
uniform_SHG = glGetUniformLocation(Program, "SHG");
uniform_SHB = glGetUniformLocation(Program, "SHB");
uniform_RHMatrix = glGetUniformLocation(Program, "RHMatrix");
+ uniform_InvRHMatrix = glGetUniformLocation(Program, "InvRHMatrix");
uniform_extents = glGetUniformLocation(Program, "extents");
vao = createFullScreenVAO(Program);
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
- void GlobalIlluminationReconstructionShader::setUniforms(const core::matrix4 &RHMatrix, const core::vector3df &extents, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_SHR, unsigned TU_SHG, unsigned TU_SHB)
+ void GlobalIlluminationReconstructionShader::setUniforms(const core::matrix4 &RHMatrix, const core::matrix4 &InvRHMatrix, const core::vector3df &extents, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_SHR, unsigned TU_SHG, unsigned TU_SHB)
{
glUniformMatrix4fv(uniform_RHMatrix, 1, GL_FALSE, RHMatrix.pointer());
+ glUniformMatrix4fv(uniform_InvRHMatrix, 1, GL_FALSE, InvRHMatrix.pointer());
glUniform1i(uniform_ntex, TU_ntex);
glUniform1i(uniform_dtex, TU_dtex);
glUniform1i(uniform_SHR, TU_SHR);
@@ -2434,27 +2286,33 @@ namespace FullScreenShader
GLuint Gaussian17TapHShader::Program;
GLuint Gaussian17TapHShader::uniform_tex;
+ GLuint Gaussian17TapHShader::uniform_depth;
GLuint Gaussian17TapHShader::uniform_pixel;
GLuint Gaussian17TapHShader::vao;
void Gaussian17TapHShader::init()
{
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
- GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian17taph.frag").c_str());
+ GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bilateralH.frag").c_str());
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_pixel = glGetUniformLocation(Program, "pixel");
+ uniform_depth = glGetUniformLocation(Program, "depth");
vao = createFullScreenVAO(Program);
}
GLuint ComputeGaussian17TapHShader::Program;
GLuint ComputeGaussian17TapHShader::uniform_source;
+ GLuint ComputeGaussian17TapHShader::uniform_depth;
GLuint ComputeGaussian17TapHShader::uniform_dest;
void ComputeGaussian17TapHShader::init()
{
#if WIN32
+ if (irr_driver->getGLSLVersion() < 420)
+ return;
Program = LoadProgram(
- GL_COMPUTE_SHADER, file_manager->getAsset("shaders/gaussian.comp").c_str());
+ GL_COMPUTE_SHADER, file_manager->getAsset("shaders/bilateralH.comp").c_str());
uniform_source = glGetUniformLocation(Program, "source");
+ uniform_depth = glGetUniformLocation(Program, "depth");
uniform_dest = glGetUniformLocation(Program, "dest");
#endif
}
@@ -2489,27 +2347,33 @@ namespace FullScreenShader
GLuint Gaussian17TapVShader::Program;
GLuint Gaussian17TapVShader::uniform_tex;
+ GLuint Gaussian17TapVShader::uniform_depth;
GLuint Gaussian17TapVShader::uniform_pixel;
GLuint Gaussian17TapVShader::vao;
void Gaussian17TapVShader::init()
{
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
- GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian17tapv.frag").c_str());
+ GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bilateralV.frag").c_str());
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_pixel = glGetUniformLocation(Program, "pixel");
+ uniform_depth = glGetUniformLocation(Program, "depth");
vao = createFullScreenVAO(Program);
}
GLuint ComputeGaussian17TapVShader::Program;
GLuint ComputeGaussian17TapVShader::uniform_source;
+ GLuint ComputeGaussian17TapVShader::uniform_depth;
GLuint ComputeGaussian17TapVShader::uniform_dest;
void ComputeGaussian17TapVShader::init()
{
#if WIN32
+ if (irr_driver->getGLSLVersion() < 420)
+ return;
Program = LoadProgram(
- GL_COMPUTE_SHADER, file_manager->getAsset("shaders/gaussianv.comp").c_str());
+ GL_COMPUTE_SHADER, file_manager->getAsset("shaders/bilateralV.comp").c_str());
uniform_source = glGetUniformLocation(Program, "source");
+ uniform_depth = glGetUniformLocation(Program, "depth");
uniform_dest = glGetUniformLocation(Program, "dest");
#endif
}
@@ -2554,6 +2418,20 @@ namespace FullScreenShader
vao = createVAO(Program);
}
+ GLuint LayerPassThroughShader::Program;
+ GLuint LayerPassThroughShader::uniform_texture;
+ GLuint LayerPassThroughShader::uniform_layer;
+ GLuint LayerPassThroughShader::vao;
+ void LayerPassThroughShader::init()
+ {
+ Program = LoadProgram(
+ GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
+ GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/layertexturequad.frag").c_str());
+ uniform_texture = glGetUniformLocation(Program, "tex");
+ uniform_layer = glGetUniformLocation(Program, "layer");
+ vao = createVAO(Program);
+ }
+
GLuint LinearizeDepthShader::Program;
GLuint LinearizeDepthShader::uniform_zn;
GLuint LinearizeDepthShader::uniform_zf;
diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp
index 551275678..db57030df 100644
--- a/src/graphics/shaders.hpp
+++ b/src/graphics/shaders.hpp
@@ -29,7 +29,7 @@ class SharedObject
{
public:
static GLuint billboardvbo;
- static GLuint cubevbo, cubeindexes;
+ static GLuint cubevbo, cubeindexes, frustrumvbo, frustrumindexes;
static GLuint ViewProjectionMatrixesUBO;
};
@@ -53,7 +53,6 @@ class ObjectPass1Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_normal;
static GLuint uniform_MM, uniform_IMM, uniform_tex;
static void init();
@@ -64,7 +63,6 @@ class ObjectRefPass1Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_normal, attrib_texcoord;
static GLuint uniform_MM, uniform_TM, uniform_IMM, uniform_tex;
static void init();
@@ -75,7 +73,6 @@ 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();
@@ -86,7 +83,6 @@ class NormalMapShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_tangent, attrib_bitangent;
static GLuint uniform_MM, uniform_IMM, uniform_normalMap, uniform_DiffuseForAlpha;
static void init();
@@ -97,7 +93,6 @@ class InstancedObjectPass1Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_normal, attrib_texcoord, attrib_origin, attrib_orientation, attrib_scale;
static GLuint uniform_tex;
static void init();
@@ -108,7 +103,6 @@ class InstancedObjectRefPass1Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_normal, attrib_texcoord, attrib_origin, attrib_orientation, attrib_scale;
static GLuint uniform_tex;
static void init();
@@ -119,7 +113,6 @@ class InstancedGrassPass1Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_normal, attrib_origin, attrib_orientation, attrib_scale, attrib_color, attrib_texcoord;
static GLuint uniform_windDir, uniform_tex;
static void init();
@@ -130,7 +123,6 @@ class ObjectPass2Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MM, uniform_TM, uniform_ambient;
static GLuint TU_Albedo;
@@ -142,7 +134,6 @@ class InstancedObjectPass2Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_origin, attrib_orientation, attrib_scale;
static GLuint uniform_VP, uniform_TM, uniform_ambient;
static GLuint TU_Albedo;
@@ -154,7 +145,6 @@ class InstancedObjectRefPass2Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_origin, attrib_orientation, attrib_scale;
static GLuint uniform_VP, uniform_TM, uniform_ambient;
static GLuint TU_Albedo;
@@ -166,7 +156,6 @@ class DetailledObjectPass2Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
static GLuint uniform_MM, uniform_ambient;
static GLuint TU_Albedo, TU_detail;
@@ -178,7 +167,6 @@ class ObjectRimLimitShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_normal, attrib_texcoord;
static GLuint uniform_MM, uniform_IMM, uniform_TM, uniform_ambient;
static GLuint TU_Albedo;
@@ -190,7 +178,6 @@ class UntexturedObjectShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_color;
static GLuint uniform_MM, uniform_ambient;
static void init();
@@ -201,7 +188,6 @@ class ObjectUnlitShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MM;
static GLuint TU_tex;
@@ -213,7 +199,6 @@ class ObjectRefPass2Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MM, uniform_TM, uniform_ambient;
static GLuint TU_Albedo;
@@ -225,7 +210,6 @@ class GrassPass2Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_color;
static GLuint uniform_MVP, uniform_ambient, uniform_windDir;
static GLuint TU_Albedo;
@@ -237,7 +221,6 @@ class InstancedGrassPass2Shader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_normal, attrib_color, attrib_origin, attrib_orientation, attrib_scale;
static GLuint uniform_VP, uniform_TM, uniform_IVM, uniform_ambient, uniform_windDir, uniform_invproj, uniform_SunDir;
static GLuint TU_Albedo, TU_dtex;
@@ -249,7 +232,6 @@ class SphereMapShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_normal;
static GLuint uniform_MM, uniform_IMM, uniform_ambient;
static GLuint TU_tex;
@@ -261,7 +243,6 @@ class SplattingShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
static GLuint uniform_MM, uniform_ambient;
static GLuint TU_tex_layout, TU_tex_detail0, TU_tex_detail1, TU_tex_detail2, TU_tex_detail3;
@@ -273,7 +254,6 @@ class BubbleShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MVP, uniform_tex, uniform_time, uniform_transparency;
static void init();
@@ -284,22 +264,20 @@ class TransparentShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_color;
static GLuint uniform_MVP, uniform_TM, uniform_tex;
static void init();
- static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex);
+ static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex);
};
class TransparentFogShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_color;
static GLuint uniform_MVP, uniform_TM, uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col;
static void init();
- static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex);
+ static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex);
};
class BillboardShader
@@ -318,7 +296,6 @@ class ColorizeShader
{
public:
static GLuint Program;
- static GLuint attrib_position;
static GLuint uniform_MM, uniform_col;
static void init();
@@ -329,7 +306,6 @@ class ShadowShader
{
public:
static GLuint Program;
- static GLuint attrib_position;
static GLuint uniform_MM, uniform_ViewProjectionMatrixesUBO;
static void init();
@@ -340,7 +316,6 @@ class RSMShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_normal;
static GLuint uniform_MM, uniform_tex, uniform_RSMMatrix;
static void init();
@@ -351,7 +326,6 @@ class InstancedShadowShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_origin, attrib_orientation, attrib_scale;
static void init();
static void setUniforms();
@@ -361,7 +335,6 @@ class RefShadowShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MM, uniform_tex;
static void init();
@@ -372,7 +345,6 @@ class InstancedRefShadowShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_origin, attrib_orientation, attrib_scale;
static GLuint uniform_tex;
static void init();
@@ -383,7 +355,6 @@ class GrassShadowShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_color;
static GLuint uniform_MVP, uniform_tex, uniform_windDir;
static void init();
@@ -394,22 +365,20 @@ class DisplaceMaskShader
{
public:
static GLuint Program;
- static GLuint attrib_position;
static GLuint uniform_MVP;
static void init();
- static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
+ static void setUniforms(const core::matrix4 &ModelMatrix);
};
class DisplaceShader
{
public:
static GLuint Program;
- static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
- static GLuint uniform_MVP, uniform_MV, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_dir, uniform_dir2;
+ static GLuint uniform_MVP, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_dir, uniform_dir2;
static void init();
- static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex);
+ static void setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex);
};
class SkyboxShader
@@ -424,6 +393,18 @@ public:
static void setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &screen, unsigned TU_tex);
};
+class ViewFrustrumShader
+{
+public:
+ static GLuint Program;
+ static GLuint attrib_position;
+ static GLuint uniform_color, uniform_idx;
+ static GLuint frustrumvao;
+
+ static void init();
+ static void setUniforms(const video::SColor &color, unsigned idx);
+};
+
}
#define MAXLIGHT 32
@@ -624,18 +605,18 @@ class GlobalIlluminationReconstructionShader
{
public:
static GLuint Program;
- static GLuint uniform_ntex, uniform_dtex, uniform_extents, uniform_SHR, uniform_SHG, uniform_SHB, uniform_RHMatrix;
+ static GLuint uniform_ntex, uniform_dtex, uniform_extents, uniform_SHR, uniform_SHG, uniform_SHB, uniform_RHMatrix, uniform_InvRHMatrix;
static GLuint vao;
static void init();
- static void setUniforms(const core::matrix4 &RHMatrix, const core::vector3df &extents, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_SHR, unsigned TU_SHG, unsigned TU_SHB);
+ static void setUniforms(const core::matrix4 &RHMatrix, const core::matrix4 &InvRHMatrix, const core::vector3df &extents, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_SHR, unsigned TU_SHG, unsigned TU_SHB);
};
class Gaussian17TapHShader
{
public:
static GLuint Program;
- static GLuint uniform_tex, uniform_pixel;
+ static GLuint uniform_tex, uniform_depth, uniform_pixel;
static GLuint vao;
static void init();
@@ -645,7 +626,7 @@ class ComputeGaussian17TapHShader
{
public:
static GLuint Program;
- static GLuint uniform_source, uniform_dest;
+ static GLuint uniform_source, uniform_depth, uniform_dest;
static void init();
};
@@ -674,7 +655,7 @@ class Gaussian17TapVShader
{
public:
static GLuint Program;
- static GLuint uniform_tex, uniform_pixel;
+ static GLuint uniform_tex, uniform_depth, uniform_pixel;
static GLuint vao;
static void init();
@@ -684,7 +665,7 @@ class ComputeGaussian17TapVShader
{
public:
static GLuint Program;
- static GLuint uniform_source, uniform_dest;
+ static GLuint uniform_source, uniform_depth, uniform_dest;
static void init();
};
@@ -720,6 +701,16 @@ public:
static void init();
};
+class LayerPassThroughShader
+{
+public:
+ static GLuint Program;
+ static GLuint uniform_layer, uniform_texture;
+ static GLuint vao;
+
+ static void init();
+};
+
class LinearizeDepthShader
{
public:
diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp
index 91769e262..793b0e621 100644
--- a/src/graphics/stkanimatedmesh.cpp
+++ b/src/graphics/stkanimatedmesh.cpp
@@ -27,18 +27,8 @@ void STKAnimatedMesh::cleanGLMeshes()
GLMesh mesh = GLmeshes[i];
if (!mesh.vertex_buffer)
continue;
- if (mesh.vao_first_pass)
- glDeleteVertexArrays(1, &(mesh.vao_first_pass));
- if (mesh.vao_second_pass)
- glDeleteVertexArrays(1, &(mesh.vao_second_pass));
- if (mesh.vao_glow_pass)
- glDeleteVertexArrays(1, &(mesh.vao_glow_pass));
- if (mesh.vao_displace_pass)
- glDeleteVertexArrays(1, &(mesh.vao_displace_pass));
- if (mesh.vao_displace_mask_pass)
- glDeleteVertexArrays(1, &(mesh.vao_displace_mask_pass));
- if (mesh.vao_shadow_pass)
- glDeleteVertexArrays(1, &(mesh.vao_shadow_pass));
+ if (mesh.vao)
+ glDeleteVertexArrays(1, &(mesh.vao));
glDeleteBuffers(1, &(mesh.vertex_buffer));
glDeleteBuffers(1, &(mesh.index_buffer));
}
@@ -227,30 +217,16 @@ void STKAnimatedMesh::render()
glUseProgram(MeshShader::BubbleShader::Program);
GLMesh* mesh;
- for_in(mesh, TransparentMesh[TM_BUBBLE])
- drawBubble(*mesh, ModelViewProjectionMatrix);
-
- if (World::getWorld() != NULL && World::getWorld()->isFogEnabled())
+ for_in(mesh, TransparentMesh[TM_DEFAULT])
{
- if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
- glUseProgram(MeshShader::TransparentFogShader::Program);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- for_in(mesh, TransparentMesh[TM_DEFAULT])
- drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
- glBlendFunc(GL_ONE, GL_ONE);
- for_in(mesh, TransparentMesh[TM_ADDITIVE])
- drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
+ TransparentMeshes::MeshSet.push_back(mesh);
+ TransparentMeshes::MVPSet.push_back(AbsoluteTransformation);
}
- else
+
+ for_in(mesh, TransparentMesh[TM_ADDITIVE])
{
- if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
- glUseProgram(MeshShader::TransparentShader::Program);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- for_in(mesh, TransparentMesh[TM_DEFAULT])
- drawTransparentObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
- glBlendFunc(GL_ONE, GL_ONE);
- for_in(mesh, TransparentMesh[TM_ADDITIVE])
- drawTransparentObject(*mesh, ModelViewProjectionMatrix, mesh->TextureMatrix);
+ TransparentMeshes::MeshSet.push_back(mesh);
+ TransparentMeshes::MVPSet.push_back(AbsoluteTransformation);
}
return;
}
diff --git a/src/graphics/stkinstancedscenenode.cpp b/src/graphics/stkinstancedscenenode.cpp
index c10e5ca6b..4dc8ffb7e 100644
--- a/src/graphics/stkinstancedscenenode.cpp
+++ b/src/graphics/stkinstancedscenenode.cpp
@@ -25,16 +25,8 @@ void STKInstancedSceneNode::cleanGL()
GLMesh mesh = GLmeshes[i];
if (!mesh.vertex_buffer)
continue;
- if (mesh.vao_first_pass)
- glDeleteVertexArrays(1, &(mesh.vao_first_pass));
- if (mesh.vao_second_pass)
- glDeleteVertexArrays(1, &(mesh.vao_second_pass));
- if (mesh.vao_glow_pass)
- glDeleteVertexArrays(1, &(mesh.vao_glow_pass));
- if (mesh.vao_displace_pass)
- glDeleteVertexArrays(1, &(mesh.vao_displace_pass));
- if (mesh.vao_displace_mask_pass)
- glDeleteVertexArrays(1, &(mesh.vao_displace_mask_pass));
+ if (mesh.vao)
+ glDeleteVertexArrays(1, &(mesh.vao));
if (mesh.vao_shadow_pass)
glDeleteVertexArrays(1, &(mesh.vao_shadow_pass));
glDeleteBuffers(1, &(mesh.vertex_buffer));
@@ -62,89 +54,34 @@ void STKInstancedSceneNode::createGLMeshes()
isMaterialInitialized = false;
}
-template
-void setInstanceAttribPointer()
-{
- glEnableVertexAttribArray(T::attrib_origin);
- glVertexAttribPointer(T::attrib_origin, 3, GL_FLOAT, GL_FALSE, 9 * sizeof(float), 0);
- glVertexAttribDivisor(T::attrib_origin, divisor);
- glEnableVertexAttribArray(T::attrib_orientation);
- glVertexAttribPointer(T::attrib_orientation, 3, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (GLvoid*)(3 * sizeof(float)));
- glVertexAttribDivisor(T::attrib_orientation, divisor);
- glEnableVertexAttribArray(T::attrib_scale);
- glVertexAttribPointer(T::attrib_scale, 3, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (GLvoid*)(6 * sizeof(float)));
- glVertexAttribDivisor(T::attrib_scale, divisor);
-}
-
void STKInstancedSceneNode::initinstancedvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat)
{
- switch (GeoMat)
- {
- case FPSM_DEFAULT:
- mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::InstancedObjectPass1Shader::attrib_position, MeshShader::InstancedObjectRefPass1Shader::attrib_texcoord, -1, MeshShader::InstancedObjectPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
- glGenBuffers(1, &instances_vbo);
- glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
- glBufferData(GL_ARRAY_BUFFER, instance_pos.size() * sizeof(float), instance_pos.data(), GL_STATIC_DRAW);
- setInstanceAttribPointer();
- if (irr_driver->getGLSLVersion() >= 150)
- {
- mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::InstancedShadowShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
- glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
- setInstanceAttribPointer();
- }
- break;
- case FPSM_ALPHA_REF_TEXTURE:
- mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::InstancedObjectRefPass1Shader::attrib_position, MeshShader::InstancedObjectRefPass1Shader::attrib_texcoord, -1, MeshShader::InstancedObjectRefPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
- glGenBuffers(1, &instances_vbo);
- glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
- glBufferData(GL_ARRAY_BUFFER, instance_pos.size() * sizeof(float), instance_pos.data(), GL_STATIC_DRAW);
- setInstanceAttribPointer();
- if (irr_driver->getGLSLVersion() >= 150)
- {
- mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::InstancedRefShadowShader::attrib_position, MeshShader::InstancedRefShadowShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
- glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
- setInstanceAttribPointer();
- }
- break;
- case FPSM_GRASS:
- mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::InstancedGrassPass1Shader::attrib_position, MeshShader::InstancedGrassPass1Shader::attrib_texcoord, -1, MeshShader::InstancedGrassPass1Shader::attrib_normal, -1, -1, MeshShader::InstancedGrassPass1Shader::attrib_color, mesh.Stride);
- glGenBuffers(1, &instances_vbo);
- glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
- glBufferData(GL_ARRAY_BUFFER, instance_pos.size() * sizeof(float), instance_pos.data(), GL_STATIC_DRAW);
- setInstanceAttribPointer();
- break;
- default:
- return;
- }
+ mesh.vao = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
+ glGenBuffers(1, &instances_vbo);
+ glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
+ glBufferData(GL_ARRAY_BUFFER, instance_pos.size() * sizeof(float), instance_pos.data(), GL_STATIC_DRAW);
+ glEnableVertexAttribArray(7);
+ glVertexAttribPointer(7, 3, GL_FLOAT, GL_FALSE, 9 * sizeof(float), 0);
+ glVertexAttribDivisor(7, 1);
+ glEnableVertexAttribArray(8);
+ glVertexAttribPointer(8, 3, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (GLvoid*)(3 * sizeof(float)));
+ glVertexAttribDivisor(8, 1);
+ glEnableVertexAttribArray(9);
+ glVertexAttribPointer(9, 3, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (GLvoid*)(6 * sizeof(float)));
+ glVertexAttribDivisor(9, 1);
-
- switch (ShadedMat)
- {
- case SM_DEFAULT:
- mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::InstancedObjectPass2Shader::attrib_position, MeshShader::InstancedObjectPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
- glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
- setInstanceAttribPointer();
- break;
- case SM_ALPHA_REF_TEXTURE:
- mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::InstancedObjectRefPass2Shader::attrib_position, MeshShader::InstancedObjectRefPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
- glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
- setInstanceAttribPointer();
- break;
- case SM_GRASS:
- mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::InstancedGrassPass2Shader::attrib_position, MeshShader::InstancedGrassPass2Shader::attrib_texcoord, -1, MeshShader::InstancedGrassPass2Shader::attrib_normal, -1, -1, MeshShader::InstancedGrassPass2Shader::attrib_color, mesh.Stride);
- glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
- setInstanceAttribPointer();
- break;
- default:
- return;
- }
+ mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
+ glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
+ glEnableVertexAttribArray(7);
+ glVertexAttribPointer(7, 3, GL_FLOAT, GL_FALSE, 9 * sizeof(float), 0);
+ glVertexAttribDivisor(7, 4);
+ glEnableVertexAttribArray(8);
+ glVertexAttribPointer(8, 3, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (GLvoid*)(3 * sizeof(float)));
+ glVertexAttribDivisor(8, 4);
+ glEnableVertexAttribArray(9);
+ glVertexAttribPointer(9, 3, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (GLvoid*)(6 * sizeof(float)));
+ glVertexAttribDivisor(9, 4);
glBindVertexArray(0);
}
@@ -164,10 +101,8 @@ void STKInstancedSceneNode::setFirstTimeMaterial()
GeometricMaterial GeometricType = MaterialTypeToGeometricMaterial(type);
ShadedMaterial ShadedType = MaterialTypeToShadedMaterial(type, mesh.textures);
initinstancedvaostate(mesh, GeometricType, ShadedType);
- if (mesh.vao_first_pass)
- GeometricMesh[GeometricType].push_back(&mesh);
- if (mesh.vao_second_pass)
- ShadedMesh[ShadedType].push_back(&mesh);
+ GeometricMesh[GeometricType].push_back(&mesh);
+ ShadedMesh[ShadedType].push_back(&mesh);
}
isMaterialInitialized = true;
}
@@ -205,7 +140,7 @@ static void drawFSPMDefault(GLMesh &mesh, size_t instance_count)
}
MeshShader::InstancedObjectPass1Shader::setUniforms(0);
- glBindVertexArray(mesh.vao_first_pass);
+ glBindVertexArray(mesh.vao);
glDrawElementsInstanced(ptype, count, itype, 0, instance_count);
if (!mesh.textures[0])
@@ -224,7 +159,6 @@ static void drawShadowDefault(GLMesh &mesh, size_t instance_count)
MeshShader::InstancedShadowShader::setUniforms();
- assert(mesh.vao_shadow_pass);
glBindVertexArray(mesh.vao_shadow_pass);
glDrawElementsInstanced(ptype, count, itype, 0, 4 * instance_count);
}
@@ -240,7 +174,7 @@ static void drawFSPMAlphaRefTexture(GLMesh &mesh, size_t instance_count)
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::InstancedObjectRefPass1Shader::setUniforms(0);
- glBindVertexArray(mesh.vao_first_pass);
+ glBindVertexArray(mesh.vao);
glDrawElementsInstanced(ptype, count, itype, 0, instance_count);
}
@@ -255,9 +189,8 @@ static void drawShadowAlphaRefTexture(GLMesh &mesh, size_t instance_count)
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::InstancedRefShadowShader::setUniforms(0);
- assert(mesh.vao_shadow_pass);
glBindVertexArray(mesh.vao_shadow_pass);
- glDrawElementsInstanced(ptype, count, itype, 0, instance_count);
+ glDrawElementsInstanced(ptype, count, itype, 0, 4 * instance_count);
}
static void drawFSPMGrass(GLMesh &mesh, const core::vector3df &windDir, size_t instance_count)
@@ -271,7 +204,7 @@ static void drawFSPMGrass(GLMesh &mesh, const core::vector3df &windDir, size_t i
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::InstancedGrassPass1Shader::setUniforms(windDir, 0);
- glBindVertexArray(mesh.vao_first_pass);
+ glBindVertexArray(mesh.vao);
glDrawElementsInstanced(ptype, count, itype, 0, instance_count);
}
@@ -296,7 +229,7 @@ static void drawSMDefault(GLMesh &mesh, const core::matrix4 &ModelViewProjection
MeshShader::InstancedObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, core::matrix4::EM4CONST_IDENTITY);
- glBindVertexArray(mesh.vao_second_pass);
+ glBindVertexArray(mesh.vao);
glDrawElementsInstanced(ptype, count, itype, 0, instance_count);
}
@@ -322,7 +255,7 @@ static void drawSMAlphaRefTexture(GLMesh &mesh, const core::matrix4 &ModelViewPr
MeshShader::InstancedObjectRefPass2Shader::setUniforms(ModelViewProjectionMatrix, core::matrix4::EM4CONST_IDENTITY);
- glBindVertexArray(mesh.vao_second_pass);
+ glBindVertexArray(mesh.vao);
glDrawElementsInstanced(ptype, count, itype, 0, instance_count);
}
@@ -350,7 +283,7 @@ static void drawSMGrass(GLMesh &mesh, const core::matrix4 &ModelViewProjectionMa
MeshShader::InstancedGrassPass2Shader::setUniforms(ModelViewProjectionMatrix, irr_driver->getInvViewMatrix(), irr_driver->getInvProjMatrix(), windDir, cb->getPosition());
- glBindVertexArray(mesh.vao_second_pass);
+ glBindVertexArray(mesh.vao);
glDrawElementsInstanced(ptype, count, itype, 0, instance_count);
}
diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp
index 245180270..ec44f1a9e 100644
--- a/src/graphics/stkmesh.cpp
+++ b/src/graphics/stkmesh.cpp
@@ -56,54 +56,80 @@ TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE typ
return TM_DEFAULT;
}
-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)
+video::E_VERTEX_TYPE getVTXTYPEFromStride(size_t stride)
+{
+ if (stride == sizeof(video::S3DVertex))
+ return video::EVT_STANDARD;
+ else if (stride == sizeof(video::S3DVertex2TCoords))
+ return video::EVT_2TCOORDS;
+ assert(stride == sizeof(video::S3DVertexTangents));
+ return video::EVT_TANGENTS;
+}
+
+GLuint createVAO(GLuint vbo, GLuint idx, video::E_VERTEX_TYPE type)
{
- if (attrib_position == -1)
- return 0;
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
+ assert(vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
- glEnableVertexAttribArray(attrib_position);
- if ((GLint)attrib_texcoord != -1)
- glEnableVertexAttribArray(attrib_texcoord);
- if ((GLint)attrib_second_texcoord != -1)
- glEnableVertexAttribArray(attrib_second_texcoord);
- if ((GLint)attrib_normal != -1)
- glEnableVertexAttribArray(attrib_normal);
- if ((GLint)attrib_tangent != -1)
- 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);
- if ((GLint)attrib_second_texcoord != -1)
+ switch (type)
{
- if (stride < 44)
- Log::error("material", "Second texcoords not present in VBO");
- glVertexAttribPointer(attrib_second_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 36);
+ case video::EVT_STANDARD:
+ // Position
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), 0);
+ // Normal
+ glEnableVertexAttribArray(1);
+ glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)12);
+ // Color
+ glEnableVertexAttribArray(2);
+ glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, getVertexPitchFromType(type), (GLvoid*)24);
+ // Texcoord
+ glEnableVertexAttribArray(3);
+ glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)28);
+ break;
+ case video::EVT_2TCOORDS:
+ // Position
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), 0);
+ // Normal
+ glEnableVertexAttribArray(1);
+ glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)12);
+ // Color
+ glEnableVertexAttribArray(2);
+ glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, getVertexPitchFromType(type), (GLvoid*)24);
+ // Texcoord
+ glEnableVertexAttribArray(3);
+ glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)28);
+ // SecondTexcoord
+ glEnableVertexAttribArray(4);
+ glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)36);
+ break;
+ case video::EVT_TANGENTS:
+ // Position
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), 0);
+ // Normal
+ glEnableVertexAttribArray(1);
+ glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)12);
+ // Color
+ glEnableVertexAttribArray(2);
+ glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, getVertexPitchFromType(type), (GLvoid*)24);
+ // Texcoord
+ glEnableVertexAttribArray(3);
+ glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)28);
+ // Tangent
+ glEnableVertexAttribArray(5);
+ glVertexAttribPointer(5, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)36);
+ // Bitangent
+ glEnableVertexAttribArray(6);
+ glVertexAttribPointer(6, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)48);
+ break;
+ default:
+ assert(0 && "Wrong vertex type");
}
- if ((GLint)attrib_normal != -1)
- glVertexAttribPointer(attrib_normal, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 12);
- if ((GLint)attrib_tangent != -1)
- {
- if (stride < 48)
- Log::error("material", "Tangents not present in VBO");
- glVertexAttribPointer(attrib_tangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)36);
- }
-
- if ((GLint)attrib_bitangent != -1)
- {
- if (stride < 60)
- 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);
-
+ assert(idx);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idx);
return vao;
}
@@ -124,6 +150,7 @@ GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
result.Stride = getVertexPitchFromType(vType);
const c8* vbuf = static_cast(vertices);
glBufferData(GL_ARRAY_BUFFER, vertexCount * result.Stride, vbuf, GL_STATIC_DRAW);
+ assert(vertexCount);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.index_buffer);
const void* indices = mb->getIndices();
@@ -224,8 +251,8 @@ void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0);
- assert(mesh.vao_first_pass);
- glBindVertexArray(mesh.vao_first_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -250,8 +277,8 @@ void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelMatrix, const c
setTexture(MeshShader::SphereMapShader::TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::SphereMapShader::setUniforms(ModelMatrix, InverseModelMatrix, irr_driver->getSceneManager()->getAmbientLight());
- assert(mesh.vao_second_pass);
- glBindVertexArray(mesh.vao_second_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -330,8 +357,8 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
MeshShader::SplattingShader::setUniforms(ModelViewProjectionMatrix);
- assert(mesh.vao_second_pass);
- glBindVertexArray(mesh.vao_second_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -357,8 +384,8 @@ void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
MeshShader::ObjectRefPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix);
- assert(mesh.vao_second_pass);
- glBindVertexArray(mesh.vao_second_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -386,8 +413,8 @@ void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
MeshShader::GrassPass2Shader::setUniforms(ModelViewProjectionMatrix, windDir);
- assert(mesh.vao_second_pass);
- glBindVertexArray(mesh.vao_second_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -400,8 +427,8 @@ void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelMatrix)
MeshShader::UntexturedObjectShader::setUniforms(ModelMatrix);
- assert(mesh.vao_second_pass);
- glBindVertexArray(mesh.vao_second_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -427,8 +454,8 @@ void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
- assert(mesh.vao_second_pass);
- glBindVertexArray(mesh.vao_second_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -454,8 +481,8 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
MeshShader::ObjectUnlitShader::setUniforms(ModelViewProjectionMatrix);
- assert(mesh.vao_second_pass);
- glBindVertexArray(mesh.vao_second_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -483,8 +510,8 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView
MeshShader::DetailledObjectPass2Shader::setUniforms(ModelViewProjectionMatrix);
- assert(mesh.vao_second_pass);
- glBindVertexArray(mesh.vao_second_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -510,8 +537,8 @@ void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
MeshShader::ObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix);
- assert(mesh.vao_second_pass);
- glBindVertexArray(mesh.vao_second_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -527,8 +554,8 @@ void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewPro
MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0);
- assert(mesh.vao_first_pass);
- glBindVertexArray(mesh.vao_first_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -562,8 +589,8 @@ void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelView
glUseProgram(MeshShader::TransparentFogShader::Program);
MeshShader::TransparentFogShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, fogmax, startH, endH, start, end, col, Camera::getCamera(0)->getCameraSceneNode()->getAbsolutePosition(), 0);
- assert(mesh.vao_first_pass);
- glBindVertexArray(mesh.vao_first_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -582,8 +609,8 @@ void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatr
MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
- assert(mesh.vao_first_pass);
- glBindVertexArray(mesh.vao_first_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -598,8 +625,8 @@ void drawShadowRef(const GLMesh &mesh, const core::matrix4 &ModelMatrix)
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::RefShadowShader::setUniforms(ModelMatrix, 0);
- assert(mesh.vao_shadow_pass);
- glBindVertexArray(mesh.vao_shadow_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElementsInstanced(ptype, count, itype, 0, 4);
}
@@ -612,8 +639,8 @@ void drawShadow(const GLMesh &mesh, const core::matrix4 &ModelMatrix)
MeshShader::ShadowShader::setUniforms(ModelMatrix);
- assert(mesh.vao_shadow_pass);
- glBindVertexArray(mesh.vao_shadow_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElementsInstanced(ptype, count, itype, 0, 4);
}
@@ -656,104 +683,11 @@ bool isObject(video::E_MATERIAL_TYPE type)
void initvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat)
{
- switch (GeoMat)
- {
- case FPSM_DEFAULT:
- mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::ObjectPass1Shader::attrib_position, MeshShader::ObjectPass1Shader::attrib_texcoord, -1, MeshShader::ObjectPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
- mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ShadowShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
- mesh.vao_rsm_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::RSMShader::attrib_position, MeshShader::RSMShader::attrib_texcoord, -1, MeshShader::RSMShader::attrib_normal, -1, -1, -1, mesh.Stride);
- break;
- case FPSM_ALPHA_REF_TEXTURE:
- mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::ObjectRefPass1Shader::attrib_position, MeshShader::ObjectRefPass1Shader::attrib_texcoord, -1, MeshShader::ObjectRefPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
- mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::RefShadowShader::attrib_position, MeshShader::RefShadowShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
- break;
- case FPSM_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, -1, mesh.Stride);
- mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ShadowShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
- break;
- case FPSM_GRASS:
- 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);
- mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::GrassShadowShader::attrib_position, MeshShader::GrassShadowShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::GrassShadowShader::attrib_color, mesh.Stride);
- break;
- default:
- assert(0 && "Unknow material");
- break;
- }
-
- switch (ShadedMat)
- {
- case SM_SPHEREMAP:
- mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::SphereMapShader::attrib_position, -1, -1, MeshShader::SphereMapShader::attrib_normal, -1, -1, -1, mesh.Stride);
- break;
- case SM_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, -1, mesh.Stride);
- break;
- case SM_ALPHA_REF_TEXTURE:
- mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::ObjectRefPass2Shader::attrib_position, MeshShader::ObjectRefPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
- break;
- case SM_RIMLIT:
- mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::ObjectRimLimitShader::attrib_position, MeshShader::ObjectRimLimitShader::attrib_texcoord, -1, MeshShader::ObjectRimLimitShader::attrib_normal, -1, -1, -1, mesh.Stride);
- break;
- case SM_GRASS:
- 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);
- break;
- case SM_UNLIT:
- mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::ObjectUnlitShader::attrib_position, MeshShader::ObjectUnlitShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
- break;
- case SM_DETAILS:
- mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::DetailledObjectPass2Shader::attrib_position, MeshShader::DetailledObjectPass2Shader::attrib_texcoord, MeshShader::DetailledObjectPass2Shader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
- break;
- case SM_UNTEXTURED:
- mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::UntexturedObjectShader::attrib_position, -1, -1, -1, -1, -1, MeshShader::UntexturedObjectShader::attrib_color, mesh.Stride);
- break;
- case SM_DEFAULT:
- mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::ObjectPass2Shader::attrib_position, MeshShader::ObjectPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
- break;
- default:
- assert(0 && "unknow shaded material");
- break;
- }
-
- mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
- mesh.vao_displace_mask_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
- if (mesh.Stride >= 44)
- mesh.vao_displace_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, MeshShader::DisplaceShader::attrib_texcoord, MeshShader::DisplaceShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
+ mesh.vao = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
}
void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat)
{
- switch (TranspMat)
- {
- case TM_BUBBLE:
- mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::BubbleShader::attrib_position, MeshShader::BubbleShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
- break;
- case TM_DEFAULT:
- case TM_ADDITIVE:
- if (World::getWorld() != NULL && World::getWorld()->isFogEnabled())
- mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::TransparentFogShader::attrib_position, MeshShader::TransparentFogShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::TransparentFogShader::attrib_color, mesh.Stride);
- else
- mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
- MeshShader::TransparentShader::attrib_position, MeshShader::TransparentShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::TransparentShader::attrib_color, mesh.Stride);
- break;
- }
- mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
- mesh.vao_displace_mask_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
- if (mesh.Stride >= 44)
- mesh.vao_displace_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, MeshShader::DisplaceShader::attrib_texcoord, MeshShader::DisplaceShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
+ mesh.vao = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
}
diff --git a/src/graphics/stkmesh.hpp b/src/graphics/stkmesh.hpp
index a7e0fb19d..fef78a453 100644
--- a/src/graphics/stkmesh.hpp
+++ b/src/graphics/stkmesh.hpp
@@ -42,12 +42,7 @@ enum TransparentMaterial
};
struct GLMesh {
- GLuint vao_first_pass;
- GLuint vao_second_pass;
- GLuint vao_glow_pass;
- GLuint vao_displace_pass;
- GLuint vao_displace_mask_pass;
- GLuint vao_rsm_pass;
+ GLuint vao;
GLuint vao_shadow_pass;
GLuint vertex_buffer;
GLuint index_buffer;
@@ -59,8 +54,9 @@ struct GLMesh {
core::matrix4 TextureMatrix;
};
-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);
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb);
+video::E_VERTEX_TYPE getVTXTYPEFromStride(size_t stride);
+GLuint createVAO(GLuint vbo, GLuint idx, video::E_VERTEX_TYPE type);
void initvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat);
void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat);
core::matrix4 computeMVP(const core::matrix4 &ModelViewProjectionMatrix);
@@ -147,6 +143,25 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
void drawShadowRef(const GLMesh &mesh, const core::matrix4 &ModelMatrix);
void drawShadow(const GLMesh &mesh, const core::matrix4 &ModelMatrix);
+template
+class TransparentMeshes
+{
+public:
+ static std::vector MeshSet;
+ static std::vector MVPSet;
+
+ static void reset()
+ {
+ MeshSet.clear();
+ MVPSet.clear();
+ }
+};
+
+template
+std::vector TransparentMeshes::MeshSet;
+template
+std::vector TransparentMeshes::MVPSet;
+
// Forward pass (for transparents meshes)
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp
index 0ecf8586d..f9a60888e 100644
--- a/src/graphics/stkmeshscenenode.cpp
+++ b/src/graphics/stkmeshscenenode.cpp
@@ -82,18 +82,8 @@ void STKMeshSceneNode::cleanGLMeshes()
GLMesh mesh = GLmeshes[i];
if (!mesh.vertex_buffer)
continue;
- if (mesh.vao_first_pass)
- glDeleteVertexArrays(1, &(mesh.vao_first_pass));
- if (mesh.vao_second_pass)
- glDeleteVertexArrays(1, &(mesh.vao_second_pass));
- if (mesh.vao_glow_pass)
- glDeleteVertexArrays(1, &(mesh.vao_glow_pass));
- if (mesh.vao_displace_pass)
- glDeleteVertexArrays(1, &(mesh.vao_displace_pass));
- if (mesh.vao_displace_mask_pass)
- glDeleteVertexArrays(1, &(mesh.vao_displace_mask_pass));
- if (mesh.vao_shadow_pass)
- glDeleteVertexArrays(1, &(mesh.vao_shadow_pass));
+ if (mesh.vao)
+ glDeleteVertexArrays(1, &(mesh.vao));
glDeleteBuffers(1, &(mesh.vertex_buffer));
glDeleteBuffers(1, &(mesh.index_buffer));
}
@@ -126,8 +116,8 @@ void STKMeshSceneNode::drawGlow(const GLMesh &mesh)
MeshShader::ColorizeShader::setUniforms(AbsoluteTransformation, cb->getRed(), cb->getGreen(), cb->getBlue());
- assert(mesh.vao_glow_pass);
- glBindVertexArray(mesh.vao_glow_pass);
+ assert(mesh.vao);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@@ -141,19 +131,14 @@ void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
- ModelViewProjectionMatrix = computeMVP(AbsoluteTransformation);
- core::matrix4 ModelViewMatrix = irr_driver->getViewMatrix();
- ModelViewMatrix *= AbsoluteTransformation;
-
// Generate displace mask
// Use RTT_TMP4 as displace mask
irr_driver->getFBO(FBO_TMP1_WITH_DS).Bind();
glUseProgram(MeshShader::DisplaceMaskShader::Program);
- MeshShader::DisplaceMaskShader::setUniforms(ModelViewProjectionMatrix);
+ MeshShader::DisplaceMaskShader::setUniforms(AbsoluteTransformation);
- assert(mesh.vao_displace_mask_pass);
- glBindVertexArray(mesh.vao_displace_mask_pass);
+ glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
// Render the effect
@@ -164,15 +149,13 @@ void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
setTexture(1, irr_driver->getRenderTargetTexture(RTT_TMP1), GL_LINEAR, GL_LINEAR, true);
setTexture(2, irr_driver->getRenderTargetTexture(RTT_COLOR), GL_LINEAR, GL_LINEAR, true);
glUseProgram(MeshShader::DisplaceShader::Program);
- MeshShader::DisplaceShader::setUniforms(ModelViewProjectionMatrix, ModelViewMatrix,
+ MeshShader::DisplaceShader::setUniforms(AbsoluteTransformation,
core::vector2df(cb->getDirX(), cb->getDirY()),
core::vector2df(cb->getDir2X(), cb->getDir2Y()),
core::vector2df(float(UserConfigParams::m_width),
float(UserConfigParams::m_height)),
0, 1, 2);
- assert(mesh.vao_displace_pass);
- glBindVertexArray(mesh.vao_displace_pass);
glDrawElements(ptype, count, itype, 0);
}
@@ -209,33 +192,9 @@ void STKMeshSceneNode::drawSolidPass2(const GLMesh &mesh, ShadedMaterial type)
{
switch (type)
{
- case SM_SPHEREMAP:
- drawSphereMap(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
- break;
- case SM_SPLATTING:
- drawSplatting(mesh, ModelViewProjectionMatrix);
- break;
- case SM_ALPHA_REF_TEXTURE:
- drawObjectRefPass2(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix);
- break;
case SM_GRASS:
drawGrassPass2(mesh, ModelViewProjectionMatrix, windDir);
break;
- case SM_RIMLIT:
- drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, core::matrix4::EM4CONST_IDENTITY);
- break;
- case SM_UNLIT:
- drawObjectUnlit(mesh, ModelViewProjectionMatrix);
- break;
- case SM_DETAILS:
- drawDetailledObjectPass2(mesh, ModelViewProjectionMatrix);
- break;
- case SM_UNTEXTURED:
- drawUntexturedObject(mesh, ModelViewProjectionMatrix);
- break;
- case SM_DEFAULT:
- drawObjectPass2(mesh, ModelViewProjectionMatrix, mesh.TextureMatrix);
- break;
default:
assert(0 && "Wrong shaded material");
break;
@@ -440,33 +399,23 @@ void STKMeshSceneNode::render()
ModelViewProjectionMatrix = computeMVP(AbsoluteTransformation);
GLMesh* mesh;
+
+ for_in(mesh, TransparentMesh[TM_DEFAULT])
+ {
+ TransparentMeshes::MeshSet.push_back(mesh);
+ TransparentMeshes::MVPSet.push_back(AbsoluteTransformation);
+ }
+
+ for_in(mesh, TransparentMesh[TM_ADDITIVE])
+ {
+ TransparentMeshes::MeshSet.push_back(mesh);
+ TransparentMeshes::MVPSet.push_back(AbsoluteTransformation);
+ }
+
if (!TransparentMesh[TM_BUBBLE].empty())
glUseProgram(MeshShader::BubbleShader::Program);
for_in(mesh, TransparentMesh[TM_BUBBLE])
drawBubble(*mesh, ModelViewProjectionMatrix);
-
- if (World::getWorld() ->isFogEnabled())
- {
- if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
- glUseProgram(MeshShader::TransparentFogShader::Program);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- for_in(mesh, TransparentMesh[TM_DEFAULT])
- drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
- glBlendFunc(GL_ONE, GL_ONE);
- for_in(mesh, TransparentMesh[TM_ADDITIVE])
- drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
- }
- else
- {
- if (!TransparentMesh[TM_DEFAULT].empty() || !TransparentMesh[TM_ADDITIVE].empty())
- glUseProgram(MeshShader::TransparentShader::Program);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- for_in(mesh, TransparentMesh[TM_DEFAULT])
- drawTransparentObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
- glBlendFunc(GL_ONE, GL_ONE);
- for_in(mesh, TransparentMesh[TM_ADDITIVE])
- drawTransparentObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
- }
return;
}
diff --git a/src/guiengine/engine.cpp b/src/guiengine/engine.cpp
index 2126d1f19..b1903c1d3 100644
--- a/src/guiengine/engine.cpp
+++ b/src/guiengine/engine.cpp
@@ -662,6 +662,7 @@ namespace GUIEngine
#include "io/file_manager.hpp"
#include "guiengine/event_handler.hpp"
#include "guiengine/modaldialog.hpp"
+#include "guiengine/message_queue.hpp"
#include "guiengine/scalable_font.hpp"
#include "guiengine/screen.hpp"
#include "guiengine/skin.hpp"
@@ -1189,6 +1190,8 @@ namespace GUIEngine
// further render)
g_env->drawAll();
+ MessageQueue::update(elapsed_time);
+
// ---- some menus may need updating
if (gamestate != GAME)
{
diff --git a/src/guiengine/message_queue.cpp b/src/guiengine/message_queue.cpp
new file mode 100755
index 000000000..3ae0d671f
--- /dev/null
+++ b/src/guiengine/message_queue.cpp
@@ -0,0 +1,180 @@
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2014 Joerg Henrichs
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+/**
+ \page addons Addons
+ */
+
+#include "guiengine/message_queue.hpp"
+
+#include "config/user_config.hpp"
+#include "guiengine/engine.hpp"
+#include "guiengine/scalable_font.hpp"
+#include "guiengine/skin.hpp"
+
+#include "IGUIElement.h"
+
+using namespace GUIEngine;
+
+namespace MessageQueue
+{
+
+/** A small helper class to store and sort messages to be displayed. */
+class Message
+{
+private:
+ /** The type of the message. */
+ MessageQueue::MessageType m_message_type;
+ /** The message. */
+ core::stringw m_message;
+
+ /** The render type of the message: either achievement-message::neutral
+ * or friend-message::neutral. */
+ std::string m_render_type;
+
+public:
+ Message(MessageQueue::MessageType mt, const core::stringw &message)
+ {
+ m_message_type = mt;
+ m_message = message;
+ if(mt==MessageQueue::MT_ACHIEVEMENT)
+ m_render_type = "achievement-message::neutral";
+ else
+ m_render_type = "friend-message::neutral";
+ } // Message
+ // ------------------------------------------------------------------------
+ /** Returns the message. */
+ const core::stringw & getMessage() const { return m_message; }
+ // ------------------------------------------------------------------------
+ /** Returns the type of the message (achievement or friend). */
+ MessageQueue::MessageType getMessageType() const { return m_message_type; }
+ // ------------------------------------------------------------------------
+ /** Returns the render type: either achievement-message::neutral or
+ * friend-message::neutral (see skin for details). */
+ const std::string &getRenderType() const
+ {
+ return m_render_type;
+ }
+}; // class Message
+
+// ============================================================================
+/** A function class to compare messages, required for priority_queue. */
+class CompareMessages
+{
+public:
+ /** Used to sort messages by priority in the priority queue. Achievement
+ * messages (1) need to have a higher priority than friend messages
+ * (value 0). */
+ bool operator() (const Message *a, const Message *b) const
+ {
+ return a->getMessageType() < b->getMessageType();
+ } // operator ()
+}; // operator()
+
+
+// ============================================================================
+/** List of all messages. */
+std::priority_queue,
+ CompareMessages> g_all_messages;
+
+/** How long the current message has been displayed. The special value
+ * -1 indicates that a new message was added when the queue was empty. */
+float g_current_display_time = -1.0f;
+
+/** How long the current message should be displaed. */
+float g_max_display_time = -1.0f;
+
+/** The label widget used to show the current message. */
+SkinWidgetContainer *g_container = NULL;
+core::recti g_area;
+
+// ============================================================================
+
+void createLabel(const Message *message)
+{
+ if(!g_container)
+ g_container = new SkinWidgetContainer();
+
+ gui::ScalableFont *font = GUIEngine::getFont();
+ core::dimension2du dim = font->getDimension(message->getMessage().c_str());
+ g_current_display_time = 0.0f;
+ // Maybe make this time dependent on message length as well?
+ g_max_display_time = 5.0f;
+ const GUIEngine::BoxRenderParams &brp =
+ GUIEngine::getSkin()->getBoxRenderParams(message->getRenderType());
+ dim.Width +=brp.m_left_border + brp.m_right_border;
+ int x = (UserConfigParams::m_width - dim.Width) / 2;
+ int y = UserConfigParams::m_height - int(1.5f*dim.Height);
+ g_area = irr::core::recti(x, y, x+dim.Width, y+dim.Height);
+} // createLabel
+
+// ----------------------------------------------------------------------------
+/** Adds a message to the message queue.
+ * \param mt The MessageType of the message.
+ * \param message The actual message.
+ */
+void add(MessageType mt, const irr::core::stringw &message)
+{
+ Message *m = new Message(mt, message);
+ if(g_all_messages.size()==0)
+ {
+ // Indicate that there is a new message, which should
+ // which needs a new label etc. to be computed.
+ g_current_display_time =-1.0f;
+ }
+ g_all_messages.push(m);
+} // add
+
+// ----------------------------------------------------------------------------
+/** Update function called from the GUIEngine to handle displaying of the
+ * messages. It will make sure that each message is shown for a certain
+ * amount of time, before it is discarded and the next message (if any)
+ * is displayed.
+ * \param dt Time step size.
+ */
+void update(float dt)
+{
+ if(g_all_messages.size()==0) return;
+
+ g_current_display_time += dt;
+ if(g_current_display_time > g_max_display_time)
+ {
+ Message *last = g_all_messages.top();
+ g_all_messages.pop();
+ delete last;
+ if(g_all_messages.size()==0) return;
+ g_current_display_time = -1.0f;
+ }
+
+ // Create new data for the display.
+ if(g_current_display_time < 0)
+ {
+ createLabel(g_all_messages.top());
+ }
+
+ Message *current = g_all_messages.top();
+ GUIEngine::getSkin()->drawMessage(g_container, g_area,
+ current->getRenderType());
+ gui::ScalableFont *font = GUIEngine::getFont();
+
+ video::SColor color(255, 0, 0, 0);
+ font->draw(current->getMessage(), g_area, color, true, true);
+
+} // update
+
+} // namespace GUIEngine
+
+// ----------------------------------------------------------------------------
diff --git a/src/guiengine/message_queue.hpp b/src/guiengine/message_queue.hpp
new file mode 100644
index 000000000..edda96d4b
--- /dev/null
+++ b/src/guiengine/message_queue.hpp
@@ -0,0 +1,43 @@
+//
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2014 Joerg Henrichs
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_MESSAGE_QUEUE_HPP
+#define HEADER_MESSAGE_QUEUE_HPP
+
+#include "guiengine/widgets/label_widget.hpp"
+
+#include "irrString.h"
+
+#include
+#include
+
+using namespace irr;
+
+namespace MessageQueue
+{
+ /** The various message type which can be shown (which might use a
+ * different look. This type is used to sort the messages, so it is
+ * important that messages that need to be shown as early as possible
+ * will be listed last (i.e. have highest priority). */
+ enum MessageType {MT_FRIEND, MT_ACHIEVEMENT};
+
+ void add(MessageType mt, const core::stringw &message);
+ void update(float dt);
+
+}; // namespace GUIEngine
+#endif
diff --git a/src/guiengine/skin.cpp b/src/guiengine/skin.cpp
index 1f4048017..b3b109326 100644
--- a/src/guiengine/skin.cpp
+++ b/src/guiengine/skin.cpp
@@ -373,6 +373,28 @@ void Skin::drawBgImage()
irr_driver->getVideoDriver()->enableMaterial2D(false);
} // drawBgImage
+// ----------------------------------------------------------------------------
+/** Returns the BoxRenderParams data structure for a given type.
+ * \param type The type name of the box render param to get.
+ */
+const BoxRenderParams& Skin::getBoxRenderParams(const std::string &type)
+{
+ return SkinConfig::m_render_params[type];
+} // getBoxRenderParams
+
+// ----------------------------------------------------------------------------
+/** Draws a background box for an in-game notification message. Example would
+ * be an achievement, or friends comming online.
+ * \param w The SkinWidgetContainer for the outline.
+ * \param dest The destination rectangle to use.
+ * \param type The type of the message (achievement or friend).
+ */
+void Skin::drawMessage(SkinWidgetContainer* w, const core::recti &dest,
+ const std::string &type)
+{
+ drawBoxFromStretchableTexture(w, dest, SkinConfig::m_render_params[type]);
+} // drawMessage
+
// ----------------------------------------------------------------------------
void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w,
const core::recti &dest,
diff --git a/src/guiengine/skin.hpp b/src/guiengine/skin.hpp
index f13a5066a..efa26f23d 100644
--- a/src/guiengine/skin.hpp
+++ b/src/guiengine/skin.hpp
@@ -270,9 +270,7 @@ namespace GUIEngine
video::ITexture* bg_image;
std::vector m_tooltips;
std::vector m_tooltip_at_mouse;
-#ifdef USE_PER_LINE_BACKGROUND
- public:
-#endif
+
LEAK_CHECK()
void drawBoxFromStretchableTexture(SkinWidgetContainer* w,
@@ -396,10 +394,11 @@ namespace GUIEngine
virtual const wchar_t*
getDefaultText(gui::EGUI_DEFAULT_TEXT text) const;
virtual gui::IGUIFont* getFont(gui::EGUI_DEFAULT_FONT which=
- gui::EGDF_DEFAULT) const ;
- virtual u32 getIcon (gui::EGUI_DEFAULT_ICON icon) const ;
- virtual s32 getSize (gui::EGUI_DEFAULT_SIZE size) const ;
- virtual gui::IGUISpriteBank * getSpriteBank () const ;
+ gui::EGDF_DEFAULT) const;
+ virtual u32 getIcon (gui::EGUI_DEFAULT_ICON icon) const;
+ virtual s32 getSize (gui::EGUI_DEFAULT_SIZE size) const;
+ const BoxRenderParams& getBoxRenderParams(const std::string &type);
+ virtual gui::IGUISpriteBank * getSpriteBank () const;
virtual void setColor (gui::EGUI_DEFAULT_COLOR which,
video::SColor newColor);
virtual void setDefaultText (gui::EGUI_DEFAULT_TEXT which,
@@ -411,6 +410,8 @@ namespace GUIEngine
virtual void setSpriteBank (gui::IGUISpriteBank *bank);
void drawTooltips();
+ void drawMessage(SkinWidgetContainer* w, const core::recti &dest,
+ const std::string &type);
video::ITexture* getImage(const char* name);
diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp
index efe45ef5c..fd720eb9d 100644
--- a/src/karts/kart.cpp
+++ b/src/karts/kart.cpp
@@ -2540,6 +2540,8 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
center_shift.setY(m_skidding->getGraphicalJumpOffset() + lean_height
- m_kart_model->getLowestPoint() -chassis_delta );
+ center_shift = getTrans().getBasis() * center_shift;
+
float heading = m_skidding->getVisualSkidRotation();
Moveable::updateGraphics(dt, center_shift,
btQuaternion(heading, 0, m_current_lean));
diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp
index 9870fb957..b95b8dbee 100644
--- a/src/karts/kart_model.cpp
+++ b/src/karts/kart_model.cpp
@@ -340,7 +340,10 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
node = irr_driver->addAnimatedMesh(m_mesh);
// as animated mesh are not cheap to render use frustum box culling
- node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX);
+ if (irr_driver->isGLSL())
+ node->setAutomaticCulling(scene::EAC_OFF);
+ else
+ node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX);
if (always_animated)
{
diff --git a/src/main.cpp b/src/main.cpp
index cac5404f1..3e438a95c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -418,17 +418,10 @@ void setupRaceStart()
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
}
- if(!track_manager->getTrack(UserConfigParams::m_last_track))
- {
- race_manager->setTrack("jungle");
- }
- else
- race_manager->setTrack(UserConfigParams::m_last_track);
-
// ASSIGN should make sure that only input from assigned devices
// is read.
input_manager->getDeviceList()->setAssignMode(ASSIGN);
-} // setupRaceMode
+} // setupRaceStart
// ----------------------------------------------------------------------------
/** Prints help for command line options to stdout.
@@ -1118,6 +1111,8 @@ void initRest()
race_manager->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
race_manager->setDifficulty(
(RaceManager::Difficulty)(int)UserConfigParams::m_difficulty);
+ if(track_manager->getTrack(UserConfigParams::m_last_track))
+ race_manager->setTrack(UserConfigParams::m_last_track);
} // initRest
diff --git a/src/main_loop.cpp b/src/main_loop.cpp
index ace649423..a24789f70 100644
--- a/src/main_loop.cpp
+++ b/src/main_loop.cpp
@@ -176,7 +176,7 @@ void MainLoop::run()
PROFILER_SYNC_FRAME();
PROFILER_POP_CPU_MARKER();
- } // while !m_exit
+ } // while !m_abort
} // run
diff --git a/src/modes/world.cpp b/src/modes/world.cpp
index facd390a1..af8ddb386 100644
--- a/src/modes/world.cpp
+++ b/src/modes/world.cpp
@@ -628,7 +628,7 @@ void World::resetAllKarts()
{
if (count++ > 100)
{
- Log::error("World", "Infitine loop waiting for all_finished?");
+ Log::error("World", "Infinite loop waiting for all_finished?");
break;
}
m_physics->update(1.f/60.f);
diff --git a/src/online/online_player_profile.cpp b/src/online/online_player_profile.cpp
index 28e955fe0..16506f5c7 100644
--- a/src/online/online_player_profile.cpp
+++ b/src/online/online_player_profile.cpp
@@ -22,7 +22,7 @@
#include "achievements/achievements_manager.hpp"
#include "config/player_manager.hpp"
#include "config/user_config.hpp"
-#include "guiengine/dialog_queue.hpp"
+#include "guiengine/message_queue.hpp"
#include "guiengine/screen.hpp"
#include "online/online_profile.hpp"
#include "online/profile_manager.hpp"
@@ -379,11 +379,7 @@ namespace Online
message = _("%d friends are now online.",
to_notify.size());
}
- NotificationDialog *dia =
- new NotificationDialog(NotificationDialog::T_Friends,
- message);
- GUIEngine::DialogQueue::get()->pushDialog(dia, false);
- OnlineProfileFriends::getInstance()->refreshFriendsList();
+ MessageQueue::add(MessageQueue::MT_FRIEND, message);
}
else if(went_offline)
{
@@ -422,10 +418,7 @@ namespace Online
{
message = _("You have a new friend request!");
}
- NotificationDialog *dia =
- new NotificationDialog(NotificationDialog::T_Friends,
- message);
- GUIEngine::DialogQueue::get()->pushDialog(dia, false);
+ MessageQueue::add(MessageQueue::MT_FRIEND, message);
OnlineProfileFriends::getInstance()->refreshFriendsList();
}
}
diff --git a/src/physics/btKart.cpp b/src/physics/btKart.cpp
index 61e389909..c195e4535 100644
--- a/src/physics/btKart.cpp
+++ b/src/physics/btKart.cpp
@@ -323,35 +323,24 @@ btScalar btKart::rayCast(unsigned int index)
#else
if(index==2 || index==3)
{
- if(m_visual_rotation==0.123123123)
+ btTransform chassisTrans = getChassisWorldTransform();
+ if (getRigidBody()->getMotionState())
{
- m_visual_contact_point[index ] = rayResults.m_hitPointInWorld;
- m_visual_contact_point[index-2] = source;
- m_visual_wheels_touch_ground &= (object!=NULL);
+ getRigidBody()->getMotionState()->getWorldTransform(chassisTrans);
}
- else
- {
- btTransform chassisTrans = getChassisWorldTransform();
- if (getRigidBody()->getMotionState())
- {
- getRigidBody()->getMotionState()->getWorldTransform(chassisTrans);
- }
- btQuaternion q(m_visual_rotation, 0, 0);
- btQuaternion rot_new = chassisTrans.getRotation() * q;
- chassisTrans.setRotation(rot_new);
- btVector3 pos = m_kart->getKartModel()->getWheelGraphicsPosition(index);
- pos.setZ(pos.getZ()*0.9f);
- //pos.setX(pos.getX()*0.1f);
- //btVector3 pos = wheel.m_chassisConnectionPointCS;
- btVector3 source = chassisTrans( pos );
- btVector3 target = source + rayvector;
- btVehicleRaycaster::btVehicleRaycasterResult rayResults;
+ btQuaternion q(m_visual_rotation, 0, 0);
+ btQuaternion rot_new = chassisTrans.getRotation() * q;
+ chassisTrans.setRotation(rot_new);
+ btVector3 pos = m_kart->getKartModel()->getWheelGraphicsPosition(index);
+ pos.setZ(pos.getZ()*0.9f);
+ btVector3 source = chassisTrans( pos );
+ btVector3 target = source + rayvector;
+ btVehicleRaycaster::btVehicleRaycasterResult rayResults;
- void* object = m_vehicleRaycaster->castRay(source,target,rayResults);
- m_visual_contact_point[index] = rayResults.m_hitPointInWorld;
- m_visual_contact_point[index-2] = source;
- m_visual_wheels_touch_ground &= (object!=NULL);
- }
+ void* object = m_vehicleRaycaster->castRay(source,target,rayResults);
+ m_visual_contact_point[index] = rayResults.m_hitPointInWorld;
+ m_visual_contact_point[index-2] = source;
+ m_visual_wheels_touch_ground &= (object!=NULL);
}
#endif
diff --git a/src/physics/physical_object.cpp b/src/physics/physical_object.cpp
index 45eaeb564..f6a612336 100644
--- a/src/physics/physical_object.cpp
+++ b/src/physics/physical_object.cpp
@@ -580,7 +580,7 @@ void PhysicalObject::hit(const Material *m, const Vec3 &normal)
if(isSoccerBall() && m != NULL &&
m->getCollisionReaction() == Material::PUSH_SOCCER_BALL)
{
- m_body->applyCentralImpulse(normal * 1000.0f);
+ m_body->applyCentralImpulse(normal * 100.0f);
}
} // hit
diff --git a/src/physics/triangle_mesh.cpp b/src/physics/triangle_mesh.cpp
index e57c37793..4b338388b 100644
--- a/src/physics/triangle_mesh.cpp
+++ b/src/physics/triangle_mesh.cpp
@@ -274,12 +274,16 @@ btVector3 TriangleMesh::getInterpolatedNormal(unsigned int index,
* \param xyz The position in world where the ray hit.
* \param material The material of the mesh that was hit.
* \param normal The intrapolated normal at that position.
+ * \param interpolate_normal If true, the returned normal is the interpolated
+ * based on the three normals of the triangle and the location of the
+ * hit point (which is more compute intensive, but results in much
+ * smoother results).
* \return True if a triangle was hit, false otherwise (and no output
* variable will be set.
*/
bool TriangleMesh::castRay(const btVector3 &from, const btVector3 &to,
btVector3 *xyz, const Material **material,
- btVector3 *normal) const
+ btVector3 *normal, bool interpolate_normal) const
{
if(!m_collision_shape)
{
@@ -300,26 +304,25 @@ bool TriangleMesh::castRay(const btVector3 &from, const btVector3 &to,
btCollisionWorld::ClosestRayResultCallback result(from, to);
-
+ /** A special ray result class that stores the index of the triangle
+ * that was hit. */
class MaterialRayResult : public btCollisionWorld::ClosestRayResultCallback
{
public:
- const Material* m_material;
- const TriangleMesh *m_this;
+ /** Stores the index of the triangle that was hit. */
+ int m_index;
// --------------------------------------------------------------------
MaterialRayResult(const btVector3 &p1, const btVector3 &p2,
const TriangleMesh *me)
: btCollisionWorld::ClosestRayResultCallback(p1,p2)
{
- m_material = NULL;
- m_this = me;
+ m_index = -1;;
} // MaterialRayResult
// --------------------------------------------------------------------
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult,
bool normalInWorldSpace)
{
- m_material =
- m_this->getMaterial(rayResult.m_localShapeInfo->m_triangleIndex);
+ m_index = rayResult.m_localShapeInfo->m_triangleIndex;
return btCollisionWorld::ClosestRayResultCallback
::addSingleResult(rayResult, normalInWorldSpace);
} // AddSingleResult
@@ -335,13 +338,23 @@ bool TriangleMesh::castRay(const btVector3 &from, const btVector3 &to,
: m_body,
m_collision_shape, world_trans,
ray_callback);
+ // Get the index of the triangle hit
+ int index = ray_callback.m_index;
if(ray_callback.hasHit())
{
*xyz = ray_callback.m_hitPointWorld;
- *material = ray_callback.m_material;
+ *material = m_triangleIndex2Material[index];
+
if(normal)
{
- *normal = ray_callback.m_hitNormalWorld;
+ // If requested interpolate the normal. I.e. instead of using
+ // the normal of the triangle interpolate the normal at the
+ // hit position based on the three normals of the triangle.
+ if(interpolate_normal)
+ *normal = getInterpolatedNormal(ray_callback.m_index,
+ ray_callback.m_hitPointWorld);
+ else
+ *normal = ray_callback.m_hitNormalWorld;
normal->normalize();
}
}
diff --git a/src/physics/triangle_mesh.hpp b/src/physics/triangle_mesh.hpp
index 118ec2de5..185c21302 100644
--- a/src/physics/triangle_mesh.hpp
+++ b/src/physics/triangle_mesh.hpp
@@ -70,7 +70,7 @@ public:
// ------------------------------------------------------------------------
bool castRay(const btVector3 &from, const btVector3 &to,
btVector3 *xyz, const Material **material,
- btVector3 *normal=NULL) const;
+ btVector3 *normal=NULL, bool interpolate_normal=false) const;
// ------------------------------------------------------------------------
/** Returns the points of the 'indx' triangle.
* \param indx Index of the triangle to get.
diff --git a/src/states_screens/options_screen_input2.cpp b/src/states_screens/options_screen_input2.cpp
index b9a0beaf3..6e941a2ae 100644
--- a/src/states_screens/options_screen_input2.cpp
+++ b/src/states_screens/options_screen_input2.cpp
@@ -233,7 +233,8 @@ void OptionsScreenInput2::updateInputButtons()
- bool conflicts = false;
+ bool conflicts_between = false;
+ bool conflicts_inside = false;
// ---- make sure there are no binding conflicts
// (same key used for two actions)
std::set currentlyUsedKeys;
@@ -249,7 +250,7 @@ void OptionsScreenInput2::updateInputButtons()
&& conflictsBetweenKbdConfig(action, PA_FIRST_GAME_ACTION,
PA_LAST_GAME_ACTION))
{
- conflicts = true;
+ conflicts_between = true;
actions->markItemBlue (KartActionStrings[action]);
}
}
@@ -266,6 +267,7 @@ void OptionsScreenInput2::updateInputButtons()
m_config->getMappingIdString(others);
if (others_item == item)
{
+ conflicts_inside = true;
actions->markItemRed( KartActionStrings[others] );
}
}
@@ -290,7 +292,7 @@ void OptionsScreenInput2::updateInputButtons()
&& conflictsBetweenKbdConfig(action, PA_FIRST_MENU_ACTION,
PA_LAST_MENU_ACTION))
{
- conflicts = true;
+ conflicts_between = true;
actions->markItemBlue (KartActionStrings[action]);
}
}
@@ -307,6 +309,7 @@ void OptionsScreenInput2::updateInputButtons()
m_config->getBindingAsString(others);
if (others_item == item)
{
+ conflicts_inside = true;
actions->markItemRed( KartActionStrings[others] );
}
}
@@ -318,11 +321,17 @@ void OptionsScreenInput2::updateInputButtons()
GUIEngine::Widget* conflict_label =
getWidget("conflict");
- if (conflicts)
- conflict_label->setText(
- _("* A red item means a conflict with another configuration") );
- else
- conflict_label->setText("");
+
+ std::wostringstream oss;
+ if (conflicts_between)
+ {
+ oss << _("* A blue item means a conflict with another configuration");
+ if (conflicts_inside)
+ oss << "\n";
+ }
+ if (conflicts_inside)
+ oss << _("* A red item means a conflict in the current configuration");
+ conflict_label->setText(oss.str().c_str());
} // updateInputButtons
@@ -442,7 +451,7 @@ void OptionsScreenInput2::eventCallback(Widget* widget,
else if (selection == "tab_video")
sm->replaceTopMostScreen(OptionsScreenVideo::getInstance());
else if (selection == "tab_players")
- sm->replaceTopMostScreen(UserScreen::getInstance());
+ sm->replaceTopMostScreen(TabbedUserScreen::getInstance());
else if (selection == "tab_ui")
sm->replaceTopMostScreen(OptionsScreenUI::getInstance());
else if (selection == "tab_controls") {}
diff --git a/src/states_screens/race_result_gui.hpp b/src/states_screens/race_result_gui.hpp
index a24e975a2..3019461ab 100644
--- a/src/states_screens/race_result_gui.hpp
+++ b/src/states_screens/race_result_gui.hpp
@@ -101,12 +101,6 @@ private:
video::ITexture *m_kart_icon;
/** The times of all karts in the right order. */
core::stringw m_finish_time_string;
-#ifdef USE_PER_LINE_BACKGROUND
- /** For the background bar behind each line. */
- GUIEngine::SkinWidgetContainer m_widget_container;
- /** The parameter for rendering the background box. */
- GUIEngine::BoxRenderParams m_box_params;
-#endif
}; // Rowinfo
/** The team icons. */
diff --git a/src/tracks/terrain_info.cpp b/src/tracks/terrain_info.cpp
index b12f0d9d3..64c60eea5 100644
--- a/src/tracks/terrain_info.cpp
+++ b/src/tracks/terrain_info.cpp
@@ -57,7 +57,8 @@ void TerrainInfo::update(const Vec3 &from)
to.setY(-10000.0f);
const TriangleMesh &tm = World::getWorld()->getTrack()->getTriangleMesh();
- tm.castRay(from, to, &m_hit_point, &m_material, &m_normal);
+ tm.castRay(from, to, &m_hit_point, &m_material, &m_normal,
+ /*interpolate*/false);
} // update
//-----------------------------------------------------------------------------
/** Update the terrain information based on the latest position.
@@ -71,7 +72,8 @@ void TerrainInfo::update(const btTransform &trans, const Vec3 &offset)
to = trans(to);
const TriangleMesh &tm = World::getWorld()->getTrack()->getTriangleMesh();
- tm.castRay(from, to, &m_hit_point, &m_material, &m_normal);
+ tm.castRay(from, to, &m_hit_point, &m_material, &m_normal,
+ /*interpolate*/true);
} // update
// -----------------------------------------------------------------------------
diff --git a/src/tracks/track_object_presentation.cpp b/src/tracks/track_object_presentation.cpp
index 266320998..ca4ddfadd 100644
--- a/src/tracks/track_object_presentation.cpp
+++ b/src/tracks/track_object_presentation.cpp
@@ -254,7 +254,7 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(const XMLNode& xml_node
else
{
m_mesh = irr_driver->getMesh(model_name);
-
+
if (tangent)
{
scene::IMeshManipulator* manip = irr_driver->getVideoDriver()->getMeshManipulator();
@@ -368,6 +368,9 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNod
m_node = irr_driver->addMesh(m_mesh, parent);
m_frame_start = 0;
m_frame_end = 0;
+
+ if (World::getWorld() != NULL && World::getWorld()->getTrack() != NULL)
+ World::getWorld()->getTrack()->handleAnimatedTextures(m_node, *xml_node);
}
//#ifdef DEBUG
// std::string debug_name = model_name+" (track-object)";
diff --git a/tools/simplify_challenges.sh b/tools/simplify_challenges.sh
new file mode 100755
index 000000000..d17610928
--- /dev/null
+++ b/tools/simplify_challenges.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# This script simplifies all challenges by removing any time
+# limit, position requirement, etc, and setting the number
+# of laps to 0. This is meant to quickly test the story
+# mode without having to fully play all challenges.
+
+for i in data/challenges/*.challenge; do
+ echo "Simplifying $i"
+ cat $i | sed 's/position="[0-9]*"/position="99"/' \
+ | sed 's/laps="[0-9]*"/laps="0"/' \
+ | sed 's/energy="[0-9]*"/energy="0"/' \
+ | sed 's/time="[0-9]*"/time="9999"/' \
+ > $i.new
+ mv $i.new $i
+done
+
+for i in data/grandprix/*.grandprix; do
+ echo "Simplyfing GP $i"
+ cat $i | sed 's/laps="[0-9]*"/laps="0"/' > $i.new
+ mv $i.new $i
+done
+echo
+echo "All challenges simplified."
+echo "PLEASE do not commit the changes back to our repository!"
+echo "========================================================"
+