[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21080] branches/soc-2009-yukishiro/source /blender: start adding Matt's patch
Jingyuan Huang
jingyuan.huang at gmail.com
Mon Jun 22 18:34:37 CEST 2009
Revision: 21080
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21080
Author: yukishiro
Date: 2009-06-22 18:34:37 +0200 (Mon, 22 Jun 2009)
Log Message:
-----------
start adding Matt's patch
Modified Paths:
--------------
branches/soc-2009-yukishiro/source/blender/makesdna/DNA_meshdata_types.h
branches/soc-2009-yukishiro/source/blender/makesdna/DNA_world_types.h
branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_scene.c
branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_world.c
branches/soc-2009-yukishiro/source/blender/render/intern/source/occlusion.c
branches/soc-2009-yukishiro/source/blender/render/intern/source/pipeline.c
branches/soc-2009-yukishiro/source/blender/render/intern/source/rayshade.c
branches/soc-2009-yukishiro/source/blender/render/intern/source/rendercore.c
branches/soc-2009-yukishiro/source/blender/sh/SH_api.h
branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c
Modified: branches/soc-2009-yukishiro/source/blender/makesdna/DNA_meshdata_types.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesdna/DNA_meshdata_types.h 2009-06-22 16:21:59 UTC (rev 21079)
+++ branches/soc-2009-yukishiro/source/blender/makesdna/DNA_meshdata_types.h 2009-06-22 16:34:37 UTC (rev 21080)
@@ -102,14 +102,6 @@
short mode, tile, unwrap;
} MTFace;
-//typedef struct MShCoeffs2 {
-// float val[9];
-//} MShCoeffs2;
-//
-//typedef struct MShCoeffs3 {
-// float val[16];
-//} MShCoeffs3;
-
typedef struct MShCoeffs {
float val[25];
} MShCoeffs;
Modified: branches/soc-2009-yukishiro/source/blender/makesdna/DNA_world_types.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesdna/DNA_world_types.h 2009-06-22 16:21:59 UTC (rev 21079)
+++ branches/soc-2009-yukishiro/source/blender/makesdna/DNA_world_types.h 2009-06-22 16:34:37 UTC (rev 21080)
@@ -138,12 +138,13 @@
#define WO_ZENUP 16
/* mode */
-#define WO_MIST 1
-#define WO_STARS 2
-#define WO_DOF 4
-#define WO_ACTIVITY_CULLING 8
-#define WO_AMB_OCC 16
-#define WO_DBVT_CULLING 32
+#define WO_MIST 1
+#define WO_STARS 2
+#define WO_DOF 4
+#define WO_ACTIVITY_CULLING 8
+#define WO_AMB_OCC 16
+#define WO_DBVT_CULLING 32
+#define WO_IBL 64
/* aomix */
#define WO_AOADD 0
@@ -164,6 +165,7 @@
#define WO_AOPLAIN 0
#define WO_AOSKYCOL 1
#define WO_AOSKYTEX 2
+#define WO_AOSH 3
/* ao_gather_method */
#define WO_AOGATHER_RAYTRACE 0
Modified: branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_scene.c 2009-06-22 16:21:59 UTC (rev 21079)
+++ branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_scene.c 2009-06-22 16:34:37 UTC (rev 21080)
@@ -650,7 +650,7 @@
RNA_def_property_boolean_negative_sdna(prop, NULL, "scemode", R_NO_TEX);
RNA_def_property_ui_text(prop, "Render Textures", "Use textures to affect material properties.");
RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
-
+
prop= RNA_def_property(srna, "edge", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE);
RNA_def_property_ui_text(prop, "Edge", "Create a toon outline around the edges of geometry");
Modified: branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_world.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_world.c 2009-06-22 16:21:59 UTC (rev 21079)
+++ branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_world.c 2009-06-22 16:34:37 UTC (rev 21080)
@@ -135,6 +135,7 @@
{WO_AOPLAIN, "PLAIN", 0, "White", "Plain diffuse energy (white.)"},
{WO_AOSKYCOL, "SKY_COLOR", 0, "Sky Color", "Use horizon and zenith color for diffuse energy."},
{WO_AOSKYTEX, "SKY_TEXTURE", 0, "Sky Texture", "Does full Sky texture render for diffuse energy."},
+ {WO_AOSH, "DIFFUSE_SH", 0, "SH Diffuse", "Use spherical harmonics."},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem prop_sample_method_items[] = {
Modified: branches/soc-2009-yukishiro/source/blender/render/intern/source/occlusion.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/render/intern/source/occlusion.c 2009-06-22 16:21:59 UTC (rev 21079)
+++ branches/soc-2009-yukishiro/source/blender/render/intern/source/occlusion.c 2009-06-22 16:34:37 UTC (rev 21080)
@@ -1297,7 +1297,14 @@
shadeSkyView(skycol, co, bn, dxyview);
}
#endif
+ else { /* WO_AODIFFUSESH */
+ float bentnor[3];
+ VECCOPY(bentnor, bn);
+ Mat4Mul3Vecfl(re->viewinv, bentnor);
+ SH_eval_color(skycol, re->scene->lightenv, bentnor);
+ }
+
VecMulf(skycol, occlusion);
}
else {
Modified: branches/soc-2009-yukishiro/source/blender/render/intern/source/pipeline.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/render/intern/source/pipeline.c 2009-06-22 16:21:59 UTC (rev 21079)
+++ branches/soc-2009-yukishiro/source/blender/render/intern/source/pipeline.c 2009-06-22 16:34:37 UTC (rev 21080)
@@ -1653,7 +1653,7 @@
if(render_scene_needs_vector(re))
RE_Database_FromScene_Vectors(re, re->scene);
else
- RE_Database_FromScene(re, re->scene, 1);
+ RE_Database_FromScene(re, re->scene, 1);
threaded_tile_processor(re);
Modified: branches/soc-2009-yukishiro/source/blender/render/intern/source/rayshade.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/render/intern/source/rayshade.c 2009-06-22 16:21:59 UTC (rev 21079)
+++ branches/soc-2009-yukishiro/source/blender/render/intern/source/rayshade.c 2009-06-22 16:34:37 UTC (rev 21080)
@@ -46,6 +46,8 @@
#include "PIL_time.h"
+#include "SH_api.h"
+
#include "render_types.h"
#include "renderpipeline.h"
#include "rendercore.h"
@@ -1545,6 +1547,8 @@
float dxyview[3], skyadded=0, div;
int aocolor;
+ float bentnor[3];
+ int noradded = 0;
isec.faceorig= (RayFace*)shi->vlr;
isec.oborig= RAY_OBJECT_SET(&R, shi->obi);
@@ -1554,6 +1558,7 @@
isec.lay= -1;
shadfac[0]= shadfac[1]= shadfac[2]= 0.0f;
+ bentnor[0]= bentnor[1]= bentnor[2]= 0.0f;
/* prevent sky colors to be added for only shadow (shadow becomes alpha) */
aocolor= R.wrld.aocolor;
@@ -1620,6 +1625,9 @@
view[1]= -dir[1];
view[2]= -dir[2];
Normalize(view);
+
+ VecAddf(bentnor, bentnor, view);
+ noradded++;
if(aocolor==WO_AOSKYCOL) {
skyfac= 0.5*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]);
@@ -1656,7 +1664,16 @@
shadfac[0]*= div; // average color times distances/hits formula
shadfac[1]*= div; // average color times distances/hits formula
shadfac[2]*= div; // average color times distances/hits formula
- } else {
+ }
+ else if(aocolor == WO_AOSH && noradded > 0) {
+ VecMulf(bentnor, (1.0f / (float)noradded));
+ Mat4Mul3Vecfl(R.viewinv, bentnor);
+ SH_eval_color(shadfac, R.scene->lightenv, bentnor);
+
+ div = (float)noradded / (float)samples * exp(R.wrld.aodistfac);
+ VecMulf(shadfac, div);
+ }
+ else {
shadfac[0]= shadfac[1]= shadfac[2]= 1.0f - fac/(float)samples;
}
Modified: branches/soc-2009-yukishiro/source/blender/render/intern/source/rendercore.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/render/intern/source/rendercore.c 2009-06-22 16:21:59 UTC (rev 21079)
+++ branches/soc-2009-yukishiro/source/blender/render/intern/source/rendercore.c 2009-06-22 16:34:37 UTC (rev 21080)
@@ -1162,7 +1162,7 @@
halo_tile(pa, rl);
// XXX: THIS IS TOTALLY A HACK NOW
- if(G.f & G_LIGHTPAINT) {
+ if((R.r.scemode & R_PREVIEWBUTS) && (G.f & G_LIGHTPAINT)) {
float *fcol= rl->rectf;
int width = R.disprect.xmax - R.disprect.xmin;
int height = R.disprect.ymax - R.disprect.ymin;
Modified: branches/soc-2009-yukishiro/source/blender/sh/SH_api.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/sh/SH_api.h 2009-06-22 16:21:59 UTC (rev 21079)
+++ branches/soc-2009-yukishiro/source/blender/sh/SH_api.h 2009-06-22 16:34:37 UTC (rev 21080)
@@ -48,6 +48,7 @@
void SH_from_disc(int L, float *n, float area, float *shresult);
float SH_eval(float *sh, float *v);
+void SH_eval_color(float *col, struct LightEnv *env, float *n);
void SH_solve(float *P, float *I[3], int totvert, int num_sh, float *C[3]);
Modified: branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c 2009-06-22 16:21:59 UTC (rev 21079)
+++ branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c 2009-06-22 16:34:37 UTC (rev 21080)
@@ -707,6 +707,7 @@
free_ShCoeffs(Y);
}
+
// size of shresult = (L + 1) * (L + 1)
/* Use 2nd order SH => 9 coefficients, stored in this order:
0 = (0,0),
@@ -746,7 +747,7 @@
y= v[1];
z= v[2];
- sum= c1*sh[8]*(x*x - y*y);
+ sum = c1*sh[8]*(x*x - y*y);
sum += c3*sh[6]*z*z;
sum += c4*sh[0];
sum += -c5*sh[6];
@@ -756,3 +757,21 @@
return sum;
}
+
+void SH_eval_color(float *col, LightEnv *env, float *n)
+{
+ int channel, i;
+ float coeffs[9];
+
+ if (env == NULL) {
+ col[0] = col[1] = col[2];
+ return;
+ }
+
+ for (channel = 0; channel < 3; channel++) {
+ for (i = 0; i < 9; i++) { // TODO: remove constant 9 later
+ coeffs[i] = env->shcoeffs[i][channel];
+ }
+ col[channel] = SH_eval(coeffs, n);
+ }
+}
More information about the Bf-blender-cvs
mailing list