Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-02 00:26:52 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-02 00:26:52 +0400
commitde9dffc61e15a6af41947cbcf09ada89779e86ac (patch)
treec3f6e42482085a3a18c8278adf55dbb1e0f76c8d /intern/cycles/kernel/svm
parent40b05d364e988bca01dd338026dc24765f56187a (diff)
Cycles: initial subsurface multiple scattering support. It's not working as
well as I would like, but it works, just add a subsurface scattering node and you can use it like any other BSDF. It is using fully raytraced sampling compatible with progressive rendering and other more advanced rendering algorithms we might used in the future, and it uses no extra memory so it's suitable for complex scenes. Disadvantage is that it can be quite noisy and slow. Two limitations that will be solved are that it does not work with bump mapping yet, and that the falloff function used is a simple cubic function, it's not using the real BSSRDF falloff function yet. The node has a color input, along with a scattering radius for each RGB color channel along with an overall scale factor for the radii. There is also no GPU support yet, will test if I can get that working later. Node Documentation: http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Shaders#BSSRDF Implementation notes: http://wiki.blender.org/index.php/Dev:2.6/Source/Render/Cycles/Subsurface_Scattering
Diffstat (limited to 'intern/cycles/kernel/svm')
-rw-r--r--intern/cycles/kernel/svm/svm_closure.h53
-rw-r--r--intern/cycles/kernel/svm/svm_types.h4
2 files changed, 55 insertions, 2 deletions
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index b5bd2b42cb4..a37646beb2e 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -306,6 +306,59 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
}
break;
}
+#ifdef __SUBSURFACE__
+ case CLOSURE_BSSRDF_ID: {
+ ShaderClosure *sc = &sd->closure[sd->num_closure];
+ float3 weight = sc->weight * mix_weight;
+ float sample_weight = fabsf(average(weight));
+
+ if(sample_weight > 1e-5f && sd->num_closure+2 < MAX_CLOSURE) {
+ /* radius * scale */
+ float3 radius = stack_load_float3(stack, data_node.w)*param1;
+ /* index of refraction */
+ float eta = fmaxf(param2, 1.0f + 1e-5f);
+
+ /* create one closure per color channel */
+ if(fabsf(weight.x) > 0.0f) {
+ sc->weight = make_float3(weight.x, 0.0f, 0.0f);
+ sc->sample_weight = sample_weight;
+ sc->data0 = radius.x;
+ sc->data1 = eta;
+ sc->N = N;
+ sd->flag |= bssrdf_setup(sc);
+
+ sd->num_closure++;
+ sc++;
+ }
+
+ if(fabsf(weight.y) > 0.0f) {
+ sc->weight = make_float3(0.0f, weight.y, 0.0f);
+ sc->sample_weight = sample_weight;
+ sc->data0 = radius.y;
+ sc->data1 = eta;
+ sc->N = N;
+ sd->flag |= bssrdf_setup(sc);
+
+ sd->num_closure++;
+ sc++;
+ }
+
+ if(fabsf(weight.z) > 0.0f) {
+ sc->weight = make_float3(0.0f, 0.0f, weight.z);
+ sc->sample_weight = sample_weight;
+ sc->data0 = radius.z;
+ sc->data1 = eta;
+ sc->N = N;
+ sd->flag |= bssrdf_setup(sc);
+
+ sd->num_closure++;
+ sc++;
+ }
+ }
+
+ break;
+ }
+#endif
default:
break;
}
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index 57177eec48f..70d73f98498 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -346,12 +346,11 @@ typedef enum ClosureType {
CLOSURE_BSDF_TRANSPARENT_ID,
- CLOSURE_BSSRDF_CUBIC_ID,
+ CLOSURE_BSSRDF_ID,
CLOSURE_EMISSION_ID,
CLOSURE_DEBUG_ID,
CLOSURE_BACKGROUND_ID,
CLOSURE_HOLDOUT_ID,
- CLOSURE_SUBSURFACE_ID,
CLOSURE_AMBIENT_OCCLUSION_ID,
CLOSURE_VOLUME_ID,
@@ -366,6 +365,7 @@ typedef enum ClosureType {
#define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_OREN_NAYAR_ID)
#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_GLOSSY_ID && type <= CLOSURE_BSDF_PHONG_RAMP_ID)
#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSMISSION_ID && type <= CLOSURE_BSDF_SHARP_GLASS_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)
#define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)