Merge pull request #1 from supertuxkart/master

merge
This commit is contained in:
Artem 2014-01-29 14:08:19 -08:00
commit 6025db77c3
57 changed files with 1203 additions and 534 deletions

6
.gitignore vendored
View File

@ -4,6 +4,7 @@ build-64/
build-win/
cmake_build/
dependencies/
CMakeFiles/
.config/
supertuxkart-64
@ -14,20 +15,25 @@ data/music
data/sfx
data/textures
data/tracks
data/.svn
*.o
*.d
*.a
*.patch
*.diff
*.obj
*.orig
*.rej
*.log
*.lib
*.tlog
*.pdb
*.dll
*.exe
*.vcxproj
*.vcxproj.filters
*.vcxproj.user
packets_log.txt
history.dat

View File

@ -0,0 +1,10 @@
#version 130
uniform sampler2D tex;
in vec2 uv;
out vec4 FragColor;
void main(void)
{
FragColor = texture(tex, uv);
}

View File

@ -0,0 +1,16 @@
#version 130
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform vec3 Position;
uniform vec2 Size;
in vec2 Corner;
in vec2 Texcoord;
out vec2 uv;
void main(void)
{
uv = Texcoord;
vec4 Center = ModelViewMatrix * vec4(Position, 1.);
gl_Position = ProjectionMatrix * (Center + vec4(Size * Corner, 0., 0.));
}

View File

@ -4,7 +4,6 @@ uniform vec2 size;
in vec2 position;
void main()
{
gl_Position = vec4(position * size + center, 0., 1.);

View File

@ -0,0 +1,24 @@
#version 130
uniform sampler2D Albedo;
uniform sampler2D Detail;
uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap;
uniform sampler2D SSAO;
uniform vec2 screen;
uniform vec3 ambient;
in vec2 uv;
in vec2 uv_bis;
out vec4 FragColor;
void main(void)
{
vec2 tc = gl_FragCoord.xy / screen;
vec4 color = texture(Albedo, uv);
vec4 detail = texture(Detail, uv_bis);
color *= detail;
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
float ao = texture(SSAO, tc).x;
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent * (1. - color.a);
FragColor = vec4(color.xyz * LightFactor * ao, 1.);
}

View File

@ -15,9 +15,9 @@ out vec4 FragColor;
void main()
{
float z = texture(tex, uv).a;
float z = texture(tex, uv).x;
vec3 tmp = vec3(gl_TexCoord[0].xy, z);
vec3 tmp = vec3(uv, z);
tmp = tmp * 2.0 - 1.0;
vec4 xpos = vec4(tmp, 1.0);

View File

@ -4,7 +4,13 @@ uniform sampler2D normalMap;
noperspective in vec3 tangent;
noperspective in vec3 bitangent;
in vec2 uv;
out vec4 FragColor;
out vec2 EncodedNormal;
// from Crytek "a bit more deferred CryEngine"
vec2 EncodeNormal(vec3 n)
{
return normalize(n.xy) * sqrt(n.z * 0.5 + 0.5);
}
void main()
{
@ -15,8 +21,6 @@ void main()
vec3 Frag_normal = normalize(cross(Frag_tangent, bitangent));
vec3 Frag_bitangent = cross(Frag_normal, Frag_tangent);
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
FragmentNormal = normalize(FragmentNormal);
FragColor = vec4(0.5 * FragmentNormal + 0.5, gl_FragCoord.z);
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
EncodedNormal = 0.5 * EncodeNormal(normalize(FragmentNormal)) + 0.5;
}

View File

@ -1,8 +1,14 @@
#version 130
noperspective in vec3 nor;
out vec4 FragColor;
out vec2 EncodedNormal;
// from Crytek "a bit more deferred CryEngine"
vec2 EncodeNormal(vec3 n)
{
return normalize(n.xy) * sqrt(n.z * 0.5 + 0.5);
}
void main(void)
{
FragColor = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
EncodedNormal = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
}

View File

@ -5,6 +5,7 @@ uniform sampler2D SpecularMap;
uniform sampler2D SSAO;
uniform vec2 screen;
uniform vec3 ambient;
in vec2 uv;
out vec4 FragColor;
@ -16,6 +17,6 @@ void main(void)
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
float ao = texture(SSAO, tc).x;
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent * (1. - color.a);
FragColor = vec4(color.xyz * LightFactor * ao, 1.);
FragColor = vec4(color.xyz * LightFactor * (0.4 + ao*0.6), 1.);
//FragColor = vec4(color.xyz * LightFactor, 1.);
}

View File

@ -3,10 +3,13 @@ uniform mat4 ModelViewProjectionMatrix;
in vec3 Position;
in vec2 Texcoord;
in vec2 SecondTexcoord;
out vec2 uv;
out vec2 uv_bis;
void main(void)
{
uv = Texcoord;
uv_bis = SecondTexcoord;
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
}

View File

@ -0,0 +1,11 @@
#version 130
uniform sampler2D tex;
in vec2 uv;
out vec4 FragColor;
void main(void)
{
vec4 color = texture(tex, uv);
if (color.a < 0.5) discard;
FragColor = vec4(color.xyz, 1.);
}

View File

@ -3,12 +3,18 @@ uniform sampler2D tex;
noperspective in vec3 nor;
in vec2 uv;
out vec4 NormalDepth;
out vec2 EncodedNormal;
// from Crytek "a bit more deferred CryEngine"
vec2 EncodeNormal(vec3 n)
{
return normalize(n.xy) * sqrt(n.z * 0.5 + 0.5);
}
void main() {
vec4 col = texture(tex, uv);
if (col.a < 0.5)
discard;
NormalDepth = vec4(0.5 * normalize(nor) + 0.5, gl_FragCoord.z);
EncodedNormal = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
}

View File

@ -1,6 +1,6 @@
#version 130
uniform sampler2D tex;
uniform sampler2D normals_and_depth;
uniform sampler2D dtex;
uniform mat4 invproj;
uniform vec2 screen;
@ -13,13 +13,12 @@ void main(void)
{
vec2 xy = gl_FragCoord.xy / screen;
float FragZ = gl_FragCoord.z;
float EnvZ = texture(normals_and_depth, xy).a;
float EnvZ = texture(dtex, xy).x;
vec4 FragmentPos = invproj * (2. * vec4(xy, FragZ, 1.0) - 1.);
FragmentPos /= FragmentPos.w;
vec4 EnvPos = invproj * (2. * vec4(xy, EnvZ, 1.0) - 1.);
EnvPos /= EnvPos.w;
float len = dot(vec3(1.0), abs(texture(normals_and_depth, xy).xyz));
float alpha = (len < 0.2) ? 1. : clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
color = texture(tex, tc);
color.a *= alpha * smoothstep(1., 0.8, lf);
}

View File

@ -1,5 +1,6 @@
#version 130
uniform sampler2D ntex;
uniform sampler2D dtex;
uniform vec4 center[16];
uniform vec4 col[16];
@ -12,11 +13,17 @@ in vec2 uv;
out vec4 Diffuse;
out vec4 Specular;
vec3 DecodeNormal(vec2 n)
{
float z = dot(n, n) * 2. - 1.;
vec2 xy = normalize(n) * sqrt(1. - z * z);
return vec3(xy,z);
}
void main() {
vec2 texc = uv;
float z = texture(ntex, texc).a;
vec3 norm = texture(ntex, texc).xyz;
norm = (norm - 0.5) * 2.0;
float z = texture(dtex, texc).x;
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, texc).xy - 1.));
vec4 xpos = 2.0 * vec4(texc, z, 1.0) - 1.0f;
xpos = invproj * xpos;

View File

@ -1,34 +1,42 @@
#version 130
uniform sampler2D normals_and_depth;
uniform sampler2D ntex;
uniform sampler2D dtex;
uniform sampler2D noise_texture;
uniform mat4 invprojm;
uniform mat4 projm;
uniform vec4 samplePoints[16];
in vec2 uv;
out vec4 FragColor;
out float ao;
const float strengh = 4.;
const float radius = .4f;
#define SAMPLES 8
#define SAMPLES 16
const float invSamples = strengh / SAMPLES;
vec3 rand(vec2 co)
{
return texture(noise_texture, co).xyz;
return texture(noise_texture, co*20.16).xyz;
}
vec3 DecodeNormal(vec2 n)
{
float z = dot(n, n) * 2. - 1.;
vec2 xy = normalize(n) * sqrt(1. - z * z);
return vec3(xy,z);
}
void main(void)
{
vec4 cur = texture(normals_and_depth, uv);
float curdepth = texture(normals_and_depth, uv).a;
vec4 cur = texture(ntex, uv);
float curdepth = texture(dtex, uv).x;
vec4 FragPos = invprojm * (2.0f * vec4(uv, curdepth, 1.0f) - 1.0f);
FragPos /= FragPos.w;
// get the normal of current fragment
vec3 norm = normalize(cur.xyz * vec3(2.0) - vec3(1.0));
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
// Workaround for nvidia and skyboxes
float len = dot(vec3(1.0), abs(cur.xyz));
if (len < 0.2 || curdepth > 0.999) discard;
@ -48,7 +56,7 @@ void main(void)
bool isInsideTexture = (sampleProj.x > -1.) && (sampleProj.x < 1.) && (sampleProj.y > -1.) && (sampleProj.y < 1.);
// get the depth of the occluder fragment
float occluderFragmentDepth = texture(normals_and_depth, (sampleProj.xy * 0.5) + 0.5).a;
float occluderFragmentDepth = texture(dtex, (sampleProj.xy * 0.5) + 0.5).x;
// Position of the occluder fragment in worldSpace
vec4 occluderPos = invprojm * vec4(sampleProj.xy, 2.0 * occluderFragmentDepth - 1.0, 1.0f);
occluderPos /= occluderPos.w;
@ -57,8 +65,5 @@ void main(void)
bl += isOccluded ? smoothstep(radius, 0, distance(samplePos, FragPos)) : 0.;
}
// output the result
float ao = 1.0 - bl * invSamples;
FragColor = vec4(ao);
ao = 1.0 - bl * invSamples;
}

View File

@ -1,5 +1,6 @@
#version 130
uniform sampler2D ntex;
uniform sampler2D dtex;
//uniform sampler2D cloudtex;
uniform vec3 direction;
@ -13,8 +14,15 @@ out vec4 Diff;
out vec4 Spec;
out vec4 SpecularMap;
vec3 DecodeNormal(vec2 n)
{
float z = dot(n, n) * 2. - 1.;
vec2 xy = normalize(n) * sqrt(1. - z * z);
return vec3(xy,z);
}
void main() {
float z = texture(ntex, uv).a;
float z = texture(dtex, uv).x;
vec4 xpos = 2.0 * vec4(uv, z, 1.0) - 1.0;
xpos = invproj * xpos;
xpos.xyz /= xpos.w;
@ -27,8 +35,7 @@ void main() {
return;
}
vec3 norm = texture(ntex, uv).xyz;
norm = (norm - 0.5) * 2.0;
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
// Normalized on the cpu
vec3 L = direction;

View File

@ -2,10 +2,11 @@
Name=SuperTuxKart
Icon=@PREFIX@/share/pixmaps/supertuxkart_128.png
GenericName=A kart racing game
GenericName[de_DE]=Ein Kart-Rennspiel
GenericName[fr_FR]=Un jeu de karting
GenericName[de]=Ein Kart-Rennspiel
GenericName[fr]=Un jeu de karting
GenericName[gl]=Xogo de carreiras con karts
GenericName[ro_RO]=Un joc de curse cu carturi
GenericName[pl]=Wyścigi gokartów
GenericName[ro]=Un joc de curse cu carturi
Exec=@PREFIX@/@STK_INSTALL_BINARY_DIR@/supertuxkart --no-console
Terminal=false
StartupNotify=false

View File

@ -82,7 +82,7 @@ void btRigidBody::setupRigidBody(const btRigidBody::btRigidBodyConstructionInfo&
setCollisionShape( constructionInfo.m_collisionShape );
m_debugBodyId = uniqueId++;
btAssert(constructionInfo.m_mass>=0);
setMassProps(constructionInfo.m_mass, constructionInfo.m_localInertia);
updateInertiaTensor();

View File

@ -79,7 +79,7 @@ public:
//! Creates a clone of this scene node and its children.
virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0);
private:
protected:
//! Size.Width is the bottom edge width
core::dimension2d<f32> Size;

View File

@ -898,6 +898,7 @@ bool COpenGLFBODepthTexture::attach(ITexture* renderTex)
return false;
}
rtt->DepthTexture=this;
rtt->DepthBufferTexture = DepthRenderBuffer;
grab(); // grab the depth buffer, not the RTT
rtt->unbindRTT();
return true;

View File

@ -167,6 +167,7 @@ public:
virtual void unbindRTT();
ITexture* DepthTexture;
GLuint DepthBufferTexture;
protected:
GLuint ColorFrameBuffer;
};

View File

@ -214,7 +214,7 @@ public:
//! Returns type of the scene node
virtual ESCENE_NODE_TYPE getType() const { return ESNT_PARTICLE_SYSTEM; }
private:
protected:
void reallocateBuffers();

View File

