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

This commit is contained in:
hiker 2014-09-22 07:55:06 +10:00
commit b4e16e8852
9 changed files with 49 additions and 23 deletions

View File

@ -949,22 +949,36 @@ void IrrDriver::setAllMaterialFlags(scene::IMesh *mesh) const
for(unsigned int i=0; i<n; i++)
{
scene::IMeshBuffer *mb = mesh->getMeshBuffer(i);
video::SMaterial &irr_material=mb->getMaterial();
video::ITexture* t=irr_material.getTexture(0);
if(t) material_manager->setAllMaterialFlags(t, mb);
video::SMaterial &irr_material = mb->getMaterial();
// special case : for splatting, the main material is on layer 1.
// it was done this way to provide a fallback for computers
// where shaders are not supported
t = irr_material.getTexture(1);
if (t)
video::ITexture* t2 = irr_material.getTexture(1);
bool is_splatting = false;
if (t2)
{
Material* mat = material_manager->getMaterialFor(t, mb);
Material* mat = material_manager->getMaterialFor(t2, mb);
if (mat != NULL && mat->getShaderType() == Material::SHADERTYPE_SPLATTING)
material_manager->setAllMaterialFlags(t, mb);
{
material_manager->setAllMaterialFlags(t2, mb);
is_splatting = true;
}
}
material_manager->setAllUntexturedMaterialFlags(mb);
if (!is_splatting)
{
video::ITexture* t = irr_material.getTexture(0);
if (t)
{
material_manager->setAllMaterialFlags(t, mb);
}
else
{
material_manager->setAllUntexturedMaterialFlags(mb);
}
}
} // for i<getMeshBufferCount()
} // setAllMaterialFlags

View File

@ -174,7 +174,8 @@ void IrrDriver::renderGLSL(float dt)
oss << "drawAll() for kart " << cam;
PROFILER_PUSH_CPU_MARKER(oss.str().c_str(), (cam+1)*60,
0x00, 0x00);
// camera->activate();
if (!UserConfigParams::m_dynamic_lights)
camera->activate();
rg->preRenderCallback(camera); // adjusts start referee
m_scene_manager->setActiveCamera(camnode);
@ -261,7 +262,8 @@ void IrrDriver::renderGLSL(float dt)
{
glEnable(GL_FRAMEBUFFER_SRGB);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
camera->activate();
if (UserConfigParams::m_dynamic_lights)
camera->activate();
m_post_processing->renderPassThrough(fbo->getRTT()[0]);
glDisable(GL_FRAMEBUFFER_SRGB);
}
@ -907,4 +909,4 @@ void IrrDriver::renderGlow(std::vector<GlowData>& glows)
m_rtts->getFBO(FBO_COLORS).Bind();
m_post_processing->renderGlow(m_rtts->getRenderTarget(RTT_QUARTER1));
glDisable(GL_STENCIL_TEST);
}
}

View File

