[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58835] branches/soc-2013-dingto/intern/ cycles/kernel: Cycles / SSS Render Passes:
Thomas Dinges
blender at dingto.org
Fri Aug 2 21:57:14 CEST 2013
Revision: 58835
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58835
Author: dingto
Date: 2013-08-02 19:57:14 +0000 (Fri, 02 Aug 2013)
Log Message:
-----------
Cycles / SSS Render Passes:
* Finished the implementation, Direct and Indirect Passes work now.
Patch by Brecht and myself.
Modified Paths:
--------------
branches/soc-2013-dingto/intern/cycles/kernel/closure/bsdf.h
branches/soc-2013-dingto/intern/cycles/kernel/kernel_accumulate.h
branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h
branches/soc-2013-dingto/intern/cycles/kernel/kernel_subsurface.h
branches/soc-2013-dingto/intern/cycles/kernel/kernel_types.h
branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_types.h
Modified: branches/soc-2013-dingto/intern/cycles/kernel/closure/bsdf.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/closure/bsdf.h 2013-08-02 19:54:32 UTC (rev 58834)
+++ branches/soc-2013-dingto/intern/cycles/kernel/closure/bsdf.h 2013-08-02 19:57:14 UTC (rev 58835)
@@ -45,6 +45,7 @@
switch(sc->type) {
case CLOSURE_BSDF_DIFFUSE_ID:
+ case CLOSURE_BSDF_BSSRDF_ID:
label = bsdf_diffuse_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
break;
@@ -134,6 +135,7 @@
if(dot(sd->Ng, omega_in) >= 0.0f) {
switch(sc->type) {
case CLOSURE_BSDF_DIFFUSE_ID:
+ case CLOSURE_BSDF_BSSRDF_ID:
eval = bsdf_diffuse_eval_reflect(sc, sd->I, omega_in, pdf);
break;
#ifdef __SVM__
@@ -195,6 +197,7 @@
else {
switch(sc->type) {
case CLOSURE_BSDF_DIFFUSE_ID:
+ case CLOSURE_BSDF_BSSRDF_ID:
eval = bsdf_diffuse_eval_transmit(sc, sd->I, omega_in, pdf);
break;
#ifdef __SVM__
@@ -262,6 +265,7 @@
switch(sc->type) {
case CLOSURE_BSDF_DIFFUSE_ID:
+ case CLOSURE_BSDF_BSSRDF_ID:
bsdf_diffuse_blur(sc, roughness);
break;
#ifdef __SVM__
Modified: branches/soc-2013-dingto/intern/cycles/kernel/kernel_accumulate.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/kernel_accumulate.h 2013-08-02 19:54:32 UTC (rev 58834)
+++ branches/soc-2013-dingto/intern/cycles/kernel/kernel_accumulate.h 2013-08-02 19:57:14 UTC (rev 58835)
@@ -33,6 +33,7 @@
eval->glossy = make_float3(0.0f, 0.0f, 0.0f);
eval->transmission = make_float3(0.0f, 0.0f, 0.0f);
eval->transparent = make_float3(0.0f, 0.0f, 0.0f);
+ eval->subsurface = make_float3(0.0f, 0.0f, 0.0f);
if(type == CLOSURE_BSDF_TRANSPARENT_ID)
eval->transparent = value;
@@ -40,8 +41,10 @@
eval->diffuse = value;
else if(CLOSURE_IS_BSDF_GLOSSY(type))
eval->glossy = value;
- else
+ else if(CLOSURE_IS_BSDF_TRANSMISSION(type))
eval->transmission = value;
+ else if(CLOSURE_IS_BSDF_BSSRDF(type))
+ eval->subsurface = value;
}
else
eval->diffuse = value;
@@ -58,8 +61,10 @@
eval->diffuse += value;
else if(CLOSURE_IS_BSDF_GLOSSY(type))
eval->glossy += value;
- else
+ else if(CLOSURE_IS_BSDF_TRANSMISSION(type))
eval->transmission += value;
+ else if(CLOSURE_IS_BSDF_BSSRDF(type))
+ eval->subsurface += value;
/* skipping transparent, this function is used by for eval(), will be zero then */
}
@@ -77,7 +82,8 @@
return is_zero(eval->diffuse)
&& is_zero(eval->glossy)
&& is_zero(eval->transmission)
- && is_zero(eval->transparent);
+ && is_zero(eval->transparent)
+ && is_zero(eval->subsurface);
}
else
return is_zero(eval->diffuse);
@@ -93,6 +99,7 @@
eval->diffuse *= value;
eval->glossy *= value;
eval->transmission *= value;
+ eval->subsurface *= value;
/* skipping transparent, this function is used by for eval(), will be zero then */
}
@@ -139,6 +146,7 @@
L->path_diffuse = make_float3(0.0f, 0.0f, 0.0f);
L->path_glossy = make_float3(0.0f, 0.0f, 0.0f);
L->path_transmission = make_float3(0.0f, 0.0f, 0.0f);
+ L->path_subsurface = make_float3(0.0f, 0.0f, 0.0f);
L->emission = make_float3(0.0f, 0.0f, 0.0f);
L->background = make_float3(0.0f, 0.0f, 0.0f);
@@ -167,14 +175,15 @@
L->path_diffuse = bsdf_eval->diffuse*value;
L->path_glossy = bsdf_eval->glossy*value;
L->path_transmission = bsdf_eval->transmission*value;
+ L->path_subsurface = bsdf_eval->subsurface*value;
- *throughput = L->path_diffuse + L->path_glossy + L->path_transmission;
+ *throughput = L->path_diffuse + L->path_glossy + L->path_transmission + L->path_subsurface;
L->direct_throughput = *throughput;
}
else {
/* transparent bounce before first hit, or indirectly visible through BSDF */
- float3 sum = (bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->transparent)*inverse_pdf;
+ float3 sum = (bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->transparent + bsdf_eval->subsurface)*inverse_pdf;
*throughput *= sum;
}
}
@@ -233,6 +242,7 @@
L->direct_diffuse += throughput*bsdf_eval->diffuse*shadow;
L->direct_glossy += throughput*bsdf_eval->glossy*shadow;
L->direct_transmission += throughput*bsdf_eval->transmission*shadow;
+ L->direct_subsurface += throughput*bsdf_eval->subsurface*shadow;
if(is_lamp) {
L->shadow.x += shadow.x*shadow_fac;
@@ -242,7 +252,7 @@
}
else {
/* indirectly visible lighting after BSDF bounce */
- float3 sum = bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission;
+ float3 sum = bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->subsurface;
L->indirect += throughput*sum*shadow;
}
}
@@ -282,11 +292,13 @@
L->direct_diffuse += L->path_diffuse*L->direct_emission;
L->direct_glossy += L->path_glossy*L->direct_emission;
L->direct_transmission += L->path_transmission*L->direct_emission;
+ L->direct_subsurface += L->path_subsurface*L->direct_emission;
L->indirect = safe_divide_color(L->indirect, L->direct_throughput);
L->indirect_diffuse += L->path_diffuse*L->indirect;
L->indirect_glossy += L->path_glossy*L->indirect;
L->indirect_transmission += L->path_transmission*L->indirect;
+ L->indirect_subsurface += L->path_subsurface*L->indirect;
}
#endif
}
@@ -298,6 +310,7 @@
L->path_diffuse = make_float3(0.0f, 0.0f, 0.0f);
L->path_glossy = make_float3(0.0f, 0.0f, 0.0f);
L->path_transmission = make_float3(0.0f, 0.0f, 0.0f);
+ L->path_subsurface = make_float3(0.0f, 0.0f, 0.0f);
L->direct_emission = make_float3(0.0f, 0.0f, 0.0f);
L->indirect = make_float3(0.0f, 0.0f, 0.0f);
@@ -312,8 +325,8 @@
path_radiance_sum_indirect(L);
float3 L_sum = L->emission
- + L->direct_diffuse + L->direct_glossy + L->direct_transmission
- + L->indirect_diffuse + L->indirect_glossy + L->indirect_transmission;
+ + L->direct_diffuse + L->direct_glossy + L->direct_transmission + L->direct_subsurface
+ + L->indirect_diffuse + L->indirect_glossy + L->indirect_transmission + L->indirect_subsurface;
if(!kernel_data.background.transparent)
L_sum += L->background;
Modified: branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h 2013-08-02 19:54:32 UTC (rev 58834)
+++ branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h 2013-08-02 19:57:14 UTC (rev 58835)
@@ -892,7 +892,7 @@
int num_samples;
- if(CLOSURE_IS_BSDF_DIFFUSE(sc->type))
+ if(CLOSURE_IS_BSDF_DIFFUSE(sc->type) || CLOSURE_IS_BSDF_BSSRDF(sc->type))
num_samples = kernel_data.integrator.diffuse_samples;
else if(CLOSURE_IS_BSDF_GLOSSY(sc->type))
num_samples = kernel_data.integrator.glossy_samples;
Modified: branches/soc-2013-dingto/intern/cycles/kernel/kernel_subsurface.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/kernel_subsurface.h 2013-08-02 19:54:32 UTC (rev 58834)
+++ branches/soc-2013-dingto/intern/cycles/kernel/kernel_subsurface.h 2013-08-02 19:57:14 UTC (rev 58835)
@@ -163,6 +163,10 @@
sd->flag |= bsdf_diffuse_setup(sc);
sd->randb_closure = 0.0f;
+ /* replace CLOSURE_BSDF_DIFFUSE_ID with this special ID so render passes
+ * can recognize it as not being a regular diffuse closure */
+ sc->type = CLOSURE_BSDF_BSSRDF_ID;
+
/* todo: evaluate shading to get blurred textures and bump mapping */
/* shader_eval_surface(kg, sd, 0.0f, state_flag, SHADER_CONTEXT_SSS); */
}
Modified: branches/soc-2013-dingto/intern/cycles/kernel/kernel_types.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/kernel_types.h 2013-08-02 19:54:32 UTC (rev 58834)
+++ branches/soc-2013-dingto/intern/cycles/kernel/kernel_types.h 2013-08-02 19:57:14 UTC (rev 58835)
@@ -310,6 +310,7 @@
float3 path_diffuse;
float3 path_glossy;
float3 path_transmission;
+ float3 path_subsurface;
float4 shadow;
float mist;
@@ -322,6 +323,7 @@
float3 glossy;
float3 transmission;
float3 transparent;
+ float3 subsurface;
} BsdfEval;
#else
Modified: branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_types.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_types.h 2013-08-02 19:54:32 UTC (rev 58834)
+++ branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_types.h 2013-08-02 19:57:14 UTC (rev 58835)
@@ -371,7 +371,8 @@
CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID,
CLOSURE_BSDF_SHARP_GLASS_ID,
- /* Transparent */
+ /* Special cases */
+ CLOSURE_BSDF_BSSRDF_ID,
CLOSURE_BSDF_TRANSPARENT_ID,
/* Other */
@@ -395,6 +396,7 @@
#define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_DIFFUSE_TOON_ID)
#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_GLOSSY_ID && type <= CLOSURE_BSDF_GLOSSY_TOON_ID)
#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSMISSION_ID && type <= CLOSURE_BSDF_SHARP_GLASS_ID)
+#define CLOSURE_IS_BSDF_BSSRDF(type) (type == CLOSURE_BSDF_BSSRDF_ID)
#define CLOSURE_IS_BSSRDF(type) (type == CLOSURE_BSSRDF_ID)
#define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_ISOTROPIC_ID)
#define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID)
More information about the Bf-blender-cvs
mailing list