Merge branch 'master' of github.com:supertuxkart/stk-code

This commit is contained in:
hiker 2014-06-26 16:52:15 +10:00
commit 76cf9ed141
25 changed files with 257 additions and 369 deletions

View File

@ -1,5 +1,8 @@
##TODO
THIS IS A 2nd TEST.
THIS IS A TEST.
SuperTuxKart is looking for additional man power to make this
one of the best free linux games out there :) We need (in
no particular order):

View File

@ -1,27 +1,33 @@
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelViewMatrix;
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
uniform mat4 ModelMatrix;
layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord;
layout(location = 4) in vec2 SecondTexcoord;
#if __VERSION__ >= 130
in vec3 Position;
in vec2 Texcoord;
in vec2 SecondTexcoord;
out vec2 uv;
out vec2 uv_bis;
out float camdist;
#else
attribute vec3 Position;
attribute vec2 Texcoord;
attribute vec2 SecondTexcoord;
varying vec2 uv;
varying vec2 uv_bis;
varying float camdist;
#endif
void main() {
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * vec4(Position, 1.);
uv = Texcoord;
uv_bis = SecondTexcoord;
camdist = length(ModelViewMatrix * vec4(Position, 1.));
camdist = length(ViewMatrix * ModelMatrix * vec4(Position, 1.));
}

View File

@ -3,22 +3,14 @@ uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView;
#if __VERSION__ >= 130
in vec3 Position;
in vec3 Normal;
in vec2 Texcoord;
in vec4 Color;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord;
out vec3 nor;
out vec2 uv;
#else
attribute vec3 Position;
attribute vec3 Normal;
attribute vec2 Texcoord;
attribute vec4 Color;
varying vec3 nor;
varying vec2 uv;
#endif
void main()
{

View File

@ -15,10 +15,10 @@ in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
in vec3 Position;
in vec3 Normal;
in vec2 Texcoord;
in vec4 Color;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord;
out vec3 nor;
out vec2 uv;

View File

@ -19,9 +19,9 @@ in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
in vec3 Position;
in vec3 Normal;
in vec2 Texcoord;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 3) in vec2 Texcoord;
out vec3 nor;
out vec2 uv;

View File

@ -11,8 +11,8 @@ in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
in vec3 Position;
in vec2 Texcoord;
layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord;
#ifdef VSLayer
out vec2 uv;

View File

@ -10,24 +10,15 @@ layout (std140) uniform MatrixesData
uniform mat4 ModelMatrix;
uniform mat4 InverseModelMatrix;
#if __VERSION__ >= 130
in vec3 Position;
in vec2 Texcoord;
in vec3 Tangent;
in vec3 Bitangent;
layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord;
layout(location = 5) in vec3 Tangent;
layout(location = 6) in vec3 Bitangent;
out vec3 tangent;
out vec3 bitangent;
out vec2 uv;
#else
attribute vec3 Position;
attribute vec2 Texcoord;
attribute vec3 Tangent;
attribute vec3 Bitangent;
varying vec3 tangent;
varying vec3 bitangent;
varying vec2 uv;
#endif
void main()
{

View File

@ -24,25 +24,17 @@ uniform mat4 TextureMatrix =
0., 0., 1., 0.,
0., 0., 0., 1.);
#if __VERSION__ >= 130
in vec3 Position;
in vec2 Texcoord;
in vec2 SecondTexcoord;
in vec3 Normal;
in vec4 Color;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord;
layout(location = 4) in vec2 SecondTexcoord;
out vec3 nor;
out vec2 uv;
out vec2 uv_bis;
out vec4 color;
#else
attribute vec3 Position;
attribute vec3 Normal;
attribute vec2 Texcoord;
attribute vec2 SecondTexcoord;
varying vec3 nor;
varying vec2 uv;
varying vec2 uv_bis;
#endif
void main(void)

View File

@ -9,9 +9,10 @@ uniform mat4 TextureMatrix =
0., 0., 0., 1.);
in vec3 Position;
in vec2 Texcoord;
in vec3 Normal;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 3) in vec2 Texcoord;
out vec3 nor;
out vec2 uv;

View File

@ -9,8 +9,8 @@ layout (std140) uniform MatrixesData
uniform mat4 ModelMatrix;
in vec3 Position;
in vec2 Texcoord;
layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord;
#ifdef VSLayer
out vec2 uv;

View File

@ -1,22 +0,0 @@
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TextureMatrix;
#if __VERSION__ >= 130
in vec3 Position;
in vec2 Texcoord;
in vec4 Color;
out vec2 uv;
out vec4 color;
#else
attribute vec3 Position;
attribute vec2 Texcoord;
varying vec2 uv;
#endif
void main()
{
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
color = Color;
}

View File

