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);
|
prepare_for_render(depsgraph);
|
||||||
|
|
||||||
GLuint framebuffer_name = 0;
|
GLuint framebuffer = 0, tex_color = 0, tex_depth = 0;
|
||||||
glGenFramebuffers(1, &framebuffer_name);
|
glGenFramebuffers(1, &framebuffer);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_name);
|
glGenTextures(1, &tex_color);
|
||||||
|
glGenTextures(1, &tex_depth);
|
||||||
|
|
||||||
// The texture we're going to render to
|
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||||
GLuint rendered_texture;
|
|
||||||
glGenTextures(1, &rendered_texture);
|
|
||||||
|
|
||||||
// "Bind" the newly created texture : all future texture functions will modify this texture
|
// Set tex_color as GL_COLOR_ATTACHMENT0
|
||||||
glBindTexture(GL_TEXTURE_2D, rendered_texture);
|
glBindTexture(GL_TEXTURE_2D, tex_color);
|
||||||
|
|
||||||
// Give an empty image to OpenGL ( the last "0" )
|
|
||||||
glTexImage2D(
|
glTexImage2D(
|
||||||
GL_TEXTURE_2D, 0, GL_RGBA32F, resolution_[0], resolution_[1], 0, GL_RGBA, GL_FLOAT, 0);
|
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_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_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
|
// Set tex_depth as GL_DEPTH_ATTACHMENT
|
||||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, rendered_texture, 0);
|
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
|
// Generate vertex array
|
||||||
GLuint vao;
|
GLuint vao;
|
||||||
@ -232,12 +244,12 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, rendered_texture);
|
glBindTexture(GL_TEXTURE_2D, tex_color);
|
||||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, pixels.data());
|
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, pixels.data());
|
||||||
update_render_result();
|
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());
|
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, pixels.data());
|
||||||
update_render_result();
|
update_render_result();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user