@ -61,6 +61,7 @@ src/graphics/skid_marks.cpp
src/graphics/slip_stream.cpp
src/graphics/stars.cpp
src/graphics/stkanimatedmesh.cpp
src/graphics/stkbillboard.cpp
src/graphics/stkmesh.cpp
src/graphics/sun.cpp
src/graphics/water.cpp
@ -389,6 +390,7 @@ src/graphics/skid_marks.hpp
src/graphics/slip_stream.hpp
src/graphics/stars.hpp
src/graphics/stkanimatedmesh.hpp
src/graphics/stkbillboard.hpp
src/graphics/stkmesh.hpp
src/graphics/sun.hpp
src/graphics/water.hpp

View File

@ -55,8 +55,6 @@ PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
#endif
static GLuint quad_buffer;
static GLuint ColoredVertex;
static bool is_gl_init = false;
//#define ARB_DEBUG_OUTPUT
@ -185,27 +183,6 @@ void initGL()
#ifdef ARB_DEBUG_OUTPUT
glDebugMessageCallbackARB((GLDEBUGPROCARB)debugCallback, NULL);
#endif
const float quad_vertex[] = {
-1., -1., -1., 1., // UpperLeft
-1., 1., -1., -1., // LowerLeft
1., -1., 1., 1., // UpperRight
1., 1., 1., -1., // LowerRight
};
glGenBuffers(1, &quad_buffer);
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad_vertex, GL_STATIC_DRAW);
const unsigned quad_color[] = {
0, 0, 0, 255,
255, 0, 0, 255,
0, 255, 0, 255,
0, 0, 255, 255,
};
glGenBuffers(1, &ColoredVertex);
glBindBuffer(GL_ARRAY_BUFFER, ColoredVertex);
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(unsigned), quad_color, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
// Mostly from shader tutorial
@ -306,29 +283,6 @@ void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
static GLuint TexturedQuadShader;
static GLuint TexturedQuadAttribPosition;
static GLuint TexturedQuadAttribTexCoord;
static GLuint TexturedQuadUniformTex;
static GLuint TexturedQuadUniformCenter;
static GLuint TexturedQuadUniformSize;
static GLuint TexturedQuadUniformTexcenter;
static GLuint TexturedQuadUniformTexsize;
static GLuint TQvao;
static GLuint ColorTexturedQuadShader;
static GLuint ColorTexturedQuadAttribPosition;
static GLuint ColorTexturedQuadAttribTexCoord;
static GLuint ColorTexturedQuadAttribColor;
static GLuint ColorTexturedQuadUniformTex;
static GLuint ColorTexturedQuadUniformCenter;
static GLuint ColorTexturedQuadUniformSize;
static GLuint ColorTexturedQuadUniformTexcenter;
static GLuint ColorTexturedQuadUniformTexsize;
static GLuint CTQvao;
static void drawTexColoredQuad(const video::ITexture *texture, const video::SColor *col, float width, float height,
float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y,
float tex_width, float tex_height)
@ -340,42 +294,15 @@ static void drawTexColoredQuad(const video::ITexture *texture, const video::SCol
col[3].getRed(), col[3].getGreen(), col[3].getBlue(), col[3].getAlpha(),
};
if (!ColorTexturedQuadShader) {
ColorTexturedQuadShader = LoadProgram(file_manager->getAsset("shaders/colortexturedquad.vert").c_str(), file_manager->getAsset("shaders/colortexturedquad.frag").c_str());
ColorTexturedQuadAttribPosition = glGetAttribLocation(ColorTexturedQuadShader, "position");
ColorTexturedQuadAttribTexCoord = glGetAttribLocation(ColorTexturedQuadShader, "texcoord");
ColorTexturedQuadAttribColor = glGetAttribLocation(ColorTexturedQuadShader, "color");
ColorTexturedQuadUniformTex = glGetUniformLocation(ColorTexturedQuadShader, "tex");
ColorTexturedQuadUniformCenter = glGetUniformLocation(ColorTexturedQuadShader, "center");
ColorTexturedQuadUniformSize = glGetUniformLocation(ColorTexturedQuadShader, "size");
ColorTexturedQuadUniformTexcenter = glGetUniformLocation(ColorTexturedQuadShader, "texcenter");
ColorTexturedQuadUniformTexsize = glGetUniformLocation(ColorTexturedQuadShader, "texsize");
glGenVertexArrays(1, &CTQvao);
glBindVertexArray(CTQvao);
glEnableVertexAttribArray(ColorTexturedQuadAttribPosition);
glEnableVertexAttribArray(ColorTexturedQuadAttribTexCoord);
glEnableVertexAttribArray(ColorTexturedQuadAttribColor);
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
glVertexAttribPointer(ColorTexturedQuadAttribPosition, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glVertexAttribPointer(ColorTexturedQuadAttribTexCoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
glBindBuffer(GL_ARRAY_BUFFER, ColoredVertex);
glVertexAttribIPointer(ColorTexturedQuadAttribColor, 4, GL_UNSIGNED_INT, 4 * sizeof(unsigned), 0);
glBindVertexArray(0);
}
glBindBuffer(GL_ARRAY_BUFFER, ColoredVertex);
glBindBuffer(GL_ARRAY_BUFFER, UIShader::ColoredTextureRectShader::colorvbo);
glBufferSubData(GL_ARRAY_BUFFER, 0, 16 * sizeof(unsigned), colors);
glUseProgram(ColorTexturedQuadShader);
glBindVertexArray(CTQvao);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glUniform1i(ColorTexturedQuadUniformTex, 0);
glUniform2f(ColorTexturedQuadUniformCenter, center_pos_x, center_pos_y);
glUniform2f(ColorTexturedQuadUniformSize, width, height);
glUniform2f(ColorTexturedQuadUniformTexcenter, tex_center_pos_x, tex_center_pos_y);
glUniform2f(ColorTexturedQuadUniformTexsize, tex_width, tex_height);
glUseProgram(UIShader::ColoredTextureRectShader::Program);
glBindVertexArray(UIShader::ColoredTextureRectShader::vao);
setTexture(0, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR);
UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
@ -385,36 +312,12 @@ void drawTexQuad(const video::ITexture *texture, float width, float height,
float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y,
float tex_width, float tex_height)
{
if (!TexturedQuadShader) {
TexturedQuadShader = LoadProgram(file_manager->getAsset("shaders/texturedquad.vert").c_str(), file_manager->getAsset("shaders/texturedquad.frag").c_str());
glUseProgram(UIShader::TextureRectShader::Program);
glBindVertexArray(UIShader::TextureRectShader::vao);
setTexture(0, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR);
UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0);
TexturedQuadAttribPosition = glGetAttribLocation(TexturedQuadShader, "position");
TexturedQuadAttribTexCoord = glGetAttribLocation(TexturedQuadShader, "texcoord");
TexturedQuadUniformTex = glGetUniformLocation(TexturedQuadShader, "tex");
TexturedQuadUniformCenter = glGetUniformLocation(TexturedQuadShader, "center");
TexturedQuadUniformSize = glGetUniformLocation(TexturedQuadShader, "size");
TexturedQuadUniformTexcenter = glGetUniformLocation(TexturedQuadShader, "texcenter");
TexturedQuadUniformTexsize = glGetUniformLocation(TexturedQuadShader, "texsize");
glGenVertexArrays(1, &TQvao);
glBindVertexArray(TQvao);
glEnableVertexAttribArray(TexturedQuadAttribPosition);
glEnableVertexAttribArray(TexturedQuadAttribTexCoord);
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
glVertexAttribPointer(TexturedQuadAttribPosition, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glVertexAttribPointer(TexturedQuadAttribTexCoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
glBindVertexArray(0);
}
glUseProgram(TexturedQuadShader);
glBindVertexArray(TQvao);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glUniform1i(TexturedQuadUniformTex, 0);
glUniform2f(TexturedQuadUniformCenter, center_pos_x, center_pos_y);
glUniform2f(TexturedQuadUniformSize, width, height);
glUniform2f(TexturedQuadUniformTexcenter, tex_center_pos_x, tex_center_pos_y);
glUniform2f(TexturedQuadUniformTexsize, tex_width, tex_height);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
@ -470,8 +373,6 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
sourceRect.LowerRightCorner.X * invW,
sourceRect.LowerRightCorner.Y *invH);
initGL();
if (useAlphaChannelOfTexture)
{
glEnable(GL_BLEND);
@ -490,12 +391,6 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
glUseProgram(0);
}
static GLuint ColoredQuadShader;
static GLuint ColoredQuadUniformCenter;
static GLuint ColoredQuadUniformSize;
static GLuint ColoredQuadUniformColor;
static GLuint CQvao;
void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
const core::rect<s32>* clip)
{
@ -521,8 +416,6 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
float height = position.LowerRightCorner.Y - position.UpperLeftCorner.Y;
height /= screen_h;
initGL();
if (color.getAlpha() < 255)
{
glEnable(GL_BLEND);
@ -533,24 +426,10 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
glDisable(GL_BLEND);
}
if (!ColoredQuadShader)
{
ColoredQuadShader = LoadProgram(file_manager->getAsset("shaders/coloredquad.vert").c_str(), file_manager->getAsset("shaders/coloredquad.frag").c_str());
ColoredQuadUniformColor = glGetUniformLocation(ColoredQuadShader, "color");
ColoredQuadUniformCenter = glGetUniformLocation(ColoredQuadShader, "center");
ColoredQuadUniformSize = glGetUniformLocation(ColoredQuadShader, "size");
glGenVertexArrays(1, &CQvao);
glBindVertexArray(CQvao);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glBindVertexArray(0);
}
glUseProgram(ColoredQuadShader);
glBindVertexArray(CQvao);
glUniform2f(ColoredQuadUniformCenter, center_pos_x, center_pos_y);
glUniform2f(ColoredQuadUniformSize, width, height);
glUniform4i(ColoredQuadUniformColor, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
glUseProgram(UIShader::ColoredRectShader::Program);
glBindVertexArray(UIShader::ColoredRectShader::vao);
UIShader::ColoredRectShader::setUniforms(center_pos_x, center_pos_y, width, height, color);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);

View File

@ -415,9 +415,6 @@ void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter)
return;
has_height_map = false;
flip = false;
// Pass a fake material type to force irrlicht to update its internal states on rendering
setMaterialType(irr_driver->getShader(ES_RAIN));
setAutomaticCulling(0);
count = emitter->getMaxParticlesPerSecond() * emitter->getMaxLifeTime() / 1000;
switch (emitter->getType())
@ -454,7 +451,6 @@ void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter)
glBindVertexArray(0);
texture = getTextureGLuint(getMaterial(0).getTexture(0));
normal_and_depth = getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
}
void ParticleSystemProxy::simulateHeightmap()
@ -528,14 +524,7 @@ void ParticleSystemProxy::simulate()
void ParticleSystemProxy::drawFlip()
{
glDepthMask(GL_FALSE);
glDisable(GL_CULL_FACE);
glEnable(GL_BLEND);
if (m_alpha_additive)
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glUseProgram(ParticleShader::FlipParticleRender::Program);
float screen[2] = {
@ -543,27 +532,17 @@ void ParticleSystemProxy::drawFlip()
(float)UserConfigParams::m_height
};
setTexture(0, texture, GL_LINEAR, GL_LINEAR);
setTexture(1, normal_and_depth, GL_NEAREST, GL_NEAREST);
setTexture(0, texture, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
setTexture(1, static_cast<video::COpenGLFBOTexture *>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST);
ParticleShader::FlipParticleRender::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), irr_driver->getInvProjMatrix(), screen[0], screen[1], 0, 1);
glBindVertexArray(current_rendering_flip_vao);
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glActiveTexture(GL_TEXTURE0);
glDisable(GL_BLEND);
}
void ParticleSystemProxy::drawNotFlip()
{
glDepthMask(GL_FALSE);
glDisable(GL_CULL_FACE);
glEnable(GL_BLEND);
if (m_alpha_additive)
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else
@ -575,19 +554,13 @@ void ParticleSystemProxy::drawNotFlip()
(float)UserConfigParams::m_height
};
setTexture(0, texture, GL_LINEAR, GL_LINEAR);
setTexture(1, normal_and_depth, GL_NEAREST, GL_NEAREST);
setTexture(0, texture, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
setTexture(1, static_cast<video::COpenGLFBOTexture *>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST);
ParticleShader::SimpleParticleRender::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), irr_driver->getInvProjMatrix(), screen[0], screen[1], 0, 1);
glBindVertexArray(current_rendering_vao);
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glActiveTexture(GL_TEXTURE0);
glDisable(GL_BLEND);
}
void ParticleSystemProxy::draw()
@ -606,10 +579,17 @@ void ParticleSystemProxy::render() {
}
simulate();
draw();
// We need to force irrlicht to update its internal states
irr::video::IVideoDriver * const drv = irr_driver->getVideoDriver();
drv->setMaterial(fakemat);
static_cast<irr::video::COpenGLDriver*>(drv)->setRenderStates3DMode();
}
void ParticleSystemProxy::OnRegisterSceneNode()
{
doParticleSystem(os::Timer::getTime());
if (IsVisible && (Particles.size() != 0))
{
SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT_EFFECT);
ISceneNode::OnRegisterSceneNode();
}
}
RainNode::RainNode(scene::ISceneManager* mgr, ITexture *tex)

