[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34263] trunk/blender/source/blender/ render/intern/source/rayshade.c: Bugfix #25580
Ton Roosendaal
ton at blender.org
Tue Jan 11 19:40:45 CET 2011
Revision: 34263
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34263
Author: ton
Date: 2011-01-11 18:40:44 +0000 (Tue, 11 Jan 2011)
Log Message:
-----------
Bugfix #25580
Raytracing didn't show soft shadow in reflections, nor did it do any
derivative even. Added a basic version for it in raytracer now, still
needs improvement on heavily curved surfaces. But it's better!
Examples:
Glass sphere, mirror cube and sphere, look how it ignores bump and shadow
http://www.blender.org/bf/derivative256.png
in svn now:
http://www.blender.org/bf/derivative-svn.png
Modified Paths:
--------------
trunk/blender/source/blender/render/intern/source/rayshade.c
Modified: trunk/blender/source/blender/render/intern/source/rayshade.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/rayshade.c 2011-01-11 17:01:12 UTC (rev 34262)
+++ trunk/blender/source/blender/render/intern/source/rayshade.c 2011-01-11 18:40:44 UTC (rev 34263)
@@ -482,13 +482,44 @@
#endif
}
+/* if(shi->osatex) */
+static void shade_ray_set_derivative(ShadeInput *shi)
+{
+ float *v1= shi->v1->co;
+ float *v2= shi->v2->co;
+ float *v3= shi->v3->co;
+ float detsh, t00, t10, t01, t11, xn, yn, zn;
+ int axis1, axis2;
+
+ /* find most stable axis to project */
+ xn= fabs(shi->facenor[0]);
+ yn= fabs(shi->facenor[1]);
+ zn= fabs(shi->facenor[2]);
+
+ if(zn>=xn && zn>=yn) { axis1= 0; axis2= 1; }
+ else if(yn>=xn && yn>=zn) { axis1= 0; axis2= 2; }
+ else { axis1= 1; axis2= 2; }
+
+ /* compute u,v and derivatives */
+ t00= v3[axis1]-v1[axis1]; t01= v3[axis2]-v1[axis2];
+ t10= v3[axis1]-v2[axis1]; t11= v3[axis2]-v2[axis2];
+
+ detsh= 1.0f/(t00*t11-t10*t01);
+ t00*= detsh; t01*=detsh;
+ t10*=detsh; t11*=detsh;
+
+ shi->dx_u= shi->dxco[axis1]*t11- shi->dxco[axis2]*t10;
+ shi->dx_v= shi->dxco[axis2]*t00- shi->dxco[axis1]*t01;
+ shi->dy_u= shi->dyco[axis1]*t11- shi->dyco[axis2]*t10;
+ shi->dy_v= shi->dyco[axis2]*t00- shi->dyco[axis1]*t01;
+
+}
void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
{
ObjectInstanceRen *obi= (ObjectInstanceRen*)is->hit.ob;
VlakRen *vlr= (VlakRen*)is->hit.face;
- int osatex= 0;
/* set up view vector */
VECCOPY(shi->view, is->vec);
@@ -506,18 +537,6 @@
shi->mat= vlr->mat;
shade_input_init_material(shi);
- // Osa structs we leave unchanged now
- SWAP(int, osatex, shi->osatex);
-
- shi->dxco[0]= shi->dxco[1]= shi->dxco[2]= 0.0f;
- shi->dyco[0]= shi->dyco[1]= shi->dyco[2]= 0.0f;
-
- // but, set Osa stuff to zero where it can confuse texture code
- if(shi->mat->texco & (TEXCO_NORM|TEXCO_REFL) ) {
- shi->dxno[0]= shi->dxno[1]= shi->dxno[2]= 0.0f;
- shi->dyno[0]= shi->dyno[1]= shi->dyno[2]= 0.0f;
- }
-
if(vlr->v4) {
if(is->isect==2)
shade_input_set_triangle_i(shi, obi, vlr, 2, 1, 3);
@@ -532,6 +551,8 @@
shi->v= is->v;
shi->dx_u= shi->dx_v= shi->dy_u= shi->dy_v= 0.0f;
+ if(shi->osatex)
+ shade_ray_set_derivative(shi);
shade_input_set_normals(shi);
shade_input_set_shade_texco(shi);
@@ -563,8 +584,6 @@
/* raytrace likes to separate the spec color */
VECSUB(shr->diff, shr->combined, shr->spec);
}
-
- SWAP(int, osatex, shi->osatex); // XXXXX!!!!
}
@@ -720,6 +739,10 @@
ShadeResult shr= {{0}};
float d= 1.0f;
+ /* for as long we don't have proper dx/dy transform for rays we copy over original */
+ VECCOPY(shi.dxco, origshi->dxco);
+ VECCOPY(shi.dyco, origshi->dyco);
+
shi.mask= origshi->mask;
shi.osatex= origshi->osatex;
shi.depth= origshi->depth + 1; /* only used to indicate tracing */
More information about the Bf-blender-cvs
mailing list