Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-10-14 02:33:30 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-10-14 02:51:17 +0300
commit53d73c51a76577b8b9bb32fd08a967560353ab47 (patch)
tree2235d1c7d135353fa3064100482bff8695f51641 /source/blender/editors/render
parent5d3e07862cceb7dc356e30b061dec065e57a7d03 (diff)
Support for multi-sample off-screen buffers
Replaces much slower manual accumulation buffer which simply did multiple renders. Needs OpenGL3.2, otherwise multi-sample is disabled.
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r--source/blender/editors/render/render_opengl.c56
1 files changed, 7 insertions, 49 deletions
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 954fcdef63e..c8ced552109 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -375,54 +375,11 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr)
rect = MEM_mallocN(sizex * sizey * sizeof(unsigned char) * 4, "offscreen rect");
- if ((scene->r.mode & R_OSA) == 0) {
- ED_view3d_draw_offscreen(
- scene, v3d, ar, sizex, sizey, NULL, winmat,
- draw_bgpic, draw_sky, is_persp,
- oglrender->ofs, oglrender->fx, &fx_settings, viewname);
- GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, rect);
- }
- else {
- /* simple accumulation, less hassle then FSAA FBO's */
- static float jit_ofs[32][2];
- float winmat_jitter[4][4];
- int *accum_buffer = MEM_mallocN(sizex * sizey * sizeof(int) * 4, "accum1");
- int i, j;
-
- BLI_jitter_init(jit_ofs, scene->r.osa);
-
- /* first sample buffer, also initializes 'rv3d->persmat' */
- ED_view3d_draw_offscreen(
- scene, v3d, ar, sizex, sizey, NULL, winmat,
- draw_bgpic, draw_sky, is_persp,
- oglrender->ofs, oglrender->fx, &fx_settings, viewname);
- GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, rect);
-
- for (i = 0; i < sizex * sizey * 4; i++)
- accum_buffer[i] = rect[i];
-
- /* skip the first sample */
- for (j = 1; j < scene->r.osa; j++) {
- copy_m4_m4(winmat_jitter, winmat);
- window_translate_m4(winmat_jitter, rv3d->persmat,
- (jit_ofs[j][0] * 2.0f) / sizex,
- (jit_ofs[j][1] * 2.0f) / sizey);
-
- ED_view3d_draw_offscreen(
- scene, v3d, ar, sizex, sizey, NULL, winmat_jitter,
- draw_bgpic, draw_sky, is_persp,
- oglrender->ofs, oglrender->fx, &fx_settings, viewname);
- GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, rect);
-
- for (i = 0; i < sizex * sizey * 4; i++)
- accum_buffer[i] += rect[i];
- }
-
- for (i = 0; i < sizex * sizey * 4; i++)
- rect[i] = accum_buffer[i] / scene->r.osa;
-
- MEM_freeN(accum_buffer);
- }
+ ED_view3d_draw_offscreen(
+ scene, v3d, ar, sizex, sizey, NULL, winmat,
+ draw_bgpic, draw_sky, is_persp,
+ oglrender->ofs, oglrender->fx, &fx_settings, viewname);
+ GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, rect);
GPU_offscreen_unbind(oglrender->ofs, true); /* unbind */
}
@@ -546,6 +503,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
const bool is_sequencer = RNA_boolean_get(op->ptr, "sequencer");
const bool is_write_still = RNA_boolean_get(op->ptr, "write_still");
char err_out[256] = "unknown";
+ int samples = (scene->r.mode & R_OSA) ? scene->r.osa : 0;
if (G.background) {
BKE_report(op->reports, RPT_ERROR, "Cannot use OpenGL render in background mode (no opengl context)");
@@ -585,7 +543,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
sizey = (scene->r.size * scene->r.ysch) / 100;
/* corrects render size with actual size, not every card supports non-power-of-two dimensions */
- ofs = GPU_offscreen_create(sizex, sizey, err_out);
+ ofs = GPU_offscreen_create(sizex, sizey, samples, err_out);
if (!ofs) {
BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL off-screen buffer, %s", err_out);