View File

@ -37,7 +37,7 @@ protected:
static GLuint quad_vertex_buffer;
GLuint texture, normal_and_depth;
GLuint texture;
unsigned count;
static void SimpleParticleVAOBind(GLuint PositionBuffer);
static void FlipParticleVAOBind(GLuint PositionBuffer, GLuint QuaternionBuffer);
@ -69,6 +69,7 @@ public:
virtual void setEmitter(scene::IParticleEmitter* emitter);
virtual void render();
virtual void OnRegisterSceneNode();
void setAlphaAdditive(bool);
void setIncreaseFactor(float);
void setHeightmap(const std::vector<std::vector<float> >&, float, float, float, float);

View File

@ -33,6 +33,7 @@
#include "graphics/shaders.hpp"
#include "graphics/shadow_importance.hpp"
#include "graphics/stkanimatedmesh.hpp"
#include "graphics/stkbillboard.hpp"
#include "graphics/stkmesh.hpp"
#include "graphics/sun.hpp"
#include "graphics/rtts.hpp"
@ -141,16 +142,21 @@ void IrrDriver::reset()
if (m_glsl) m_post_processing->reset();
} // reset
void IrrDriver::setPhase(unsigned p)
void IrrDriver::setPhase(STKRenderingPass p)
{
phase = p;
}
unsigned IrrDriver::getPhase() const
STKRenderingPass IrrDriver::getPhase() const
{
return phase;
}
void IrrDriver::IncreaseObjectCount()
{
object_count[phase]++;
}
core::array<video::IRenderTarget> &IrrDriver::getMainSetup()
{
return m_mrt;
@ -651,8 +657,8 @@ void IrrDriver::applyResolutionSettings()
attachment_manager->removeTextures();
projectile_manager->removeTextures();
ItemManager::removeTextures();
kart_properties_manager -> unloadAllKarts();
powerup_manager-> unloadPowerups();
kart_properties_manager->unloadAllKarts();
powerup_manager->unloadPowerups();
Referee::cleanup();
ParticleKindManager::get()->cleanup();
delete input_manager;
@ -704,7 +710,6 @@ void IrrDriver::applyResolutionSettings()
file_manager->popTextureSearchPath();
KartPropertiesManager::addKartSearchDir(file_manager->getAddonsFile("karts"));
kart_properties_manager->loadAllKarts();
attachment_manager->loadModels();
@ -968,8 +973,17 @@ scene::ISceneNode *IrrDriver::addBillboard(const core::dimension2d< f32 > size,
video::ITexture *texture,
scene::ISceneNode* parent, bool alphaTesting)
{
scene::IBillboardSceneNode* node =
m_scene_manager->addBillboardSceneNode(parent, size);
scene::IBillboardSceneNode* node;
if (isGLSL())
{
if (!parent)
parent = m_scene_manager->getRootSceneNode();
node = new STKBillboard(parent, m_scene_manager, -1, vector3df(0., 0., 0.), size);
node->drop();
}
else
node = m_scene_manager->addBillboardSceneNode(parent, size);
assert(node->getMaterialCount() > 0);
node->setMaterialTexture(0, texture);
if(alphaTesting)
@ -1145,6 +1159,7 @@ scene::ISceneNode *IrrDriver::addSkyDome(video::ITexture *texture,
float texture_percent,
float sphere_percent)
{
Log::error("skybox", "Using deprecated SkyDome");
return m_scene_manager->addSkyDomeSceneNode(texture, hori_res, vert_res,
texture_percent,
sphere_percent);
@ -1164,11 +1179,17 @@ scene::ISceneNode *IrrDriver::addSkyDome(video::ITexture *texture,
scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*>
&texture)
{
SkyboxTextures = texture;
return m_scene_manager->addSkyBoxSceneNode(texture[0], texture[1],
texture[2], texture[3],
texture[4], texture[5]);
} // addSkyBox
void IrrDriver::suppressSkyBox()
{
SkyboxTextures.clear();
}
// ----------------------------------------------------------------------------
/** Adds a camera to the scene.
*/
@ -1493,12 +1514,13 @@ void IrrDriver::displayFPS()
if (low > kilotris) low = kilotris;
if (high < kilotris) high = kilotris;
static char buffer[64];
static char buffer[128];
if (UserConfigParams::m_artist_debug_mode)
{
sprintf(buffer, "FPS: %i/%i/%i - %.2f/%.2f/%.2f KTris - LightDst : ~%d",
min, fps, max, low, kilotris, high, m_last_light_bucket_distance);
sprintf(buffer, "FPS: %i/%i/%i - Objects (P1:%d P2:%d T:%d) KTris - LightDst : ~%d",
min, fps, max, object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[TRANSPARENT_PASS], m_last_light_bucket_distance);
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = object_count[SOLID_NORMAL_AND_DEPTH_PASS] = object_count[TRANSPARENT_PASS] = 0;
}
else
{

View File

@ -63,6 +63,17 @@ class PostProcessing;
class LightNode;
class ShadowImportance;
enum STKRenderingPass
{
SOLID_NORMAL_AND_DEPTH_PASS,
SOLID_LIT_PASS,
TRANSPARENT_PASS,
GLOW_PASS,
DISPLACEMENT_PASS,
SHADOW_PASS,
PASS_COUNT,
};
/**
* \brief class that creates the irrLicht device and offers higher-level
* ways to manage the 3D scene
@ -102,6 +113,8 @@ private:
/** Matrixes used in several places stored here to avoid recomputation. */
core::matrix4 m_ViewMatrix, m_ProjMatrix, m_InvProjMatrix, m_ProjViewMatrix, m_InvProjViewMatrix;
std::vector<video::ITexture *> SkyboxTextures;
/** Flag to indicate if a resolution change is pending (which will be
* acted upon in the next update). None means no change, yes means
* change to new resolution and trigger confirmation dialog.
@ -152,7 +165,9 @@ private:
bool m_shadowviz;
bool m_lightviz;
bool m_distortviz;
/** Performance stats */
unsigned m_last_light_bucket_distance;
unsigned object_count[PASS_COUNT];
u32 m_renderpass;
u32 m_lensflare_query;
scene::IMeshSceneNode *m_sun_interposer;
@ -174,7 +189,7 @@ private:
std::vector<scene::ISceneNode *> m_background;
unsigned phase;
STKRenderingPass phase;
#ifdef DEBUG
/** Used to visualise skeletons. */
@ -196,6 +211,7 @@ private:
std::vector<GlowData>& glows,
const core::aabbox3df& cambox,
int cam);
void renderSkybox();
void renderLights(const core::aabbox3df& cambox,
scene::ICameraSceneNode * const camnode,
video::SOverrideMaterial &overridemat,
@ -208,8 +224,9 @@ public:
~IrrDriver();
void initDevice();
void reset();
void setPhase(unsigned);
unsigned getPhase() const;
void setPhase(STKRenderingPass);
STKRenderingPass getPhase() const;
void IncreaseObjectCount();
core::array<video::IRenderTarget> &getMainSetup();
void updateConfigIfRelevant();
void setAllMaterialFlags(scene::IMesh *mesh) const;
@ -259,6 +276,7 @@ public:
int vert_res, float texture_percent,
float sphere_percent);
scene::ISceneNode *addSkyBox(const std::vector<video::ITexture*> &texture_names);
void suppressSkyBox();
void removeNode(scene::ISceneNode *node);
void removeMeshFromCache(scene::IMesh *mesh);
void removeTexture(video::ITexture *t);

View File

@ -653,18 +653,14 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
}
if (!m_lighting && irr_driver->isGLSL() && !m_alpha_blending && !m_add)
{
// we abuse alpha blender a little here : in the shader-based pipeline,
// transparent objects are rendered after lighting has been applied.
// Therefore, pretending the object is transparent will have the effect
// of making it unaffected by lights
m_alpha_blending = true;
m_disable_z_write = false;
}
int modes = 0;
if (!m_lighting && irr_driver->isGLSL() && !m_alpha_blending && !m_add)
{
m->MaterialType = irr_driver->getShader(ES_OBJECT_UNLIT);
modes++;
}
if (m_alpha_testing)
{
m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;

View File

@ -164,12 +164,16 @@ ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,2
{
size->get("min", &m_min_size);
size->get("max", &m_max_size);
bool has_x = size->get("x-increase-factor", &m_scale_affector_factor_x) == 1;
bool has_y = size->get("y-increase-factor", &m_scale_affector_factor_y) == 1;
m_has_scale_affector = (has_x || has_y);
}
bool has_x = size->get("x-increase-factor", &m_scale_affector_factor_x)==1;
bool has_y = size->get("y-increase-factor", &m_scale_affector_factor_y)==1;
m_has_scale_affector = (has_x || has_y);
else
{
m_has_scale_affector = false;
}
//std::cout << "m_particle_size = " << m_particle_size << "\n";
//std::cout << "m_min_size = " << m_min_size << "\n";
//std::cout << "m_max_size = " << m_max_size << "\n";

View File

@ -302,7 +302,7 @@ void renderColorLevel(ITexture *in)
glEnable(GL_DEPTH_TEST);
}
void PostProcessing::renderPointlight(ITexture *in, const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy)
void PostProcessing::renderPointlight(const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy)
{
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
@ -312,18 +312,9 @@ void PostProcessing::renderPointlight(ITexture *in, const std::vector<float> &po
glUseProgram(FullScreenShader::PointLightShader::Program);
glBindVertexArray(FullScreenShader::PointLightShader::vao);
glUniform4fv(FullScreenShader::PointLightShader::uniform_center, 16, positions.data());
glUniform4fv(FullScreenShader::PointLightShader::uniform_col, 16, colors.data());
glUniform1fv(FullScreenShader::PointLightShader::uniform_energy, 16, energy.data());
glUniform1f(FullScreenShader::PointLightShader::uniform_spec, 200);
glUniformMatrix4fv(FullScreenShader::PointLightShader::uniform_invproj, 1, GL_FALSE, irr_driver->getInvProjMatrix().pointer());
glUniformMatrix4fv(FullScreenShader::PointLightShader::uniform_viewm, 1, GL_FALSE, irr_driver->getViewMatrix().pointer());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(in)->getOpenGLTextureName());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glUniform1i(FullScreenShader::PointLightShader::uniform_ntex, 0);
setTexture(0, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(1, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST);
FullScreenShader::PointLightShader::setUniforms(irr_driver->getInvProjMatrix(), irr_driver->getViewMatrix(), positions, colors, energy, 200, 0, 1);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
@ -344,9 +335,9 @@ void PostProcessing::renderSunlight()
glUseProgram(FullScreenShader::SunLightShader::Program);
glBindVertexArray(FullScreenShader::SunLightShader::vao);
GLuint ntex_id = static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->getOpenGLTextureName();
setTexture(0, ntex_id, GL_NEAREST, GL_NEAREST);
FullScreenShader::SunLightShader::setUniforms(cb->getPosition(), irr_driver->getInvProjMatrix(), cb->getRed(), cb->getGreen(), cb->getBlue(), 0);
setTexture(0, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(1, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST);
FullScreenShader::SunLightShader::setUniforms(cb->getPosition(), irr_driver->getInvProjMatrix(), cb->getRed(), cb->getGreen(), cb->getBlue(), 0, 1);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
}
@ -531,30 +522,18 @@ void PostProcessing::renderSSAO(const core::matrix4 &invprojm, const core::matri
{
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
if (!noise_tex)
noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/noise.png").c_str());
glUseProgram(FullScreenShader::SSAOShader::Program);
glBindVertexArray(FullScreenShader::SSAOShader::vao);
glUniformMatrix4fv(FullScreenShader::SSAOShader::uniform_invprojm, 1, GL_FALSE, invprojm.pointer());
glUniformMatrix4fv(FullScreenShader::SSAOShader::uniform_projm, 1, GL_FALSE, projm.pointer());
glUniform4fv(FullScreenShader::SSAOShader::uniform_samplePoints, 16, FullScreenShader::SSAOShader::SSAOSamples);
setTexture(0, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(1, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_LINEAR, GL_LINEAR);
setTexture(2, static_cast<irr::video::COpenGLTexture*>(noise_tex)->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->getOpenGLTextureName());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glUniform1i(FullScreenShader::SSAOShader::uniform_normals_and_depth, 0);
if (!noise_tex)
noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/tarmac.jpg").c_str());
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(noise_tex)->getOpenGLTextureName());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glUniform1i(FullScreenShader::SSAOShader::uniform_noise_texture, 1);
FullScreenShader::SSAOShader::setUniforms(projm, invprojm, 0, 1, 2);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
@ -576,9 +555,9 @@ void PostProcessing::renderFog(const core::vector3df &campos, const core::matrix
const float end = track->getFogEnd();
const SColor tmpcol = track->getFogColor();
const float col[3] = { tmpcol.getRed() / 255.0f,
core::vector3df col( tmpcol.getRed() / 255.0f,
tmpcol.getGreen() / 255.0f,
tmpcol.getBlue() / 255.0f };
tmpcol.getBlue() / 255.0f );
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
@ -588,17 +567,8 @@ void PostProcessing::renderFog(const core::vector3df &campos, const core::matrix
glUseProgram(FullScreenShader::FogShader::Program);
glBindVertexArray(FullScreenShader::FogShader::vao);
glUniform1f(FullScreenShader::FogShader::uniform_fogmax, fogmax);
glUniform1f(FullScreenShader::FogShader::uniform_startH, startH);
glUniform1f(FullScreenShader::FogShader::uniform_endH, endH);
glUniform1f(FullScreenShader::FogShader::uniform_start, start);
glUniform1f(FullScreenShader::FogShader::uniform_end, end);
glUniform3f(FullScreenShader::FogShader::uniform_col, col[0], col[1], col[2]);
glUniform3f(FullScreenShader::FogShader::uniform_campos, campos.X, campos.Y, campos.Z);
glUniformMatrix4fv(FullScreenShader::FogShader::uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->getOpenGLTextureName());
glUniform1i(FullScreenShader::FogShader::uniform_tex, 0);
setTexture(0, static_cast<irr::video::COpenGLFBOTexture*>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST);
FullScreenShader::FogShader::setUniforms(ipvmat, fogmax, startH, endH, start, end, col, campos, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);

View File

@ -73,7 +73,7 @@ public:
void update(float dt);
/** Generate diffuse and specular map */
void renderPointlight(video::ITexture *in, const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy);
void renderPointlight(const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy);
void renderSunlight();
/** Blend all light related map */
void renderLightbBlend(video::ITexture *diffuse, video::ITexture *specular, video::ITexture *ao, video::ITexture *specmap, bool debug);

View File

@ -165,7 +165,7 @@ void IrrDriver::renderGLSL(float dt)
rg->preRenderCallback(camera); // adjusts start referee
const u32 bgnodes = m_background.size();
if (bgnodes)
/* if (bgnodes)
{
// If there are background nodes (3d skybox), draw them now.
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false);
@ -187,14 +187,18 @@ void IrrDriver::renderGLSL(float dt)
overridemat = prev;
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, true);
}
}*/
// Fire up the MRT
m_video_driver->setRenderTarget(m_mrt, false, false);
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
irr_driver->setPhase(0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS);
m_scene_manager->drawAll(m_renderpass);
irr_driver->setProjMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION));
irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW));
@ -225,7 +229,11 @@ void IrrDriver::renderGLSL(float dt)
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("- Solid Pass 2", 0x00, 0x00, 0xFF);
irr_driver->setPhase(1);
irr_driver->setPhase(SOLID_LIT_PASS);
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_BLEND);
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
m_scene_manager->drawAll(m_renderpass);
@ -243,22 +251,18 @@ void IrrDriver::renderGLSL(float dt)
// Render anything glowing.
if (!m_mipviz && !m_wireframe)
{
irr_driver->setPhase(2);
irr_driver->setPhase(GLOW_PASS);
renderGlow(overridemat, glows, cambox, cam);
} // end glow
PROFILER_POP_CPU_MARKER();
if (!bgnodes)
{
PROFILER_PUSH_CPU_MARKER("- Skybox", 0xFF, 0x00, 0xFF);
// If there are no BG nodes, it's more efficient to do the skybox here.
m_renderpass = scene::ESNRP_SKY_BOX;
m_scene_manager->drawAll(m_renderpass);
PROFILER_POP_CPU_MARKER();
}
if (!SkyboxTextures.empty())
{
PROFILER_PUSH_CPU_MARKER("- Skybox", 0xFF, 0x00, 0xFF);
renderSkybox();
PROFILER_POP_CPU_MARKER();
}
PROFILER_PUSH_CPU_MARKER("- Lensflare/godray", 0x00, 0xFF, 0xFF);
// Is the lens flare enabled & visible? Check last frame's query.
@ -289,16 +293,26 @@ void IrrDriver::renderGLSL(float dt)
}
PROFILER_POP_CPU_MARKER();
// We need to re-render camera due to the per-cam-node hack.
PROFILER_PUSH_CPU_MARKER("- Transparent Pass", 0xFF, 0x00, 0x00);
irr_driver->setPhase(3);
irr_driver->setPhase(TRANSPARENT_PASS);
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT;
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_CULL_FACE);
m_scene_manager->drawAll(m_renderpass);
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("- Particles", 0xFF, 0xFF, 0x00);
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT_EFFECT;
glDepthMask(GL_FALSE);
glDisable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
m_scene_manager->drawAll(m_renderpass);
PROFILER_POP_CPU_MARKER();
@ -351,8 +365,10 @@ void IrrDriver::renderGLSL(float dt)
PROFILER_POP_CPU_MARKER();
} // for i<getNumKarts
PROFILER_PUSH_CPU_MARKER("GUIEngine", 0x75, 0x75, 0x75);
// Either render the gui, or the global elements of the race gui.
GUIEngine::render(dt);
PROFILER_POP_CPU_MARKER();
// Render the profiler
if(UserConfigParams::m_profiler_enabled)
@ -365,7 +381,9 @@ void IrrDriver::renderGLSL(float dt)
drawDebugMeshes();
#endif
PROFILER_PUSH_CPU_MARKER("EndSccene", 0x45, 0x75, 0x45);
m_video_driver->endScene();
PROFILER_POP_CPU_MARKER();
getPostProcessing()->update(dt);
}
@ -635,6 +653,11 @@ void IrrDriver::renderGlow(video::SOverrideMaterial &overridemat,
glStencilFunc(GL_ALWAYS, 1, ~0);
glEnable(GL_STENCIL_TEST);
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_BLEND);
for (u32 i = 0; i < glowcount; i++)
{
const GlowData &dat = glows[i];
@ -793,7 +816,7 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
accumulatedLightColor.push_back(0.);
accumulatedLightEnergy.push_back(0.);
}
m_post_processing->renderPointlight(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH) , accumulatedLightPos, accumulatedLightColor, accumulatedLightEnergy);
m_post_processing->renderPointlight(accumulatedLightPos, accumulatedLightColor, accumulatedLightEnergy);
// Handle SSAO
m_video_driver->setRenderTarget(irr_driver->getRTT(RTT_SSAO), true, false,
SColor(255, 255, 255, 255));
@ -810,6 +833,105 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false);
}
static GLuint cubevao = 0;
static GLuint cubevbo;
static GLuint cubeidx;
static void createcubevao()
{
// From CSkyBoxSceneNode. Not optimal at all
float corners[] =
{
// top side
1., 1., -1., 1., 1.,
1., 1., 1., 0., 1.,
-1., 1., 1., 0., 0.,
-1., 1., -1., 1., 0.,
// Bottom side
1., -1., 1., 0., 0.,
1., -1., -1., 1., 0.,
-1., -1., -1., 1., 1.,
-1., -1., 1., 0., 1.,
// right side
1., -1, -1, 1., 1.,
1., -1, 1, 0., 1.,
1., 1., 1., 0., 0.,
1., 1., -1., 1., 0.,
// left side
-1., -1., 1., 1., 1.,
-1., -1., -1., 0., 1.,
-1., 1., -1., 0., 0.,
-1., 1., 1., 1., 0.,
// back side
-1., -1., -1., 1., 1.,
1., -1, -1., 0., 1.,
1, 1, -1., 0., 0.,
-1, 1, -1., 1., 0.,
// front side
1., -1., 1., 1., 1.,
-1., -1., 1., 0., 1.,
-1, 1., 1., 0., 0.,
1., 1., 1., 1., 0.,
};
int indices[] = {
0, 1, 2, 2, 3, 0,
4, 5, 6, 6, 7, 4,
8, 9, 10, 10, 11, 8,
12, 13, 14, 14, 15, 12,
16, 17, 18, 18, 19, 16,
20, 21, 22, 22, 23, 20
};
glGenBuffers(1, &cubevbo);
glGenBuffers(1, &cubeidx);
glGenVertexArrays(1, &cubevao);
glBindVertexArray(cubevao);
glBindBuffer(GL_ARRAY_BUFFER, cubevbo);
glBufferData(GL_ARRAY_BUFFER, 6 * 5 * 4 * sizeof(float), corners, GL_STATIC_DRAW);
glEnableVertexAttribArray(MeshShader::ObjectUnlitShader::attrib_position);
glEnableVertexAttribArray(MeshShader::ObjectUnlitShader::attrib_texcoord);
glVertexAttribPointer(MeshShader::ObjectUnlitShader::attrib_position, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), 0);
glVertexAttribPointer(MeshShader::ObjectUnlitShader::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (GLvoid *)(3 * sizeof(float)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cubeidx);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6 * 6 * sizeof(int), indices, GL_STATIC_DRAW);
}
void IrrDriver::renderSkybox()
{
scene::ICameraSceneNode *camera = m_scene_manager->getActiveCamera();
if (!cubevao)
createcubevao();
glBindVertexArray(cubevao);
glDisable(GL_CULL_FACE);
assert(SkyboxTextures.size() == 6);
core::matrix4 transform = irr_driver->getProjViewMatrix();
core::matrix4 translate;
translate.setTranslation(camera->getAbsolutePosition());
// Draw the sky box between the near and far clip plane
const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f;
core::matrix4 scale;
scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance));
transform *= translate * scale;
for (unsigned i = 0; i < 6; i++)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(SkyboxTextures[i])->getOpenGLTextureName());
glUseProgram(MeshShader::ObjectUnlitShader::Program);
MeshShader::ObjectUnlitShader::setUniforms(transform, 0);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, (GLvoid*) (6 * i * sizeof(int)));
}
glBindVertexArray(0);
}
// ----------------------------------------------------------------------------
void IrrDriver::renderDisplacement(video::SOverrideMaterial &overridemat,
@ -835,7 +957,12 @@ void IrrDriver::renderDisplacement(video::SOverrideMaterial &overridemat,
cb->update();
const int displacingcount = m_displacing.size();
irr_driver->setPhase(4);
irr_driver->setPhase(DISPLACEMENT_PASS);
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_BLEND);
for (int i = 0; i < displacingcount; i++)
{

View File

@ -67,7 +67,7 @@ RTT::RTT()
rtts[RTT_TMP2] = drv->addRenderTargetTexture(res, "rtt.tmp2", ECF_A8R8G8B8, stencil);
rtts[RTT_TMP3] = drv->addRenderTargetTexture(res, "rtt.tmp3", ECF_A8R8G8B8, stencil);
rtts[RTT_TMP4] = drv->addRenderTargetTexture(res, "rtt.tmp4", ECF_R8, stencil);
rtts[RTT_NORMAL_AND_DEPTH] = drv->addRenderTargetTexture(res, "rtt.normal_and_depth", ECF_A32B32G32R32F, stencil);
rtts[RTT_NORMAL_AND_DEPTH] = drv->addRenderTargetTexture(res, "rtt.normal_and_depth", ECF_G16R16F, stencil);
rtts[RTT_COLOR] = drv->addRenderTargetTexture(res, "rtt.color", ECF_A16B16G16R16F, stencil);
rtts[RTT_SPECULARMAP] = drv->addRenderTargetTexture(res, "rtt.specularmap", ECF_R8, stencil);

View File

@ -61,11 +61,10 @@ Shaders::Shaders()
loadShaders();
}
GLuint quad_vbo = 0;
GLuint quad_vbo;
static void initQuadVBO()
{
initGL();
const float quad_vertex[] = {
-1., -1., 0., 0., // UpperLeft
-1., 1., 0., 1., // LowerLeft
@ -78,6 +77,22 @@ static void initQuadVBO()
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
// It should be possible to merge it with previous one...
GLuint quad_buffer;
static void initQuadBuffer()
{
const float quad_vertex[] = {
-1., -1., -1., 1., // UpperLeft
-1., 1., -1., -1., // LowerLeft
1., -1., 1., 1., // UpperRight
1., 1., 1., -1., // LowerRight
};
glGenBuffers(1, &quad_buffer);
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad_vertex, GL_STATIC_DRAW);
}
void Shaders::loadShaders()
{
const std::string &dir = file_manager->getAsset(FileManager::SHADER, "");
@ -145,6 +160,8 @@ void Shaders::loadShaders()
m_shaders[ES_OBJECTPASS] = glslmat(dir + "objectpass.vert", dir + "objectpass.frag",
m_callbacks[ES_OBJECTPASS], EMT_SOLID);
m_shaders[ES_OBJECT_UNLIT] = glslmat(dir + "objectpass.vert", dir + "objectpass.frag",
m_callbacks[ES_OBJECTPASS], EMT_SOLID);
m_shaders[ES_OBJECTPASS_REF] = glslmat(dir + "objectpass.vert", dir + "objectpass_ref.frag",
m_callbacks[ES_OBJECTPASS], EMT_SOLID);
m_shaders[ES_OBJECTPASS_RIMLIT] = glslmat(dir + "objectpass_rimlit.vert", dir + "objectpass_rimlit.frag",
@ -222,6 +239,7 @@ void Shaders::loadShaders()
initGL();
initQuadVBO();
initQuadBuffer();
FullScreenShader::BloomBlendShader::init();
FullScreenShader::BloomShader::init();
FullScreenShader::ColorLevelShader::init();
@ -242,20 +260,26 @@ void Shaders::loadShaders()
MeshShader::ObjectPass1Shader::init();
MeshShader::ObjectRefPass1Shader::init();
MeshShader::ObjectPass2Shader::init();
MeshShader::DetailledObjectPass2Shader::init();
MeshShader::ObjectRimLimitShader::init();
MeshShader::UntexturedObjectShader::init();
MeshShader::ObjectRefPass2Shader::init();
MeshShader::ObjectUnlitShader::init();
MeshShader::SphereMapShader::init();
MeshShader::SplattingShader::init();
MeshShader::GrassPass1Shader::init();
MeshShader::GrassPass2Shader::init();
MeshShader::BubbleShader::init();
MeshShader::TransparentShader::init();
MeshShader::BillboardShader::init();
MeshShader::DisplaceShader::init();
ParticleShader::FlipParticleRender::init();
ParticleShader::HeightmapSimulationShader::init();
ParticleShader::SimpleParticleRender::init();
ParticleShader::SimpleSimulationShader::init();
UIShader::ColoredRectShader::init();
UIShader::ColoredTextureRectShader::init();
UIShader::TextureRectShader::init();
}
Shaders::~Shaders()
@ -370,6 +394,69 @@ namespace MeshShader
glUniform3f(uniform_ambient, s.r, s.g, s.b);
}
GLuint DetailledObjectPass2Shader::Program;
GLuint DetailledObjectPass2Shader::attrib_position;
GLuint DetailledObjectPass2Shader::attrib_texcoord;
GLuint DetailledObjectPass2Shader::attrib_second_texcoord;
GLuint DetailledObjectPass2Shader::uniform_MVP;
GLuint DetailledObjectPass2Shader::uniform_Albedo;
GLuint DetailledObjectPass2Shader::uniform_Detail;
GLuint DetailledObjectPass2Shader::uniform_DiffuseMap;
GLuint DetailledObjectPass2Shader::uniform_SpecularMap;
GLuint DetailledObjectPass2Shader::uniform_SSAO;
GLuint DetailledObjectPass2Shader::uniform_screen;
GLuint DetailledObjectPass2Shader::uniform_ambient;
void DetailledObjectPass2Shader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/object_pass2.vert").c_str(), 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_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_Albedo = glGetUniformLocation(Program, "Albedo");
uniform_Detail = glGetUniformLocation(Program, "Detail");
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
}
void DetailledObjectPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_Albedo, unsigned TU_detail, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
{
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniform1i(uniform_Albedo, TU_Albedo);
glUniform1i(uniform_Detail, TU_detail);
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
glUniform1i(uniform_SpecularMap, TU_SpecularMap);
glUniform1i(uniform_SSAO, TU_SSAO);
glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height);
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
}
GLuint ObjectUnlitShader::Program;
GLuint ObjectUnlitShader::attrib_position;
GLuint ObjectUnlitShader::attrib_texcoord;
GLuint ObjectUnlitShader::uniform_MVP;
GLuint ObjectUnlitShader::uniform_tex;
void ObjectUnlitShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/object_pass2.vert").c_str(), 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");
}
void ObjectUnlitShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex)
{
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniform1i(uniform_tex, TU_tex);
}
GLuint ObjectRimLimitShader::Program;
GLuint ObjectRimLimitShader::attrib_position;
GLuint ObjectRimLimitShader::attrib_texcoord;
@ -707,6 +794,37 @@ namespace MeshShader
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniform1i(uniform_tex, TU_tex);
}
GLuint BillboardShader::Program;
GLuint BillboardShader::attrib_corner;
GLuint BillboardShader::attrib_texcoord;
GLuint BillboardShader::uniform_MV;
GLuint BillboardShader::uniform_P;
GLuint BillboardShader::uniform_tex;
GLuint BillboardShader::uniform_Position;
GLuint BillboardShader::uniform_Size;
void BillboardShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/billboard.vert").c_str(), file_manager->getAsset("shaders/billboard.frag").c_str());
attrib_corner = glGetAttribLocation(Program, "Corner");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MV = glGetUniformLocation(Program, "ModelViewMatrix");
uniform_P = glGetUniformLocation(Program, "ProjectionMatrix");
uniform_Position = glGetUniformLocation(Program, "Position");
uniform_Size = glGetUniformLocation(Program, "Size");
uniform_tex = glGetUniformLocation(Program, "tex");
printf("TUTex is %d, Texcoord is %d\n", uniform_tex, attrib_texcoord);
}
void BillboardShader::setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d<float> &size, unsigned TU_tex)
{
glUniformMatrix4fv(uniform_MV, 1, GL_FALSE, ModelViewMatrix.pointer());
glUniformMatrix4fv(uniform_P, 1, GL_FALSE, ProjectionMatrix.pointer());
glUniform3f(uniform_Position, Position.X, Position.Y, Position.Z);
glUniform2f(uniform_Size, size.Width, size.Height);
glUniform1i(uniform_tex, TU_tex);
}
GLuint ColorizeShader::Program;
GLuint ColorizeShader::attrib_position;
@ -861,7 +979,7 @@ namespace ParticleShader
GLuint SimpleParticleRender::uniform_matrix;
GLuint SimpleParticleRender::uniform_viewmatrix;
GLuint SimpleParticleRender::uniform_tex;
GLuint SimpleParticleRender::uniform_normal_and_depths;
GLuint SimpleParticleRender::uniform_dtex;
GLuint SimpleParticleRender::uniform_screen;
GLuint SimpleParticleRender::uniform_invproj;
@ -880,17 +998,17 @@ namespace ParticleShader
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_invproj = glGetUniformLocation(Program, "invproj");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_normal_and_depths = glGetUniformLocation(Program, "normals_and_depth");
uniform_dtex = glGetUniformLocation(Program, "dtex");
}
void SimpleParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth)
void SimpleParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex)
{
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
glUniform2f(uniform_screen, width, height);
glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer());
glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer());
glUniform1i(uniform_tex, TU_tex);
glUniform1i(uniform_normal_and_depths, TU_normal_and_depth);
glUniform1i(uniform_dtex, TU_dtex);
}
GLuint FlipParticleRender::Program;
@ -904,7 +1022,7 @@ namespace ParticleShader
GLuint FlipParticleRender::uniform_matrix;
GLuint FlipParticleRender::uniform_viewmatrix;
GLuint FlipParticleRender::uniform_tex;
GLuint FlipParticleRender::uniform_normal_and_depths;
GLuint FlipParticleRender::uniform_dtex;
GLuint FlipParticleRender::uniform_screen;
GLuint FlipParticleRender::uniform_invproj;
@ -924,17 +1042,17 @@ namespace ParticleShader
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_invproj = glGetUniformLocation(Program, "invproj");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_normal_and_depths = glGetUniformLocation(Program, "normals_and_depth");
uniform_dtex = glGetUniformLocation(Program, "dtex");
}
void FlipParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth)
void FlipParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex)
{
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
glUniform2f(uniform_screen, width, height);
glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer());
glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer());
glUniform1i(uniform_tex, TU_tex);
glUniform1i(uniform_normal_and_depths, TU_normal_and_depth);
glUniform1i(uniform_dtex, TU_dtex);
}
}
@ -1009,6 +1127,7 @@ namespace FullScreenShader
GLuint PointLightShader::Program;
GLuint PointLightShader::uniform_ntex;
GLuint PointLightShader::uniform_dtex;
GLuint PointLightShader::uniform_center;
GLuint PointLightShader::uniform_col;
GLuint PointLightShader::uniform_energy;
@ -1016,10 +1135,12 @@ namespace FullScreenShader
GLuint PointLightShader::uniform_invproj;
GLuint PointLightShader::uniform_viewm;
GLuint PointLightShader::vao;
void PointLightShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/pointlight.frag").c_str());
uniform_ntex = glGetUniformLocation(Program, "ntex");
uniform_dtex = glGetUniformLocation(Program, "dtex");
uniform_center = glGetUniformLocation(Program, "center[0]");
uniform_col = glGetUniformLocation(Program, "col[0]");
uniform_energy = glGetUniformLocation(Program, "energy[0]");
@ -1029,8 +1150,22 @@ namespace FullScreenShader
vao = createVAO(Program);
}
void PointLightShader::setUniforms(const core::matrix4 &InvProjMatrix, const core::matrix4 &ViewMatrix, const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy, unsigned spec, unsigned TU_ntex, unsigned TU_dtex)
{
glUniform4fv(FullScreenShader::PointLightShader::uniform_center, 16, positions.data());
glUniform4fv(FullScreenShader::PointLightShader::uniform_col, 16, colors.data());
glUniform1fv(FullScreenShader::PointLightShader::uniform_energy, 16, energy.data());
glUniform1f(FullScreenShader::PointLightShader::uniform_spec, 200);
glUniformMatrix4fv(FullScreenShader::PointLightShader::uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
glUniformMatrix4fv(FullScreenShader::PointLightShader::uniform_viewm, 1, GL_FALSE, ViewMatrix.pointer());
glUniform1i(FullScreenShader::PointLightShader::uniform_ntex, TU_ntex);
glUniform1i(FullScreenShader::PointLightShader::uniform_dtex, TU_dtex);
}
GLuint SunLightShader::Program;
GLuint SunLightShader::uniform_ntex;
GLuint SunLightShader::uniform_dtex;
GLuint SunLightShader::uniform_direction;
GLuint SunLightShader::uniform_col;
GLuint SunLightShader::uniform_invproj;
@ -1040,18 +1175,21 @@ namespace FullScreenShader
{
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/sunlight.frag").c_str());
uniform_ntex = glGetUniformLocation(Program, "ntex");
uniform_dtex = glGetUniformLocation(Program, "dtex");
uniform_direction = glGetUniformLocation(Program, "direction");
uniform_col = glGetUniformLocation(Program, "col");
uniform_invproj = glGetUniformLocation(Program, "invproj");
vao = createVAO(Program);
printf("uniform %d\n", uniform_ntex);
}
void SunLightShader::setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex)
void SunLightShader::setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex)
{
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
glUniform3f(uniform_direction, direction.X, direction.Y, direction.Z);
glUniform3f(uniform_col, r, g, b);
glUniform1i(uniform_ntex, TU_ntex);
glUniform1i(uniform_dtex, TU_dtex);
}
GLuint LightBlendShader::Program;
@ -1141,35 +1279,130 @@ namespace FullScreenShader
}
GLuint SSAOShader::Program;
GLuint SSAOShader::uniform_normals_and_depth;
GLuint SSAOShader::uniform_ntex;
GLuint SSAOShader::uniform_dtex;
GLuint SSAOShader::uniform_noise_texture;
GLuint SSAOShader::uniform_invprojm;
GLuint SSAOShader::uniform_projm;
GLuint SSAOShader::uniform_samplePoints;
GLuint SSAOShader::vao;
float SSAOShader::SSAOSamples[64];
void SSAOShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/ssao.frag").c_str());
uniform_normals_and_depth = glGetUniformLocation(Program, "normals_and_depth");
uniform_ntex = glGetUniformLocation(Program, "ntex");
uniform_dtex = glGetUniformLocation(Program, "dtex");
uniform_noise_texture = glGetUniformLocation(Program, "noise_texture");
uniform_invprojm = glGetUniformLocation(Program, "invprojm");
uniform_projm = glGetUniformLocation(Program, "projm");
uniform_samplePoints = glGetUniformLocation(Program, "samplePoints[0]");
vao = createVAO(Program);
for (unsigned i = 0; i < 16; i++) {
// Generate x/y component between -1 and 1
// SSAOSamples[4 * i] and SSAOSamples[4 * i + 1] can be negative
SSAOSamples[0] = 0.135061f;
SSAOSamples[1] = 0.207948f;
SSAOSamples[2] = 0.968770f;
SSAOSamples[3] = 0.983032f;
SSAOSamples[4] = 0.273456f;
SSAOSamples[5] = -0.805390f;
SSAOSamples[6] = 0.525898f;
SSAOSamples[7] = 0.942808f;
SSAOSamples[8] = 0.443450f;
SSAOSamples[9] = -0.803786f;
SSAOSamples[10] = 0.396585f;
SSAOSamples[11] = 0.007996f;
SSAOSamples[12] = 0.742420f;
SSAOSamples[13] = -0.620072f;
SSAOSamples[14] = 0.253621f;
SSAOSamples[15] = 0.284829f;
SSAOSamples[16] = 0.892464f;
SSAOSamples[17] = 0.046221f;
SSAOSamples[18] = 0.448744f;
SSAOSamples[19] = 0.753655f;
SSAOSamples[20] = 0.830350f;
SSAOSamples[21] = -0.043593f;
SSAOSamples[22] = 0.555535f;
SSAOSamples[23] = 0.357463f;
SSAOSamples[24] = -0.600612f;
SSAOSamples[25] = -0.536421f;
SSAOSamples[26] = 0.592889f;
SSAOSamples[27] = 0.670583f;
SSAOSamples[28] = -0.280658f;
SSAOSamples[29] = 0.674894f;
SSAOSamples[30] = 0.682458f;
SSAOSamples[31] = 0.553362f;
SSAOSamples[32] = -0.654493f;
SSAOSamples[33] = -0.140866f;
SSAOSamples[34] = 0.742830f;
SSAOSamples[35] = 0.699820f;
SSAOSamples[36] = 0.114730f;
SSAOSamples[37] = 0.873130f;
SSAOSamples[38] = 0.473794f;
SSAOSamples[39] = 0.483901f;
SSAOSamples[40] = 0.699167f;
SSAOSamples[41] = 0.632210f;
SSAOSamples[42] = 0.333879f;
SSAOSamples[43] = 0.010956f;
SSAOSamples[44] = 0.904603f;
SSAOSamples[45] = 0.393410f;
SSAOSamples[46] = 0.164080f;
SSAOSamples[47] = 0.780297f;
SSAOSamples[48] = 0.631662f;
SSAOSamples[49] = -0.405195f;
SSAOSamples[50] = 0.660924f;
SSAOSamples[51] = 0.865596f;
SSAOSamples[52] = -0.195668f;
SSAOSamples[53] = 0.629185f;
SSAOSamples[54] = 0.752223f;
SSAOSamples[55] = 0.019013f;
SSAOSamples[56] = -0.511316f;
SSAOSamples[57] = 0.635504f;
SSAOSamples[58] = 0.578524f;
SSAOSamples[59] = 0.605457f;
SSAOSamples[60] = -0.898843f;
SSAOSamples[61] = 0.067382f;
SSAOSamples[62] = 0.433061f;
SSAOSamples[63] = 0.772942f;
// Generate another random distribution, if needed
/* for (unsigned i = 0; i < 16; i++) {
// Use double to avoid denorm and get a true uniform distribution
// Generate z component between [0.1; 1] to avoid being too close from surface
double z = rand();
z /= RAND_MAX;
z = 0.1 + 0.9 * z;
// Now generate x,y on the unit circle
double x = rand();
x /= RAND_MAX;
x = 2 * x - 1;
double y = rand();
y /= RAND_MAX;
y = 2 * y - 1;
double xynorm = sqrt(x * x + y * y);
x /= xynorm;
y /= xynorm;
// Now resize x,y so that norm(x,y,z) is one
x *= sqrt(1. - z * z);
y *= sqrt(1. - z * z);
// compute z so that norm (x,y,z) is one
double z = sqrt(x * x + y * y);
// Norm factor
double w = rand();
w /= RAND_MAX;
@ -1177,7 +1410,18 @@ namespace FullScreenShader
SSAOSamples[4 * i + 1] = (float)y;
SSAOSamples[4 * i + 2] = (float)z;
SSAOSamples[4 * i + 3] = (float)w;
}
}*/
}
void SSAOShader::setUniforms(const core::matrix4& projm, const core::matrix4 &invprojm, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_noise)
{
glUniformMatrix4fv(FullScreenShader::SSAOShader::uniform_invprojm, 1, GL_FALSE, invprojm.pointer());
glUniformMatrix4fv(FullScreenShader::SSAOShader::uniform_projm, 1, GL_FALSE, projm.pointer());
glUniform4fv(FullScreenShader::SSAOShader::uniform_samplePoints, 16, FullScreenShader::SSAOShader::SSAOSamples);
glUniform1i(FullScreenShader::SSAOShader::uniform_ntex, TU_ntex);
glUniform1i(FullScreenShader::SSAOShader::uniform_dtex, TU_dtex);
glUniform1i(FullScreenShader::SSAOShader::uniform_noise_texture, TU_noise);
}
GLuint FogShader::Program;
@ -1191,6 +1435,7 @@ namespace FullScreenShader
GLuint FogShader::uniform_campos;
GLuint FogShader::uniform_ipvmat;
GLuint FogShader::vao;
void FogShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/fog.frag").c_str());
@ -1205,4 +1450,143 @@ namespace FullScreenShader
uniform_ipvmat = glGetUniformLocation(Program, "ipvmat");
vao = createVAO(Program);
}
void FogShader::setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_ntex)
{
glUniform1f(FullScreenShader::FogShader::uniform_fogmax, fogmax);
glUniform1f(FullScreenShader::FogShader::uniform_startH, startH);
glUniform1f(FullScreenShader::FogShader::uniform_endH, endH);
glUniform1f(FullScreenShader::FogShader::uniform_start, start);
glUniform1f(FullScreenShader::FogShader::uniform_end, end);
glUniform3f(FullScreenShader::FogShader::uniform_col, col.X, col.Y, col.Z);
glUniform3f(FullScreenShader::FogShader::uniform_campos, campos.X, campos.Y, campos.Z);
glUniformMatrix4fv(FullScreenShader::FogShader::uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer());
glUniform1i(FullScreenShader::FogShader::uniform_tex, TU_ntex);
}
}
namespace UIShader
{
GLuint TextureRectShader::Program;
GLuint TextureRectShader::attrib_position;
GLuint TextureRectShader::attrib_texcoord;
GLuint TextureRectShader::uniform_tex;
GLuint TextureRectShader::uniform_center;
GLuint TextureRectShader::uniform_size;
GLuint TextureRectShader::uniform_texcenter;
GLuint TextureRectShader::uniform_texsize;
GLuint TextureRectShader::vao;
void TextureRectShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/texturedquad.vert").c_str(), file_manager->getAsset("shaders/texturedquad.frag").c_str());
attrib_position = glGetAttribLocation(Program, "position");
attrib_texcoord = glGetAttribLocation(Program, "texcoord");
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_center = glGetUniformLocation(Program, "center");
uniform_size = glGetUniformLocation(Program, "size");
uniform_texcenter = glGetUniformLocation(Program, "texcenter");
uniform_texsize = glGetUniformLocation(Program, "texsize");
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glEnableVertexAttribArray(attrib_position);
glEnableVertexAttribArray(attrib_texcoord);
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
glBindVertexArray(0);
}
void TextureRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex)
{
glUniform1i(uniform_tex, TU_tex);
glUniform2f(uniform_center, center_pos_x, center_pos_y);
glUniform2f(uniform_size, width, height);
glUniform2f(uniform_texcenter, tex_center_pos_x, tex_center_pos_y);
glUniform2f(uniform_texsize, tex_width, tex_height);
}
GLuint ColoredTextureRectShader::Program;
GLuint ColoredTextureRectShader::attrib_position;
GLuint ColoredTextureRectShader::attrib_texcoord;
GLuint ColoredTextureRectShader::attrib_color;
GLuint ColoredTextureRectShader::uniform_tex;
GLuint ColoredTextureRectShader::uniform_center;
GLuint ColoredTextureRectShader::uniform_size;
GLuint ColoredTextureRectShader::uniform_texcenter;
GLuint ColoredTextureRectShader::uniform_texsize;
GLuint ColoredTextureRectShader::colorvbo;
GLuint ColoredTextureRectShader::vao;
void ColoredTextureRectShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/colortexturedquad.vert").c_str(), file_manager->getAsset("shaders/colortexturedquad.frag").c_str());
attrib_position = glGetAttribLocation(Program, "position");
attrib_texcoord = glGetAttribLocation(Program, "texcoord");
attrib_color = glGetAttribLocation(Program, "color");
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_center = glGetUniformLocation(Program, "center");
uniform_size = glGetUniformLocation(Program, "size");
uniform_texcenter = glGetUniformLocation(Program, "texcenter");
uniform_texsize = glGetUniformLocation(Program, "texsize");
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glEnableVertexAttribArray(attrib_position);
glEnableVertexAttribArray(attrib_texcoord);
glEnableVertexAttribArray(attrib_color);
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
const unsigned quad_color[] = {
0, 0, 0, 255,
255, 0, 0, 255,
0, 255, 0, 255,
0, 0, 255, 255,
};
glGenBuffers(1, &colorvbo);
glBindBuffer(GL_ARRAY_BUFFER, colorvbo);
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(unsigned), quad_color, GL_DYNAMIC_DRAW);
glVertexAttribIPointer(attrib_color, 4, GL_UNSIGNED_INT, 4 * sizeof(unsigned), 0);
glBindVertexArray(0);
}
void ColoredTextureRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex)
{
glUniform1i(uniform_tex, TU_tex);
glUniform2f(uniform_center, center_pos_x, center_pos_y);
glUniform2f(uniform_size, width, height);
glUniform2f(uniform_texcenter, tex_center_pos_x, tex_center_pos_y);
glUniform2f(uniform_texsize, tex_width, tex_height);
}
GLuint ColoredRectShader::Program;
GLuint ColoredRectShader::attrib_position;
GLuint ColoredRectShader::uniform_center;
GLuint ColoredRectShader::uniform_size;
GLuint ColoredRectShader::uniform_color;
GLuint ColoredRectShader::vao;
void ColoredRectShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/coloredquad.vert").c_str(), file_manager->getAsset("shaders/coloredquad.frag").c_str());
attrib_position = glGetAttribLocation(Program, "position");
uniform_color = glGetUniformLocation(Program, "color");
uniform_center = glGetUniformLocation(Program, "center");
uniform_size = glGetUniformLocation(Program, "size");
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glEnableVertexAttribArray(attrib_position);
glBindBuffer(GL_ARRAY_BUFFER, quad_buffer);
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glBindVertexArray(0);
}
void ColoredRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color)
{
glUniform2f(uniform_center, center_pos_x, center_pos_y);
glUniform2f(uniform_size, width, height);
glUniform4i(uniform_color, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
}
}

