Use direct gl calls for BloomBlend too.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@15026 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a49d85fa3e
commit
f8e17ecffa
@ -1,11 +1,13 @@
|
|||||||
#version 130
|
#version 130
|
||||||
uniform sampler2D tex;
|
uniform sampler2D tex;
|
||||||
|
|
||||||
|
in vec2 uv;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 col = texture2D(tex, gl_TexCoord[0].xy);
|
vec4 col = texture2D(tex, uv);
|
||||||
|
|
||||||
col.xyz *= 10.0 * col.a;
|
col.xyz *= 10.0 * col.a;
|
||||||
|
|
||||||
gl_FragColor = vec4(col.xyz, 1.0);
|
gl_FragColor = vec4(col.xyz, 1.);
|
||||||
}
|
}
|
||||||
|
@ -240,34 +240,62 @@ static void initQuadVBO()
|
|||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace BloomShader
|
namespace BloomShader
|
||||||
{
|
{
|
||||||
GLuint Program = 0;
|
GLuint Program = 0;
|
||||||
GLuint attrib_position, attrib_texcoord;
|
GLuint attrib_position, attrib_texcoord;
|
||||||
GLuint uniform_texture, uniform_low;
|
GLuint uniform_texture, uniform_low;
|
||||||
GLuint vao = 0;
|
GLuint vao = 0;
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
initGL();
|
initGL();
|
||||||
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/bloom.frag").c_str());
|
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/bloom.frag").c_str());
|
||||||
attrib_position = glGetAttribLocation(Program, "Position");
|
attrib_position = glGetAttribLocation(Program, "Position");
|
||||||
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
uniform_texture = glGetUniformLocation(Program, "tex");
|
uniform_texture = glGetUniformLocation(Program, "tex");
|
||||||
uniform_low = glGetUniformLocation(Program, "low");
|
uniform_low = glGetUniformLocation(Program, "low");
|
||||||
|
|
||||||
if (!quad_vbo)
|
if (!quad_vbo)
|
||||||
initQuadVBO();
|
initQuadVBO();
|
||||||
glGenVertexArrays(1, &vao);
|
glGenVertexArrays(1, &vao);
|
||||||
glBindVertexArray(vao);
|
glBindVertexArray(vao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, quad_vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, quad_vbo);
|
||||||
glEnableVertexAttribArray(attrib_position);
|
glEnableVertexAttribArray(attrib_position);
|
||||||
glEnableVertexAttribArray(attrib_texcoord);
|
glEnableVertexAttribArray(attrib_texcoord);
|
||||||
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||||
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*)(2 * sizeof(float)));
|
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*)(2 * sizeof(float)));
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace BloomBlendShader
|
||||||
|
{
|
||||||
|
GLuint Program = 0;
|
||||||
|
GLuint attrib_position, attrib_texcoord;
|
||||||
|
GLuint uniform_texture, uniform_low;
|
||||||
|
GLuint vao = 0;
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
initGL();
|
||||||
|
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/bloomblend.frag").c_str());
|
||||||
|
attrib_position = glGetAttribLocation(Program, "Position");
|
||||||
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
|
uniform_texture = glGetUniformLocation(Program, "tex");
|
||||||
|
|
||||||
|
if (!quad_vbo)
|
||||||
|
initQuadVBO();
|
||||||
|
glGenVertexArrays(1, &vao);
|
||||||
|
glBindVertexArray(vao);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, quad_vbo);
|
||||||
|
glEnableVertexAttribArray(attrib_position);
|
||||||
|
glEnableVertexAttribArray(attrib_texcoord);
|
||||||
|
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||||
|
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*)(2 * sizeof(float)));
|
||||||
|
glBindVertexArray(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -287,6 +315,33 @@ void renderBloom(ITexture *in)
|
|||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void renderBloomBlend(ITexture *in)
|
||||||
|
{
|
||||||
|
if (!BloomBlendShader::Program)
|
||||||
|
BloomBlendShader::init();
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
|
glBlendFunc(GL_ONE, GL_ONE);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
glUseProgram(BloomBlendShader::Program);
|
||||||
|
glBindVertexArray(BloomBlendShader::vao);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(in)->getOpenGLTextureName());
|
||||||
|
glUniform1i(BloomBlendShader::uniform_texture, 0);
|
||||||
|
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
glBindVertexArray(0);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -477,14 +532,8 @@ void PostProcessing::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Additively blend on top of tmp1
|
// Additively blend on top of tmp1
|
||||||
m_material.BlendOperation = EBO_ADD;
|
drv->setRenderTarget(out, false, false);
|
||||||
m_material.MaterialType = irr_driver->getShader(ES_BLOOM_BLEND);
|
renderBloomBlend(irr_driver->getRTT(RTT_EIGHTH1));
|
||||||
m_material.setTexture(0, irr_driver->getRTT(RTT_EIGHTH1));
|
|
||||||
drv->setRenderTarget(out, false, false);
|
|
||||||
|
|
||||||
drawQuad(cam, m_material);
|
|
||||||
|
|
||||||
m_material.BlendOperation = EBO_NONE;
|
|
||||||
} // end if bloom
|
} // end if bloom
|
||||||
|
|
||||||
in = irr_driver->getRTT(RTT_TMP1);
|
in = irr_driver->getRTT(RTT_TMP1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user