@ -212,8 +212,8 @@ struct SplattingMat
static const std::vector<size_t> SecondPassTextures;
};
const std::vector<size_t> SplattingMat::FirstPassTextures = { 1 };
const std::vector<size_t> SplattingMat::SecondPassTextures = { 1, 2, 3, 4, 0 };
const std::vector<size_t> SplattingMat::FirstPassTextures = { 6 };
const std::vector<size_t> SplattingMat::SecondPassTextures = { 1, 2, 3, 4, 5 };
namespace RenderGeometry
{

View File

@ -226,7 +226,7 @@ RTT::RTT(size_t width, size_t height)
if (UserConfigParams::m_shadows && !irr_driver->needUBOWorkaround())
{
shadowColorTex = generateRTT3D(GL_TEXTURE_2D_ARRAY, 1024, 1024, 4, GL_R8, GL_RED, GL_UNSIGNED_BYTE);
shadowDepthTex = generateRTT3D(GL_TEXTURE_2D_ARRAY, 1024, 1024, 4, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
shadowDepthTex = generateRTT3D(GL_TEXTURE_2D_ARRAY, 1024, 1024, 4, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
somevector.clear();
somevector.push_back(shadowColorTex);
@ -238,7 +238,7 @@ RTT::RTT(size_t width, size_t height)
//Todo : use "normal" shadowtex
RSM_Color = generateRTT(shadowsize0, GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE);
RSM_Normal = generateRTT(shadowsize0, GL_RGB16F, GL_RGB, GL_FLOAT);
RSM_Depth = generateRTT(shadowsize0, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
RSM_Depth = generateRTT(shadowsize0, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
somevector.clear();
somevector.push_back(RSM_Color);

View File

@ -43,15 +43,18 @@ void STKAnimatedMesh::cleanGLMeshes()
if (mesh.index_buffer)
glDeleteBuffers(1, &(mesh.index_buffer));
}
GLmeshes.clear();
for (unsigned i = 0; i < MAT_COUNT; i++)
MeshSolidMaterial[i].clearWithoutDeleting();
for (unsigned i = 0; i < TM_COUNT; i++)
TransparentMesh[i].clearWithoutDeleting();
}
void STKAnimatedMesh::setMesh(scene::IAnimatedMesh* mesh)
{
isGLInitialized = false;
isMaterialInitialized = false;
GLmeshes.clear();
for (unsigned i = 0; i < MAT_COUNT; i++)
MeshSolidMaterial[i].clearWithoutDeleting();
cleanGLMeshes();
CAnimatedMeshSceneNode::setMesh(mesh);
}

View File

@ -177,7 +177,7 @@ GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
case scene::EPT_QUADS:
assert(0 && "Unsupported primitive type");
}
for (unsigned i = 0; i < 6; i++)
for (unsigned i = 0; i < 8; i++)
result.textures[i] = mb->getMaterial().getTexture(i);
result.TextureMatrix = 0;
result.VAOType = mb->getVertexType();
@ -333,10 +333,12 @@ void InitTextures(GLMesh &mesh, MeshMaterial Mat)
break;
case MAT_SPLATTING:
SetTexture(mesh, 0, true);
SetTexture(mesh, 1, true);
SetTexture(mesh, 1, false);
SetTexture(mesh, 2, true);
SetTexture(mesh, 3, true);
SetTexture(mesh, 4, true);
SetTexture(mesh, 5, true);
SetTexture(mesh, 6, false);
break;
}
}

View File

@ -36,7 +36,7 @@ struct GLMesh {
GLuint vao;
GLuint vertex_buffer;
GLuint index_buffer;
video::ITexture *textures[6];
video::ITexture *textures[8];
GLenum PrimitiveType;
GLenum IndexType;
size_t IndexCount;

View File

@ -63,6 +63,8 @@ void STKMeshSceneNode::cleanGLMeshes()
GLmeshes.clear();
for (unsigned i = 0; i < MAT_COUNT; i++)
MeshSolidMaterial[i].clearWithoutDeleting();
for (unsigned i = 0; i < TM_COUNT; i++)
TransparentMesh[i].clearWithoutDeleting();
}
void STKMeshSceneNode::setMesh(irr::scene::IMesh* mesh)
@ -250,8 +252,6 @@ void STKMeshSceneNode::render()
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
if (!mesh.textures[0])
mesh.textures[0] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
compressTexture(mesh.textures[0], true);
if (UserConfigParams::m_azdo)
{

View File

@ -32,6 +32,7 @@
#include "physics/physics.hpp"
#include "race/race_manager.hpp"
#include "utils/string_utils.hpp"
#include "graphics/glwrap.hpp"
#include "utils/log.hpp" //TODO: remove after debugging is done
@ -69,6 +70,10 @@ RubberBand::RubberBand(Plunger *plunger, AbstractKart *kart)
verts[i].Color = color;
}
// Color
mb->getMaterial().setTexture(0, getUnicolorTexture(video::SColor(255, 255, 255, 255)));
// Gloss
mb->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
updatePosition();
m_node = irr_driver->addMesh(m_mesh);
irr_driver->applyObjectPassShader(m_node);