View File

@ -59,6 +59,17 @@ public:
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
};
class DetailledObjectPass2Shader
{
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
static GLuint uniform_MVP, uniform_Albedo, uniform_Detail, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_Albedo, unsigned TU_detail, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
};
class ObjectRimLimitShader
{
public:
@ -81,6 +92,17 @@ public:
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
};
class ObjectUnlitShader
{
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MVP, uniform_tex;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex);
};
class ObjectRefPass2Shader
{
public:
@ -169,6 +191,17 @@ public:
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex);
};
class BillboardShader
{
public:
static GLuint Program;
static GLuint attrib_corner, attrib_texcoord;
static GLuint uniform_MV, uniform_P, uniform_tex, uniform_Position, uniform_Size;
static void init();
static void setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d<float> &size, unsigned TU_tex);
};
class ColorizeShader
{
@ -225,7 +258,7 @@ class SimpleParticleRender
public:
static GLuint Program;
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_normal_and_depths, uniform_screen, uniform_invproj;
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj;
static void init();
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth);
@ -236,7 +269,7 @@ class FlipParticleRender
public:
static GLuint Program;
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz, attrib_rotationvec, attrib_anglespeed;
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_normal_and_depths, uniform_screen, uniform_invproj;
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj;
static void init();
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth);
@ -290,21 +323,22 @@ class PointLightShader
{
public:
static GLuint Program;
static GLuint uniform_ntex, uniform_center, uniform_col, uniform_energy, uniform_spec, uniform_invproj, uniform_viewm;
static GLuint uniform_ntex, uniform_dtex, uniform_center, uniform_col, uniform_energy, uniform_spec, uniform_invproj, uniform_viewm;
static GLuint vao;
static void init();
static void setUniforms(const core::matrix4 &InvProjMatrix, const core::matrix4 &ViewMatrix, const std::vector<float> &positions, const std::vector<float> &colors, const std::vector<float> &energy, unsigned spec, unsigned TU_ntex, unsigned TU_dtex);
};
class SunLightShader
{
public:
static GLuint Program;
static GLuint uniform_ntex, uniform_direction, uniform_col, uniform_invproj;
static GLuint uniform_ntex, uniform_dtex, uniform_direction, uniform_col, uniform_invproj;
static GLuint vao;
static void init();
static void setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex);
static void setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex);
};
class LightBlendShader
@ -381,11 +415,12 @@ class SSAOShader
{
public:
static GLuint Program;
static GLuint uniform_normals_and_depth, uniform_noise_texture, uniform_invprojm, uniform_projm, uniform_samplePoints;
static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_invprojm, uniform_projm, uniform_samplePoints;
static GLuint vao;
static float SSAOSamples[64];
static void init();
static void setUniforms(const core::matrix4& projm, const core::matrix4 &invprojm, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_noise);
};
class FogShader
@ -396,10 +431,51 @@ public:
static GLuint vao;
static void init();
static void setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_ntex);
};
}
namespace UIShader
{
class TextureRectShader
{
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
static GLuint vao;
static void init();
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
};
class ColoredTextureRectShader
{
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_color;
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
static GLuint colorvbo;
static GLuint vao;
static void init();
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
};
class ColoredRectShader
{
public:
static GLuint Program;
static GLuint attrib_position;
static GLuint uniform_center, uniform_size, uniform_color;
static GLuint vao;
static void init();
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color);
};
}
#define FOREACH_SHADER(ACT) \
ACT(ES_NORMAL_MAP) \
ACT(ES_NORMAL_MAP_LIGHTMAP) \
@ -419,6 +495,7 @@ public:
ACT(ES_COLORIZE) \
ACT(ES_COLORIZE_REF) \
ACT(ES_GLOW) \
ACT(ES_OBJECT_UNLIT) \
ACT(ES_OBJECTPASS) \
ACT(ES_OBJECTPASS_REF) \
ACT(ES_SUNLIGHT) \

