forked from blender/blender
Fix rendering of Final render for Storm delegate #61
@ -179,27 +179,39 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
|
||||
{
|
||||
prepare_for_render(depsgraph);
|
||||
|
||||
GLuint framebuffer_name = 0;
|
||||
glGenFramebuffers(1, &framebuffer_name);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_name);
|
||||
GLuint framebuffer = 0, tex_color = 0, tex_depth = 0;
|
||||
glGenFramebuffers(1, &framebuffer);
|
||||
glGenTextures(1, &tex_color);
|
||||
glGenTextures(1, &tex_depth);
|
||||
|
||||
// The texture we're going to render to
|
||||
GLuint rendered_texture;
|
||||
glGenTextures(1, &rendered_texture);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
|
||||
// "Bind" the newly created texture : all future texture functions will modify this texture
|
||||
glBindTexture(GL_TEXTURE_2D, rendered_texture);
|
||||
|
||||
// Give an empty image to OpenGL ( the last "0" )
|
||||
// Set tex_color as GL_COLOR_ATTACHMENT0
|
||||
glBindTexture(GL_TEXTURE_2D, tex_color);
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D, 0, GL_RGBA32F, resolution_[0], resolution_[1], 0, GL_RGBA, GL_FLOAT, 0);
|
||||
|
||||
// Poor filtering. Needed !
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 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);
|
||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex_color, 0);
|
||||
|
||||
// Set "rendered_texture" as our colour attachement #0
|
||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, rendered_texture, 0);
|
||||
// Set tex_depth as GL_DEPTH_ATTACHMENT
|
||||
glBindTexture(GL_TEXTURE_2D, tex_depth);
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_DEPTH_COMPONENT32,
|
||||
resolution_[0],
|
||||
resolution_[1],
|
||||
0,
|
||||
GL_DEPTH_COMPONENT,
|
||||
GL_FLOAT,
|
||||
0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 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);
|
||||
//glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tex_depth, 0);
|
||||
|
||||
// Generate vertex array
|
||||
GLuint vao;
|
||||
@ -232,12 +244,12 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
|
||||
break;
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, rendered_texture);
|
||||
glBindTexture(GL_TEXTURE_2D, tex_color);
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, pixels.data());
|
||||
update_render_result();
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, rendered_texture);
|
||||
glBindTexture(GL_TEXTURE_2D, tex_color);
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, pixels.data());
|
||||
update_render_result();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user