Moved skybox from IrrDriver to Renderer class
This commit is contained in:
parent
a753008521
commit
288b9db71b
@ -199,6 +199,7 @@ void AbstractRenderer::drawJoint(bool drawline, bool drawname,
|
||||
|
||||
AbstractRenderer::AbstractRenderer()
|
||||
{
|
||||
m_wireframe = false;
|
||||
m_mipviz = false;
|
||||
|
||||
m_wireframe = false;
|
||||
m_mipviz = false;
|
||||
}
|
||||
|
@ -43,10 +43,16 @@ protected:
|
||||
irr::scene::ISkinnedMesh* mesh, int id) const;
|
||||
#endif
|
||||
|
||||
void renderSkybox(const irr::scene::ICameraSceneNode *camera) const;
|
||||
|
||||
|
||||
public:
|
||||
AbstractRenderer();
|
||||
virtual ~AbstractRenderer(){}
|
||||
|
||||
virtual void addSkyBox(const std::vector<irr::video::ITexture*> &texture) {}
|
||||
virtual void removeSkyBox() {}
|
||||
|
||||
virtual void addSunLight(const irr::core::vector3df &pos){}
|
||||
|
||||
virtual void addGlowingNode(irr::scene::ISceneNode *n,
|
||||
|
@ -124,7 +124,6 @@ IrrDriver::IrrDriver()
|
||||
m_post_processing = NULL;
|
||||
m_renderer = NULL;
|
||||
m_wind = new Wind();
|
||||
m_skybox = NULL;
|
||||
m_spherical_harmonics = NULL;
|
||||
|
||||
m_mipviz = m_wireframe = m_normals = m_ssaoviz = false;
|
||||
@ -1382,10 +1381,7 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*> &tex
|
||||
{
|
||||
assert(texture.size() == 6);
|
||||
|
||||
if (CVS->isGLSL())
|
||||
{
|
||||
m_skybox = new Skybox(texture);
|
||||
}
|
||||
m_renderer->addSkyBox(texture);
|
||||
|
||||
if(spherical_harmonics_textures.size() == 6)
|
||||
{
|
||||
@ -1399,8 +1395,7 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*> &tex
|
||||
|
||||
void IrrDriver::suppressSkyBox()
|
||||
{
|
||||
delete m_skybox;
|
||||
m_skybox = NULL;
|
||||
m_renderer->removeSkyBox();;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "ISkinnedMesh.h"
|
||||
#include "graphics/abstract_renderer.hpp"
|
||||
#include "graphics/gl_headers.hpp"
|
||||
#include "graphics/skybox.hpp"
|
||||
#include "graphics/sphericalHarmonics.hpp"
|
||||
#include "graphics/wind.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
@ -223,7 +222,6 @@ private:
|
||||
/** Matrixes used in several places stored here to avoid recomputation. */
|
||||
core::matrix4 m_ViewMatrix, m_InvViewMatrix, m_ProjMatrix, m_InvProjMatrix, m_ProjViewMatrix, m_InvProjViewMatrix;
|
||||
|
||||
Skybox *m_skybox;
|
||||
SphericalHarmonics *m_spherical_harmonics;
|
||||
|
||||
private:
|
||||
@ -328,7 +326,6 @@ public:
|
||||
void getOpenGLData(std::string *vendor, std::string *renderer,
|
||||
std::string *version);
|
||||
|
||||
void renderSkybox(const scene::ICameraSceneNode *camera);
|
||||
void setPhase(STKRenderingPass);
|
||||
STKRenderingPass getPhase() const;
|
||||
void IncreaseObjectCount();
|
||||
@ -510,9 +507,7 @@ public:
|
||||
inline PostProcessing* getPostProcessing() {return m_post_processing;}
|
||||
// ------------------------------------------------------------------------
|
||||
inline core::vector3df getWind() {return m_wind->getWind();}
|
||||
// -----------------------------------------------------------------------
|
||||
/** Returns a pointer to the skybox. */
|
||||
inline Skybox *getSkybox() {return m_skybox;}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
/** Returns a pointer to spherical harmonics. */
|
||||
inline SphericalHarmonics *getSphericalHarmonics() {return m_spherical_harmonics;}
|
||||
|
@ -465,7 +465,8 @@ void LightingPasses::renderGlobalIllumination( const ShadowMatrices& shadow_mat
|
||||
// ----------------------------------------------------------------------------
|
||||
void LightingPasses::renderLights( bool has_shadow,
|
||||
const FrameBuffer& shadow_framebuffer,
|
||||
const FrameBuffer& diffuse_specular_framebuffer)
|
||||
const FrameBuffer& diffuse_specular_framebuffer,
|
||||
GLuint specular_probe)
|
||||
{
|
||||
PostProcessing *post_processing = irr_driver->getPostProcessing();
|
||||
|
||||
@ -474,15 +475,7 @@ void LightingPasses::renderLights( bool has_shadow,
|
||||
|
||||
{
|
||||
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_ENVMAP));
|
||||
Skybox *skybox = irr_driver->getSkybox();
|
||||
if(skybox)
|
||||
{
|
||||
post_processing->renderEnvMap(skybox->getSpecularProbe());
|
||||
}
|
||||
else
|
||||
{
|
||||
post_processing->renderEnvMap(0);
|
||||
}
|
||||
post_processing->renderEnvMap(specular_probe);
|
||||
}
|
||||
|
||||
// Render sunlight if and only if track supports shadow
|
||||
|
@ -39,7 +39,8 @@ public:
|
||||
const FrameBuffer& diffuse_framebuffer);
|
||||
void renderLights( bool has_shadow,
|
||||
const FrameBuffer& shadow_framebuffer,
|
||||
const FrameBuffer& diffuse_specular_framebuffer);
|
||||
const FrameBuffer& diffuse_specular_framebuffer,
|
||||
GLuint specular_probe);
|
||||
void renderAmbientScatter();
|
||||
void renderLightsScatter();
|
||||
|
||||
|
@ -125,15 +125,15 @@ Material* MaterialManager::getDefaultMaterial(video::E_MATERIAL_TYPE shader_type
|
||||
if (it == m_default_materials.end())
|
||||
{
|
||||
Material* default_material = new Material("", false, false, false);
|
||||
|
||||
|
||||
// TODO: workaround, should not hardcode these material types here?
|
||||
// Try to find a cleaner way
|
||||
// If graphics are disabled, shaders should not be accessed (getShader
|
||||
// asserts that shaders are initialised).
|
||||
if(!ProfileWorld::isNoGraphics() &&
|
||||
if(CVS->isGLSL() && !ProfileWorld::isNoGraphics() &&
|
||||
shader_type == Shaders::getShader(ShaderType::ES_OBJECT_UNLIT))
|
||||
default_material->setShaderType(Material::SHADERTYPE_SOLID_UNLIT);
|
||||
else if (!ProfileWorld::isNoGraphics() &&
|
||||
else if (CVS->isGLSL() && !ProfileWorld::isNoGraphics() &&
|
||||
shader_type == Shaders::getShader(ShaderType::ES_OBJECTPASS_REF))
|
||||
default_material->setShaderType(Material::SHADERTYPE_ALPHA_TEST);
|
||||
//else if (!ProfileWorld::isNoGraphics() &&
|
||||
@ -141,7 +141,7 @@ Material* MaterialManager::getDefaultMaterial(video::E_MATERIAL_TYPE shader_type
|
||||
// default_material->setShaderType(Material::SHADERTYPE_ALPHA_BLEND);
|
||||
else
|
||||
default_material->setShaderType(Material::SHADERTYPE_SOLID);
|
||||
|
||||
|
||||
m_default_materials[shader_type] = default_material;
|
||||
return default_material;
|
||||
}
|
||||
|
@ -1,58 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2009-2015 Joerg Henrichs
|
||||
//
|
||||
// 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/irr_driver.hpp"
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/callbacks.hpp"
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/glwrap.hpp"
|
||||
#include "graphics/graphics_restrictions.hpp"
|
||||
#include "graphics/lod_node.hpp"
|
||||
#include "graphics/post_processing.hpp"
|
||||
#include "graphics/referee.hpp"
|
||||
#include "graphics/rtts.hpp"
|
||||
#include "graphics/screen_quad.hpp"
|
||||
#include "graphics/shaders.hpp"
|
||||
#include "graphics/shadow_matrices.hpp"
|
||||
#include "graphics/shared_gpu_objects.hpp"
|
||||
#include "graphics/stk_mesh_scene_node.hpp"
|
||||
#include "graphics/stk_scene_manager.hpp"
|
||||
#include "items/item_manager.hpp"
|
||||
#include "items/powerup_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "physics/physics.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/profiler.hpp"
|
||||
|
||||
#define MAX2(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MIN2(a, b) ((a) > (b) ? (b) : (a))
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void IrrDriver::renderSkybox(const scene::ICameraSceneNode *camera)
|
||||
{
|
||||
if(m_skybox)
|
||||
{
|
||||
m_skybox->render(camera);
|
||||
}
|
||||
} // renderSkybox
|
||||
|
||||
|
||||
|
||||
|
@ -164,6 +164,16 @@ void ShaderBasedRenderer::computeMatrixesAndCameras(scene::ICameraSceneNode *con
|
||||
m_shadow_matrices.computeMatrixesAndCameras(camnode, width, height);
|
||||
} // computeMatrixesAndCameras
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void ShaderBasedRenderer::renderSkybox(const scene::ICameraSceneNode *camera) const
|
||||
{
|
||||
if(m_skybox)
|
||||
{
|
||||
m_skybox->render(camera);
|
||||
}
|
||||
} // renderSkybox
|
||||
|
||||
|
||||
// ============================================================================
|
||||
void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
|
||||
float dt,
|
||||
@ -258,9 +268,20 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
|
||||
irr_driver->getRTT()->getFBO(FBO_DIFFUSE));
|
||||
}
|
||||
|
||||
GLuint specular_probe;
|
||||
if(m_skybox)
|
||||
{
|
||||
specular_probe = m_skybox->getSpecularProbe();
|
||||
}
|
||||
else
|
||||
{
|
||||
specular_probe = 0;
|
||||
}
|
||||
|
||||
m_lighting_passes.renderLights( hasShadow,
|
||||
irr_driver->getRTT()->getShadowFrameBuffer(),
|
||||
irr_driver->getRTT()->getFBO(FBO_COMBINED_DIFFUSE_SPECULAR));
|
||||
irr_driver->getRTT()->getFBO(FBO_COMBINED_DIFFUSE_SPECULAR),
|
||||
specular_probe);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
||||
@ -318,7 +339,7 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- Skybox", 0xFF, 0x00, 0xFF);
|
||||
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_SKYBOX));
|
||||
irr_driver->renderSkybox(camnode);
|
||||
renderSkybox(camnode);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
||||
@ -507,6 +528,8 @@ void ShaderBasedRenderer::renderPostProcessing(Camera * const camera)
|
||||
|
||||
ShaderBasedRenderer::ShaderBasedRenderer()
|
||||
{
|
||||
|
||||
m_skybox = NULL;
|
||||
m_nb_static_glowing = 0;
|
||||
|
||||
if (CVS->isAZDOEnabled())
|
||||
@ -522,7 +545,20 @@ ShaderBasedRenderer::~ShaderBasedRenderer()
|
||||
delete m_geometry_passes;
|
||||
}
|
||||
|
||||
void ShaderBasedRenderer::addSunLight(const core::vector3df &pos) {
|
||||
|
||||
void ShaderBasedRenderer::addSkyBox(const std::vector<video::ITexture*> &texture)
|
||||
{
|
||||
m_skybox = new Skybox(texture);
|
||||
}
|
||||
|
||||
void ShaderBasedRenderer::removeSkyBox()
|
||||
{
|
||||
delete m_skybox;
|
||||
m_skybox = NULL;
|
||||
}
|
||||
|
||||
void ShaderBasedRenderer::addSunLight(const core::vector3df &pos)
|
||||
{
|
||||
m_shadow_matrices.addLight(pos);
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,16 @@
|
||||
#include "graphics/geometry_passes.hpp"
|
||||
#include "graphics/lighting_passes.hpp"
|
||||
#include "graphics/shadow_matrices.hpp"
|
||||
#include "graphics/skybox.hpp"
|
||||
#include "graphics/sphericalHarmonics.hpp"
|
||||
|
||||
|
||||
class ShaderBasedRenderer: public AbstractRenderer
|
||||
{
|
||||
private:
|
||||
Skybox *m_skybox;
|
||||
//SphericalHarmonics *m_spherical_harmonics;
|
||||
|
||||
|
||||
//GLsync m_sync; //TODO
|
||||
DrawCalls m_draw_calls;
|
||||
@ -59,6 +64,9 @@ private:
|
||||
|
||||
void resetShadowCamNodes(){m_shadow_matrices.resetShadowCamNodes();}
|
||||
|
||||
void renderSkybox(const scene::ICameraSceneNode *camera) const;
|
||||
|
||||
|
||||
void prepareDrawCalls(scene::ICameraSceneNode *camnode);
|
||||
|
||||
void renderScene(irr::scene::ICameraSceneNode * const camnode,
|
||||
@ -75,6 +83,9 @@ public:
|
||||
ShaderBasedRenderer();
|
||||
~ShaderBasedRenderer();
|
||||
|
||||
void addSkyBox(const std::vector<irr::video::ITexture*> &texture) override;
|
||||
void removeSkyBox() override;
|
||||
|
||||
void addSunLight(const irr::core::vector3df &pos) override;
|
||||
|
||||
void addGlowingNode(scene::ISceneNode *n,
|
||||
|
Loading…
x
Reference in New Issue
Block a user