View File

@ -115,7 +115,7 @@ void ShowCurve::addPoint(const Vec3 &pnt)
// 4 sides of the 'tunnel', so all in all 24 indices.
irr::u16 *indices = new irr::u16[24];
m_buffer->append(vertices, 4, indices, 24);
delete indices;
delete[] indices;
indices = m_buffer->getIndices();
// index = first newly added index

View File

@ -24,53 +24,23 @@ void STKAnimatedMesh::setMesh(scene::IAnimatedMesh* mesh)
CAnimatedMeshSceneNode::setMesh(mesh);
}
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
void STKAnimatedMesh::drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
{
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
assert(irr_driver->getPhase() == TRANSPARENT_PASS);
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
if (irr_driver->getLightViz())
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
else
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
computeMVP(ModelViewProjectionMatrix);
setTexture(1, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP1))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(2, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP2))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(3, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_SSAO))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
if (!UserConfigParams::m_ssao)
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
drawTransparentObject(mesh, ModelViewProjectionMatrix);
glUseProgram(MeshShader::ObjectRimLimitShader::Program);
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0, 1, 2, 3);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
return;
}
void STKAnimatedMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
{
switch (irr_driver->getPhase())
{
case 0:
case SOLID_NORMAL_AND_DEPTH_PASS:
{
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
computeMVP(ModelViewProjectionMatrix);
computeTIMV(TransposeInverseModelView);
@ -78,22 +48,18 @@ void STKAnimatedMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
drawObjectRefPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
else
drawObjectPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getMainSetup(), false, false);
break;
}
case 1:
case SOLID_LIT_PASS:
{
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_BLEND);
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
drawObjectRefPass2(mesh, ModelViewProjectionMatrix);
else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
else if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
drawObjectUnlit(mesh, ModelViewProjectionMatrix);
else if (mesh.textures[1])
drawDetailledObjectPass2(mesh, ModelViewProjectionMatrix);
else
drawObjectPass2(mesh, ModelViewProjectionMatrix);
break;
@ -114,6 +80,12 @@ isObjectPass(video::E_MATERIAL_TYPE type)
return true;
if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
return true;
if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
return true;
if (type == video::EMT_ONETEXTURE_BLEND)
return true;
if (type == video::EMT_TRANSPARENT_ADD_COLOR)
return true;
return false;
}
@ -167,27 +139,25 @@ void STKAnimatedMesh::render()
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((scene::SSkinMeshBuffer*)mb)->Transformation);
if (isObjectPass(material.MaterialType))
{
irr_driver->IncreaseObjectCount();
initvaostate(GLmeshes[i], material.MaterialType);
if (irr_driver->getPhase() == 0)
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS)
{
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, GLmeshes[i].vertex_buffer);
glBufferSubData(GL_ARRAY_BUFFER, 0, mb->getVertexCount() * GLmeshes[i].Stride, mb->getVertices());
}
drawSolid(GLmeshes[i], material.MaterialType);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
video::SMaterial material;
material.MaterialType = irr_driver->getShader(ES_RAIN);
material.BlendOperation = video::EBO_NONE;
material.ZWriteEnable = true;
material.Lighting = false;
irr_driver->getVideoDriver()->setMaterial(material);
static_cast<irr::video::COpenGLDriver*>(irr_driver->getVideoDriver())->setRenderStates3DMode();
if (isTransparentPass)
drawTransparent(GLmeshes[i], material.MaterialType);
else
drawSolid(GLmeshes[i], material.MaterialType);
}
else
{
driver->setMaterial(material);
driver->drawMeshBuffer(mb);
#ifdef DEBUG
Log::warn("material", "Unhandled (animated) material type : %d", material.MaterialType);
#endif
continue;
}
}
}

