[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12919] branches/soc-2007-joeedh/source/ blender: commit of (not particularly functional) current copy prior to winter break
Joseph Eagar
joeedh at gmail.com
Mon Dec 17 07:45:51 CET 2007
Revision: 12919
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12919
Author: joeedh
Date: 2007-12-17 07:45:50 +0100 (Mon, 17 Dec 2007)
Log Message:
-----------
commit of (not particularly functional) current copy prior to winter break
away-from-desktop time.
Modified Paths:
--------------
branches/soc-2007-joeedh/source/blender/include/BIF_editview.h
branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h
branches/soc-2007-joeedh/source/blender/render/intern/source/convertblender.c
branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
branches/soc-2007-joeedh/source/blender/render/intern/source/rayshade.c
branches/soc-2007-joeedh/source/blender/render/intern/source/shadeoutput.c
branches/soc-2007-joeedh/source/blender/src/drawview.c
branches/soc-2007-joeedh/source/blender/src/space.c
Modified: branches/soc-2007-joeedh/source/blender/include/BIF_editview.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/include/BIF_editview.h 2007-12-17 06:32:53 UTC (rev 12918)
+++ branches/soc-2007-joeedh/source/blender/include/BIF_editview.h 2007-12-17 06:45:50 UTC (rev 12919)
@@ -57,5 +57,16 @@
void view3d_border_zoom(void);
void view3d_edit_clipping(struct View3D *v3d);
+void BSE_Add3DVisPoint(float *co, float *clr, int index);
+void BSE_PushMatrix4fl(float mat[4][4]);
+void BSE_PopMatrix(void);
+void BSE_Kill3DVisPoint(int index);
+void BSE_Refresh(void);
+
+extern float BSE_Yellow[3];
+extern float BSE_Red[3];
+extern float BSE_Blue[3];
+extern float BSE_Orange[3];
+
#endif
Modified: branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h 2007-12-17 06:32:53 UTC (rev 12918)
+++ branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h 2007-12-17 06:45:50 UTC (rev 12919)
@@ -372,6 +372,8 @@
float sh_invcampos[3], sh_zfac; /* sh_= spothalo */
float mat[3][3]; /* 3x3 part from lampmat x viewmat */
+ float fullmat[4][4];
+
float area[8][3], areasize;
/* passes & node shader support: all shadow info for a pixel */
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/convertblender.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/convertblender.c 2007-12-17 06:32:53 UTC (rev 12918)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/convertblender.c 2007-12-17 06:45:50 UTC (rev 12919)
@@ -3009,6 +3009,7 @@
MTC_Mat3CpyMat4(lar->mat, mat);
MTC_Mat3CpyMat4(lar->imat, ob->imat);
+ MTC_Mat4CpyMat4(lar->fullmat, ob->obmat);
lar->bufsize = la->bufsize;
lar->samp = la->samp;
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2007-12-17 06:32:53 UTC (rev 12918)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2007-12-17 06:45:50 UTC (rev 12919)
@@ -66,6 +66,9 @@
#include "MEM_guardedalloc.h"
+#include "BIF_space.h"
+#include "BIF_editview.h"
+
extern Render R;
static TCS_TilePool *deepbuffer_pool = NULL;
@@ -1189,20 +1192,26 @@
if ((zenter <= func->zmin+bias && zexit >= func->zmin+bias) ||
(zenter >= func->zmin+bias && zenter <= func->zmax+bias)) {
- if (zenter < func->zmin) zenter = func->zmin;
- if (zexit > func->zmax) zexit = func->zmax;
+ //if (zenter < func->zmin+bias) zenter = func->zmin+bias;
+ //if (zexit > func->zmax+bias) zexit = func->zmax+bias;
samp = func->samples + 1;
for (i=1; i < func->totsamples; i++, samp++) {
+ if ((samp-1)->depth < func->zmin || (samp-1)->depth > func->zmax)
+ printf("Evil! Out of Z range!\n");
+
+ if ((samp)->depth < func->zmin || (samp)->depth > func->zmax)
+ printf("Evil2! Out of Z range!\n");
+
if (shadclr[index] < 0.001) break;
//[s | e |] and ([| s | e] which includes [|s e|])
/*first check if the ray intersects samp-1's depth sample*/
- if ((zenter <= (samp-1)->depth+bias && zexit >= (samp-1)->depth+bias) ||
+ //if ((zenter <= (samp-1)->depth+bias && zexit >= (samp-1)->depth+bias) ||
//(zenter >= (samp-1)->depth-bias && zenter <= (samp-1)->depth+bias) ||
- (zenter <= (samp)->depth+bias && zexit >= (samp)->depth+bias)) { // ||
+ if ((zenter <= (samp)->depth+bias && zexit >= (samp)->depth+bias)) { // ||
//(zenter >= (samp)->depth-bias && zenter <= (samp)->depth+bias)) {
shadclr[index] *= 1.0f - ((samp-1)->value - (samp)->value);
- } else if (samp->orig_totsamples && (zenter > (samp-1)->depth+bias && zexit < (samp)->depth-bias)) {
- /*divide into buckets as in the paper.*/
+ }/* else if (samp->orig_totsamples && (zenter > (samp-1)->depth+bias && zexit < (samp)->depth-bias)) {
+ // divide into buckets as in the paper.
int j, zs, curz = (samp-1)->depth;
zs = (samp->depth - (samp-1)->depth) / samp->orig_totsamples;
for (j=0; j<samp->orig_totsamples; j++, curz += zs) {
@@ -1211,7 +1220,7 @@
shadclr[index] *= 1.0f - ((samp-1)->value - (samp)->value) / samp->orig_totsamples;
}
}
- }
+ }*/
}
}
}
@@ -1384,10 +1393,10 @@
int xs, ys;
int zs, bias;
float raystart[4], sco[4];
- float shadclr[3], averfac;
+ float shadclr[3];
int samples=0;
float samp3d[3], jit[3];
- float vec[3], sfac;
+ float vec[3], sfac, matinv[4][4];
float colsq[4];
float adapt_thresh = lar->adapt_thresh;
int max_samples = lar->ray_totsamp;
@@ -1499,13 +1508,21 @@
VECCOPY(vec, lar->co);
shadclr[0] = shadclr[1] = shadclr[2] = 0.0f;
- averfac = 1.0f/((float)(max_samples));
+
+#define DSMUSEQMC
+#ifdef DSMUSEQMC
+
+ Mat4Invert(matinv, lar->fullmat);
+
+ BSE_PushMatrix4fl(lar->fullmat);
+
while (samples < max_samples) {
/* manually jitter the start shading co-ord per sample
* based on the pre-generated OSA texture sampling offsets,
* for anti-aliasing sharp shadow edges. */
VECCOPY(pos, shi->co);
+
if (shi->vlr && !full_osa) {
QMC_sampleRect(jit, qsa_jit, shi->thread, samples, 1.0, 1.0);
@@ -1540,29 +1557,37 @@
/* sampling, returns quasi-random vector in [sizex,sizey]^2 plane */
QMC_sampleRect(samp3d, qsa, shi->thread, samples, lar->area_size, lar->area_sizey);
- /* align samples to lamp vector */
- Mat3MulVecfl(lar->mat, samp3d);
+ ///* align samples to lamp vector */
+ //Mat3MulVecfl(lar->mat, samp3d);
}
- sco[0]= vec[0]+samp3d[0];
- sco[1]= vec[1]+samp3d[1];
- sco[2]= vec[2]+samp3d[2];
+ sco[0]= samp3d[0];
+ sco[1]= samp3d[1];
+ sco[2]= samp3d[2];
} else {
VECCOPY(sco, vec);
}
-
+
+ sco[2] = 0.0f;
+
VECCOPY(raystart, pos);
/* trace the ray */
MTC_Mat4MulVecfl(shb->viewmat, raystart);
- MTC_Mat4MulVecfl(shb->viewmat, sco);
- VecClipLine3f(raystart, sco, 2, shb->clipsta+0.001f);
+ VecClipLine3f(raystart, sco, 2, -shb->clipsta-0.001f);
+
+ BSE_Add3DVisPoint(raystart, BSE_Yellow, 0);
+ BSE_Add3DVisPoint(sco, BSE_Yellow, 1);
+ BSE_Refresh();
raystart[3] = sco[3] = 1.0f;
+ printf("ray: [%f, %f, %f, %f]-[%f, %f, %f, %f]\n", raystart[0], raystart[1], raystart[2], raystart[3], sco[0], sco[1], sco[2], sco[3]);
+
MTC_Mat4MulVec4fl(shb->winmat, raystart);
MTC_Mat4MulVec4fl(shb->winmat, sco);
if (DSM_zbufclipwire(shb->clipsta, shb->clipend, shb->size, shb->size, raystart, sco)) {// int DSM_zbufclipwire(int rectx, int recty, float *v1, float *v2);
+ //printf("postray: [%f, %f, %f, %f]-[%f, %f, %f, %f]\n", raystart[0], raystart[1], raystart[2], raystart[3], sco[0], sco[1], sco[2], sco[3]);
if (G.rt == 31) {
/*convert vector Z from homogenous (e.g. non-linear) to
linear.*/
@@ -1604,8 +1629,13 @@
if ((qsa) && (qsa->type == SAMP_TYPE_HALTON)) QMC_freeSampler(qsa);
VECCOPY(shadowclr, shadclr);
+ BSE_PopMatrix();
+#else
+{
+ float raystart2[4], sadd, rayend[4];
+ float lamp_raystart[4], averfac;
+ int sx, sy;
-#if 0
/*Initalize sco*/
sco[0] = -0.5f;
sco[1] = -0.5f;
@@ -1671,7 +1701,7 @@
printf("raystart2: [%f, %f, %f, %f]\n", raystart2[0], raystart2[1], raystart2[2], raystart2[3]);
printf("clipped-rayend: [%f, %f, %f, %f]\n", rayend[0], rayend[1], rayend[2], rayend[3]);
}
- DSM_RasterRayPath(buf, bias, shadclr, raystart2, rayend, averfac);
+ DSM_RasterRayPath(buf, bias, shadclr, raystart, sco);
}
sco[0] += sadd;
}
@@ -1679,6 +1709,7 @@
}
VECCOPY(shadowclr, shadclr);
+}
#endif
}
@@ -1803,6 +1834,56 @@
drawing should happen. v1 and v2 are modified (clipped).*/
int DSM_zbufclipwire(float clipsta, float clipend, int rectx, int recty, float *v1, float *v2)
{
+ float vez[8];
+ int c1, c2, and, or;
+ ZSpan zspan;
+
+ memset(&zspan, 0, sizeof(zspan));
+
+ zspan.hoco_to_zco = linear_hoco_to_zco;
+ zspan.zofsx = zspan.zofsy = 0.0f; //-0.5f;
+ zspan.zmulx = ((float)rectx) / 2.0f;
+ zspan.zmuly = ((float)recty) / 2.0f;
+ zspan.rectx = rectx;
+ zspan.recty = recty;
+
+ c1= testclip(v1); //vlr->v1->clip;
+ c2= testclip(v2); //vlr->v2->clip;
+
+ and= (c1 & c2);
+ or= (c1 | c2);
+
+ if(or) { /* not in the middle */
+ if(and) { /* out completely */
+ return 0;
+ }
+ else { /* clipping */
+ QUATCOPY(vez, v1);
+ QUATCOPY(vez+4, v2);
+ if( clipline(vez, vez+4)) {
+ hoco_to_zco(&zspan, clipsta, clipend, vez, vez);
+ hoco_to_zco(&zspan, clipsta, clipend, vez+4, vez+4);
+
+ QUATCOPY(v1, vez);
+ QUATCOPY(v2, vez+4);
+ return 1;
+ } else return 0;
+ }
+ }
+
+ hoco_to_zco(&zspan, clipsta, clipend, vez, v1);
+ hoco_to_zco(&zspan, clipsta, clipend, vez+4, v2);
+ QUATCOPY(v1, vez);
+ QUATCOPY(v2, vez+4);
+
+ return 1;
+}
+
+/* Modified zbufclipwire from zbuf.c
+ v1 and v2 are in homogenous coordinates. returns true if
+ drawing should happen. v1 and v2 are modified (clipped).*/
+int DSM_zbufclipwire_old(float clipsta, float clipend, int rectx, int recty, float *v1, float *v2)
+{
float vez[20], *f1, *f2, *f3, v3[4];
int c1, c2, c3, and, or;
ZSpan zspan;
@@ -1810,7 +1891,7 @@
memset(&zspan, 0, sizeof(zspan));
zspan.hoco_to_zco = linear_hoco_to_zco;
- zspan.zofsx = zspan.zofsy = 0;
+ zspan.zofsx = zspan.zofsy = -0.5f;
zspan.zmulx = ((float)rectx) / 2.0f;
zspan.zmuly = ((float)recty) / 2.0f;
zspan.rectx = rectx;
@@ -1925,16 +2006,32 @@
/* Clip for z: clipsta and clipend clip values of the shadow buffer. We
* can test for -1.0/1.0 because of the properties of the
* coordinate transformations. */
- if (G.rt == 30) fac= (co[2]-shb->clipsta)/(shb->clipend - shb->clipsta);
- else fac = co[2]/co[3];
if (G.rt == 20) d = -0.0f;
else d = -1.0f;
- if(fac>=1.0f) {
- return 0.0f;
- } else if(fac<= d) {
- return 1.0f;
+ if (G.rt == 30) {
+ if (co[2] - shb->clipsta < -0.00001f) return 1.0; //shb->clipsta) return;
+ else if (co[2] > shb->clipend) co[2] = shb->clipend - 0.001;
+
+ fac= (double)(co[2] - shb->clipsta) / (double)(shb->clipend - shb->clipsta);
+ } else {
+
+ /* Clip for z: clipsta and clipend clip values of the shadow buffer. We
+ * can test for -1.0/1.0 because of the properties of the
+ * coordinate transformations. */
+ fac= (co[2]/co[3]);
+
+ if(fac>=1.0f) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list