Merge branch 'fboencapsulate'
This commit is contained in:
commit
8673d36885
@ -1,10 +1,19 @@
|
||||
uniform sampler2D displacement_tex;
|
||||
uniform sampler2D mask_tex;
|
||||
uniform sampler2D color_tex;
|
||||
uniform vec2 screen;
|
||||
uniform vec2 dir;
|
||||
uniform vec2 dir2;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
|
@ -1,7 +1,15 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D dtex;
|
||||
uniform mat4 invprojm;
|
||||
uniform vec2 screen;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
@ -13,7 +21,7 @@ float range = 100.;
|
||||
void main()
|
||||
{
|
||||
float curdepth = texture(dtex, uv).x;
|
||||
vec4 FragPos = invprojm * (2.0f * vec4(uv, curdepth, 1.0f) - 1.0f);
|
||||
vec4 FragPos = InverseProjectionMatrix * (2.0f * vec4(uv, curdepth, 1.0f) - 1.0f);
|
||||
FragPos /= FragPos.w;
|
||||
|
||||
float depth = FragPos.z;
|
||||
|
@ -1,5 +1,12 @@
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 ViewMatrix;
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
in vec2 quadcorner;
|
||||
in vec2 texcoord;
|
||||
|
@ -20,6 +20,7 @@ layout (std140) uniform MatrixesData
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -5,6 +5,7 @@ layout (std140) uniform MatrixesData
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
uniform vec3 windDir;
|
||||
|
@ -11,6 +11,7 @@ layout (std140) uniform MatrixesData
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -11,6 +11,7 @@ layout (std140) uniform MatrixesData
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -2,9 +2,18 @@ uniform sampler2D Albedo;
|
||||
uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
|
@ -11,11 +11,11 @@ layout (std140) uniform MatrixesData
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
uniform samplerCube tex;
|
||||
uniform vec2 screen;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 nor;
|
||||
|
@ -1,7 +1,16 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D dtex;
|
||||
uniform mat4 invproj;
|
||||
uniform vec2 screen;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
in float lf;
|
||||
in vec2 tc;
|
||||
|
@ -1,5 +1,12 @@
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 ViewMatrix;
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
uniform vec3 color_from;
|
||||
uniform vec3 color_to;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
uniform sampler2D ntex;
|
||||
uniform sampler2D dtex;
|
||||
uniform float spec;
|
||||
uniform vec2 screen;
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
@ -16,6 +15,7 @@ layout (std140) uniform MatrixesData
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -11,6 +11,7 @@ layout (std140) uniform MatrixesData
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -11,12 +11,11 @@ layout (std140) uniform MatrixesData
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
uniform samplerCube tex;
|
||||
uniform vec2 screen;
|
||||
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
out vec4 FragColor;
|
||||
|
@ -6,9 +6,18 @@ uniform sampler2D tex_detail3;
|
||||
uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
uniform sampler2D dtex;
|
||||
uniform vec4 samplePoints[16];
|
||||
uniform vec2 screen;
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
@ -18,6 +17,7 @@ layout (std140) uniform MatrixesData
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -6,8 +6,17 @@ uniform float endH;
|
||||
uniform float start;
|
||||
uniform float end;
|
||||
uniform vec3 col;
|
||||
uniform mat4 ipvmat;
|
||||
uniform vec2 screen;
|
||||
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
@ -26,7 +35,7 @@ void main()
|
||||
tmp = 2. * tmp - 1.;
|
||||
|
||||
vec4 xpos = vec4(tmp, 1.0);
|
||||
xpos = ipvmat * xpos;
|
||||
xpos = InverseProjectionMatrix * xpos;
|
||||
xpos.xyz /= xpos.w;
|
||||
|
||||
float dist = length(xpos.xyz);
|
||||
|
@ -1,9 +1,18 @@
|
||||
uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
vec3 getLightFactor(float specMapValue)
|
||||
{
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
|
@ -476,15 +476,6 @@ void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum
|
||||
glGetError();
|
||||
}
|
||||
|
||||
void blitFBO(GLuint Src, GLuint Dst, size_t width, size_t height)
|
||||
{
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, Src);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, Dst);
|
||||
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
ScopedGPUTimer::ScopedGPUTimer(GPUTimer &timer)
|
||||
{
|
||||
if (!UserConfigParams::m_profiler_enabled) return;
|
||||
@ -525,6 +516,64 @@ unsigned GPUTimer::elapsedTimeus()
|
||||
return result / 1000;
|
||||
}
|
||||
|
||||
FrameBuffer::FrameBuffer() {}
|
||||
|
||||
FrameBuffer::FrameBuffer(const std::vector<GLuint> &RTTs, size_t w, size_t h) :
|
||||
DepthTexture(0), RenderTargets(RTTs), width(w), height(h)
|
||||
{
|
||||
glGenFramebuffers(1, &fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
for (unsigned i = 0; i < RTTs.size(); i++)
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, RTTs[i], 0);
|
||||
GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
assert(result == GL_FRAMEBUFFER_COMPLETE_EXT);
|
||||
}
|
||||
|
||||
FrameBuffer::FrameBuffer(const std::vector<GLuint> &RTTs, GLuint DS, size_t w, size_t h) :
|
||||
DepthTexture(DS), RenderTargets(RTTs), width(w), height(h)
|
||||
{
|
||||
glGenFramebuffers(1, &fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
for (unsigned i = 0; i < RTTs.size(); i++)
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, RTTs[i], 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, DS, 0);
|
||||
GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
assert(result == GL_FRAMEBUFFER_COMPLETE_EXT);
|
||||
}
|
||||
|
||||
FrameBuffer::~FrameBuffer()
|
||||
{
|
||||
glDeleteFramebuffers(1, &fbo);
|
||||
}
|
||||
|
||||
void FrameBuffer::Bind()
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
glViewport(0, 0, width, height);
|
||||
irr::video::COpenGLDriver *gl_driver = (irr::video::COpenGLDriver*)irr_driver->getDevice()->getVideoDriver();
|
||||
GLenum bufs[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
|
||||
gl_driver->extGlDrawBuffers(RenderTargets.size(), bufs);
|
||||
}
|
||||
|
||||
void FrameBuffer::Blit(const FrameBuffer &Src, FrameBuffer &Dst, GLbitfield mask, GLenum filter)
|
||||
{
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, Src.fbo);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, Dst.fbo);
|
||||
glBlitFramebuffer(0, 0, Src.width, Src.height, 0, 0, Dst.width, Dst.height, mask, filter);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
void FrameBuffer::BlitToDefault(size_t x0, size_t y0, size_t x1, size_t y1)
|
||||
{
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
glBlitFramebuffer(0, 0, width, height, x0, y0, x1, y1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
void draw3DLine(const core::vector3df& start,
|
||||
const core::vector3df& end, irr::video::SColor color)
|
||||
{
|
||||
|
@ -24,6 +24,7 @@
|
||||
# include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include "utils/log.hpp"
|
||||
|
||||
// already includes glext.h, which defines useful GL constants.
|
||||
@ -180,6 +181,27 @@ public:
|
||||
unsigned elapsedTimeus();
|
||||
};
|
||||
|
||||
class FrameBuffer
|
||||
{
|
||||
private:
|
||||
GLuint fbo;
|
||||
std::vector<GLuint> RenderTargets;
|
||||
GLuint DepthTexture;
|
||||
size_t width, height;
|
||||
public:
|
||||
FrameBuffer();
|
||||
FrameBuffer(const std::vector <GLuint> &RTTs, size_t w, size_t h);
|
||||
FrameBuffer(const std::vector <GLuint> &RTTs, GLuint DS, size_t w, size_t h);
|
||||
~FrameBuffer();
|
||||
void Bind();
|
||||
std::vector<GLuint> &getRTT() { return RenderTargets; }
|
||||
GLuint &getDepthTexture() { assert(DepthTexture); return DepthTexture; }
|
||||
size_t getWidth() const { return width; }
|
||||
size_t getHeight() const { return height; }
|
||||
static void Blit(const FrameBuffer &Src, FrameBuffer &Dst, GLbitfield mask = GL_COLOR_BUFFER_BIT, GLenum filter = GL_NEAREST);
|
||||
void BlitToDefault(size_t, size_t, size_t, size_t);
|
||||
};
|
||||
|
||||
// core::rect<s32> needs these includes
|
||||
#include <rect.h>
|
||||
#include "utils/vec3.hpp"
|
||||
@ -190,7 +212,6 @@ void resetTextureTable();
|
||||
void compressTexture(irr::video::ITexture *tex, bool srgb, bool premul_alpha = false);
|
||||
bool loadCompressedTexture(const std::string& compressed_tex);
|
||||
void saveCompressedTexture(const std::string& compressed_tex);
|
||||
void blitFBO(GLuint Src, GLuint Dst, size_t width, size_t height);
|
||||
|
||||
void draw3DLine(const core::vector3df& start,
|
||||
const core::vector3df& end, irr::video::SColor color);
|
||||
|
@ -472,9 +472,6 @@ void IrrDriver::initDevice()
|
||||
if (m_glsl)
|
||||
{
|
||||
Log::info("irr_driver", "GLSL supported.");
|
||||
|
||||
// Order matters, create RTTs as soon as possible, as they are the largest blocks.
|
||||
m_rtts = new RTT();
|
||||
}
|
||||
// m_glsl might be reset in rtt if an error occurs.
|
||||
if(m_glsl)
|
||||
@ -1560,7 +1557,22 @@ video::ITexture* IrrDriver::applyMask(video::ITexture* texture,
|
||||
mask->drop();
|
||||
return t;
|
||||
} // applyMask
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void IrrDriver::onLoadWorld()
|
||||
{
|
||||
if (m_glsl)
|
||||
{
|
||||
const core::recti &viewport = Camera::getCamera(0)->getViewport();
|
||||
size_t width = viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, height = viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y;
|
||||
m_rtts = new RTT(width, height);
|
||||
}
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
void IrrDriver::onUnloadWorld()
|
||||
{
|
||||
delete m_rtts;
|
||||
m_rtts = NULL;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Sets the ambient light.
|
||||
* \param light The colour of the light to set.
|
||||
|
@ -276,7 +276,7 @@ private:
|
||||
void renderParticles();
|
||||
void computeSunVisibility();
|
||||
void renderScene(scene::ICameraSceneNode * const camnode, std::vector<GlowData>& glows, float dt, bool hasShadows);
|
||||
void computeCameraMatrix(scene::ICameraSceneNode * const camnode);
|
||||
void computeCameraMatrix(scene::ICameraSceneNode * const camnode, size_t width, size_t height);
|
||||
void renderShadows();
|
||||
void renderGlow(std::vector<GlowData>& glows);
|
||||
void renderSSAO();
|
||||
@ -478,7 +478,7 @@ public:
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
inline GLuint getRenderTargetTexture(TypeRTT which) { return m_rtts->getRenderTarget(which); }
|
||||
inline GLuint getFBO(TypeFBO which) { return m_rtts->getFBO(which); }
|
||||
inline FrameBuffer& getFBO(TypeFBO which) { return m_rtts->getFBO(which); }
|
||||
inline GLuint getDepthStencilTexture() { return m_rtts->getDepthStencilTexture(); }
|
||||
// ------------------------------------------------------------------------
|
||||
inline bool isGLSL() const { return m_glsl; }
|
||||
@ -590,6 +590,10 @@ public:
|
||||
} // addDebugMesh
|
||||
|
||||
#endif
|
||||
|
||||
void onLoadWorld();
|
||||
void onUnloadWorld();
|
||||
|
||||
// --------------------- RTT --------------------
|
||||
/**
|
||||
* Class that provides RTT (currently, only when no other 3D rendering
|
||||
|
@ -317,17 +317,18 @@ void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &su
|
||||
}
|
||||
|
||||
|
||||
void PostProcessing::renderGaussian3Blur(GLuint in_fbo, GLuint in_tex, GLuint tmp_fbo, GLuint tmp_tex, size_t width, size_t height)
|
||||
void PostProcessing::renderGaussian3Blur(FrameBuffer &in_fbo, FrameBuffer &auxiliary)
|
||||
{
|
||||
float inv_width = 1.0f / width, inv_height = 1.0f / height;
|
||||
assert(in_fbo.getWidth() == auxiliary.getWidth() && in_fbo.getHeight() == auxiliary.getHeight());
|
||||
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, tmp_fbo);
|
||||
auxiliary.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian3VBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3VBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian3VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, in_tex, GL_LINEAR, GL_LINEAR);
|
||||
setTexture(0, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian3VBlurShader::uniform_tex, 0);
|
||||
@ -335,13 +336,13 @@ void PostProcessing::renderGaussian3Blur(GLuint in_fbo, GLuint in_tex, GLuint tm
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, in_fbo);
|
||||
in_fbo.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian3HBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3HBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian3HBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, tmp_tex, GL_LINEAR, GL_LINEAR);
|
||||
setTexture(0, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian3HBlurShader::uniform_tex, 0);
|
||||
@ -350,17 +351,18 @@ void PostProcessing::renderGaussian3Blur(GLuint in_fbo, GLuint in_tex, GLuint tm
|
||||
}
|
||||
}
|
||||
|
||||
void PostProcessing::renderGaussian6Blur(GLuint in_fbo, GLuint in_tex, GLuint tmp_fbo, GLuint tmp_tex, size_t width, size_t height)
|
||||
void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxiliary)
|
||||
{
|
||||
float inv_width = 1.f / width, inv_height = 1.f / height;
|
||||
assert(in_fbo.getWidth() == auxiliary.getWidth() && in_fbo.getHeight() == auxiliary.getHeight());
|
||||
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, tmp_fbo);
|
||||
auxiliary.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian6VBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6VBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian6VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, in_tex, GL_LINEAR, GL_LINEAR);
|
||||
setTexture(0, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian6VBlurShader::uniform_tex, 0);
|
||||
@ -368,13 +370,13 @@ void PostProcessing::renderGaussian6Blur(GLuint in_fbo, GLuint in_tex, GLuint tm
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, in_fbo);
|
||||
in_fbo.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian6HBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6HBlurShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian6HBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, tmp_tex, GL_LINEAR, GL_LINEAR);
|
||||
setTexture(0, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian6HBlurShader::uniform_tex, 0);
|
||||
@ -383,17 +385,18 @@ void PostProcessing::renderGaussian6Blur(GLuint in_fbo, GLuint in_tex, GLuint tm
|
||||
}
|
||||
}
|
||||
|
||||
void PostProcessing::renderGaussian17TapBlur(unsigned in_fbo, unsigned in_tex, unsigned tmp_fbo, unsigned tmp_tex, size_t width, size_t height)
|
||||
void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &auxiliary)
|
||||
{
|
||||
float inv_width = 1.f / width, inv_height = 1.f / height;
|
||||
assert(in_fbo.getWidth() == auxiliary.getWidth() && in_fbo.getHeight() == auxiliary.getHeight());
|
||||
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, tmp_fbo);
|
||||
auxiliary.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian17TapHShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian17TapHShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian17TapHShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, in_tex, GL_LINEAR, GL_LINEAR);
|
||||
setTexture(0, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian17TapHShader::uniform_tex, 0);
|
||||
@ -401,13 +404,13 @@ void PostProcessing::renderGaussian17TapBlur(unsigned in_fbo, unsigned in_tex, u
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, in_fbo);
|
||||
in_fbo.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian17TapVShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian17TapVShader::vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian17TapVShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, tmp_tex, GL_LINEAR, GL_LINEAR);
|
||||
setTexture(0, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian17TapVShader::uniform_tex, 0);
|
||||
@ -452,13 +455,13 @@ void PostProcessing::renderSSAO()
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
||||
// Generate linear depth buffer
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_LINEAR_DEPTH));
|
||||
irr_driver->getFBO(FBO_LINEAR_DEPTH).Bind();
|
||||
glUseProgram(FullScreenShader::LinearizeDepthShader::Program);
|
||||
glBindVertexArray(FullScreenShader::LinearizeDepthShader::vao);
|
||||
setTexture(0, irr_driver->getDepthStencilTexture(), GL_LINEAR, GL_LINEAR);
|
||||
FullScreenShader::LinearizeDepthShader::setUniforms(irr_driver->getSceneManager()->getActiveCamera()->getNearValue(), irr_driver->getSceneManager()->getActiveCamera()->getFarValue(), 0);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_SSAO));
|
||||
irr_driver->getFBO(FBO_SSAO).Bind();
|
||||
|
||||
if (!noise_tex)
|
||||
noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/noise.png").c_str());
|
||||
@ -510,9 +513,8 @@ void PostProcessing::renderFog()
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void PostProcessing::renderMotionBlur(unsigned cam, GLuint in_rtt, GLuint out_fbo)
|
||||
void PostProcessing::renderMotionBlur(unsigned cam, FrameBuffer &in_fbo, FrameBuffer &out_fbo)
|
||||
{
|
||||
|
||||
MotionBlurProvider * const cb = (MotionBlurProvider *)irr_driver->
|
||||
getCallback(ES_MOTIONBLUR);
|
||||
|
||||
@ -529,18 +531,18 @@ void PostProcessing::renderMotionBlur(unsigned cam, GLuint in_rtt, GLuint out_fb
|
||||
const float karty = (ndc[1] / ndc[3]) * 0.5f + 0.5f;
|
||||
setMotionBlurCenterY(cam, karty);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
|
||||
out_fbo.Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glUseProgram(FullScreenShader::MotionBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::MotionBlurShader::vao);
|
||||
|
||||
setTexture(0, in_rtt, GL_NEAREST, GL_NEAREST);
|
||||
setTexture(0, in_fbo.getRTT()[0], GL_NEAREST, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
FullScreenShader::MotionBlurShader
|
||||
::setUniforms(cb->getBoostTime(cam), cb->getCenter(cam),
|
||||
cb->getDirection(cam), 0.15f,
|
||||
cb->getDirection(cam), 0.15f,
|
||||
cb->getMaxHeight(cam) * 0.7f, 0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
@ -566,9 +568,9 @@ static void renderGodRay(GLuint tex, const core::vector2df &sunpos)
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
static void toneMap(GLuint fbo, GLuint rtt)
|
||||
static void toneMap(FrameBuffer &fbo, GLuint rtt)
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
fbo.Bind();
|
||||
glUseProgram(FullScreenShader::ToneMapShader::Program);
|
||||
glBindVertexArray(FullScreenShader::ToneMapShader::vao);
|
||||
setTexture(0, rtt, GL_NEAREST, GL_NEAREST);
|
||||
@ -578,15 +580,14 @@ static void toneMap(GLuint fbo, GLuint rtt)
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
static void renderDoF(GLuint fbo, GLuint rtt)
|
||||
static void renderDoF(FrameBuffer &fbo, GLuint rtt)
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
fbo.Bind();
|
||||
glUseProgram(FullScreenShader::DepthOfFieldShader::Program);
|
||||
glBindVertexArray(FullScreenShader::DepthOfFieldShader::vao);
|
||||
setTexture(0, rtt, GL_LINEAR, GL_LINEAR);
|
||||
setTexture(1, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::DepthOfFieldShader::setUniforms(irr_driver->getInvProjMatrix(), core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height), 0, 1);
|
||||
FullScreenShader::DepthOfFieldShader::setUniforms(0, 1);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
@ -600,8 +601,7 @@ static void averageTexture(GLuint tex)
|
||||
|
||||
static void computeLogLuminance(GLuint tex)
|
||||
{
|
||||
glViewport(0, 0, 1024, 1024);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_LOG_LUMINANCE));
|
||||
irr_driver->getFBO(FBO_LOG_LUMINANCE).Bind();
|
||||
glUseProgram(FullScreenShader::LogLuminanceShader::Program);
|
||||
glBindVertexArray(FullScreenShader::LogLuminanceShader::vao);
|
||||
setTexture(0, tex, GL_LINEAR, GL_LINEAR);
|
||||
@ -616,7 +616,7 @@ void PostProcessing::applyMLAA()
|
||||
{
|
||||
const core::vector2df &PIXEL_SIZE = core::vector2df(1.0f / UserConfigParams::m_width, 1.0f / UserConfigParams::m_height);
|
||||
IVideoDriver *const drv = irr_driver->getVideoDriver();
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_TMP1_WITH_DS));
|
||||
irr_driver->getFBO(FBO_TMP1_WITH_DS).Bind();
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
@ -635,7 +635,7 @@ void PostProcessing::applyMLAA()
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
|
||||
// Pass 2: blend weights
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_TMP2_WITH_DS));
|
||||
irr_driver->getFBO(FBO_TMP2_WITH_DS).Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glUseProgram(FullScreenShader::MLAABlendWeightSHader::Program);
|
||||
@ -647,10 +647,10 @@ void PostProcessing::applyMLAA()
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
// Blit in to tmp1
|
||||
blitFBO(irr_driver->getFBO(FBO_MLAA_COLORS), irr_driver->getFBO(FBO_TMP1_WITH_DS), UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
FrameBuffer::Blit(irr_driver->getFBO(FBO_MLAA_COLORS), irr_driver->getFBO(FBO_TMP1_WITH_DS));
|
||||
|
||||
// Pass 3: gather
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_MLAA_COLORS));
|
||||
irr_driver->getFBO(FBO_MLAA_COLORS).Bind();
|
||||
|
||||
glUseProgram(FullScreenShader::MLAAGatherSHader::Program);
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_TMP1), GL_NEAREST, GL_NEAREST);
|
||||
@ -667,7 +667,7 @@ void PostProcessing::applyMLAA()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Render the post-processed scene */
|
||||
void PostProcessing::render(scene::ICameraSceneNode * const camnode)
|
||||
FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode)
|
||||
{
|
||||
IVideoDriver * const drv = irr_driver->getVideoDriver();
|
||||
|
||||
@ -676,8 +676,8 @@ void PostProcessing::render(scene::ICameraSceneNode * const camnode)
|
||||
GaussianBlurProvider * const gacb = (GaussianBlurProvider *) irr_driver->
|
||||
getCallback(ES_GAUSSIAN3H);
|
||||
|
||||
GLuint in_rtt = irr_driver->getRenderTargetTexture(RTT_COLOR), in_fbo = irr_driver->getFBO(FBO_COLORS);
|
||||
GLuint out_rtt = irr_driver->getRenderTargetTexture(RTT_TMP1), out_fbo = irr_driver->getFBO(FBO_TMP1_WITH_DS);
|
||||
FrameBuffer *in_fbo = &irr_driver->getFBO(FBO_COLORS);
|
||||
FrameBuffer *out_fbo = &irr_driver->getFBO(FBO_TMP1_WITH_DS);
|
||||
// Each effect uses these as named, and sets them up for the next effect.
|
||||
// This allows chaining effects where some may be disabled.
|
||||
|
||||
@ -687,8 +687,7 @@ void PostProcessing::render(scene::ICameraSceneNode * const camnode)
|
||||
|
||||
if (UserConfigParams::m_dof)
|
||||
{
|
||||
renderDoF(out_fbo, in_rtt);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
renderDoF(*out_fbo, in_fbo->getRTT()[0]);
|
||||
std::swap(in_fbo, out_fbo);
|
||||
}
|
||||
|
||||
@ -700,7 +699,7 @@ void PostProcessing::render(scene::ICameraSceneNode * const camnode)
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
// Grab the sky
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
|
||||
out_fbo->Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
irr_driver->renderSkybox(camnode);
|
||||
|
||||
@ -717,17 +716,12 @@ void PostProcessing::render(scene::ICameraSceneNode * const camnode)
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
// Fade to quarter
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER1));
|
||||
irr_driver->getFBO(FBO_QUARTER1).Bind();
|
||||
glViewport(0, 0, UserConfigParams::m_width / 4, UserConfigParams::m_height / 4);
|
||||
renderGodFade(out_rtt, col);
|
||||
renderGodFade(out_fbo->getRTT()[0], col);
|
||||
|
||||
// Blur
|
||||
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER1), irr_driver->getRenderTargetTexture(RTT_QUARTER1),
|
||||
irr_driver->getFBO(FBO_QUARTER2), irr_driver->getRenderTargetTexture(RTT_QUARTER2),
|
||||
UserConfigParams::m_width / 4,
|
||||
UserConfigParams::m_height / 4);
|
||||
|
||||
|
||||
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER1), irr_driver->getFBO(FBO_QUARTER2));
|
||||
|
||||
// Calculate the sun's position in texcoords
|
||||
const core::vector3df pos = sun->getPosition();
|
||||
@ -744,22 +738,18 @@ void PostProcessing::render(scene::ICameraSceneNode * const camnode)
|
||||
const float suny = ((ndc[1] / ndc[3]) * 0.5f + 0.5f) * texh;
|
||||
|
||||
// Rays please
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER2));
|
||||
irr_driver->getFBO(FBO_QUARTER2).Bind();
|
||||
renderGodRay(irr_driver->getRenderTargetTexture(RTT_QUARTER1), core::vector2df(sunx, suny));
|
||||
|
||||
// Blur
|
||||
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER2), irr_driver->getRenderTargetTexture(RTT_QUARTER2),
|
||||
irr_driver->getFBO(FBO_QUARTER1), irr_driver->getRenderTargetTexture(RTT_QUARTER1),
|
||||
UserConfigParams::m_width / 4,
|
||||
UserConfigParams::m_height / 4);
|
||||
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER2), irr_driver->getFBO(FBO_QUARTER1));
|
||||
|
||||
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
// Blend
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, in_fbo);
|
||||
in_fbo->Bind();
|
||||
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_QUARTER2));
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
@ -775,44 +765,24 @@ void PostProcessing::render(scene::ICameraSceneNode * const camnode)
|
||||
{
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, in_fbo);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, irr_driver->getFBO(FBO_BLOOM_1024));
|
||||
glBlitFramebuffer(0, 0, UserConfigParams::m_width, UserConfigParams::m_height, 0, 0, 1024, 1024, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
FrameBuffer::Blit(*in_fbo, irr_driver->getFBO(FBO_BLOOM_1024), GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_BLOOM_512));
|
||||
glViewport(0, 0, 512, 512);
|
||||
irr_driver->getFBO(FBO_BLOOM_512).Bind();
|
||||
renderBloom(irr_driver->getRenderTargetTexture(RTT_BLOOM_1024));
|
||||
|
||||
// Downsample
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, irr_driver->getFBO(FBO_BLOOM_512));
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, irr_driver->getFBO(FBO_BLOOM_256));
|
||||
glBlitFramebuffer(0, 0, 512, 512, 0, 0, 256, 256, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, irr_driver->getFBO(FBO_BLOOM_256));
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, irr_driver->getFBO(FBO_BLOOM_128));
|
||||
glBlitFramebuffer(0, 0, 256, 256, 0, 0, 128, 128, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
FrameBuffer::Blit(irr_driver->getFBO(FBO_BLOOM_512), irr_driver->getFBO(FBO_BLOOM_256), GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
FrameBuffer::Blit(irr_driver->getFBO(FBO_BLOOM_256), irr_driver->getFBO(FBO_BLOOM_128), GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
// Blur
|
||||
glViewport(0, 0, 512, 512);
|
||||
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_512), irr_driver->getRenderTargetTexture(RTT_BLOOM_512),
|
||||
irr_driver->getFBO(FBO_TMP_512), irr_driver->getRenderTargetTexture(RTT_TMP_512), 512, 512);
|
||||
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_512), irr_driver->getFBO(FBO_TMP_512));
|
||||
|
||||
glViewport(0, 0, 256, 256);
|
||||
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_256), irr_driver->getRenderTargetTexture(RTT_BLOOM_256),
|
||||
irr_driver->getFBO(FBO_TMP_256), irr_driver->getRenderTargetTexture(RTT_TMP_256), 256, 256);
|
||||
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_256), irr_driver->getFBO(FBO_TMP_256));
|
||||
|
||||
glViewport(0, 0, 128, 128);
|
||||
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_128), irr_driver->getRenderTargetTexture(RTT_BLOOM_128),
|
||||
irr_driver->getFBO(FBO_TMP_128), irr_driver->getRenderTargetTexture(RTT_TMP_128), 128, 128);
|
||||
|
||||
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_128), irr_driver->getFBO(FBO_TMP_128));
|
||||
|
||||
// Additively blend on top of tmp1
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, in_fbo);
|
||||
in_fbo->Bind();
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
@ -831,8 +801,7 @@ void PostProcessing::render(scene::ICameraSceneNode * const camnode)
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- Tonemap", 0xFF, 0x00, 0x00);
|
||||
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_TONEMAP));
|
||||
toneMap(out_fbo, in_rtt);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
toneMap(*out_fbo, in_fbo->getRTT()[0]);
|
||||
std::swap(in_fbo, out_fbo);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
@ -842,43 +811,23 @@ void PostProcessing::render(scene::ICameraSceneNode * const camnode)
|
||||
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_MOTIONBLUR));
|
||||
if (UserConfigParams::m_motionblur && m_any_boost) // motion blur
|
||||
{
|
||||
renderMotionBlur(0, in_rtt, out_fbo);
|
||||
renderMotionBlur(0, *in_fbo, *out_fbo);
|
||||
std::swap(in_fbo, out_fbo);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
||||
if (irr_driver->getNormals())
|
||||
{
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH));
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
else if (irr_driver->getSSAOViz())
|
||||
{
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_SSAO));
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
else if (UserConfigParams::m_mlaa) // MLAA. Must be the last pp filter.
|
||||
if (UserConfigParams::m_mlaa) // MLAA. Must be the last pp filter.
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- MLAA", 0xFF, 0x00, 0x00);
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_MLAA_COLORS));
|
||||
renderPassThrough(in_rtt);
|
||||
irr_driver->getFBO(FBO_MLAA_COLORS).Bind();
|
||||
renderPassThrough(in_fbo->getRTT()[0]);
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
applyMLAA();
|
||||
blitFBO(irr_driver->getFBO(FBO_MLAA_COLORS), 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
out_fbo = &irr_driver->getFBO(FBO_MLAA_COLORS);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
renderPassThrough(in_rtt);
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
|
||||
return out_fbo;
|
||||
} // render
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "S3DVertex.h"
|
||||
#include "SMaterial.h"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/glwrap.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -82,19 +83,19 @@ public:
|
||||
void renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff);
|
||||
|
||||
/** Blur the in texture */
|
||||
void renderGaussian3Blur(unsigned in_fbo, unsigned in_tex, unsigned tmp_fbo, unsigned tmp_tex, size_t inv_width, size_t inv_height);
|
||||
void renderGaussian6Blur(unsigned in_fbo, unsigned in_tex, unsigned tmp_fbo, unsigned tmp_tex, size_t width, size_t height);
|
||||
void renderGaussian17TapBlur(unsigned in_fbo, unsigned in_tex, unsigned tmp_fbo, unsigned tmp_tex, size_t width, size_t height);
|
||||
void renderGaussian3Blur(FrameBuffer &in_fbo, FrameBuffer &auxiliary);
|
||||
void renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxiliary);
|
||||
void renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &auxiliary);
|
||||
|
||||
/** Render tex. Used for blit/texture resize */
|
||||
void renderPassThrough(unsigned tex);
|
||||
void applyMLAA();
|
||||
|
||||
void renderMotionBlur(unsigned cam, unsigned in_rtt, unsigned out_fbo);
|
||||
void renderMotionBlur(unsigned cam, FrameBuffer &in_fbo, FrameBuffer &out_fbo);
|
||||
void renderGlow(unsigned tex);
|
||||
|
||||
/** Render the post-processed scene */
|
||||
void render(scene::ICameraSceneNode * const camnode);
|
||||
FrameBuffer *render(scene::ICameraSceneNode * const camnode);
|
||||
|
||||
/** Use motion blur for a short time */
|
||||
void giveBoost(unsigned int cam_index);
|
||||
|
@ -142,6 +142,9 @@ void IrrDriver::renderGLSL(float dt)
|
||||
rg->preRenderCallback(camera); // adjusts start referee
|
||||
m_scene_manager->setActiveCamera(camnode);
|
||||
|
||||
const core::recti &viewport = camera->getViewport();
|
||||
|
||||
computeCameraMatrix(camnode, viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y);
|
||||
renderScene(camnode, glows, dt, track->hasShadows());
|
||||
|
||||
// Debug physic
|
||||
@ -183,10 +186,26 @@ void IrrDriver::renderGLSL(float dt)
|
||||
|
||||
// Render the post-processed scene
|
||||
if (UserConfigParams::m_dynamic_lights)
|
||||
m_post_processing->render(camnode);
|
||||
{
|
||||
FrameBuffer *fbo = m_post_processing->render(camnode);
|
||||
|
||||
if (!UserConfigParams::m_mlaa) // MLAA_COLORS already in srgb space
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
|
||||
if (irr_driver->getNormals())
|
||||
irr_driver->getFBO(FBO_NORMAL_AND_DEPTHS).BlitToDefault(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
|
||||
else if (irr_driver->getSSAOViz())
|
||||
irr_driver->getFBO(FBO_SSAO).BlitToDefault(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
|
||||
else
|
||||
fbo->BlitToDefault(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
|
||||
|
||||
if (!UserConfigParams::m_mlaa)
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
else
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
|
||||
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
} // for i<world->getNumKarts()
|
||||
|
||||
@ -238,7 +257,6 @@ void IrrDriver::renderGLSL(float dt)
|
||||
|
||||
void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, std::vector<GlowData>& glows, float dt, bool hasShadow)
|
||||
{
|
||||
computeCameraMatrix(camnode);
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, 0, SharedObject::ViewProjectionMatrixesUBO);
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
|
||||
@ -284,9 +302,7 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, std::vector
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getFBO(FBO_COLORS));
|
||||
}
|
||||
m_rtts->getFBO(FBO_COLORS).Bind();
|
||||
renderSolidSecondPass();
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
@ -454,8 +470,7 @@ void IrrDriver::computeSunVisibility()
|
||||
|
||||
void IrrDriver::renderSolidFirstPass()
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getFBO(FBO_NORMAL_AND_DEPTHS));
|
||||
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
m_rtts->getFBO(FBO_NORMAL_AND_DEPTHS).Bind();
|
||||
glClearColor(0., 0., 0., 0.);
|
||||
glDepthMask(GL_TRUE);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
@ -586,7 +601,7 @@ void IrrDriver::renderParticles()
|
||||
m_scene_manager->drawAll(scene::ESNRP_TRANSPARENT_EFFECT);
|
||||
}
|
||||
|
||||
void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode)
|
||||
void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, size_t width, size_t height)
|
||||
{
|
||||
m_scene_manager->drawAll(scene::ESNRP_CAMERA);
|
||||
irr_driver->setProjMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION));
|
||||
@ -672,7 +687,7 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode)
|
||||
camnode->setNearValue(oldnear);
|
||||
camnode->setFarValue(oldfar);
|
||||
|
||||
float *tmp = new float[16 * 8];
|
||||
float *tmp = new float[18 * 8];
|
||||
|
||||
memcpy(tmp, irr_driver->getViewMatrix().pointer(), 16 * sizeof(float));
|
||||
memcpy(&tmp[16], irr_driver->getProjMatrix().pointer(), 16 * sizeof(float));
|
||||
@ -681,9 +696,11 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode)
|
||||
size_t size = irr_driver->getShadowViewProj().size();
|
||||
for (unsigned i = 0; i < size; i++)
|
||||
memcpy(&tmp[16 * i + 64], irr_driver->getShadowViewProj()[i].pointer(), 16 * sizeof(float));
|
||||
tmp[128] = width;
|
||||
tmp[129] = height;
|
||||
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, SharedObject::ViewProjectionMatrixesUBO);
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, 16 * 8 * sizeof(float), tmp);
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, (16 * 8 + 2) * sizeof(float), tmp);
|
||||
delete []tmp;
|
||||
}
|
||||
|
||||
@ -710,7 +727,7 @@ void IrrDriver::renderShadows()
|
||||
void IrrDriver::renderGlow(std::vector<GlowData>& glows)
|
||||
{
|
||||
m_scene_manager->setCurrentRendertime(scene::ESNRP_SOLID);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getFBO(FBO_TMP1_WITH_DS));
|
||||
m_rtts->getFBO(FBO_TMP1_WITH_DS).Bind();
|
||||
glClearStencil(0);
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
@ -747,25 +764,18 @@ void IrrDriver::renderGlow(std::vector<GlowData>& glows)
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
// To half
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, irr_driver->getFBO(FBO_TMP1_WITH_DS));
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, irr_driver->getFBO(FBO_HALF1));
|
||||
glBlitFramebuffer(0, 0, UserConfigParams::m_width, UserConfigParams::m_height, 0, 0, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
FrameBuffer::Blit(irr_driver->getFBO(FBO_TMP1_WITH_DS), irr_driver->getFBO(FBO_HALF1), GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
// To quarter
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, irr_driver->getFBO(FBO_HALF1));
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER1));
|
||||
glBlitFramebuffer(0, 0, UserConfigParams::m_width / 2, UserConfigParams::m_height / 2, 0, 0, UserConfigParams::m_width / 4, UserConfigParams::m_height / 4, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
FrameBuffer::Blit(irr_driver->getFBO(FBO_HALF1), irr_driver->getFBO(FBO_QUARTER1), GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
|
||||
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);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getFBO(FBO_COLORS));
|
||||
m_rtts->getFBO(FBO_COLORS).Bind();
|
||||
m_post_processing->renderGlow(m_rtts->getRenderTarget(RTT_QUARTER1));
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
}
|
||||
@ -802,16 +812,13 @@ void IrrDriver::renderLights(scene::ICameraSceneNode * const camnode, float dt)
|
||||
|
||||
for (unsigned i = 0; i < sun_ortho_matrix.size(); i++)
|
||||
sun_ortho_matrix[i] *= getInvViewMatrix();
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getFBO(FBO_COMBINED_TMP1_TMP2));
|
||||
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
|
||||
GLenum bufs[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
|
||||
gl_driver->extGlDrawBuffers(2, bufs);
|
||||
m_rtts->getFBO(FBO_COMBINED_TMP1_TMP2).Bind();
|
||||
if (!UserConfigParams::m_dynamic_lights)
|
||||
glClearColor(.5, .5, .5, .5);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
if (!UserConfigParams::m_dynamic_lights)
|
||||
{
|
||||
gl_driver->extGlDrawBuffers(1, bufs);
|
||||
//gl_driver->extGlDrawBuffers(1, bufs);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -889,20 +896,17 @@ void IrrDriver::renderLights(scene::ICameraSceneNode * const camnode, float dt)
|
||||
renderPointLights(MIN2(lightnum, MAXLIGHT));
|
||||
if (SkyboxCubeMap)
|
||||
m_post_processing->renderDiffuseEnvMap(blueSHCoeff, greenSHCoeff, redSHCoeff);
|
||||
gl_driver->extGlDrawBuffers(1, bufs);
|
||||
// gl_driver->extGlDrawBuffers(1, bufs);
|
||||
}
|
||||
|
||||
void IrrDriver::renderSSAO()
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getFBO(FBO_SSAO));
|
||||
m_rtts->getFBO(FBO_SSAO).Bind();
|
||||
glClearColor(1., 1., 1., 1.);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
m_post_processing->renderSSAO();
|
||||
// Blur it to reduce noise.
|
||||
m_post_processing->renderGaussian17TapBlur(irr_driver->getFBO(FBO_SSAO), irr_driver->getRenderTargetTexture(RTT_SSAO),
|
||||
irr_driver->getFBO(FBO_TMP4), irr_driver->getRenderTargetTexture(RTT_TMP4), UserConfigParams::m_width, UserConfigParams::m_height );
|
||||
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
m_post_processing->renderGaussian17TapBlur(irr_driver->getFBO(FBO_SSAO), irr_driver->getFBO(FBO_TMP4));
|
||||
}
|
||||
|
||||
static void getXYZ(GLenum face, float i, float j, float &x, float &y, float &z)
|
||||
@ -1394,9 +1398,9 @@ void IrrDriver::renderSkybox(const scene::ICameraSceneNode *camera)
|
||||
|
||||
void IrrDriver::renderDisplacement()
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_TMP4));
|
||||
irr_driver->getFBO(FBO_TMP1_WITH_DS).Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_DISPLACE));
|
||||
irr_driver->getFBO(FBO_DISPLACE).Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
DisplaceProvider * const cb = (DisplaceProvider *)irr_driver->getCallback(ES_DISPLACE);
|
||||
@ -1419,7 +1423,7 @@ void IrrDriver::renderDisplacement()
|
||||
m_displacing[i]->render();
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_COLORS));
|
||||
irr_driver->getFBO(FBO_COLORS).Bind();
|
||||
glStencilFunc(GL_EQUAL, 1, 0xFF);
|
||||
m_post_processing->renderPassThrough(m_rtts->getRenderTarget(RTT_DISPLACE));
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
|
@ -51,14 +51,14 @@ static GLuint generateFBO(GLuint ColorAttachement, GLuint DepthAttachement)
|
||||
return fbo;
|
||||
}
|
||||
|
||||
RTT::RTT()
|
||||
RTT::RTT(size_t width, size_t height)
|
||||
{
|
||||
initGL();
|
||||
using namespace video;
|
||||
using namespace core;
|
||||
|
||||
IVideoDriver * const drv = irr_driver->getVideoDriver();
|
||||
const dimension2du res(UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
const dimension2du res(width, height);
|
||||
const dimension2du half = res/2;
|
||||
const dimension2du quarter = res/4;
|
||||
const dimension2du eighth = res/8;
|
||||
@ -107,37 +107,35 @@ RTT::RTT()
|
||||
RenderTargetTextures[RTT_TMP_128] = generateRTT(shadowsize3, GL_RGBA16F, GL_BGR, GL_FLOAT);
|
||||
RenderTargetTextures[RTT_LOG_LUMINANCE] = generateRTT(shadowsize0, GL_R16F, GL_RED, GL_FLOAT);
|
||||
|
||||
FrameBuffers[FBO_SSAO] = generateFBO(RenderTargetTextures[RTT_SSAO]);
|
||||
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_SSAO]}, res.Width, res.Height));
|
||||
// Clear this FBO to 1s so that if no SSAO is computed we can still use it.
|
||||
glClearColor(1., 1., 1., 1.);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
FrameBuffers[FBO_NORMAL_AND_DEPTHS] = generateFBO(RenderTargetTextures[RTT_NORMAL_AND_DEPTH], DepthStencilTexture);
|
||||
FrameBuffers[FBO_COLORS] = generateFBO(RenderTargetTextures[RTT_COLOR], DepthStencilTexture);
|
||||
FrameBuffers[FBO_MLAA_COLORS] = generateFBO(RenderTargetTextures[RTT_MLAA_COLORS], DepthStencilTexture);
|
||||
FrameBuffers[FBO_LOG_LUMINANCE] = generateFBO(RenderTargetTextures[RTT_LOG_LUMINANCE]);
|
||||
FrameBuffers[FBO_TMP1_WITH_DS] = generateFBO(RenderTargetTextures[RTT_TMP1], DepthStencilTexture);
|
||||
FrameBuffers[FBO_TMP2_WITH_DS] = generateFBO(RenderTargetTextures[RTT_TMP2], DepthStencilTexture);
|
||||
FrameBuffers[FBO_TMP4] = generateFBO(RenderTargetTextures[RTT_TMP4], DepthStencilTexture);
|
||||
FrameBuffers[FBO_LINEAR_DEPTH] = generateFBO(RenderTargetTextures[RTT_LINEAR_DEPTH]);
|
||||
FrameBuffers[FBO_DISPLACE] = generateFBO(RenderTargetTextures[RTT_DISPLACE], DepthStencilTexture);
|
||||
FrameBuffers[FBO_HALF1] = generateFBO(RenderTargetTextures[RTT_HALF1]);
|
||||
FrameBuffers[FBO_HALF2] = generateFBO(RenderTargetTextures[RTT_HALF2]);
|
||||
FrameBuffers[FBO_QUARTER1] = generateFBO(RenderTargetTextures[RTT_QUARTER1]);
|
||||
FrameBuffers[FBO_QUARTER2] = generateFBO(RenderTargetTextures[RTT_QUARTER2]);
|
||||
FrameBuffers[FBO_EIGHTH1] = generateFBO(RenderTargetTextures[RTT_EIGHTH1]);
|
||||
FrameBuffers[FBO_EIGHTH2] = generateFBO(RenderTargetTextures[RTT_EIGHTH2]);
|
||||
|
||||
FrameBuffers[FBO_BLOOM_1024] = generateFBO(RenderTargetTextures[RTT_BLOOM_1024]);
|
||||
FrameBuffers[FBO_BLOOM_512] = generateFBO(RenderTargetTextures[RTT_BLOOM_512]);
|
||||
FrameBuffers[FBO_TMP_512] = generateFBO(RenderTargetTextures[RTT_TMP_512]);
|
||||
FrameBuffers[FBO_BLOOM_256] = generateFBO(RenderTargetTextures[RTT_BLOOM_256]);
|
||||
FrameBuffers[FBO_TMP_256] = generateFBO(RenderTargetTextures[RTT_TMP_256]);
|
||||
FrameBuffers[FBO_BLOOM_128] = generateFBO(RenderTargetTextures[RTT_BLOOM_128]);
|
||||
FrameBuffers[FBO_TMP_128] = generateFBO(RenderTargetTextures[RTT_TMP_128]);
|
||||
|
||||
FrameBuffers[FBO_COMBINED_TMP1_TMP2] = generateFBO(RenderTargetTextures[RTT_TMP1], DepthStencilTexture);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, RenderTargetTextures[RTT_TMP2], 0);
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_NORMAL_AND_DEPTH]}, DepthStencilTexture, res.Width, res.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_TMP1], RenderTargetTextures[RTT_TMP2]}, DepthStencilTexture, res.Width, res.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_COLOR]}, DepthStencilTexture, res.Width, res.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_LOG_LUMINANCE]}, res.Width, res.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_MLAA_COLORS]}, res.Width, res.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_TMP1]}, DepthStencilTexture, res.Width, res.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_TMP2]}, DepthStencilTexture, res.Width, res.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_TMP4]}, res.Width, res.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_LINEAR_DEPTH]}, res.Width, res.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_HALF1]}, half.Width, half.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_HALF2]}, half.Width, half.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_QUARTER1]}, quarter.Width, quarter.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_QUARTER2]}, quarter.Width, quarter.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_EIGHTH1]}, eighth.Width, eighth.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_EIGHTH2]}, eighth.Width, eighth.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_DISPLACE]}, DepthStencilTexture, res.Width, res.Height));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_BLOOM_1024]}, 1024, 1024));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_BLOOM_512]}, 512, 512));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_TMP_512]}, 512, 512));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_BLOOM_256]}, 256, 256));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_TMP_256]}, 256, 256));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_BLOOM_128]}, 128, 128));
|
||||
FrameBuffers.push_back(new FrameBuffer(std::vector<GLuint> {RenderTargetTextures[RTT_TMP_128]}, 128, 128));
|
||||
|
||||
if (irr_driver->getGLSLVersion() >= 150)
|
||||
{
|
||||
@ -159,7 +157,6 @@ RTT::RTT()
|
||||
|
||||
RTT::~RTT()
|
||||
{
|
||||
glDeleteFramebuffers(FBO_COUNT, FrameBuffers);
|
||||
glDeleteTextures(RTT_COUNT, RenderTargetTextures);
|
||||
glDeleteTextures(1, &DepthStencilTexture);
|
||||
if (irr_driver->getGLSLVersion() >= 150)
|
||||
|
@ -17,6 +17,10 @@
|
||||
#ifndef HEADER_RTTS_HPP
|
||||
#define HEADER_RTTS_HPP
|
||||
|
||||
#include "graphics/glwrap.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
#include "utils/leak_check.hpp"
|
||||
|
||||
namespace irr {
|
||||
namespace video {
|
||||
class ITexture;
|
||||
@ -109,7 +113,7 @@ enum TypeFBO
|
||||
class RTT
|
||||
{
|
||||
public:
|
||||
RTT();
|
||||
RTT(size_t width, size_t height);
|
||||
~RTT();
|
||||
|
||||
unsigned getShadowFBO() const { return shadowFBO; }
|
||||
@ -117,12 +121,15 @@ public:
|
||||
|
||||
unsigned getDepthStencilTexture() const { return DepthStencilTexture; }
|
||||
unsigned getRenderTarget(enum TypeRTT target) const { return RenderTargetTextures[target]; }
|
||||
unsigned getFBO(enum TypeFBO fbo) { return FrameBuffers[fbo]; }
|
||||
FrameBuffer& getFBO(enum TypeFBO fbo) { return FrameBuffers[fbo]; }
|
||||
private:
|
||||
unsigned RenderTargetTextures[RTT_COUNT], FrameBuffers[FBO_COUNT];
|
||||
unsigned RenderTargetTextures[RTT_COUNT];
|
||||
PtrVector<FrameBuffer> FrameBuffers;
|
||||
unsigned DepthStencilTexture;
|
||||
|
||||
unsigned shadowFBO, shadowColorTex, shadowDepthTex;
|
||||
|
||||
LEAK_CHECK();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -170,7 +170,7 @@ static void initShadowVPMUBO()
|
||||
{
|
||||
glGenBuffers(1, &SharedObject::ViewProjectionMatrixesUBO);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, SharedObject::ViewProjectionMatrixesUBO);
|
||||
glBufferData(GL_UNIFORM_BUFFER, 16 * 8 * sizeof(float), 0, GL_STATIC_DRAW);
|
||||
glBufferData(GL_UNIFORM_BUFFER, (16 * 8 + 2) * sizeof(float), 0, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
}
|
||||
|
||||
@ -699,7 +699,6 @@ namespace MeshShader
|
||||
GLuint ObjectPass2Shader::attrib_texcoord;
|
||||
GLuint ObjectPass2Shader::uniform_MM;
|
||||
GLuint ObjectPass2Shader::uniform_TM;
|
||||
GLuint ObjectPass2Shader::uniform_screen;
|
||||
GLuint ObjectPass2Shader::uniform_ambient;
|
||||
GLuint ObjectPass2Shader::TU_Albedo;
|
||||
|
||||
@ -717,7 +716,6 @@ namespace MeshShader
|
||||
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -737,7 +735,6 @@ namespace MeshShader
|
||||
bypassUBO(Program);
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
||||
glUniform2f(uniform_screen, float(UserConfigParams::m_width), float(UserConfigParams::m_height));
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
@ -750,7 +747,6 @@ namespace MeshShader
|
||||
GLuint InstancedObjectPass2Shader::attrib_scale;
|
||||
GLuint InstancedObjectPass2Shader::uniform_VP;
|
||||
GLuint InstancedObjectPass2Shader::uniform_TM;
|
||||
GLuint InstancedObjectPass2Shader::uniform_screen;
|
||||
GLuint InstancedObjectPass2Shader::uniform_ambient;
|
||||
GLuint InstancedObjectPass2Shader::TU_Albedo;
|
||||
|
||||
@ -772,7 +768,6 @@ namespace MeshShader
|
||||
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
TU_Albedo = 3;
|
||||
|
||||
@ -793,7 +788,6 @@ namespace MeshShader
|
||||
bypassUBO(Program);
|
||||
glUniformMatrix4fv(uniform_VP, 1, GL_FALSE, ViewProjectionMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
||||
glUniform2f(uniform_screen, float(UserConfigParams::m_width), float(UserConfigParams::m_height));
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
@ -806,7 +800,6 @@ namespace MeshShader
|
||||
GLuint InstancedObjectRefPass2Shader::attrib_scale;
|
||||
GLuint InstancedObjectRefPass2Shader::uniform_VP;
|
||||
GLuint InstancedObjectRefPass2Shader::uniform_TM;
|
||||
GLuint InstancedObjectRefPass2Shader::uniform_screen;
|
||||
GLuint InstancedObjectRefPass2Shader::uniform_ambient;
|
||||
GLuint InstancedObjectRefPass2Shader::TU_Albedo;
|
||||
|
||||
@ -828,7 +821,6 @@ namespace MeshShader
|
||||
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
TU_Albedo = 3;
|
||||
|
||||
@ -849,7 +841,6 @@ namespace MeshShader
|
||||
bypassUBO(Program);
|
||||
glUniformMatrix4fv(uniform_VP, 1, GL_FALSE, ViewProjectionMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
||||
glUniform2f(uniform_screen, float(UserConfigParams::m_width), float(UserConfigParams::m_height));
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
@ -859,7 +850,6 @@ namespace MeshShader
|
||||
GLuint DetailledObjectPass2Shader::attrib_texcoord;
|
||||
GLuint DetailledObjectPass2Shader::attrib_second_texcoord;
|
||||
GLuint DetailledObjectPass2Shader::uniform_MM;
|
||||
GLuint DetailledObjectPass2Shader::uniform_screen;
|
||||
GLuint DetailledObjectPass2Shader::uniform_ambient;
|
||||
GLuint DetailledObjectPass2Shader::TU_Albedo;
|
||||
GLuint DetailledObjectPass2Shader::TU_detail;
|
||||
@ -879,7 +869,6 @@ namespace MeshShader
|
||||
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -900,8 +889,6 @@ namespace MeshShader
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
bypassUBO(Program);
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
|
||||
float(UserConfigParams::m_height));
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
@ -944,7 +931,6 @@ namespace MeshShader
|
||||
GLuint ObjectRimLimitShader::uniform_MM;
|
||||
GLuint ObjectRimLimitShader::uniform_IMM;
|
||||
GLuint ObjectRimLimitShader::uniform_TM;
|
||||
GLuint ObjectRimLimitShader::uniform_screen;
|
||||
GLuint ObjectRimLimitShader::uniform_ambient;
|
||||
GLuint ObjectRimLimitShader::TU_Albedo;
|
||||
|
||||
@ -963,7 +949,6 @@ namespace MeshShader
|
||||
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
GLuint uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -987,8 +972,6 @@ namespace MeshShader
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_IMM, 1, GL_FALSE, InverseModelMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
||||
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
|
||||
float(UserConfigParams::m_height));
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
@ -997,7 +980,6 @@ namespace MeshShader
|
||||
GLuint UntexturedObjectShader::attrib_position;
|
||||
GLuint UntexturedObjectShader::attrib_color;
|
||||
GLuint UntexturedObjectShader::uniform_MM;
|
||||
GLuint UntexturedObjectShader::uniform_screen;
|
||||
GLuint UntexturedObjectShader::uniform_ambient;
|
||||
|
||||
void UntexturedObjectShader::init()
|
||||
@ -1012,7 +994,6 @@ namespace MeshShader
|
||||
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -1029,8 +1010,6 @@ namespace MeshShader
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
bypassUBO(Program);
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
|
||||
float(UserConfigParams::m_height));
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
@ -1041,7 +1020,6 @@ namespace MeshShader
|
||||
GLuint ObjectRefPass2Shader::attrib_texcoord;
|
||||
GLuint ObjectRefPass2Shader::uniform_MM;
|
||||
GLuint ObjectRefPass2Shader::uniform_TM;
|
||||
GLuint ObjectRefPass2Shader::uniform_screen;
|
||||
GLuint ObjectRefPass2Shader::uniform_ambient;
|
||||
GLuint ObjectRefPass2Shader::TU_Albedo;
|
||||
|
||||
@ -1060,7 +1038,6 @@ namespace MeshShader
|
||||
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -1081,8 +1058,6 @@ namespace MeshShader
|
||||
bypassUBO(Program);
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
||||
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
|
||||
float(UserConfigParams::m_height));
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
@ -1092,7 +1067,6 @@ namespace MeshShader
|
||||
GLuint GrassPass2Shader::attrib_texcoord;
|
||||
GLuint GrassPass2Shader::attrib_color;
|
||||
GLuint GrassPass2Shader::uniform_MVP;
|
||||
GLuint GrassPass2Shader::uniform_screen;
|
||||
GLuint GrassPass2Shader::uniform_ambient;
|
||||
GLuint GrassPass2Shader::uniform_windDir;
|
||||
GLuint GrassPass2Shader::TU_Albedo;
|
||||
@ -1111,7 +1085,6 @@ namespace MeshShader
|
||||
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
uniform_windDir = glGetUniformLocation(Program, "windDir");
|
||||
TU_Albedo = 3;
|
||||
@ -1128,8 +1101,6 @@ namespace MeshShader
|
||||
const core::vector3df &windDirection)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
|
||||
float(UserConfigParams::m_height));
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
glUniform3f(uniform_windDir, windDirection.X, windDirection.Y, windDirection.Z);
|
||||
@ -1144,7 +1115,6 @@ namespace MeshShader
|
||||
GLuint InstancedGrassPass2Shader::attrib_orientation;
|
||||
GLuint InstancedGrassPass2Shader::attrib_scale;
|
||||
GLuint InstancedGrassPass2Shader::uniform_VP;
|
||||
GLuint InstancedGrassPass2Shader::uniform_screen;
|
||||
GLuint InstancedGrassPass2Shader::uniform_ambient;
|
||||
GLuint InstancedGrassPass2Shader::uniform_windDir;
|
||||
GLuint InstancedGrassPass2Shader::uniform_invproj;
|
||||
@ -1173,7 +1143,6 @@ namespace MeshShader
|
||||
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
GLuint uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
uniform_windDir = glGetUniformLocation(Program, "windDir");
|
||||
uniform_invproj = glGetUniformLocation(Program, "invproj");
|
||||
@ -1201,7 +1170,6 @@ namespace MeshShader
|
||||
glUniformMatrix4fv(uniform_VP, 1, GL_FALSE, ViewProjectionMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, invproj.pointer());
|
||||
glUniformMatrix4fv(uniform_IVM, 1, GL_FALSE, InverseViewMatrix.pointer());
|
||||
glUniform2f(uniform_screen, float(UserConfigParams::m_width), float(UserConfigParams::m_height));
|
||||
glUniform3f(uniform_SunDir, SunDir.X, SunDir.Y, SunDir.Z);
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
@ -1213,7 +1181,6 @@ namespace MeshShader
|
||||
GLuint SphereMapShader::attrib_normal;
|
||||
GLuint SphereMapShader::uniform_MM;
|
||||
GLuint SphereMapShader::uniform_IMM;
|
||||
GLuint SphereMapShader::uniform_screen;
|
||||
GLuint SphereMapShader::TU_tex;
|
||||
|
||||
void SphereMapShader::init()
|
||||
@ -1226,7 +1193,6 @@ namespace MeshShader
|
||||
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
|
||||
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
|
||||
GLuint uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
TU_tex = 3;
|
||||
@ -1242,7 +1208,6 @@ namespace MeshShader
|
||||
bypassUBO(Program);
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_IMM, 1, GL_FALSE, InverseModelMatrix.pointer());
|
||||
glUniform2f(uniform_screen, screen.X, screen.Y);
|
||||
}
|
||||
|
||||
GLuint SplattingShader::Program;
|
||||
@ -1250,7 +1215,6 @@ namespace MeshShader
|
||||
GLuint SplattingShader::attrib_texcoord;
|
||||
GLuint SplattingShader::attrib_second_texcoord;
|
||||
GLuint SplattingShader::uniform_MM;
|
||||
GLuint SplattingShader::uniform_screen;
|
||||
GLuint SplattingShader::uniform_ambient;
|
||||
GLuint SplattingShader::TU_tex_layout;
|
||||
GLuint SplattingShader::TU_tex_detail0;
|
||||
@ -1275,7 +1239,6 @@ namespace MeshShader
|
||||
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
TU_tex_layout = 3;
|
||||
TU_tex_detail0 = 4;
|
||||
@ -1298,8 +1261,6 @@ namespace MeshShader
|
||||
void SplattingShader::setUniforms(const core::matrix4 &ModelMatrix)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
|
||||
float(UserConfigParams::m_height));
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
@ -1310,7 +1271,6 @@ namespace MeshShader
|
||||
GLuint CausticsShader::uniform_MVP;
|
||||
GLuint CausticsShader::uniform_dir;
|
||||
GLuint CausticsShader::uniform_dir2;
|
||||
GLuint CausticsShader::uniform_screen;
|
||||
GLuint CausticsShader::uniform_ambient;
|
||||
GLuint CausticsShader::TU_Albedo;
|
||||
GLuint CausticsShader::TU_caustictex;
|
||||
@ -1331,7 +1291,6 @@ namespace MeshShader
|
||||
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
TU_Albedo = 3;
|
||||
TU_caustictex = 4;
|
||||
@ -1350,7 +1309,6 @@ namespace MeshShader
|
||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||
glUniform2f(uniform_dir, dir.X, dir.Y);
|
||||
glUniform2f(uniform_dir2, dir2.X, dir2.Y);
|
||||
glUniform2f(uniform_screen, screen.X, screen.Y);
|
||||
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
|
||||
glUniform3f(uniform_ambient, s.r, s.g, s.b);
|
||||
}
|
||||
@ -1424,8 +1382,6 @@ namespace MeshShader
|
||||
GLuint TransparentFogShader::uniform_start;
|
||||
GLuint TransparentFogShader::uniform_end;
|
||||
GLuint TransparentFogShader::uniform_col;
|
||||
GLuint TransparentFogShader::uniform_screen;
|
||||
GLuint TransparentFogShader::uniform_ipvmat;
|
||||
|
||||
void TransparentFogShader::init()
|
||||
{
|
||||
@ -1444,11 +1400,11 @@ namespace MeshShader
|
||||
uniform_start = glGetUniformLocation(Program, "start");
|
||||
uniform_end = glGetUniformLocation(Program, "end");
|
||||
uniform_col = glGetUniformLocation(Program, "col");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_ipvmat = glGetUniformLocation(Program, "ipvmat");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void TransparentFogShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex)
|
||||
void TransparentFogShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
||||
@ -1458,8 +1414,6 @@ namespace MeshShader
|
||||
glUniform1f(uniform_start, start);
|
||||
glUniform1f(uniform_end, end);
|
||||
glUniform3f(uniform_col, col.X, col.Y, col.Z);
|
||||
glUniform2f(uniform_screen, float(UserConfigParams::m_width), float(UserConfigParams::m_height));
|
||||
glUniformMatrix4fv(uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer());
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
}
|
||||
|
||||
@ -1751,7 +1705,6 @@ namespace MeshShader
|
||||
GLuint DisplaceShader::uniform_color_tex;
|
||||
GLuint DisplaceShader::uniform_dir;
|
||||
GLuint DisplaceShader::uniform_dir2;
|
||||
GLuint DisplaceShader::uniform_screen;
|
||||
|
||||
void DisplaceShader::init()
|
||||
{
|
||||
@ -1768,7 +1721,8 @@ namespace MeshShader
|
||||
uniform_mask_tex = glGetUniformLocation(Program, "mask_tex");
|
||||
uniform_dir = glGetUniformLocation(Program, "dir");
|
||||
uniform_dir2 = glGetUniformLocation(Program, "dir2");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void DisplaceShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex)
|
||||
@ -1777,7 +1731,6 @@ namespace MeshShader
|
||||
glUniformMatrix4fv(uniform_MV, 1, GL_FALSE, ModelViewMatrix.pointer());
|
||||
glUniform2f(uniform_dir, dir.X, dir.Y);
|
||||
glUniform2f(uniform_dir2, dir2.X, dir2.Y);
|
||||
glUniform2f(uniform_screen, screen.X, screen.Y);
|
||||
glUniform1i(uniform_displacement_tex, TU_displacement_tex);
|
||||
glUniform1i(uniform_mask_tex, TU_mask_tex);
|
||||
glUniform1i(uniform_color_tex, TU_color_tex);
|
||||
@ -1787,7 +1740,6 @@ namespace MeshShader
|
||||
GLuint SkyboxShader::attrib_position;
|
||||
GLuint SkyboxShader::uniform_MM;
|
||||
GLuint SkyboxShader::uniform_tex;
|
||||
GLuint SkyboxShader::uniform_screen;
|
||||
GLuint SkyboxShader::cubevao;
|
||||
|
||||
void SkyboxShader::init()
|
||||
@ -1798,7 +1750,6 @@ namespace MeshShader
|
||||
attrib_position = glGetAttribLocation(Program, "Position");
|
||||
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
|
||||
@ -1817,7 +1768,6 @@ namespace MeshShader
|
||||
bypassUBO(Program);
|
||||
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
glUniform2f(uniform_screen, screen.X, screen.Y);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1832,7 +1782,6 @@ namespace LightShader
|
||||
GLuint PointLightShader::uniform_ntex;
|
||||
GLuint PointLightShader::uniform_dtex;
|
||||
GLuint PointLightShader::uniform_spec;
|
||||
GLuint PointLightShader::uniform_screen;
|
||||
GLuint PointLightShader::vbo;
|
||||
GLuint PointLightShader::vao;
|
||||
|
||||
@ -1851,7 +1800,6 @@ namespace LightShader
|
||||
uniform_ntex = glGetUniformLocation(Program, "ntex");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_spec = glGetUniformLocation(Program, "spec");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
@ -1880,7 +1828,6 @@ namespace LightShader
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
bypassUBO(Program);
|
||||
glUniform1f(uniform_spec, 200);
|
||||
glUniform2f(uniform_screen, screen.X, screen.Y);
|
||||
|
||||
glUniform1i(uniform_ntex, TU_ntex);
|
||||
glUniform1i(uniform_dtex, TU_dtex);
|
||||
@ -1990,7 +1937,6 @@ namespace ParticleShader
|
||||
GLuint SimpleParticleRender::uniform_viewmatrix;
|
||||
GLuint SimpleParticleRender::uniform_tex;
|
||||
GLuint SimpleParticleRender::uniform_dtex;
|
||||
GLuint SimpleParticleRender::uniform_screen;
|
||||
GLuint SimpleParticleRender::uniform_invproj;
|
||||
GLuint SimpleParticleRender::uniform_color_from;
|
||||
GLuint SimpleParticleRender::uniform_color_to;
|
||||
@ -2011,7 +1957,6 @@ namespace ParticleShader
|
||||
uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_invproj = glGetUniformLocation(Program, "invproj");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_color_from = glGetUniformLocation(Program, "color_from");
|
||||
assert(uniform_color_from != -1);
|
||||
@ -2024,7 +1969,6 @@ namespace ParticleShader
|
||||
const ParticleSystemProxy* particle_system)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
|
||||
glUniform2f(uniform_screen, width, height);
|
||||
glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer());
|
||||
glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer());
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
@ -2048,7 +1992,6 @@ namespace ParticleShader
|
||||
GLuint FlipParticleRender::uniform_viewmatrix;
|
||||
GLuint FlipParticleRender::uniform_tex;
|
||||
GLuint FlipParticleRender::uniform_dtex;
|
||||
GLuint FlipParticleRender::uniform_screen;
|
||||
GLuint FlipParticleRender::uniform_invproj;
|
||||
|
||||
void FlipParticleRender::init()
|
||||
@ -2068,14 +2011,12 @@ namespace ParticleShader
|
||||
uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix");
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_invproj = glGetUniformLocation(Program, "invproj");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
}
|
||||
|
||||
void FlipParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
|
||||
glUniform2f(uniform_screen, width, height);
|
||||
glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer());
|
||||
glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer());
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
@ -2168,8 +2109,6 @@ namespace FullScreenShader
|
||||
GLuint DepthOfFieldShader::Program;
|
||||
GLuint DepthOfFieldShader::uniform_tex;
|
||||
GLuint DepthOfFieldShader::uniform_depth;
|
||||
GLuint DepthOfFieldShader::uniform_invproj;
|
||||
GLuint DepthOfFieldShader::uniform_screen;
|
||||
GLuint DepthOfFieldShader::vao;
|
||||
|
||||
void DepthOfFieldShader::init()
|
||||
@ -2179,15 +2118,13 @@ namespace FullScreenShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/dof.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_depth = glGetUniformLocation(Program, "dtex");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
uniform_invproj = glGetUniformLocation(Program, "invprojm");
|
||||
vao = createVAO(Program);
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
||||
void DepthOfFieldShader::setUniforms(const core::matrix4 &invproj, const core::vector2df &screen, unsigned TU_tex, unsigned TU_dtex)
|
||||
void DepthOfFieldShader::setUniforms(unsigned TU_tex, unsigned TU_dtex)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, invproj.pointer());
|
||||
glUniform2f(uniform_screen, screen.X, screen.Y);
|
||||
glUniform1i(uniform_tex, TU_tex);
|
||||
glUniform1i(uniform_depth, TU_dtex);
|
||||
}
|
||||
@ -2551,7 +2488,6 @@ namespace FullScreenShader
|
||||
GLuint SSAOShader::uniform_dtex;
|
||||
GLuint SSAOShader::uniform_noise_texture;
|
||||
GLuint SSAOShader::uniform_samplePoints;
|
||||
GLuint SSAOShader::uniform_screen;
|
||||
GLuint SSAOShader::vao;
|
||||
float SSAOShader::SSAOSamples[64];
|
||||
|
||||
@ -2566,7 +2502,6 @@ namespace FullScreenShader
|
||||
uniform_dtex = glGetUniformLocation(Program, "dtex");
|
||||
uniform_noise_texture = glGetUniformLocation(Program, "noise_texture");
|
||||
uniform_samplePoints = glGetUniformLocation(Program, "samplePoints[0]");
|
||||
uniform_screen = glGetUniformLocation(Program, "screen");
|
||||
vao = createVAO(Program);
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -2690,7 +2625,6 @@ namespace FullScreenShader
|
||||
if (UserConfigParams::m_ubo_disabled)
|
||||
bypassUBO(Program);
|
||||
glUniform4fv(uniform_samplePoints, 16, SSAOSamples);
|
||||
glUniform2f(uniform_screen, screen.X, screen.Y);
|
||||
|
||||
glUniform1i(uniform_dtex, TU_dtex);
|
||||
glUniform1i(uniform_noise_texture, TU_noise);
|
||||
|
@ -131,7 +131,7 @@ class ObjectPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MM, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_TM, uniform_ambient;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
@ -143,7 +143,7 @@ class InstancedObjectPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_origin, attrib_orientation, attrib_scale;
|
||||
static GLuint uniform_VP, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_VP, uniform_TM, uniform_ambient;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
@ -155,7 +155,7 @@ class InstancedObjectRefPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_origin, attrib_orientation, attrib_scale;
|
||||
static GLuint uniform_VP, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_VP, uniform_TM, uniform_ambient;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
@ -167,7 +167,7 @@ class DetailledObjectPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||
static GLuint uniform_MM, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_ambient;
|
||||
static GLuint TU_Albedo, TU_detail;
|
||||
|
||||
static void init();
|
||||
@ -179,7 +179,7 @@ class ObjectRimLimitShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||
static GLuint uniform_MM, uniform_IMM, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_IMM, uniform_TM, uniform_ambient;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
@ -191,7 +191,7 @@ class UntexturedObjectShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_color;
|
||||
static GLuint uniform_MM, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_ambient;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelMatrix);
|
||||
@ -214,7 +214,7 @@ class ObjectRefPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MM, uniform_TM, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_TM, uniform_ambient;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
@ -226,7 +226,7 @@ class GrassPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient, uniform_windDir;
|
||||
static GLuint uniform_MVP, uniform_ambient, uniform_windDir;
|
||||
static GLuint TU_Albedo;
|
||||
|
||||
static void init();
|
||||
@ -238,7 +238,7 @@ class InstancedGrassPass2Shader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_normal, attrib_color, attrib_origin, attrib_orientation, attrib_scale;
|
||||
static GLuint uniform_VP, uniform_TM, uniform_IVM, uniform_screen, uniform_ambient, uniform_windDir, uniform_invproj, uniform_SunDir;
|
||||
static GLuint uniform_VP, uniform_TM, uniform_IVM, uniform_ambient, uniform_windDir, uniform_invproj, uniform_SunDir;
|
||||
static GLuint TU_Albedo, TU_dtex;
|
||||
|
||||
static void init();
|
||||
@ -250,7 +250,7 @@ class SphereMapShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal;
|
||||
static GLuint uniform_MM, uniform_IMM, uniform_screen;
|
||||
static GLuint uniform_MM, uniform_IMM;
|
||||
static GLuint TU_tex;
|
||||
|
||||
static void init();
|
||||
@ -262,7 +262,7 @@ class SplattingShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||
static GLuint uniform_MM, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MM, uniform_ambient;
|
||||
static GLuint TU_tex_layout, TU_tex_detail0, TU_tex_detail1, TU_tex_detail2, TU_tex_detail3;
|
||||
|
||||
static void init();
|
||||
@ -274,7 +274,7 @@ class CausticsShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_dir, uniform_dir2, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MVP, uniform_dir, uniform_dir2, uniform_ambient;
|
||||
static GLuint TU_Albedo, TU_caustictex;
|
||||
|
||||
static void init();
|
||||
@ -308,10 +308,10 @@ class TransparentFogShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_screen, uniform_ipvmat;
|
||||
static GLuint uniform_MVP, uniform_TM, uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex);
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex);
|
||||
};
|
||||
|
||||
class BillboardShader
|
||||
@ -407,7 +407,7 @@ class DisplaceShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||
static GLuint uniform_MVP, uniform_MV, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_screen, uniform_dir, uniform_dir2;
|
||||
static GLuint uniform_MVP, uniform_MV, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_dir, uniform_dir2;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex);
|
||||
@ -418,7 +418,7 @@ class SkyboxShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position;
|
||||
static GLuint uniform_MM, uniform_tex, uniform_screen;
|
||||
static GLuint uniform_MM, uniform_tex;
|
||||
static GLuint cubevao;
|
||||
|
||||
static void init();
|
||||
@ -449,7 +449,7 @@ namespace LightShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_Position, attrib_Energy, attrib_Color, attrib_Radius;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_spec, uniform_screen;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_spec;
|
||||
static GLuint vbo;
|
||||
static GLuint vao;
|
||||
|
||||
@ -489,7 +489,7 @@ class SimpleParticleRender
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
|
||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj, uniform_color_from, uniform_color_to;
|
||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_invproj, uniform_color_from, uniform_color_to;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix,
|
||||
@ -502,7 +502,7 @@ class FlipParticleRender
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz, attrib_rotationvec, attrib_anglespeed;
|
||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj;
|
||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_invproj;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth);
|
||||
@ -549,11 +549,11 @@ class DepthOfFieldShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_depth, uniform_screen, uniform_invproj;
|
||||
static GLuint uniform_tex, uniform_depth;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &invproj, const core::vector2df &screen, unsigned TU_tex, unsigned TU_depth);
|
||||
static void setUniforms(unsigned TU_tex, unsigned TU_depth);
|
||||
};
|
||||
|
||||
class ColorLevelShader
|
||||
@ -738,7 +738,7 @@ class SSAOShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_samplePoints, uniform_screen;
|
||||
static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_samplePoints;
|
||||
static GLuint vao;
|
||||
static float SSAOSamples[64];
|
||||
|
||||
|
@ -670,7 +670,7 @@ void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelView
|
||||
setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
|
||||
glUseProgram(MeshShader::TransparentFogShader::Program);
|
||||
MeshShader::TransparentFogShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, irr_driver->getInvProjMatrix(), fogmax, startH, endH, start, end, col, Camera::getCamera(0)->getCameraSceneNode()->getAbsolutePosition(), 0);
|
||||
MeshShader::TransparentFogShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, fogmax, startH, endH, start, end, col, Camera::getCamera(0)->getCameraSceneNode()->getAbsolutePosition(), 0);
|
||||
|
||||
assert(mesh.vao_first_pass);
|
||||
glBindVertexArray(mesh.vao_first_pass);
|
||||
|
@ -147,7 +147,7 @@ void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
|
||||
|
||||
// Generate displace mask
|
||||
// Use RTT_TMP4 as displace mask
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_TMP4));
|
||||
irr_driver->getFBO(FBO_TMP1_WITH_DS).Bind();
|
||||
|
||||
glUseProgram(MeshShader::DisplaceMaskShader::Program);
|
||||
MeshShader::DisplaceMaskShader::setUniforms(ModelViewProjectionMatrix);
|
||||
@ -159,9 +159,9 @@ void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
|
||||
// Render the effect
|
||||
if (!displaceTex)
|
||||
displaceTex = irr_driver->getTexture(FileManager::TEXTURE, "displace.png");
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_DISPLACE));
|
||||
irr_driver->getFBO(FBO_DISPLACE).Bind();
|
||||
setTexture(0, getTextureGLuint(displaceTex), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(1, irr_driver->getRenderTargetTexture(RTT_TMP4), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(1, irr_driver->getRenderTargetTexture(RTT_TMP1), GL_LINEAR, GL_LINEAR, true);
|
||||
setTexture(2, irr_driver->getRenderTargetTexture(RTT_COLOR), GL_LINEAR, GL_LINEAR, true);
|
||||
glUseProgram(MeshShader::DisplaceShader::Program);
|
||||
MeshShader::DisplaceShader::setUniforms(ModelViewProjectionMatrix, ModelViewMatrix,
|
||||
|
@ -345,6 +345,8 @@ Controller* World::loadAIController(AbstractKart *kart)
|
||||
//-----------------------------------------------------------------------------
|
||||
World::~World()
|
||||
{
|
||||
irr_driver->onUnloadWorld();
|
||||
|
||||
if(ReplayPlay::get())
|
||||
{
|
||||
// Destroy the old replay object, which also stored the ghost
|
||||
|
@ -462,6 +462,8 @@ void RaceManager::startNextRace()
|
||||
// functions.
|
||||
World::getWorld()->reset();
|
||||
|
||||
irr_driver->onLoadWorld();
|
||||
|
||||
// Save the current score and set last time to zero. This is necessary
|
||||
// if someone presses esc after finishing a gp, and selects restart:
|
||||
// The race is rerun, and the points and scores get reset ... but if
|
||||
|
Loading…
Reference in New Issue
Block a user