@ -264,7 +264,7 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
// enumerate video modes
s32 modeCount;
XF86VidModeModeInfo** modes;
float refresh_rate;
float refresh_rate, refresh_rate_old;
XF86VidModeGetAllModeLines(display, screennr, &modeCount, &modes);
@ -273,22 +273,17 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
{
if (bestMode==-1 && modes[i]->hdisplay >= Width && modes[i]->vdisplay >= Height)
{
float pixels_per_second = modes[i]->dotclock * 1000.0;
float pixels_per_frame = modes[i]->htotal * modes[i]->vtotal;
refresh_rate = pixels_per_second / pixels_per_frame;
bestMode = i;
}
else if (bestMode!=-1 &&
modes[i]->hdisplay == modes[bestMode]->hdisplay &&
modes[i]->vdisplay == modes[bestMode]->vdisplay)
{
float pixels_per_second = modes[i]->dotclock * 1000.0;
float pixels_per_frame = modes[i]->htotal * modes[i]->vtotal;
float refresh_rate_tmp = pixels_per_second / pixels_per_frame;
refresh_rate_old = (modes[bestMode]->dotclock * 1000.0) / (modes[bestMode]->htotal * modes[bestMode]->vtotal);
refresh_rate = (modes[i]->dotclock * 1000.0) / (modes[i]->htotal * modes[i]->vtotal);
if (refresh_rate_tmp > refresh_rate)
if (refresh_rate > refresh_rate_old)
{
refresh_rate = refresh_rate_tmp;
bestMode = i;
}
}
@ -298,9 +293,6 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
modes[i]->hdisplay <= modes[bestMode]->hdisplay &&
modes[i]->vdisplay <= modes[bestMode]->vdisplay)
{
float pixels_per_second = modes[i]->dotclock * 1000.0;
float pixels_per_frame = modes[i]->htotal * modes[i]->vtotal;
refresh_rate = pixels_per_second / pixels_per_frame;
bestMode = i;
}
}

View File

@ -33,6 +33,8 @@ AnimationBase::AnimationBase(const XMLNode &node)
node.get("fps", &fps);
for(unsigned int i=0; i<node.getNumNodes(); i++)
{
if (node.getNode(i)->getName() == "animated-texture")
continue;
Ipo *ipo = new Ipo(*node.getNode(i), fps);
m_all_ipos.push_back(ipo);
}

View File

@ -415,7 +415,7 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
setTexture(0, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
setTexture(1, irr_driver->getDepthStencilTexture(), GL_LINEAR, GL_LINEAR);
setTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glUniform1i(FullScreenShader::Gaussian17TapHShader::uniform_tex, 0);
@ -452,7 +452,7 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
setTexture(0, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
setTexture(1, irr_driver->getDepthStencilTexture(), GL_LINEAR, GL_LINEAR);
setTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glUniform1i(FullScreenShader::Gaussian17TapVShader::uniform_tex, 0);

View File

@ -540,7 +540,7 @@ void IrrDriver::renderSolidFirstPass()
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
draw<MeshShader::ObjectPass1Shader>(mesh, mesh.vao_first_pass, GroupedFPSM<FPSM_DEFAULT>::MVPSet[i], GroupedFPSM<FPSM_DEFAULT>::TIMVSet[i], 0);
draw<MeshShader::ObjectPass1Shader>(mesh, mesh.vao, GroupedFPSM<FPSM_DEFAULT>::MVPSet[i], GroupedFPSM<FPSM_DEFAULT>::TIMVSet[i], 0);
if (!mesh.textures[0])
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
@ -554,7 +554,7 @@ void IrrDriver::renderSolidFirstPass()
const GLMesh &mesh = *GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MeshSet[i];
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
draw<MeshShader::ObjectRefPass1Shader>(mesh, mesh.vao_first_pass, GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MVPSet[i], GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::TIMVSet[i], GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MeshSet[i]->TextureMatrix, 0);
draw<MeshShader::ObjectRefPass1Shader>(mesh, mesh.vao, GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MVPSet[i], GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::TIMVSet[i], GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MeshSet[i]->TextureMatrix, 0);
}
glUseProgram(MeshShader::NormalMapShader::Program);
for (unsigned i = 0; i < GroupedFPSM<FPSM_NORMAL_MAP>::MeshSet.size(); ++i)
@ -565,7 +565,7 @@ void IrrDriver::renderSolidFirstPass()
setTexture(0, getTextureGLuint(mesh.textures[1]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
compressTexture(mesh.textures[0], true);
setTexture(1, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
draw<MeshShader::NormalMapShader>(mesh, mesh.vao_first_pass, GroupedFPSM<FPSM_NORMAL_MAP>::MVPSet[i], GroupedFPSM<FPSM_NORMAL_MAP>::TIMVSet[i], 0, 1);
draw<MeshShader::NormalMapShader>(mesh, mesh.vao, GroupedFPSM<FPSM_NORMAL_MAP>::MVPSet[i], GroupedFPSM<FPSM_NORMAL_MAP>::TIMVSet[i], 0, 1);
}
}
}
@ -912,7 +912,7 @@ void IrrDriver::renderShadows()
continue;
compressTexture(mesh.textures[0], true);
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
draw<MeshShader::RSMShader>(mesh, mesh.vao_rsm_pass, rsm_matrix, GroupedFPSM<FPSM_DEFAULT>::MVPSet[i], 0);
draw<MeshShader::RSMShader>(mesh, mesh.vao, rsm_matrix, GroupedFPSM<FPSM_DEFAULT>::MVPSet[i], 0);
}
}