View File

@ -14,6 +14,7 @@ protected:
std::vector<GLMesh> GLmeshes;
core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView;
void drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
void drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
public:
STKAnimatedMesh(irr::scene::IAnimatedMesh* mesh, irr::scene::ISceneNode* parent,
irr::scene::ISceneManager* mgr, irr::s32 id,

View File

@ -0,0 +1,52 @@
#include "graphics/stkbillboard.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/shaders.hpp"
#include "graphics/irr_driver.hpp"
using namespace irr;
static GLuint billboardvbo;
static GLuint billboardvao = 0;
static void createbillboardvao()
{
float quad[] = {
-.5, -.5, 0., 1.,
-.5, .5, 0., 0.,
.5, -.5, 1., 1.,
.5, .5, 1., 0.,
};
glGenBuffers(1, &billboardvbo);
glGenVertexArrays(1, &billboardvao);
glBindVertexArray(billboardvao);
glBindBuffer(GL_ARRAY_BUFFER, billboardvbo);
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad, GL_STATIC_DRAW);
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_corner);
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_texcoord);
glVertexAttribPointer(MeshShader::BillboardShader::attrib_corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glVertexAttribPointer(MeshShader::BillboardShader::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*) (2 * sizeof(float)));
glBindVertexArray(0);
}
STKBillboard::STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
const irr::core::vector3df& position, const irr::core::dimension2d<irr::f32>& size,
irr::video::SColor colorTop, irr::video::SColor colorBottom) :
CBillboardSceneNode(parent, mgr, id, position, size, colorTop, colorBottom), IBillboardSceneNode(parent, mgr, id, position)
{
if (!billboardvao)
createbillboardvao();
}
void STKBillboard::render()
{
core::vector3df pos = getAbsolutePosition();
glBindVertexArray(billboardvao);
GLuint texid = static_cast<irr::video::COpenGLTexture*>(Material.getTexture(0))->getOpenGLTextureName();
setTexture(0, texid, GL_LINEAR, GL_LINEAR);
glUseProgram(MeshShader::BillboardShader::Program);
MeshShader::BillboardShader::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), pos, Size, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
return;
}

