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

This commit is contained in:
hiker 2014-10-29 15:44:24 +11:00
commit 0264677750
15 changed files with 79 additions and 38 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!-- For sky particles, the size of the box is ignored -->
<particles emitter="box">
<particles emitter="box" randomize-initial-y="true">
<spreading angle="3" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -33,6 +33,9 @@ ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter,
const core::vector3df& scale,
bool randomize_initial_y) : CParticleSystemSceneNode(createDefaultEmitter, parent, mgr, id, position, rotation, scale), m_alpha_additive(false), m_first_execution(true)
{
if (randomize_initial_y)
m_randomize_initial_y = randomize_initial_y;
m_randomize_initial_y = randomize_initial_y;
size_increase_factor = 0.;
ParticleParams = NULL;

View File

@ -35,8 +35,10 @@
#include "graphics/stkanimatedmesh.hpp"
#include "graphics/stkbillboard.hpp"
#include "graphics/stkmeshscenenode.hpp"
#include "graphics/stkscenemanager.hpp"
#include "graphics/sun.hpp"
#include "graphics/rtts.hpp"
#include "graphics/texturemanager.hpp"
#include "graphics/water.hpp"
#include "graphics/wind.hpp"
#include "guiengine/engine.hpp"
@ -804,6 +806,12 @@ void IrrDriver::applyResolutionSettings()
// That's just error prone
// (we're sure to update main.cpp at some point and forget this one...)
m_shaders->killShaders();
VAOManager::getInstance()->kill();
SolidPassCmd::getInstance()->kill();
ShadowPassCmd::getInstance()->kill();
RSMPassCmd::getInstance()->kill();
GlowPassCmd::getInstance()->kill();
resetTextureTable();
// initDevice will drop the current device.
initDevice();

View File

@ -450,7 +450,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
else
{
if (m_is_glsl)
m_node = ParticleSystemProxy::addParticleNode(m_is_glsl, false);
m_node = ParticleSystemProxy::addParticleNode(m_is_glsl, type->randomizeInitialY());
else
m_node = irr_driver->addParticleNode();

View File

@ -58,7 +58,7 @@ ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,2
m_wind_speed = 0;
m_flips = false;
m_vertical_particles = false;
m_randomize_initial_y = false;
// ----- Read XML file
@ -82,6 +82,8 @@ ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,2
std::string emitterShape = "point";
xml->get("emitter", &emitterShape);
xml->get("randomize-initial-y", &m_randomize_initial_y);
if (emitterShape == "point")
{
m_shape = EMITTER_POINT;

View File

@ -103,6 +103,9 @@ private:
player by rotating around the Y axis only */
bool m_vertical_particles;
/** Used mainly for weather, like snow */
bool m_randomize_initial_y;
public:
/**
@ -167,6 +170,8 @@ public:
bool isVerticalParticles() const { return m_vertical_particles; }
bool randomizeInitialY() const { return m_randomize_initial_y; }
std::string getName() const { return m_name; }
};

View File

@ -683,36 +683,54 @@ void IrrDriver::renderSolidSecondPass()
}
}
template<enum video::E_VERTEX_TYPE VertexType, typename... TupleType>
static void renderMeshNormals(std::vector<STK::Tuple<TupleType...> > *meshes)
template<typename T>
static void renderInstancedMeshNormals()
{
std::vector<GLMesh *> &meshes = T::InstancedList::getInstance()->SolidPass;
glUseProgram(MeshShader::NormalVisualizer::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance));
for (unsigned i = 0; i < meshes.size(); i++)
{
GLMesh *mesh = meshes[i];
MeshShader::NormalVisualizer::getInstance()->setUniforms(video::SColor(255, 0, 255, 0));
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((SolidPassCmd::getInstance()->Offset[T::MaterialType] + i) * sizeof(DrawElementsIndirectCommand)));
}
}
template<typename T>
static void renderMultiMeshNormals()
{
glUseProgram(MeshShader::NormalVisualizer::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getVAO(VertexType));
for (unsigned i = 0; i < meshes->size(); i++)
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance));
if (SolidPassCmd::getInstance()->Size[T::MaterialType])
{
GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i)));
if (mesh.VAOType != VertexType)
{
#ifdef DEBUG
Log::error("Materials", "Wrong vertex Type associed to pass 2 (hint texture : %s)", mesh.textures[0]->getName().getPath().c_str());
#endif
continue;
}
draw(MeshShader::NormalVisualizer::getInstance(), STK::tuple_get<0>(meshes->at(i)), STK::tuple_get<1>(meshes->at(i)), STK::tuple_get<2>(meshes->at(i)), video::SColor(255, 0, 255, 0));
MeshShader::NormalVisualizer::getInstance()->setUniforms(video::SColor(255, 0, 255, 0));
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT,
(const void*)(SolidPassCmd::getInstance()->Offset[T::MaterialType] * sizeof(DrawElementsIndirectCommand)),
(int)SolidPassCmd::getInstance()->Size[T::MaterialType],
(int)sizeof(DrawElementsIndirectCommand));
}
}
void IrrDriver::renderNormalsVisualisation()
{
// renderMeshNormals<video::EVT_STANDARD>(ListMatDefault::getInstance());
// renderMeshNormals<video::EVT_STANDARD>(ListMatAlphaRef::getInstance());
// renderMeshNormals<video::EVT_STANDARD>(ListMatSphereMap::getInstance());
// renderMeshNormals<video::EVT_STANDARD>(ListMatGrass::getInstance());
// renderMeshNormals<video::EVT_2TCOORDS>(ListMatDetails::getInstance());
// renderMeshNormals<video::EVT_STANDARD>(ListMatUnlit::getInstance());
// renderMeshNormals<video::EVT_2TCOORDS>(ListMatSplatting::getInstance());
// renderMeshNormals<video::EVT_TANGENTS>(ListMatNormalMap::getInstance());
if (UserConfigParams::m_azdo) {
renderMultiMeshNormals<DefaultMaterial>();
renderMultiMeshNormals<AlphaRef>();
renderMultiMeshNormals<UnlitMat>();
renderMultiMeshNormals<SphereMap>();
renderMultiMeshNormals<DetailMat>();
renderMultiMeshNormals<NormalMat>();
}
else if (irr_driver->hasARB_draw_indirect())
{
renderInstancedMeshNormals<DefaultMaterial>();
renderInstancedMeshNormals<AlphaRef>();
renderInstancedMeshNormals<UnlitMat>();
renderInstancedMeshNormals<SphereMap>();
renderInstancedMeshNormals<DetailMat>();
renderInstancedMeshNormals<NormalMat>();
}
}
template<typename Shader, enum video::E_VERTEX_TYPE VertexType, int...List, typename... TupleType>

View File

@ -1387,10 +1387,11 @@ namespace MeshShader
NormalVisualizer::NormalVisualizer()
{
Program = LoadProgram(OBJECT,
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_VERTEX_SHADER, file_manager->getAsset("shaders/utils/getworldmatrix.vert").c_str(),
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/normal_visualizer.geom").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/coloredquad.frag").c_str());
AssignUniforms("ModelMatrix", "InverseModelMatrix", "color");
AssignUniforms("color");
}
GLuint ViewFrustrumShader::Program;

View File

@ -284,7 +284,7 @@ public:
GLuint cubevao;
};
class NormalVisualizer : public ShaderHelperSingleton<NormalVisualizer, core::matrix4, core::matrix4, video::SColor>
class NormalVisualizer : public ShaderHelperSingleton<NormalVisualizer, video::SColor>
{
public:
NormalVisualizer();

View File

@ -270,7 +270,7 @@ void STKMeshSceneNode::render()
if (UserConfigParams::m_azdo)
{
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]);
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
MeshShader::ObjectPass1Shader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]);
@ -320,11 +320,11 @@ void STKMeshSceneNode::render()
glMakeTextureHandleResidentARB(SSAOHandle);
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]);
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
if (!mesh.TextureHandles[1])
mesh.TextureHandles[1] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[1]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]);
mesh.TextureHandles[1] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[1]), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[1]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[1]);
MeshShader::ObjectPass2Shader::getInstance()->SetTextureHandles(DiffuseHandle, SpecularHandle, SSAOHandle, mesh.TextureHandles[0], mesh.TextureHandles[1]);

View File

@ -16,10 +16,13 @@ GLuint getDepthTexture(irr::video::ITexture *tex)
return static_cast<irr::video::COpenGLFBOTexture*>(tex)->DepthBufferTexture;
}
std::set<irr::video::ITexture *> AlreadyTransformedTexture;
static std::set<irr::video::ITexture *> AlreadyTransformedTexture;
static std::map<int, video::ITexture*> unicolor_cache;
void resetTextureTable()
{
AlreadyTransformedTexture.clear();
unicolor_cache.clear();
}
void compressTexture(irr::video::ITexture *tex, bool srgb, bool premul_alpha)
@ -167,10 +170,6 @@ void saveCompressedTexture(const std::string& compressed_tex)
delete[] data;
}
static unsigned colorcount = 0;
std::map<int, video::ITexture*> unicolor_cache;
video::ITexture* getUnicolorTexture(const video::SColor &c)
{
std::map<int, video::ITexture*>::iterator it = unicolor_cache.find(c.color);

View File

@ -199,7 +199,7 @@ void ModelViewWidget::setupRTTScene(PtrVector<scene::IMesh, REF>& mesh,
if (model_frames[0] == -1)
{
scene::ISceneNode* node = irr_driver->addMesh(mesh.get(0), NULL);
scene::ISceneNode* node = irr_driver->addMesh(mesh.get(0), "rtt_mesh", NULL);
node->setPosition(mesh_location[0].toIrrVector());
node->setScale(mesh_scale[0].toIrrVector());
node->setMaterialFlag(video::EMF_FOG_ENABLE, false);

View File

@ -8,7 +8,12 @@ namespace STK {
template<typename... _Types> class Tuple;
// empty tuple
template<> class Tuple<> {};
template<> class Tuple<> {
public:
Tuple()
{
}
};
// recursive tuple definition
template<typename _This, typename... _Rest>