View File

@ -1360,19 +1360,24 @@ namespace MeshShader
void TransparentShader::init()
{
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/transparent.vert").c_str(),
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparent.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
attrib_color = glGetAttribLocation(Program, "Color");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_MVP = glGetUniformLocation(Program, "ModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
}
void TransparentShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex)
void TransparentShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex)
{
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelMatrix.pointer());
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
glUniform1i(uniform_tex, TU_tex);
}
@ -1394,12 +1399,12 @@ namespace MeshShader
void TransparentFogShader::init()
{
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/transparent.vert").c_str(),
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparentfog.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
attrib_color = glGetAttribLocation(Program, "Color");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_MVP = glGetUniformLocation(Program, "ModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_fogmax = glGetUniformLocation(Program, "fogmax");
@ -1415,9 +1420,9 @@ namespace MeshShader
}
}
void TransparentFogShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex)
void TransparentFogShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex)
{
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelMatrix.pointer());
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
glUniform1f(uniform_fogmax, fogmax);
glUniform1f(uniform_startH, startH);
@ -1728,12 +1733,14 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/displace.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_MVP = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
void DisplaceMaskShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix)
void DisplaceMaskShader::setUniforms(const core::matrix4 &ModelMatrix)
{
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelMatrix.pointer());
}
GLuint DisplaceShader::Program;
@ -1741,7 +1748,6 @@ namespace MeshShader
GLuint DisplaceShader::attrib_texcoord;
GLuint DisplaceShader::attrib_second_texcoord;
GLuint DisplaceShader::uniform_MVP;
GLuint DisplaceShader::uniform_MV;
GLuint DisplaceShader::uniform_displacement_tex;
GLuint DisplaceShader::uniform_mask_tex;
GLuint DisplaceShader::uniform_color_tex;
@ -1756,8 +1762,7 @@ namespace MeshShader
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_MV = glGetUniformLocation(Program, "ModelViewMatrix");
uniform_MVP = glGetUniformLocation(Program, "ModelMatrix");
uniform_displacement_tex = glGetUniformLocation(Program, "displacement_tex");
uniform_color_tex = glGetUniformLocation(Program, "color_tex");
uniform_mask_tex = glGetUniformLocation(Program, "mask_tex");
@ -1767,10 +1772,9 @@ namespace MeshShader
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
}
void DisplaceShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex)
void DisplaceShader::setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex)
{
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniformMatrix4fv(uniform_MV, 1, GL_FALSE, ModelViewMatrix.pointer());
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelMatrix.pointer());
glUniform2f(uniform_dir, dir.X, dir.Y);
glUniform2f(uniform_dir2, dir2.X, dir2.Y);
glUniform1i(uniform_displacement_tex, TU_displacement_tex);

View File

@ -288,7 +288,7 @@ public:
static GLuint uniform_MVP, uniform_TM, uniform_tex;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex);
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex);
};
class TransparentFogShader
@ -299,7 +299,7 @@ public:
static GLuint uniform_MVP, uniform_TM, uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex);
static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex);
};
class BillboardShader
@ -398,7 +398,7 @@ public:
static GLuint uniform_MVP;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
static void setUniforms(const core::matrix4 &ModelMatrix);
};
class DisplaceShader
@ -406,10 +406,10 @@ class DisplaceShader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
static GLuint uniform_MVP, uniform_MV, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_dir, uniform_dir2;
static GLuint uniform_MVP, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_dir, uniform_dir2;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex);
static void setUniforms(const core::matrix4 &ModelMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex);
};
class SkyboxShader

View File