View File

@ -0,0 +1,19 @@
#ifndef STKBILLBOARD_HPP
#define STKBILLBOARD_HPP
#include "../lib/irrlicht/source/Irrlicht/CBillboardSceneNode.h"
#include <IBillboardSceneNode.h>
#include <irrTypes.h>
class STKBillboard : public irr::scene::CBillboardSceneNode
{
public:
STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
const irr::core::vector3df& position, const irr::core::dimension2d<irr::f32>& size,
irr::video::SColor colorTop = irr::video::SColor(0xFFFFFFFF),
irr::video::SColor colorBottom = irr::video::SColor(0xFFFFFFFF));
virtual void render();
};
#endif

View File

@ -60,10 +60,10 @@ GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_t
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
{
initGL();
GLMesh result = {};
if (!mb)
return result;
glBindVertexArray(0);
glGenBuffers(1, &(result.vertex_buffer));
glGenBuffers(1, &(result.index_buffer));
@ -472,10 +472,69 @@ void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProj
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
{
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
if (irr_driver->getLightViz())
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
else
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
setTexture(1, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP1))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(2, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP2))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(3, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_SSAO))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
if (!UserConfigParams::m_ssao)
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
glUseProgram(MeshShader::ObjectRimLimitShader::Program);
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0, 1, 2, 3);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
{
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
if (irr_driver->getLightViz())
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
else
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
glUseProgram(MeshShader::ObjectUnlitShader::Program);
MeshShader::ObjectUnlitShader::setUniforms(ModelViewProjectionMatrix, 0);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
{
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
@ -493,29 +552,64 @@ void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
setTexture(1, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP1))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(2, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP2))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(3, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_SSAO))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(1, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
setTexture(2, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP1))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(3, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP2))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(4, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_SSAO))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
if (!UserConfigParams::m_ssao)
{
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ONE};
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
glUseProgram(MeshShader::ObjectPass2Shader::Program);
MeshShader::ObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, 0, 1, 2, 3);
glUseProgram(MeshShader::DetailledObjectPass2Shader::Program);
MeshShader::DetailledObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, 0, 1, 2, 3, 4);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
void STKMesh::drawTransparentObject(const GLMesh &mesh)
void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
{
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
if (irr_driver->getLightViz())
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
else
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
setTexture(1, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP1))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(2, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_TMP2))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
setTexture(3, static_cast<irr::video::COpenGLTexture*>(irr_driver->getRTT(RTT_SSAO))->getOpenGLTextureName(), GL_NEAREST, GL_NEAREST);
if (!UserConfigParams::m_ssao)
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
glUseProgram(MeshShader::ObjectPass2Shader::Program);
MeshShader::ObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, 0, 1, 2, 3);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
{
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
computeMVP(ModelViewProjectionMatrix);
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
glUseProgram(MeshShader::TransparentShader::Program);
@ -525,7 +619,7 @@ void STKMesh::drawTransparentObject(const GLMesh &mesh)
glDrawElements(ptype, count, itype, 0);
}
void STKMesh::drawBubble(const GLMesh &mesh)
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
{
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
float transparency = 1.;
@ -534,7 +628,6 @@ void STKMesh::drawBubble(const GLMesh &mesh)
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
computeMVP(ModelViewProjectionMatrix);
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
glUseProgram(MeshShader::BubbleShader::Program);
@ -547,10 +640,7 @@ void STKMesh::drawBubble(const GLMesh &mesh)
void STKMesh::drawGlow(const GLMesh &mesh)
{
ColorizeProvider * const cb = (ColorizeProvider *)irr_driver->getCallback(ES_COLORIZE);
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_BLEND);
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
@ -561,17 +651,12 @@ void STKMesh::drawGlow(const GLMesh &mesh)
glBindVertexArray(mesh.vao_glow_pass);
glDrawElements(ptype, count, itype, 0);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void STKMesh::drawDisplace(const GLMesh &mesh)
{
DisplaceProvider * const cb = (DisplaceProvider *)irr_driver->getCallback(ES_DISPLACE);
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_BLEND);
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
@ -585,24 +670,18 @@ void STKMesh::drawDisplace(const GLMesh &mesh)
glBindVertexArray(mesh.vao_displace_pass);
glDrawElements(ptype, count, itype, 0);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void STKMesh::drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
{
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_CULL_FACE);
assert(irr_driver->getPhase() == TRANSPARENT_PASS);
computeMVP(ModelViewProjectionMatrix);
if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL)
drawTransparentObject(mesh);
if (type == irr_driver->getShader(ES_BUBBLES))
drawBubble(mesh);
drawBubble(mesh, ModelViewProjectionMatrix);
else
drawTransparentObject(mesh, ModelViewProjectionMatrix);
return;
}
@ -610,15 +689,9 @@ void STKMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
{
switch (irr_driver->getPhase())
{
case 0:
case SOLID_NORMAL_AND_DEPTH_PASS:
{
windDir = getWind();
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
computeMVP(ModelViewProjectionMatrix);
computeTIMV(TransposeInverseModelView);
@ -631,18 +704,10 @@ void STKMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
drawGrassPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, windDir);
else
drawObjectPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getMainSetup(), false, false);
break;
}
case 1:
case SOLID_LIT_PASS:
{
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_BLEND);
if (type == irr_driver->getShader(ES_SPHERE_MAP))
drawSphereMap(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
else if (type == irr_driver->getShader(ES_SPLATTING))
@ -651,6 +716,12 @@ void STKMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
drawObjectRefPass2(mesh, ModelViewProjectionMatrix);
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
drawGrassPass2(mesh, ModelViewProjectionMatrix, windDir);
else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
else if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
drawObjectUnlit(mesh, ModelViewProjectionMatrix);
else if (mesh.textures[1] && type != irr_driver->getShader(ES_NORMAL_MAP))
drawDetailledObjectPass2(mesh, ModelViewProjectionMatrix);
else if (!mesh.textures[0])
drawUntexturedObject(mesh, ModelViewProjectionMatrix);
else
@ -670,6 +741,8 @@ static bool isObject(video::E_MATERIAL_TYPE type)
return true;
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
return true;
if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
return true;
if (type == irr_driver->getShader(ES_NORMAL_MAP))
return true;
if (type == irr_driver->getShader(ES_SPHERE_MAP))
@ -682,8 +755,14 @@ static bool isObject(video::E_MATERIAL_TYPE type)
return true;
if (type == irr_driver->getShader(ES_BUBBLES))
return true;
if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
return true;
if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL)
return true;
if (type == video::EMT_ONETEXTURE_BLEND)
return true;
if (type == video::EMT_TRANSPARENT_ADD_COLOR)
return true;
return false;
}
@ -691,7 +770,7 @@ void initvaostate(GLMesh &mesh, video::E_MATERIAL_TYPE type)
{
switch (irr_driver->getPhase())
{
case 0: // Solid Pass 1
case SOLID_NORMAL_AND_DEPTH_PASS:
if (mesh.vao_first_pass)
return;
if (type == irr_driver->getShader(ES_NORMAL_MAP))
@ -715,7 +794,7 @@ void initvaostate(GLMesh &mesh, video::E_MATERIAL_TYPE type)
MeshShader::ObjectPass1Shader::attrib_position, -1, -1, MeshShader::ObjectPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
}
return;
case 1: // Solid pass 2
case SOLID_LIT_PASS:
if (mesh.vao_second_pass)
return;
if (type == irr_driver->getShader(ES_SPHERE_MAP))
@ -743,6 +822,16 @@ void initvaostate(GLMesh &mesh, video::E_MATERIAL_TYPE type)
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::GrassPass2Shader::attrib_position, MeshShader::GrassPass2Shader::attrib_texcoord, -1, -1, -1, -1, MeshShader::GrassPass2Shader::attrib_color, mesh.Stride);
}
else if (type == irr_driver->getShader(ES_OBJECT_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);
}
else if (mesh.textures[1])
{
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);
}
else if (!mesh.textures[0])
{
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
@ -754,12 +843,12 @@ void initvaostate(GLMesh &mesh, video::E_MATERIAL_TYPE type)
MeshShader::ObjectPass2Shader::attrib_position, MeshShader::ObjectPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
}
return;
case 2: // Glow
case GLOW_PASS:
if (mesh.vao_glow_pass)
return;
mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
return;
case 3: // Transparent
case TRANSPARENT_PASS:
if (mesh.vao_first_pass)
return;
if (type == irr_driver->getShader(ES_BUBBLES))
@ -767,13 +856,13 @@ void initvaostate(GLMesh &mesh, video::E_MATERIAL_TYPE type)
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);
}
else if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL)
else
{
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::TransparentShader::attrib_position, MeshShader::TransparentShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
}
return;
case 4:
case DISPLACEMENT_PASS:
if (mesh.vao_displace_pass)
return;
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);
@ -808,7 +897,7 @@ void STKMesh::render()
if (isTransparentPass != transparent)
continue;
if (irr_driver->getPhase() == 4)
if (irr_driver->getPhase() == DISPLACEMENT_PASS)
{
initvaostate(GLmeshes[i], material.MaterialType);
drawDisplace(GLmeshes[i]);
@ -816,34 +905,27 @@ void STKMesh::render()
}
if (!isObject(material.MaterialType))
{
driver->setMaterial(material);
driver->drawMeshBuffer(mb);
#ifdef DEBUG
Log::warn("material", "Unhandled (static) material type : %d", material.MaterialType);
#endif
continue;
}
// only render transparent buffer if this is the transparent render pass
// and solid only in solid pass
if (irr_driver->getPhase() == 2)
if (irr_driver->getPhase() == GLOW_PASS)
{
initvaostate(GLmeshes[i], material.MaterialType);
drawGlow(GLmeshes[i]);
}
else
{
irr_driver->IncreaseObjectCount();
initvaostate(GLmeshes[i], material.MaterialType);
if (transparent)
drawTransparent(GLmeshes[i], material.MaterialType);
else
drawSolid(GLmeshes[i], material.MaterialType);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
video::SMaterial material;
material.MaterialType = irr_driver->getShader(ES_RAIN);
material.BlendOperation = video::EBO_NONE;
material.ZWriteEnable = true;
material.Lighting = false;
irr_driver->getVideoDriver()->setMaterial(material);
static_cast<irr::video::COpenGLDriver*>(irr_driver->getVideoDriver())->setRenderStates3DMode();
}
}
}

