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@gmail.com>2017-11-01 23:07:15 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2017-11-05 20:13:44 +0300
commitc571be4e05788b8d3447a0bfe59942ebb4464750 (patch)
tree9ee997dee0a0d11b04cf1806f3ca5da9f06c3a78 /intern/cycles/kernel/closure
parent2c02a04c464c2f5c6e211ceb7b21255eaca7e087 (diff)
Code refactor: sum transparent and absorption weights outside closures.
Diffstat (limited to 'intern/cycles/kernel/closure')
-rw-r--r--intern/cycles/kernel/closure/bsdf_transparent.h18
-rw-r--r--intern/cycles/kernel/closure/volume.h26
2 files changed, 30 insertions, 14 deletions
diff --git a/intern/cycles/kernel/closure/bsdf_transparent.h b/intern/cycles/kernel/closure/bsdf_transparent.h
index 3c2fd8004df..22ca7f3847e 100644
--- a/intern/cycles/kernel/closure/bsdf_transparent.h
+++ b/intern/cycles/kernel/closure/bsdf_transparent.h
@@ -35,10 +35,22 @@
CCL_NAMESPACE_BEGIN
-ccl_device int bsdf_transparent_setup(ShaderClosure *sc)
+ccl_device void bsdf_transparent_setup(ShaderData *sd, const float3 weight)
{
- sc->type = CLOSURE_BSDF_TRANSPARENT_ID;
- return SD_BSDF|SD_TRANSPARENT;
+ if(sd->flag & SD_TRANSPARENT) {
+ sd->closure_transparent_extinction += weight;
+ }
+ else {
+ sd->flag |= SD_BSDF|SD_TRANSPARENT;
+ sd->closure_transparent_extinction = weight;
+ }
+
+ ShaderClosure *bsdf = bsdf_alloc(sd, sizeof(ShaderClosure), weight);
+
+ if(bsdf) {
+ bsdf->N = sd->N;
+ bsdf->type = CLOSURE_BSDF_TRANSPARENT_ID;
+ }
}
ccl_device float3 bsdf_transparent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
diff --git a/intern/cycles/kernel/closure/volume.h b/intern/cycles/kernel/closure/volume.h
index 01e67c7c2fd..4bb5e680723 100644
--- a/intern/cycles/kernel/closure/volume.h
+++ b/intern/cycles/kernel/closure/volume.h
@@ -19,14 +19,27 @@
CCL_NAMESPACE_BEGIN
+/* VOLUME EXTINCTION */
+
+ccl_device void volume_extinction_setup(ShaderData *sd, float3 weight)
+{
+ if(sd->flag & SD_EXTINCTION) {
+ sd->closure_transparent_extinction += weight;
+ }
+ else {
+ sd->flag |= SD_EXTINCTION;
+ sd->closure_transparent_extinction = weight;
+ }
+}
+
+/* HENYEY-GREENSTEIN CLOSURE */
+
typedef ccl_addr_space struct HenyeyGreensteinVolume {
SHADER_CLOSURE_BASE;
float g;
} HenyeyGreensteinVolume;
-/* HENYEY-GREENSTEIN CLOSURE */
-
/* Given cosine between rays, return probability density that a photon bounces
* to that direction. The g parameter controls how different it is from the
* uniform sphere. g=0 uniform diffuse-like, g=1 close to sharp single ray. */
@@ -110,15 +123,6 @@ ccl_device int volume_henyey_greenstein_sample(const ShaderClosure *sc, float3 I
return LABEL_VOLUME_SCATTER;
}
-/* ABSORPTION VOLUME CLOSURE */
-
-ccl_device int volume_absorption_setup(ShaderClosure *sc)
-{
- sc->type = CLOSURE_VOLUME_ABSORPTION_ID;
-
- return SD_ABSORPTION;
-}
-
/* VOLUME CLOSURE */
ccl_device float3 volume_phase_eval(const ShaderData *sd, const ShaderClosure *sc, float3 omega_in, float *pdf)