@ -27,18 +27,8 @@ void STKAnimatedMesh::cleanGLMeshes()
GLMesh mesh = GLmeshes[i];
if (!mesh.vertex_buffer)
continue;
if (mesh.vao_first_pass)
glDeleteVertexArrays(1, &(mesh.vao_first_pass));
if (mesh.vao_second_pass)
glDeleteVertexArrays(1, &(mesh.vao_second_pass));
if (mesh.vao_glow_pass)
glDeleteVertexArrays(1, &(mesh.vao_glow_pass));
if (mesh.vao_displace_pass)
glDeleteVertexArrays(1, &(mesh.vao_displace_pass));
if (mesh.vao_displace_mask_pass)
glDeleteVertexArrays(1, &(mesh.vao_displace_mask_pass));
if (mesh.vao_shadow_pass)
glDeleteVertexArrays(1, &(mesh.vao_shadow_pass));
if (mesh.vao)
glDeleteVertexArrays(1, &(mesh.vao));
glDeleteBuffers(1, &(mesh.vertex_buffer));
glDeleteBuffers(1, &(mesh.index_buffer));
}
@ -230,13 +220,13 @@ void STKAnimatedMesh::render()
for_in(mesh, TransparentMesh[TM_DEFAULT])
{
TransparentMeshes<TM_DEFAULT>::MeshSet.push_back(mesh);
TransparentMeshes<TM_DEFAULT>::MVPSet.push_back(ModelViewProjectionMatrix);
TransparentMeshes<TM_DEFAULT>::MVPSet.push_back(AbsoluteTransformation);
}
for_in(mesh, TransparentMesh[TM_ADDITIVE])
{
TransparentMeshes<TM_ADDITIVE>::MeshSet.push_back(mesh);
TransparentMeshes<TM_ADDITIVE>::MVPSet.push_back(ModelViewProjectionMatrix);
TransparentMeshes<TM_ADDITIVE>::MVPSet.push_back(AbsoluteTransformation);
}
return;
}

View File

