Some cleaning.

This commit is contained in:
Vincent Lejeune
2014-03-31 20:04:34 +02:00
parent 427ca42f49
commit 7ebeaa45e8
5 changed files with 17 additions and 190 deletions

View File

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

View File

@@ -1,60 +0,0 @@
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 Lauri Kasanen
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/glow.hpp"
#include "graphics/callbacks.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/material.hpp"
#include "graphics/rtts.hpp"
#include "graphics/shaders.hpp"
using namespace video;
using namespace scene;
using namespace core;
IMesh * GlowNode::sphere = NULL;
SMaterial GlowNode::mat;
aabbox3df GlowNode::box;
GlowNode::GlowNode(scene::ISceneManager* mgr, float radius): ISceneNode(mgr->getRootSceneNode(), mgr, -1)
{
if (!sphere)
{
sphere = mgr->getGeometryCreator()->createSphereMesh(1, 4, 4);
box = sphere->getBoundingBox();
}
setScale(vector3df(radius));
}
GlowNode::~GlowNode()
{
}
void GlowNode::render()
{
}
void GlowNode::OnRegisterSceneNode()
{
}

View File

@@ -1,53 +0,0 @@
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 Lauri Kasanen
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_GLOW_HPP
#define HEADER_GLOW_HPP
#include <ISceneNode.h>
#include <IMesh.h>
using namespace irr;
// The actual node
class GlowNode: public scene::ISceneNode
{
public:
GlowNode(scene::ISceneManager* mgr, float radius);
~GlowNode();
virtual void render();
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return box;
}
virtual void OnRegisterSceneNode();
virtual u32 getMaterialCount() const { return 1; }
virtual video::SMaterial& getMaterial(u32 i) { return mat; }
private:
static video::SMaterial mat;
static core::aabbox3df box;
static scene::IMesh *sphere;
};
#endif

View File

@@ -21,7 +21,6 @@
#include "config/user_config.hpp"
#include "graphics/callbacks.hpp"
#include "graphics/camera.hpp"
#include "graphics/glow.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/lens_flare.hpp"
#include "graphics/light.hpp"
@@ -77,24 +76,11 @@ void IrrDriver::renderGLSL(float dt)
// Get a list of all glowing things. The driver's list contains the static ones,
// here we add items, as they may disappear each frame.
std::vector<GlowData> glows = m_glowing;
std::vector<GlowNode *> transparent_glow_nodes;
ItemManager * const items = ItemManager::get();
const u32 itemcount = items->getNumberOfItems();
u32 i;
// For each static node, give it a glow representation
const u32 staticglows = glows.size();
for (i = 0; i < staticglows; i++)
{
scene::ISceneNode * const node = glows[i].node;
const float radius = (node->getBoundingBox().getExtent().getLength() / 2) * 2.0f;
GlowNode * const repnode = new GlowNode(irr_driver->getSceneManager(), radius);
repnode->setPosition(node->getTransformedBoundingBox().getCenter());
transparent_glow_nodes.push_back(repnode);
}
for (i = 0; i < itemcount; i++)
{
Item * const item = items->getItem(i);
@@ -127,12 +113,6 @@ void IrrDriver::renderGLSL(float dt)
dat.b = c.getBlue();
glows.push_back(dat);
// Push back its representation too
const float radius = (node->getBoundingBox().getExtent().getLength() / 2) * 2.0f;
GlowNode * const repnode = new GlowNode(irr_driver->getSceneManager(), radius);
repnode->setPosition(node->getTransformedBoundingBox().getCenter());
transparent_glow_nodes.push_back(repnode);
}
// Start the RTT for post-processing.
@@ -249,27 +229,25 @@ void IrrDriver::renderGLSL(float dt)
m_scene_manager->drawAll(m_renderpass);
PROFILER_POP_CPU_MARKER();
if (World::getWorld()->getTrack()->isFogEnabled())
{
PROFILER_PUSH_CPU_MARKER("- Fog", 0xFF, 0x00, 0x00);
m_post_processing->renderFog(irr_driver->getInvProjMatrix());
PROFILER_POP_CPU_MARKER();
}
PROFILER_PUSH_CPU_MARKER("- Glow", 0xFF, 0xFF, 0x00);
// Render anything glowing.
if (!m_mipviz && !m_wireframe)
{
irr_driver->setPhase(GLOW_PASS);
renderGlow(overridemat, glows, cambox, cam);
} // end glow
if (World::getWorld()->getTrack()->isFogEnabled())
{
PROFILER_PUSH_CPU_MARKER("- Fog", 0xFF, 0x00, 0x00);
m_post_processing->renderFog(irr_driver->getInvProjMatrix());
PROFILER_POP_CPU_MARKER();
}
PROFILER_PUSH_CPU_MARKER("- Skybox", 0xFF, 0x00, 0xFF);
renderSkybox();
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("- Skybox", 0xFF, 0x00, 0xFF);
renderSkybox();
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("- Glow", 0xFF, 0xFF, 0x00);
// Render anything glowing.
if (!m_mipviz && !m_wireframe)
{
irr_driver->setPhase(GLOW_PASS);
renderGlow(overridemat, glows, cambox, cam);
} // end glow
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("- Lensflare/godray", 0x00, 0xFF, 0xFF);
// Is the lens flare enabled & visible? Check last frame's query.
@@ -336,14 +314,6 @@ void IrrDriver::renderGLSL(float dt)
}
PROFILER_POP_CPU_MARKER();
// Drawing for this cam done, cleanup
const u32 glowrepcount = transparent_glow_nodes.size();
for (i = 0; i < glowrepcount; i++)
{
transparent_glow_nodes[i]->remove();
transparent_glow_nodes[i]->drop();
}
PROFILER_POP_CPU_MARKER();
// Note that drawAll must be called before rendering

View File

@@ -423,7 +423,7 @@ namespace MeshShader
void ObjectRefPass1Shader::init()
{
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/objectref_pass1.vert").c_str(),
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");