diff --git a/data/gfx/snow.xml b/data/gfx/snow.xml index 531266b3b..f1fcbfe67 100644 --- a/data/gfx/snow.xml +++ b/data/gfx/snow.xml @@ -1,7 +1,7 @@ - + diff --git a/data/skins/peach/achievement.png b/data/skins/peach/achievement.png index 07381cc89..b2d4585a8 100644 Binary files a/data/skins/peach/achievement.png and b/data/skins/peach/achievement.png differ diff --git a/data/skins/peach/friend.png b/data/skins/peach/friend.png index 91fc9a357..9238c8add 100644 Binary files a/data/skins/peach/friend.png and b/data/skins/peach/friend.png differ diff --git a/src/graphics/gpuparticles.cpp b/src/graphics/gpuparticles.cpp index 0120e4f6b..f3d48d00d 100644 --- a/src/graphics/gpuparticles.cpp +++ b/src/graphics/gpuparticles.cpp @@ -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; diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 3ac485698..7d610c32e 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -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(); diff --git a/src/graphics/particle_emitter.cpp b/src/graphics/particle_emitter.cpp index 201921afe..b5ae06a60 100644 --- a/src/graphics/particle_emitter.cpp +++ b/src/graphics/particle_emitter.cpp @@ -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(); diff --git a/src/graphics/particle_kind.cpp b/src/graphics/particle_kind.cpp index 9ed5a4d8e..8feff73c1 100644 --- a/src/graphics/particle_kind.cpp +++ b/src/graphics/particle_kind.cpp @@ -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; diff --git a/src/graphics/particle_kind.hpp b/src/graphics/particle_kind.hpp index e7d379309..0546ff102 100644 --- a/src/graphics/particle_kind.hpp +++ b/src/graphics/particle_kind.hpp @@ -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; } }; diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index eb366b07d..ba9b30916 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -683,36 +683,54 @@ void IrrDriver::renderSolidSecondPass() } } -template -static void renderMeshNormals(std::vector > *meshes) +template +static void renderInstancedMeshNormals() +{ + std::vector &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 +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(ListMatDefault::getInstance()); -// renderMeshNormals(ListMatAlphaRef::getInstance()); -// renderMeshNormals(ListMatSphereMap::getInstance()); -// renderMeshNormals(ListMatGrass::getInstance()); -// renderMeshNormals(ListMatDetails::getInstance()); -// renderMeshNormals(ListMatUnlit::getInstance()); -// renderMeshNormals(ListMatSplatting::getInstance()); -// renderMeshNormals(ListMatNormalMap::getInstance()); + if (UserConfigParams::m_azdo) { + renderMultiMeshNormals(); + renderMultiMeshNormals(); + renderMultiMeshNormals(); + renderMultiMeshNormals(); + renderMultiMeshNormals(); + renderMultiMeshNormals(); + } + else if (irr_driver->hasARB_draw_indirect()) + { + renderInstancedMeshNormals(); + renderInstancedMeshNormals(); + renderInstancedMeshNormals(); + renderInstancedMeshNormals(); + renderInstancedMeshNormals(); + renderInstancedMeshNormals(); + } } template diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 6566c25ae..aa272fab1 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -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; diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index edd5a58d4..c429fc48a 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -284,7 +284,7 @@ public: GLuint cubevao; }; -class NormalVisualizer : public ShaderHelperSingleton +class NormalVisualizer : public ShaderHelperSingleton { public: NormalVisualizer(); diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index f14b63f87..418c34e4c 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -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]); diff --git a/src/graphics/texturemanager.cpp b/src/graphics/texturemanager.cpp index d15792ce9..b5a7b40af 100644 --- a/src/graphics/texturemanager.cpp +++ b/src/graphics/texturemanager.cpp @@ -16,10 +16,13 @@ GLuint getDepthTexture(irr::video::ITexture *tex) return static_cast(tex)->DepthBufferTexture; } -std::set AlreadyTransformedTexture; +static std::set AlreadyTransformedTexture; +static std::map 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 unicolor_cache; - video::ITexture* getUnicolorTexture(const video::SColor &c) { std::map::iterator it = unicolor_cache.find(c.color); diff --git a/src/guiengine/widgets/model_view_widget.cpp b/src/guiengine/widgets/model_view_widget.cpp index 91454d385..6cb901d4b 100644 --- a/src/guiengine/widgets/model_view_widget.cpp +++ b/src/guiengine/widgets/model_view_widget.cpp @@ -199,7 +199,7 @@ void ModelViewWidget::setupRTTScene(PtrVector& 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); diff --git a/src/utils/tuple.hpp b/src/utils/tuple.hpp index 533e95fde..9b10d5d80 100644 --- a/src/utils/tuple.hpp +++ b/src/utils/tuple.hpp @@ -8,7 +8,12 @@ namespace STK { template class Tuple; // empty tuple - template<> class Tuple<> {}; + template<> class Tuple<> { + public: + Tuple() + { + } + }; // recursive tuple definition template