[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32261] trunk/blender/source/blender/ editors/render/render_opengl.c: fix for last commit, was using the window area size rather then the image size to make the window matrix .
Campbell Barton
ideasman42 at gmail.com
Sat Oct 2 20:25:12 CEST 2010
Revision: 32261
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32261
Author: campbellbarton
Date: 2010-10-02 20:25:12 +0200 (Sat, 02 Oct 2010)
Log Message:
-----------
fix for last commit, was using the window area size rather then the image size to make the window matrix.
Modified Paths:
--------------
trunk/blender/source/blender/editors/render/render_opengl.c
Modified: trunk/blender/source/blender/editors/render/render_opengl.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_opengl.c 2010-10-02 17:10:28 UTC (rev 32260)
+++ trunk/blender/source/blender/editors/render/render_opengl.c 2010-10-02 18:25:12 UTC (rev 32261)
@@ -141,8 +141,8 @@
rctf viewplane;
float clipsta, clipend;
- is_ortho= get_view3d_viewplane(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL);
- if(is_ortho) orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
+ is_ortho= get_view3d_viewplane(v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend, NULL);
+ if(is_ortho) orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, -clipend, clipend);
else perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
}
@@ -153,15 +153,18 @@
else {
/* simple accumulation, less hassle then FSAA FBO's */
# define SAMPLES 5 /* fixed, easy to have more but for now this is ok */
-
+ const float jit_ofs[SAMPLES][2] = {{0, 0}, {1,1}, {-1,-1}, {-1,1}, {1,-1}};
float winmat_jitter[4][4];
- float *accum_buffer= MEM_callocN(sizex * sizey * sizeof(float) * 4, "accum1");
- float *accum_tmp= MEM_callocN(sizex * sizey * sizeof(float) * 4, "accum2");
+ float *accum_buffer= MEM_mallocN(sizex * sizey * sizeof(float) * 4, "accum1");
+ float *accum_tmp= MEM_mallocN(sizex * sizey * sizeof(float) * 4, "accum2");
int j, i;
- float jiy[SAMPLES][2] = {{1,1}, {-1,-1}, {-1,1}, {1,-1}, {0, 0}};
float *from, *to;
float pixelsize[2];
-
+
+ /* first sample buffer, also initializes 'rv3d->persmat' */
+ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat);
+ glReadPixels(0, 0, sizex, sizey, GL_RGBA, GL_FLOAT, accum_buffer);
+
if(is_ortho) {
pixelsize[0]= 0.5f / sizex;
pixelsize[1]= 0.5f / sizey;
@@ -177,16 +180,17 @@
pixelsize[1]= 0.5 * len2 * winmat[1][1];
}
- for(j=0; j < SAMPLES; j++) {
+ /* skip the first sample */
+ for(j=1; j < SAMPLES; j++) {
copy_m4_m4(winmat_jitter, winmat);
if(is_ortho) {
- winmat_jitter[3][0] += jiy[j][0] * pixelsize[0];
- winmat_jitter[3][1] += jiy[j][1] * pixelsize[1];
+ winmat_jitter[3][0] += jit_ofs[j][0] * pixelsize[0];
+ winmat_jitter[3][1] += jit_ofs[j][1] * pixelsize[1];
}
else {
- winmat_jitter[2][0] += jiy[j][0] * pixelsize[0];
- winmat_jitter[2][1] += jiy[j][1] * pixelsize[1];
+ winmat_jitter[2][0] += jit_ofs[j][0] * pixelsize[0];
+ winmat_jitter[2][1] += jit_ofs[j][1] * pixelsize[1];
}
ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat_jitter);
More information about the Bf-blender-cvs
mailing list