Improved interfaces
This commit is contained in:
@@ -29,9 +29,6 @@
|
||||
#include <SColor.h>
|
||||
#include <S3DVertex.h>
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\page geometry_passes Geometry Rendering Overview
|
||||
|
||||
@@ -41,9 +38,9 @@ You need to consider twice before adding a new material : in the worst case a ma
|
||||
one for each solid pass, one for shadow pass, one for RSM pass, and you need to double that for instanced version.
|
||||
|
||||
You need to declare a new enum in MeshMaterial and to write the corresponding dispatch code in getMeshMaterialFromType
|
||||
and to create 2 new List* structures (one for standard and one for instanced version).
|
||||
and to create a new List* structure for non instanced.
|
||||
|
||||
Then you need to write the code in shader_based_renderer.cpp that will add any mesh with the new material to their corresponding
|
||||
Then you need to write the code in draw_calls.cpp that will add any mesh with the new material to their corresponding
|
||||
lists : in handleSTKCommon for the standard version and in the body of prepareDrawCalls for instanced version.
|
||||
|
||||
\section vertex_layout Available Vertex Layout
|
||||
@@ -73,12 +70,8 @@ layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 5) in vec3 Tangent;
|
||||
layout(location = 6) in vec3 Bitangent;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
// ============================================================================
|
||||
namespace RenderGeometry
|
||||
{
|
||||
@@ -132,7 +125,6 @@ namespace RenderGeometry
|
||||
|
||||
using namespace RenderGeometry;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void AbstractGeometryPasses::prepareShadowRendering(const FrameBuffer& shadow_framebuffer) const
|
||||
{
|
||||
@@ -156,6 +148,7 @@ void AbstractGeometryPasses::prepareShadowRendering(const FrameBuffer& shadow_fr
|
||||
glClearColor(0., 0., 0., 0.);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void AbstractGeometryPasses::shadowPostProcessing(const ShadowMatrices& shadow_matrices,
|
||||
const FrameBuffer& shadow_framebuffer,
|
||||
const FrameBuffer& scalar_framebuffer,
|
||||
@@ -180,33 +173,6 @@ void AbstractGeometryPasses::shadowPostProcessing(const ShadowMatrices& shadow_m
|
||||
glGenerateMipmap(GL_TEXTURE_2D_ARRAY);
|
||||
}
|
||||
|
||||
|
||||
void AbstractGeometryPasses::glowPostProcessing(const FrameBuffer& glow_framebuffer,
|
||||
const FrameBuffer& half_framebuffer,
|
||||
const FrameBuffer& quarter_framebuffer,
|
||||
const FrameBuffer& color_framebuffer,
|
||||
GLuint quarter_render_target,
|
||||
const PostProcessing* post_processing) const
|
||||
{
|
||||
// To half
|
||||
FrameBuffer::Blit(glow_framebuffer, half_framebuffer, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
// To quarter
|
||||
FrameBuffer::Blit(half_framebuffer, quarter_framebuffer, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glStencilFunc(GL_EQUAL, 0, ~0);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
color_framebuffer.bind();
|
||||
post_processing->renderGlow(quarter_render_target);//TODO
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
|
||||
}
|
||||
|
||||
|
||||
AbstractGeometryPasses::AbstractGeometryPasses()
|
||||
{
|
||||
m_displace_tex = irr_driver->getTexture(FileManager::TEXTURE, "displace.png");
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
#include "utils/profiler.hpp"
|
||||
#include <ITexture.h>
|
||||
|
||||
|
||||
|
||||
|
||||
class AbstractGeometryPasses
|
||||
{
|
||||
protected:
|
||||
@@ -42,15 +39,7 @@ protected:
|
||||
const FrameBuffer& shadow_framebuffer,
|
||||
const FrameBuffer& scalar_framebuffer,
|
||||
const PostProcessing* post_processing) const;
|
||||
|
||||
//TODO: move it in ShaderBasedRenderer
|
||||
void glowPostProcessing(const FrameBuffer& glow_framebuffer,
|
||||
const FrameBuffer& half_framebuffer,
|
||||
const FrameBuffer& quater_framebuffer,
|
||||
const FrameBuffer& color_framebuffer,
|
||||
GLuint quarter_render_target,
|
||||
const PostProcessing* post_processing) const;
|
||||
|
||||
|
||||
public:
|
||||
AbstractGeometryPasses();
|
||||
virtual ~AbstractGeometryPasses(){}
|
||||
@@ -63,14 +52,9 @@ public:
|
||||
|
||||
virtual void renderNormalsVisualisation(const DrawCalls& draw_calls) const = 0;
|
||||
|
||||
virtual void renderGlow(const DrawCalls& draw_calls,
|
||||
const std::vector<GlowData>& glows,
|
||||
const FrameBuffer& glow_framebuffer,
|
||||
const FrameBuffer& half_framebuffer,
|
||||
const FrameBuffer& quarter_framebuffer,
|
||||
const FrameBuffer& color_framebuffer,
|
||||
GLuint quarter_render_target,
|
||||
const PostProcessing* post_processing ) const = 0;
|
||||
virtual void renderGlowingObjects(const DrawCalls& draw_calls,
|
||||
const std::vector<GlowData>& glows,
|
||||
const FrameBuffer& glow_framebuffer) const = 0;
|
||||
|
||||
void renderTransparent(const DrawCalls& draw_calls,
|
||||
const FrameBuffer& tmp_framebuffer,
|
||||
@@ -78,41 +62,38 @@ public:
|
||||
const FrameBuffer& colors_framebuffer,
|
||||
const PostProcessing* post_processing);
|
||||
|
||||
virtual void renderShadows(const DrawCalls& draw_calls,
|
||||
const ShadowMatrices& shadow_matrices,
|
||||
const FrameBuffer& shadow_framebuffer,
|
||||
const FrameBuffer& scalar_framebuffer,
|
||||
const PostProcessing* post_processing) const = 0;
|
||||
virtual void renderShadows (const DrawCalls& draw_calls,
|
||||
const ShadowMatrices& shadow_matrices,
|
||||
const FrameBuffer& shadow_framebuffer,
|
||||
const FrameBuffer& scalar_framebuffer,
|
||||
const PostProcessing* post_processing ) const = 0;
|
||||
|
||||
|
||||
virtual void renderReflectiveShadowMap(const DrawCalls& draw_calls,
|
||||
const ShadowMatrices& shadow_matrices,
|
||||
const FrameBuffer& reflective_shadow_map_framebuffer) const = 0 ;
|
||||
|
||||
|
||||
};
|
||||
|
||||
template<typename DrawPolicy>
|
||||
class GeometryPasses: public AbstractGeometryPasses, public DrawPolicy
|
||||
{
|
||||
public:
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Render the solid first pass (depth and normals)*/
|
||||
void renderSolidFirstPass(const DrawCalls& draw_calls) const
|
||||
{
|
||||
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_SOLID_PASS1));
|
||||
irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS);
|
||||
|
||||
draw_calls.renderImmediateDrawList();
|
||||
DrawPolicy::drawSolidFirstPass(draw_calls);
|
||||
|
||||
} // renderSolidFirstPass
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Render the solid second pass (apply lighting on materials) */
|
||||
void renderSolidSecondPass( const DrawCalls& draw_calls) const
|
||||
{
|
||||
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_SOLID_PASS2));
|
||||
irr_driver->setPhase(SOLID_LIT_PASS);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
draw_calls.renderImmediateDrawList();
|
||||
DrawPolicy::drawSolidSecondPass(draw_calls,
|
||||
m_textures_handles,
|
||||
@@ -125,14 +106,9 @@ public:
|
||||
DrawPolicy::drawNormals(draw_calls);
|
||||
}
|
||||
|
||||
void renderGlow(const DrawCalls& draw_calls,
|
||||
const std::vector<GlowData>& glows,
|
||||
const FrameBuffer& glow_framebuffer,
|
||||
const FrameBuffer& half_framebuffer,
|
||||
const FrameBuffer& quarter_framebuffer,
|
||||
const FrameBuffer& color_framebuffer,
|
||||
GLuint quarter_render_target,
|
||||
const PostProcessing* post_processing) const
|
||||
void renderGlowingObjects(const DrawCalls& draw_calls,
|
||||
const std::vector<GlowData>& glows,
|
||||
const FrameBuffer& glow_framebuffer) const
|
||||
{
|
||||
irr_driver->getSceneManager()->setCurrentRendertime(scene::ESNRP_SOLID);
|
||||
glow_framebuffer.bind();
|
||||
@@ -152,13 +128,6 @@ public:
|
||||
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glowPostProcessing(glow_framebuffer, half_framebuffer,
|
||||
quarter_framebuffer, color_framebuffer,
|
||||
quarter_render_target,
|
||||
post_processing);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1187,9 +1187,26 @@ void PostProcessing::renderTextureLayer(unsigned tex, unsigned layer) const
|
||||
} // renderTextureLayer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void PostProcessing::renderGlow(unsigned tex) const
|
||||
void PostProcessing::renderGlow(const FrameBuffer& glow_framebuffer,
|
||||
const FrameBuffer& half_framebuffer,
|
||||
const FrameBuffer& quarter_framebuffer,
|
||||
const FrameBuffer& color_framebuffer ) const
|
||||
{
|
||||
GlowShader::getInstance()->render(tex);
|
||||
// To half
|
||||
FrameBuffer::Blit(glow_framebuffer, half_framebuffer, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
// To quarter
|
||||
FrameBuffer::Blit(half_framebuffer, quarter_framebuffer, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glStencilFunc(GL_EQUAL, 0, ~0);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
color_framebuffer.bind();
|
||||
GlowShader::getInstance()->render(quarter_framebuffer.getRTT()[0]);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
} // renderGlow
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -112,7 +112,10 @@ public:
|
||||
void renderMotionBlur(unsigned cam, const FrameBuffer &in_fbo,
|
||||
FrameBuffer &out_fbo,
|
||||
GLuint depth_stencil_texture);
|
||||
void renderGlow(unsigned tex) const;
|
||||
void renderGlow(const FrameBuffer& glow_framebuffer,
|
||||
const FrameBuffer& half_framebuffer,
|
||||
const FrameBuffer& quarter_framebuffer,
|
||||
const FrameBuffer& color_framebuffer) const;
|
||||
void renderLightning(core::vector3df intensity);
|
||||
|
||||
/** Use motion blur for a short time */
|
||||
|
||||
@@ -393,6 +393,8 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
|
||||
glDepthMask(GL_FALSE);
|
||||
}
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
m_geometry_passes->renderSolidSecondPass(m_draw_calls);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
@@ -463,13 +465,13 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
|
||||
{
|
||||
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_GLOW));
|
||||
irr_driver->setPhase(GLOW_PASS);
|
||||
m_geometry_passes->renderGlow(m_draw_calls, m_glowing,
|
||||
m_rtts->getFBO(FBO_TMP1_WITH_DS),
|
||||
m_geometry_passes->renderGlowingObjects(m_draw_calls, m_glowing,
|
||||
m_rtts->getFBO(FBO_TMP1_WITH_DS));
|
||||
|
||||
m_post_processing->renderGlow(m_rtts->getFBO(FBO_TMP1_WITH_DS),
|
||||
m_rtts->getFBO(FBO_HALF1),
|
||||
m_rtts->getFBO(FBO_QUARTER1),
|
||||
m_rtts->getFBO(FBO_COLORS),
|
||||
m_rtts->getRenderTarget(RTT_QUARTER1),
|
||||
m_post_processing);
|
||||
m_rtts->getFBO(FBO_COLORS));
|
||||
} // end glow
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user