Added shader which could manipulate the color of the flames.
This commit is contained in:
parent
00506c6b3e
commit
1b8b8125f4
11
data/shader/flame_color.fsh
Normal file
11
data/shader/flame_color.fsh
Normal file
@ -0,0 +1,11 @@
|
||||
#version 150
|
||||
|
||||
in vec2 vTexCoord;
|
||||
|
||||
uniform sampler2D flame_fbo;
|
||||
|
||||
out vec4 oColor;
|
||||
|
||||
void main() {
|
||||
oColor = texture(flame_fbo, vTexCoord);
|
||||
}
|
11
data/shader/flame_color.vsh
Normal file
11
data/shader/flame_color.vsh
Normal file
@ -0,0 +1,11 @@
|
||||
#version 150
|
||||
|
||||
in vec2 aPosition;
|
||||
in vec2 aTexCoord;
|
||||
|
||||
out vec2 vTexCoord;
|
||||
|
||||
void main() {
|
||||
vTexCoord = aTexCoord;
|
||||
gl_Position = vec4(aPosition, 0.0, 1.0);
|
||||
}
|
15
graphics.cc
15
graphics.cc
@ -90,6 +90,9 @@ void Graphics::init(Level* level) {
|
||||
flameShader = ShaderProgramCreator("flame")
|
||||
.attributeLocations(flame_positions->getAttributeLocations()).create();
|
||||
|
||||
flameColorShader = ShaderProgramCreator("flame_color")
|
||||
.attributeLocations(fullscreen_quad->getAttributeLocations()).create();
|
||||
|
||||
flamePostShader = ShaderProgramCreator("flame_post")
|
||||
.attributeLocations(fullscreen_quad->getAttributeLocations()).create();
|
||||
|
||||
@ -99,8 +102,8 @@ void Graphics::init(Level* level) {
|
||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &number_of_texture_units);
|
||||
printf("Your graphics card supports %d texture units.\n", number_of_texture_units);
|
||||
// Exit if we need more texture units
|
||||
if (number_of_texture_units < 18) {
|
||||
printf("You need at least 18 texture units to run this application. Exiting\n");
|
||||
if (number_of_texture_units < 19) {
|
||||
printf("You need at least 19 texture units to run this application. Exiting\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -188,6 +191,9 @@ void Graphics::init(Level* level) {
|
||||
mergeShader->setTexture("flame_fbo", flame_fbo_color_texture, 16);
|
||||
mergeShader->setTexture("light_fbo", light_fbo_color_texture, 17);
|
||||
|
||||
flameColorShader->use();
|
||||
flameColorShader->setTexture("flame_fbo", flame_fbo_color_texture, 18);
|
||||
|
||||
updateClosestLights();
|
||||
}
|
||||
|
||||
@ -340,8 +346,11 @@ void Graphics::render(double time)
|
||||
flame_positions->render();
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
framebuffer_light->bind();
|
||||
glDepthMask(GL_FALSE);
|
||||
flameColorShader->use();
|
||||
fullscreen_quad->render();
|
||||
|
||||
framebuffer_light->bind();
|
||||
mergeShader->use();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
fullscreen_quad->render();
|
||||
|
@ -35,6 +35,7 @@ class Graphics {
|
||||
SharedShaderProgram depthCubeShader;
|
||||
SharedShaderProgram depthShader;
|
||||
SharedShaderProgram flameShader;
|
||||
SharedShaderProgram flameColorShader;
|
||||
SharedShaderProgram flamePostShader;
|
||||
SharedShaderProgram mergeShader;
|
||||
std::vector<SharedTexture2D> depth_directionalMaps;
|
||||
|
Loading…
Reference in New Issue
Block a user