@ -25,16 +25,10 @@ void STKInstancedSceneNode::cleanGL()
GLMesh mesh = GLmeshes[i];
if (!mesh.vertex_buffer)
continue;
if (mesh.vao_first_pass)
glDeleteVertexArrays(1, &(mesh.vao_first_pass));
if (mesh.vao)
glDeleteVertexArrays(1, &(mesh.vao));
if (mesh.vao_second_pass)
glDeleteVertexArrays(1, &(mesh.vao_second_pass));
if (mesh.vao_glow_pass)
glDeleteVertexArrays(1, &(mesh.vao_glow_pass));
if (mesh.vao_displace_pass)
glDeleteVertexArrays(1, &(mesh.vao_displace_pass));
if (mesh.vao_displace_mask_pass)
glDeleteVertexArrays(1, &(mesh.vao_displace_mask_pass));
if (mesh.vao_shadow_pass)
glDeleteVertexArrays(1, &(mesh.vao_shadow_pass));
glDeleteBuffers(1, &(mesh.vertex_buffer));
@ -81,36 +75,33 @@ void STKInstancedSceneNode::initinstancedvaostate(GLMesh &mesh, GeometricMateria
switch (GeoMat)
{
case FPSM_DEFAULT:
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::InstancedObjectPass1Shader::attrib_position, MeshShader::InstancedObjectRefPass1Shader::attrib_texcoord, -1, MeshShader::InstancedObjectPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
glGenBuffers(1, &instances_vbo);
glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
glBufferData(GL_ARRAY_BUFFER, instance_pos.size() * sizeof(float), instance_pos.data(), GL_STATIC_DRAW);
setInstanceAttribPointer<MeshShader::InstancedObjectPass1Shader, 1>();
if (irr_driver->getGLSLVersion() >= 150)
{
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::InstancedShadowShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
setInstanceAttribPointer<MeshShader::InstancedShadowShader, 4>();
}
break;
case FPSM_ALPHA_REF_TEXTURE:
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::InstancedObjectRefPass1Shader::attrib_position, MeshShader::InstancedObjectRefPass1Shader::attrib_texcoord, -1, MeshShader::InstancedObjectRefPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
glGenBuffers(1, &instances_vbo);
glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
glBufferData(GL_ARRAY_BUFFER, instance_pos.size() * sizeof(float), instance_pos.data(), GL_STATIC_DRAW);
setInstanceAttribPointer<MeshShader::InstancedObjectRefPass1Shader, 1>();
if (irr_driver->getGLSLVersion() >= 150)
{
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::InstancedRefShadowShader::attrib_position, MeshShader::InstancedRefShadowShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
setInstanceAttribPointer<MeshShader::InstancedRefShadowShader, 4>();
}
break;
case FPSM_GRASS:
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::InstancedGrassPass1Shader::attrib_position, MeshShader::InstancedGrassPass1Shader::attrib_texcoord, -1, MeshShader::InstancedGrassPass1Shader::attrib_normal, -1, -1, MeshShader::InstancedGrassPass1Shader::attrib_color, mesh.Stride);
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
glGenBuffers(1, &instances_vbo);
glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
glBufferData(GL_ARRAY_BUFFER, instance_pos.size() * sizeof(float), instance_pos.data(), GL_STATIC_DRAW);
@ -125,20 +116,17 @@ void STKInstancedSceneNode::initinstancedvaostate(GLMesh &mesh, GeometricMateria
switch (ShadedMat)
{
case SM_DEFAULT:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::InstancedObjectPass2Shader::attrib_position, MeshShader::InstancedObjectPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
setInstanceAttribPointer<MeshShader::InstancedObjectPass2Shader, 1>();
break;
case SM_ALPHA_REF_TEXTURE:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::InstancedObjectRefPass2Shader::attrib_position, MeshShader::InstancedObjectRefPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
setInstanceAttribPointer<MeshShader::InstancedObjectRefPass2Shader, 1>();
break;
case SM_GRASS:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::InstancedGrassPass2Shader::attrib_position, MeshShader::InstancedGrassPass2Shader::attrib_texcoord, -1, MeshShader::InstancedGrassPass2Shader::attrib_normal, -1, -1, MeshShader::InstancedGrassPass2Shader::attrib_color, mesh.Stride);
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
glBindBuffer(GL_ARRAY_BUFFER, instances_vbo);
setInstanceAttribPointer<MeshShader::InstancedGrassPass2Shader, 1>();
break;

View File

@ -56,54 +56,80 @@ TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE typ
return TM_DEFAULT;
}
GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_texcoord, GLuint attrib_second_texcoord, GLuint attrib_normal, GLuint attrib_tangent, GLuint attrib_bitangent, GLuint attrib_color, size_t stride)
video::E_VERTEX_TYPE getVTXTYPEFromStride(size_t stride)
{
if (stride == sizeof(video::S3DVertex))
return video::EVT_STANDARD;
else if (stride == sizeof(video::S3DVertex2TCoords))
return video::EVT_2TCOORDS;
assert(stride == sizeof(video::S3DVertexTangents));
return video::EVT_TANGENTS;
}
GLuint createVAO(GLuint vbo, GLuint idx, video::E_VERTEX_TYPE type)
{
if (attrib_position == -1)
return 0;
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
assert(vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glEnableVertexAttribArray(attrib_position);
if ((GLint)attrib_texcoord != -1)
glEnableVertexAttribArray(attrib_texcoord);
if ((GLint)attrib_second_texcoord != -1)
glEnableVertexAttribArray(attrib_second_texcoord);
if ((GLint)attrib_normal != -1)
glEnableVertexAttribArray(attrib_normal);
if ((GLint)attrib_tangent != -1)
glEnableVertexAttribArray(attrib_tangent);
if ((GLint)attrib_bitangent != -1)
glEnableVertexAttribArray(attrib_bitangent);
if ((GLint)attrib_color != -1)
glEnableVertexAttribArray(attrib_color);
glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, stride, 0);
if ((GLint)attrib_texcoord != -1)
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 28);
if ((GLint)attrib_second_texcoord != -1)
switch (type)
{
if (stride < 44)
Log::error("material", "Second texcoords not present in VBO");
glVertexAttribPointer(attrib_second_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 36);
case video::EVT_STANDARD:
// Position
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), 0);
// Normal
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)12);
// Color
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, getVertexPitchFromType(type), (GLvoid*)24);
// Texcoord
glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)28);
break;
case video::EVT_2TCOORDS:
// Position
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), 0);
// Normal
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)12);
// Color
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, getVertexPitchFromType(type), (GLvoid*)24);
// Texcoord
glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)28);
// SecondTexcoord
glEnableVertexAttribArray(4);
glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)36);
break;
case video::EVT_TANGENTS:
// Position
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), 0);
// Normal
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)12);
// Color
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, getVertexPitchFromType(type), (GLvoid*)24);
// Texcoord
glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)28);
// Tangent
glEnableVertexAttribArray(5);
glVertexAttribPointer(5, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)36);
// Bitangent
glEnableVertexAttribArray(6);
glVertexAttribPointer(6, 3, GL_FLOAT, GL_FALSE, getVertexPitchFromType(type), (GLvoid*)48);
break;
default:
assert(0 && "Wrong vertex type");
}
if ((GLint)attrib_normal != -1)
glVertexAttribPointer(attrib_normal, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 12);
if ((GLint)attrib_tangent != -1)
{
if (stride < 48)
Log::error("material", "Tangents not present in VBO");
glVertexAttribPointer(attrib_tangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)36);
}
if ((GLint)attrib_bitangent != -1)
{
if (stride < 60)
Log::error("material", "Bitangents not present in VBO");
glVertexAttribPointer(attrib_bitangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)48);
}
if ((GLint)attrib_color != -1)
glVertexAttribPointer(attrib_color, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, (GLvoid*)24);
assert(idx);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idx);
return vao;
}
@ -124,6 +150,7 @@ GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
result.Stride = getVertexPitchFromType(vType);
const c8* vbuf = static_cast<const c8*>(vertices);
glBufferData(GL_ARRAY_BUFFER, vertexCount * result.Stride, vbuf, GL_STATIC_DRAW);
assert(vertexCount);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.index_buffer);
const void* indices = mb->getIndices();
@ -224,8 +251,8 @@ void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0);
assert(mesh.vao_first_pass);
glBindVertexArray(mesh.vao_first_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -250,8 +277,8 @@ void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelMatrix, const c
setTexture(MeshShader::SphereMapShader::TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::SphereMapShader::setUniforms(ModelMatrix, InverseModelMatrix, irr_driver->getSceneManager()->getAmbientLight());
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -330,8 +357,8 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
MeshShader::SplattingShader::setUniforms(ModelViewProjectionMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -357,8 +384,8 @@ void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
MeshShader::ObjectRefPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -386,8 +413,8 @@ void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
MeshShader::GrassPass2Shader::setUniforms(ModelViewProjectionMatrix, windDir);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -400,8 +427,8 @@ void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelMatrix)
MeshShader::UntexturedObjectShader::setUniforms(ModelMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -427,8 +454,8 @@ void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -454,8 +481,8 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
MeshShader::ObjectUnlitShader::setUniforms(ModelViewProjectionMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -483,8 +510,8 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView
MeshShader::DetailledObjectPass2Shader::setUniforms(ModelViewProjectionMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -510,8 +537,8 @@ void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
MeshShader::ObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -527,8 +554,8 @@ void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewPro
MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0);
assert(mesh.vao_first_pass);
glBindVertexArray(mesh.vao_first_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -562,8 +589,8 @@ void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelView
glUseProgram(MeshShader::TransparentFogShader::Program);
MeshShader::TransparentFogShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, fogmax, startH, endH, start, end, col, Camera::getCamera(0)->getCameraSceneNode()->getAbsolutePosition(), 0);
assert(mesh.vao_first_pass);
glBindVertexArray(mesh.vao_first_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -582,8 +609,8 @@ void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatr
MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
assert(mesh.vao_first_pass);
glBindVertexArray(mesh.vao_first_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -598,8 +625,8 @@ void drawShadowRef(const GLMesh &mesh, const core::matrix4 &ModelMatrix)
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::RefShadowShader::setUniforms(ModelMatrix, 0);
assert(mesh.vao_shadow_pass);
glBindVertexArray(mesh.vao_shadow_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElementsInstanced(ptype, count, itype, 0, 4);
}
@ -612,8 +639,8 @@ void drawShadow(const GLMesh &mesh, const core::matrix4 &ModelMatrix)
MeshShader::ShadowShader::setUniforms(ModelMatrix);
assert(mesh.vao_shadow_pass);
glBindVertexArray(mesh.vao_shadow_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElementsInstanced(ptype, count, itype, 0, 4);
}
@ -656,104 +683,11 @@ bool isObject(video::E_MATERIAL_TYPE type)
void initvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat)
{
switch (GeoMat)
{
case FPSM_DEFAULT:
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::ObjectPass1Shader::attrib_position, MeshShader::ObjectPass1Shader::attrib_texcoord, -1, MeshShader::ObjectPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ShadowShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
mesh.vao_rsm_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::RSMShader::attrib_position, MeshShader::RSMShader::attrib_texcoord, -1, MeshShader::RSMShader::attrib_normal, -1, -1, -1, mesh.Stride);
break;
case FPSM_ALPHA_REF_TEXTURE:
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::ObjectRefPass1Shader::attrib_position, MeshShader::ObjectRefPass1Shader::attrib_texcoord, -1, MeshShader::ObjectRefPass1Shader::attrib_normal, -1, -1, -1, mesh.Stride);
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::RefShadowShader::attrib_position, MeshShader::RefShadowShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
break;
case FPSM_NORMAL_MAP:
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::NormalMapShader::attrib_position, MeshShader::NormalMapShader::attrib_texcoord, -1, -1, MeshShader::NormalMapShader::attrib_tangent, MeshShader::NormalMapShader::attrib_bitangent, -1, mesh.Stride);
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ShadowShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
break;
case FPSM_GRASS:
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::GrassPass1Shader::attrib_position, MeshShader::GrassPass1Shader::attrib_texcoord, -1, MeshShader::GrassPass1Shader::attrib_normal, -1, -1, MeshShader::GrassPass1Shader::attrib_color, mesh.Stride);
mesh.vao_shadow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::GrassShadowShader::attrib_position, MeshShader::GrassShadowShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::GrassShadowShader::attrib_color, mesh.Stride);
break;
default:
assert(0 && "Unknow material");
break;
}
switch (ShadedMat)
{
case SM_SPHEREMAP:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::SphereMapShader::attrib_position, -1, -1, MeshShader::SphereMapShader::attrib_normal, -1, -1, -1, mesh.Stride);
break;
case SM_SPLATTING:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::SplattingShader::attrib_position, MeshShader::SplattingShader::attrib_texcoord, MeshShader::SplattingShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
break;
case SM_ALPHA_REF_TEXTURE:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::ObjectRefPass2Shader::attrib_position, MeshShader::ObjectRefPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
break;
case SM_RIMLIT:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::ObjectRimLimitShader::attrib_position, MeshShader::ObjectRimLimitShader::attrib_texcoord, -1, MeshShader::ObjectRimLimitShader::attrib_normal, -1, -1, -1, mesh.Stride);
break;
case SM_GRASS:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::GrassPass2Shader::attrib_position, MeshShader::GrassPass2Shader::attrib_texcoord, -1, -1, -1, -1, MeshShader::GrassPass2Shader::attrib_color, mesh.Stride);
break;
case SM_UNLIT:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::ObjectUnlitShader::attrib_position, MeshShader::ObjectUnlitShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
break;
case SM_DETAILS:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::DetailledObjectPass2Shader::attrib_position, MeshShader::DetailledObjectPass2Shader::attrib_texcoord, MeshShader::DetailledObjectPass2Shader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
break;
case SM_UNTEXTURED:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::UntexturedObjectShader::attrib_position, -1, -1, -1, -1, -1, MeshShader::UntexturedObjectShader::attrib_color, mesh.Stride);
break;
case SM_DEFAULT:
mesh.vao_second_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::ObjectPass2Shader::attrib_position, MeshShader::ObjectPass2Shader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
break;
default:
assert(0 && "unknow shaded material");
break;
}
mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
mesh.vao_displace_mask_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
if (mesh.Stride >= 44)
mesh.vao_displace_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, MeshShader::DisplaceShader::attrib_texcoord, MeshShader::DisplaceShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
mesh.vao = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
}
void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat)
{
switch (TranspMat)
{
case TM_BUBBLE:
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::BubbleShader::attrib_position, MeshShader::BubbleShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
break;
case TM_DEFAULT:
case TM_ADDITIVE:
if (World::getWorld() != NULL && World::getWorld()->isFogEnabled())
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::TransparentFogShader::attrib_position, MeshShader::TransparentFogShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::TransparentFogShader::attrib_color, mesh.Stride);
else
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::TransparentShader::attrib_position, MeshShader::TransparentShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::TransparentShader::attrib_color, mesh.Stride);
break;
}
mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
mesh.vao_displace_mask_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
if (mesh.Stride >= 44)
mesh.vao_displace_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, MeshShader::DisplaceShader::attrib_texcoord, MeshShader::DisplaceShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);
mesh.vao = createVAO(mesh.vertex_buffer, mesh.index_buffer, getVTXTYPEFromStride(mesh.Stride));
}

