Merge branch 'master' of https://github.com/supertuxkart/stk-code into ScriptEngine
This commit is contained in:
commit
07d5527ee0
@ -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));
|
||||
}
|
||||
|
37
data/shaders/bilateralH.frag
Normal file
37
data/shaders/bilateralH.frag
Normal file
@ -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;
|
||||
}
|
@ -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));
|
||||
}
|
||||
|
38
data/shaders/bilateralV.frag
Normal file
38
data/shaders/bilateralV.frag
Normal file
@ -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;
|
||||
}
|
||||
|
18
data/shaders/frustrum.vert
Normal file
18
data/shaders/frustrum.vert
Normal file
@ -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.);
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
10
data/shaders/layertexturequad.frag
Normal file
10
data/shaders/layertexturequad.frag
Normal file
@ -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)));
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -68,6 +68,14 @@ when the border that intersect at this corner are enabled.
|
||||
<!-- Stateless -->
|
||||
<element type="background" image="ocean/background.jpg" />
|
||||
|
||||
<element type="achievement-message" image="ocean/glassbutton.png"
|
||||
left_border="13" right_border="13" top_border="13" bottom_border="13"
|
||||
preserve_h_aspect_ratios="true" hborder_out_portion="0" vborder_out_portion="0"/>
|
||||
|
||||
<element type="friend-message" image="ocean/glassbutton.png"
|
||||
left_border="13" right_border="13" top_border="13" bottom_border="13"
|
||||
preserve_h_aspect_ratios="true" hborder_out_portion="0" vborder_out_portion="0"/>
|
||||
|
||||
<element type="button" state="neutral" image="ocean/glassbutton.png"
|
||||
left_border="13" right_border="13" top_border="13" bottom_border="13"
|
||||
preserve_h_aspect_ratios="true" hborder_out_portion="0" vborder_out_portion="0"/>
|
||||
|
@ -68,6 +68,14 @@ when the border that intersect at this corner are enabled.
|
||||
<!-- Stateless -->
|
||||
<element type="background" image="peach/background.jpg" />
|
||||
|
||||
<element type="achievement-message" image="peach/achievement.png"
|
||||
left_border="128" right_border="13" top_border="13" bottom_border="13"
|
||||
preserve_h_aspect_ratios="true" hborder_out_portion="0.3" vborder_out_portion="0"/>
|
||||
|
||||
<element type="friend-message" image="peach/friend.png"
|
||||
left_border="128" right_border="13" top_border="13" bottom_border="13"
|
||||
preserve_h_aspect_ratios="true" hborder_out_portion="0" vborder_out_portion="0"/>
|
||||
|
||||
<element type="button" state="neutral" image="peach/glassbutton.png"
|
||||
left_border="13" right_border="13" top_border="13" bottom_border="13"
|
||||
preserve_h_aspect_ratios="true" hborder_out_portion="0" vborder_out_portion="0"/>
|
||||
|
BIN
data/skins/peach/achievement.png
Normal file
BIN
data/skins/peach/achievement.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
BIN
data/skins/peach/friend.png
Normal file
BIN
data/skins/peach/friend.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
@ -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.
|
||||
|
@ -33,6 +33,8 @@ AnimationBase::AnimationBase(const XMLNode &node)
|
||||
node.get("fps", &fps);
|
||||
for(unsigned int i=0; i<node.getNumNodes(); i++)
|
||||
{
|
||||
if (node.getNode(i)->getName() == "animated-texture")
|
||||
continue;
|
||||
Ipo *ipo = new Ipo(*node.getNode(i), fps);
|
||||
m_all_ipos.push_back(ipo);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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<GlowData> m_glowing;
|
||||
|
||||
@ -380,6 +381,7 @@ private:
|
||||
void renderSSAO();
|
||||
void renderLights(unsigned pointlightCount);
|
||||
void renderDisplacement();
|
||||
void renderShadowsDebug();
|
||||
void doScreenShot();
|
||||
public:
|
||||
IrrDriver();
|
||||
|
@ -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->getDepthStencilTexture(), 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->getDepthStencilTexture(), 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)
|
||||
{
|
||||
|
||||
|
@ -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);
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "utils/profiler.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#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);
|
||||
}
|
||||
@ -648,7 +653,30 @@ void IrrDriver::renderTransparent()
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glDisable(GL_CULL_FACE);
|
||||
TransparentMeshes<TM_DEFAULT>::reset();
|
||||
TransparentMeshes<TM_ADDITIVE>::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<TM_DEFAULT>::MeshSet.size(); i++)
|
||||
drawTransparentFogObject(*TransparentMeshes<TM_DEFAULT>::MeshSet[i], TransparentMeshes<TM_DEFAULT>::MVPSet[i], TransparentMeshes<TM_DEFAULT>::MeshSet[i]->TextureMatrix);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
for (unsigned i = 0; i < TransparentMeshes<TM_ADDITIVE>::MeshSet.size(); i++)
|
||||
drawTransparentFogObject(*TransparentMeshes<TM_ADDITIVE>::MeshSet[i], TransparentMeshes<TM_ADDITIVE>::MVPSet[i], TransparentMeshes<TM_ADDITIVE>::MeshSet[i]->TextureMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
glUseProgram(MeshShader::TransparentShader::Program);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
for (unsigned i = 0; i < TransparentMeshes<TM_DEFAULT>::MeshSet.size(); i++)
|
||||
drawTransparentObject(*TransparentMeshes<TM_DEFAULT>::MeshSet[i], TransparentMeshes<TM_DEFAULT>::MVPSet[i], TransparentMeshes<TM_DEFAULT>::MeshSet[i]->TextureMatrix);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
for (unsigned i = 0; i < TransparentMeshes<TM_ADDITIVE>::MeshSet.size(); i++)
|
||||
drawTransparentObject(*TransparentMeshes<TM_ADDITIVE>::MeshSet[i], TransparentMeshes<TM_ADDITIVE>::MVPSet[i], TransparentMeshes<TM_ADDITIVE>::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<float>::infinity();
|
||||
float xmax = -std::numeric_limits<float>::infinity();
|
||||
float ymin = std::numeric_limits<float>::infinity();
|
||||
float ymax = -std::numeric_limits<float>::infinity();
|
||||
float zmin = std::numeric_limits<float>::infinity();
|
||||
float zmax = -std::numeric_limits<float>::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));
|
||||
@ -824,6 +916,36 @@ void IrrDriver::renderShadows()
|
||||
}
|
||||
}
|
||||
|
||||
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<GlowData>& glows)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
@ -1791,6 +1814,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
|
||||
@ -2400,6 +2458,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 +2474,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 +2495,31 @@ 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
|
||||
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 +2554,31 @@ 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
|
||||
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 +2623,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;
|
||||
|
@ -29,7 +29,7 @@ class SharedObject
|
||||
{
|
||||
public:
|
||||
static GLuint billboardvbo;
|
||||
static GLuint cubevbo, cubeindexes;
|
||||
static GLuint cubevbo, cubeindexes, frustrumvbo, frustrumindexes;
|
||||
static GLuint ViewProjectionMatrixesUBO;
|
||||
};
|
||||
|
||||
@ -424,6 +424,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 +636,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 +657,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 +686,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 +696,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 +732,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:
|
||||
|
@ -227,30 +227,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<TM_DEFAULT>::MeshSet.push_back(mesh);
|
||||
TransparentMeshes<TM_DEFAULT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
}
|
||||
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<TM_ADDITIVE>::MeshSet.push_back(mesh);
|
||||
TransparentMeshes<TM_ADDITIVE>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -147,6 +147,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<enum TransparentMaterial T>
|
||||
class TransparentMeshes
|
||||
{
|
||||
public:
|
||||
static std::vector<GLMesh *> MeshSet;
|
||||
static std::vector<core::matrix4> MVPSet;
|
||||
|
||||
static void reset()
|
||||
{
|
||||
MeshSet.clear();
|
||||
MVPSet.clear();
|
||||
}
|
||||
};
|
||||
|
||||
template<enum TransparentMaterial T>
|
||||
std::vector<GLMesh *> TransparentMeshes<T>::MeshSet;
|
||||
template<enum TransparentMaterial T>
|
||||
std::vector<core::matrix4> TransparentMeshes<T>::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);
|
||||
|
@ -209,33 +209,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 +416,23 @@ void STKMeshSceneNode::render()
|
||||
ModelViewProjectionMatrix = computeMVP(AbsoluteTransformation);
|
||||
|
||||
GLMesh* mesh;
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
{
|
||||
TransparentMeshes<TM_DEFAULT>::MeshSet.push_back(mesh);
|
||||
TransparentMeshes<TM_DEFAULT>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
}
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
{
|
||||
TransparentMeshes<TM_ADDITIVE>::MeshSet.push_back(mesh);
|
||||
TransparentMeshes<TM_ADDITIVE>::MVPSet.push_back(ModelViewProjectionMatrix);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
180
src/guiengine/message_queue.cpp
Executable file
180
src/guiengine/message_queue.cpp
Executable file
@ -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<Message*, std::vector<Message*>,
|
||||
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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
43
src/guiengine/message_queue.hpp
Normal file
43
src/guiengine/message_queue.hpp
Normal file
@ -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 <queue>
|
||||
#include <vector>
|
||||
|
||||
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
|
@ -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,
|
||||
|
@ -270,9 +270,7 @@ namespace GUIEngine
|
||||
video::ITexture* bg_image;
|
||||
std::vector<Widget*> m_tooltips;
|
||||
std::vector<bool> 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);
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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. */
|
||||
|
@ -255,7 +255,7 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(const XMLNode& xml_node
|
||||
else
|
||||
{
|
||||
m_mesh = irr_driver->getMesh(model_name);
|
||||
|
||||
|
||||
if (tangent)
|
||||
{
|
||||
scene::IMeshManipulator* manip = irr_driver->getVideoDriver()->getMeshManipulator();
|
||||
@ -369,6 +369,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)";
|
||||
|
Loading…
Reference in New Issue
Block a user