View File

@ -35,12 +35,19 @@ void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProje
void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, core::vector3df windDir);
// Pass 2 shader (ie shaders that outputs final color)
void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView);
void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector3df windDir);
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView);
void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
// Forward pass (for transparents meshes)
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
class STKMesh : public irr::scene::CMeshSceneNode
{
@ -50,10 +57,6 @@ protected:
core::vector3df windDir;
void drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
void drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type);
// Forward pass (for transparents meshes)
void drawTransparentObject(const GLMesh &mesh);
void drawBubble(const GLMesh &mesh);
// Misc passes shaders (glow, displace...)
void drawGlow(const GLMesh &mesh);

View File

@ -42,6 +42,7 @@ ListWidget::ListWidget() : Widget(WTYPE_LIST)
m_selected_column = NULL;
m_sort_desc = false;
m_sort_default = true;
m_sort_col = 0;
}
// -----------------------------------------------------------------------------

View File

@ -79,7 +79,7 @@ struct Input
Input()
: m_type(IT_NONE), m_device_id(0), m_button_id(0),
m_axis_direction(0), m_character(0)
m_axis_direction(0), m_axis_range(Input::AR_FULL), m_character(0)
{
// Nothing to do.
}
@ -109,7 +109,7 @@ struct Input
*/
Input(InputType ntype, int deviceID , int btnID = 0, int axisDirection= 0)
: m_type(ntype), m_device_id(deviceID), m_button_id(btnID),
m_axis_direction(axisDirection)
m_axis_direction(axisDirection), m_axis_range(Input::AR_FULL)
{
// Nothing to do.
}

View File

@ -258,24 +258,16 @@ bool GamePadDevice::processAndMapInput(Input::InputType type, const int id,
if (!m_axis_ok[id]) return false;
}
if (m_configuration != NULL)
if (mode == InputManager::INGAME)
{
if (mode == InputManager::INGAME)
{
success = m_configuration->getGameAction(type, id, value, action);
}
else if (abs(*value) > Input::MAX_VALUE/2)
{
// bindings can only be accessed in game and menu modes
assert(mode == InputManager::MENU);
success = m_configuration->getMenuAction(type, id, value, action);
}
success = m_configuration->getGameAction(type, id, value, action);
}
else
else if (abs(*value) > Input::MAX_VALUE/2)
{
fprintf(stderr, "processAndMapInput() called on improperly "
"initialized GamePadDevice\n");
abort();
// bindings can only be accessed in game and menu modes
assert(mode == InputManager::MENU);
success = m_configuration->getMenuAction(type, id, value, action);
}
return success;

View File

@ -53,6 +53,7 @@ Attachment::Attachment(AbstractKart* kart)
m_bomb_sound = NULL;
m_bubble_explode_sound = NULL;
m_node_scale = 1.0f;
m_initial_speed = 0.0f;
// If we attach a NULL mesh, we get a NULL scene node back. So we
// have to attach some kind of mesh, but make it invisible.

View File

@ -46,10 +46,6 @@ class Flyable : public Moveable, public TerrainInfo
public:
private:
bool m_has_hit_something;
/** This flag is used to avoid that a rocket explodes mode than once.
* It can happen that more than one collision between a rocket and
* a track or kart is reported by the physics. */
bool m_exploded;
/** If this flag is set, the up velocity of the kart will not be
* adjusted in case that the objects is too high or too low above the

View File

@ -187,9 +187,6 @@ private:
/** A 'ping' sound effect to be played when the ball hits the ground. */
SFXBase *m_ping_sfx;
/** Sound effect to be played when a ball hits a kart. */
SFXBase *m_hit_sfx;
void computeTarget();
void updateDistanceToTarget();
unsigned int getSuccessorToHitTarget(unsigned int node_index,

View File

@ -42,8 +42,7 @@ private:
RB_TO_KART, /**< Rubber band is attached to a kart hit. */
RB_TO_TRACK} /**< Rubber band is attached to track. */
m_attached_state;
/** True if plunger was fired backwards. */
bool m_is_backward;
/** If rubber band is attached to track, the coordinates. */
Vec3 m_hit_position;
/** The plunger the rubber band is attached to. */

View File

@ -1805,7 +1805,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
m_body->applyCentralImpulse( -4000.0f*push );
m_bounce_back_time = 2.0f;
core::stringw msg = _("You need more points\nto enter this challenge!");
core::stringw msg = _("You need more points\nto enter this challenge!\nCheck the minimap for\navailable challenges.");
std::vector<core::stringw> parts = StringUtils::split(msg, '\n', false);
// For now, until we have scripting, special-case the overworld... (TODO)
@ -2565,16 +2565,17 @@ void Kart::setOnScreenText(const wchar_t *text)
// FIXME: Titlefont is the only font guaranteed to be loaded if STK
// is started without splash screen (since "Loading" is shown even in this
// case). A smaller font would be better
sm->addBillboardTextSceneNode(GUIEngine::getFont() ? GUIEngine::getFont()
// TODO: Add support in the engine for BillboardText or find a replacement
/*sm->addBillboardTextSceneNode(GUIEngine::getFont() ? GUIEngine::getFont()
: GUIEngine::getTitleFont(),
text,
getNode(),
core::dimension2df(textsize.Width/55.0f,
textsize.Height/55.0f),
core::vector3df(0.0f, 1.5f, 0.0f),
-1 /* id */,
-1, // id
video::SColor(255, 255, 225, 0),
video::SColor(255, 255, 89, 0));
video::SColor(255, 255, 89, 0));*/
// No need to store the reference to the billboard scene node:
// It has one reference to the parent, and will get deleted
// when the parent is deleted.

View File

@ -64,6 +64,9 @@ void KartPropertiesManager::addKartSearchDir(const std::string &s)
} // addKartSearchDir
//-----------------------------------------------------------------------------
/** Removes all karts from the KartPropertiesManager, so that they can be
* reloade. This is necessary after a change of the screen resolution.
*/
void KartPropertiesManager::unloadAllKarts()
{
m_karts_properties.clearAndDeleteAll();
@ -71,23 +74,8 @@ void KartPropertiesManager::unloadAllKarts()
m_kart_available.clear();
m_groups_2_indices.clear();
m_all_groups.clear();
m_kart_search_path.clear();
} // unloadAllKarts
//-----------------------------------------------------------------------------
/** Reloads all karts, i.e. reloads the meshes and textures. This is used
* when changing the screen resolution.
*/
void KartPropertiesManager::reLoadAllKarts()
{
m_karts_properties.clearAndDeleteAll();
m_selected_karts.clear();
m_kart_available.clear();
m_groups_2_indices.clear();
m_all_groups.clear();
loadAllKarts(false);
} // reLoadAllKarts
//-----------------------------------------------------------------------------
/** Remove a kart from the kart manager.
* \param id The kart id (i.e. name of the directory) to remove.

View File

@ -77,7 +77,6 @@ public:
bool loadKart (const std::string &dir);
void loadAllKarts (bool loading_icon = true);
void unloadAllKarts ();
void reLoadAllKarts ();
void removeKart(const std::string &id);
const std::vector<int> getKartsInGroup (const std::string& g);
bool kartAvailable(int kartid);

View File

@ -91,7 +91,7 @@ void PhysicalObject::Settings::init()
m_body_type = PhysicalObject::MP_NONE;
m_crash_reset = false;
m_knock_kart = false;
m_mass = -1.0f;
m_mass = 0.0f;
m_radius = -1.0f;
m_reset_when_too_low = false;
m_flatten_kart = false;

View File

@ -41,6 +41,8 @@ TerrainInfo::TerrainInfo()
TerrainInfo::TerrainInfo(const Vec3 &pos)
{
// initialise HoT
m_last_material = NULL;
m_material = NULL;
update(pos);
} // TerrainInfo
//-----------------------------------------------------------------------------

View File

@ -945,17 +945,18 @@ bool Track::loadMainTrack(const XMLNode &root)
assert(GUIEngine::getHighresDigitFont() != NULL);
scene::ISceneNode* sn =
// TODO: Add support in the engine for BillboardText or find a replacement
/* scene::ISceneNode* sn =
sm->addBillboardTextSceneNode(GUIEngine::getHighresDigitFont(),
msg.c_str(),
NULL,
core::dimension2df(textsize.Width/45.0f,
textsize.Height/45.0f),
xyz,
-1 /* id */,
-1, // id
video::SColor(255, 255, 225, 0),
video::SColor(255, 255, 89, 0));
m_all_nodes.push_back(sn);
m_all_nodes.push_back(sn);*/
if (!shown) continue;
}
else if (condition == "allchallenges")
@ -1341,7 +1342,7 @@ void Track::createWater(const XMLNode &node)
if (UserConfigParams::m_graphical_effects)
{
scene::IMesh *welded;
/*scene::IMesh *welded;
scene_node = irr_driver->addWaterNode(mesh, &welded,
wave_height,
wave_speed,
@ -1351,7 +1352,7 @@ void Track::createWater(const XMLNode &node)
irr_driver->grabAllTextures(mesh);
m_all_cached_meshes.push_back(mesh);
mesh = welded;
mesh = welded;*/
}
else
{
@ -1585,6 +1586,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
// Sky dome and boxes support
// --------------------------
irr_driver->suppressSkyBox();
if(m_sky_type==SKY_DOME && m_sky_textures.size() > 0)
{
scene::ISceneNode *node = irr_driver->addSkyDome(m_sky_textures[0],

View File

@ -274,20 +274,17 @@ void TrackObject::move(const core::vector3df& xyz, const core::vector3df& hpr,
if (m_presentation != NULL) m_presentation->move(xyz, hpr, scale);
if (update_rigid_body && m_physical_object != NULL)
{
// If we set a bullet position from an irrlicht position, we need to
// get the absolute transform from the presentation object (as set in
// the line before), since xyz etc here are only relative to a
// potential parent scene node.
TrackObjectPresentationSceneNode *tops =
dynamic_cast<TrackObjectPresentationSceneNode*>(m_presentation);
if(tops)
{
core::matrix4 m = tops->getNode()->getAbsoluteTransformation();
core::vector3df xyz_abs;
m.transformVect(xyz_abs, xyz);
core::vector3df hpr_abs;
// FIXME - adding the rotations appears odd
// perhaps we should create the matrix and multiply
// with the absolute transform?
hpr_abs = hpr + tops->getNode()->getAbsoluteTransformation()
.getRotationDegrees();
m_physical_object->move(xyz_abs, hpr_abs);
const core::matrix4 &m = tops->getNode()
->getAbsoluteTransformation();
m_physical_object->move(m.getTranslation(),m.getRotationDegrees());
}
else
{