View File

@ -42,6 +42,7 @@ enum TransparentMaterial
};
struct GLMesh {
GLuint vao;
GLuint vao_first_pass;
GLuint vao_second_pass;
GLuint vao_glow_pass;
@ -59,8 +60,9 @@ struct GLMesh {
core::matrix4 TextureMatrix;
};
GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_texcoord, GLuint attrib_second_texcoord, GLuint attrib_normal, GLuint attrib_tangent, GLuint attrib_bitangent, GLuint attrib_color, size_t stride);
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb);
video::E_VERTEX_TYPE getVTXTYPEFromStride(size_t stride);
GLuint createVAO(GLuint vbo, GLuint idx, video::E_VERTEX_TYPE type);
void initvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat);
void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat);
core::matrix4 computeMVP(const core::matrix4 &ModelViewProjectionMatrix);

View File

@ -82,18 +82,8 @@ void STKMeshSceneNode::cleanGLMeshes()
GLMesh mesh = GLmeshes[i];
if (!mesh.vertex_buffer)
continue;
if (mesh.vao_first_pass)
glDeleteVertexArrays(1, &(mesh.vao_first_pass));
if (mesh.vao_second_pass)
glDeleteVertexArrays(1, &(mesh.vao_second_pass));
if (mesh.vao_glow_pass)
glDeleteVertexArrays(1, &(mesh.vao_glow_pass));
if (mesh.vao_displace_pass)
glDeleteVertexArrays(1, &(mesh.vao_displace_pass));
if (mesh.vao_displace_mask_pass)
glDeleteVertexArrays(1, &(mesh.vao_displace_mask_pass));
if (mesh.vao_shadow_pass)
glDeleteVertexArrays(1, &(mesh.vao_shadow_pass));
if (mesh.vao)
glDeleteVertexArrays(1, &(mesh.vao));
glDeleteBuffers(1, &(mesh.vertex_buffer));
glDeleteBuffers(1, &(mesh.index_buffer));
}
@ -126,8 +116,8 @@ void STKMeshSceneNode::drawGlow(const GLMesh &mesh)
MeshShader::ColorizeShader::setUniforms(AbsoluteTransformation, cb->getRed(), cb->getGreen(), cb->getBlue());
assert(mesh.vao_glow_pass);
glBindVertexArray(mesh.vao_glow_pass);
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
}
@ -141,19 +131,14 @@ void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
ModelViewProjectionMatrix = computeMVP(AbsoluteTransformation);
core::matrix4 ModelViewMatrix = irr_driver->getViewMatrix();
ModelViewMatrix *= AbsoluteTransformation;
// Generate displace mask
// Use RTT_TMP4 as displace mask
irr_driver->getFBO(FBO_TMP1_WITH_DS).Bind();
glUseProgram(MeshShader::DisplaceMaskShader::Program);
MeshShader::DisplaceMaskShader::setUniforms(ModelViewProjectionMatrix);
MeshShader::DisplaceMaskShader::setUniforms(AbsoluteTransformation);
assert(mesh.vao_displace_mask_pass);
glBindVertexArray(mesh.vao_displace_mask_pass);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
// Render the effect
@ -164,15 +149,13 @@ void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
setTexture(1, irr_driver->getRenderTargetTexture(RTT_TMP1), GL_LINEAR, GL_LINEAR, true);
setTexture(2, irr_driver->getRenderTargetTexture(RTT_COLOR), GL_LINEAR, GL_LINEAR, true);
glUseProgram(MeshShader::DisplaceShader::Program);
MeshShader::DisplaceShader::setUniforms(ModelViewProjectionMatrix, ModelViewMatrix,
MeshShader::DisplaceShader::setUniforms(AbsoluteTransformation,
core::vector2df(cb->getDirX(), cb->getDirY()),
core::vector2df(cb->getDir2X(), cb->getDir2Y()),
core::vector2df(float(UserConfigParams::m_width),
float(UserConfigParams::m_height)),
0, 1, 2);
assert(mesh.vao_displace_pass);
glBindVertexArray(mesh.vao_displace_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -420,13 +403,13 @@ void STKMeshSceneNode::render()
for_in(mesh, TransparentMesh[TM_DEFAULT])
{
TransparentMeshes<TM_DEFAULT>::MeshSet.push_back(mesh);
TransparentMeshes<TM_DEFAULT>::MVPSet.push_back(ModelViewProjectionMatrix);
TransparentMeshes<TM_DEFAULT>::MVPSet.push_back(AbsoluteTransformation);
}
for_in(mesh, TransparentMesh[TM_ADDITIVE])
{
TransparentMeshes<TM_ADDITIVE>::MeshSet.push_back(mesh);
TransparentMeshes<TM_ADDITIVE>::MVPSet.push_back(ModelViewProjectionMatrix);
TransparentMeshes<TM_ADDITIVE>::MVPSet.push_back(AbsoluteTransformation);
}
if (!TransparentMesh[TM_BUBBLE].empty())

View File

@ -176,7 +176,7 @@ void MainLoop::run()
PROFILER_SYNC_FRAME();
PROFILER_POP_CPU_MARKER();
} // while !m_exit
} // while !m_abort
} // run

View File

@ -254,7 +254,7 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(const XMLNode& xml_node
else
{
m_mesh = irr_driver->getMesh(model_name);
if (tangent)
{
scene::IMeshManipulator* manip = irr_driver->getVideoDriver()->getMeshManipulator();
@ -368,6 +368,9 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNod
m_node = irr_driver->addMesh(m_mesh, parent);
m_frame_start = 0;
m_frame_end = 0;
if (World::getWorld() != NULL && World::getWorld()->getTrack() != NULL)
World::getWorld()->getTrack()->handleAnimatedTextures(m_node, *xml_node);
}
//#ifdef DEBUG
// std::string debug_name = model_name+" (track-object)";

27
tools/simplify_challenges.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# This script simplifies all challenges by removing any time
# limit, position requirement, etc, and setting the number
# of laps to 0. This is meant to quickly test the story
# mode without having to fully play all challenges.
for i in data/challenges/*.challenge; do
echo "Simplifying $i"
cat $i | sed 's/position="[0-9]*"/position="99"/' \
| sed 's/laps="[0-9]*"/laps="0"/' \
| sed 's/energy="[0-9]*"/energy="0"/' \
| sed 's/time="[0-9]*"/time="9999"/' \
> $i.new
mv $i.new $i
done
for i in data/grandprix/*.grandprix; do
echo "Simplyfing GP $i"
cat $i | sed 's/laps="[0-9]*"/laps="0"/' > $i.new
mv $i.new $i
done
echo
echo "All challenges simplified."
echo "PLEASE do not commit the changes back to our repository!"
echo "========================================================"