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>2011-09-08 22:58:07 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-09-08 22:58:07 +0400
commit9b31cba74e2bd84e9988ebdab723e6e43f9b8357 (patch)
treefb8e8e539247f916784fb967387641f7a9291ace /intern/cycles
parent6b134ae357188358f1437650924ab38886386860 (diff)
Cycles: some warning fixes, cpu device task tweaks, avoid unnecessary
tonemap in non-viewport render, and some utility functions.
Diffstat (limited to 'intern/cycles')
-rw-r--r--intern/cycles/device/device.cpp5
-rw-r--r--intern/cycles/device/device_cpu.cpp7
-rw-r--r--intern/cycles/kernel/kernel_types.h4
-rw-r--r--intern/cycles/kernel/svm/bsdf_ashikhmin_velvet.h14
-rw-r--r--intern/cycles/kernel/svm/bsdf_diffuse.h10
-rw-r--r--intern/cycles/kernel/svm/bsdf_microfacet.h128
-rw-r--r--intern/cycles/kernel/svm/bsdf_reflection.h3
-rw-r--r--intern/cycles/kernel/svm/bsdf_refraction.h8
-rw-r--r--intern/cycles/kernel/svm/bsdf_ward.h42
-rw-r--r--intern/cycles/kernel/svm/bsdf_westin.h37
-rw-r--r--intern/cycles/render/session.cpp5
-rw-r--r--intern/cycles/util/util_cuda.cpp14
-rw-r--r--intern/cycles/util/util_cuda.h2
-rwxr-xr-xintern/cycles/util/util_opencl.h6
-rw-r--r--intern/cycles/util/util_path.cpp13
-rw-r--r--intern/cycles/util/util_path.h2
-rw-r--r--intern/cycles/util/util_system.cpp5
-rw-r--r--intern/cycles/util/util_system.h1
18 files changed, 170 insertions, 136 deletions
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index aed0be96229..e21dce45d80 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -24,6 +24,7 @@
#include "util_cuda.h"
#include "util_debug.h"
+#include "util_math.h"
#include "util_opencl.h"
#include "util_opengl.h"
#include "util_types.h"
@@ -43,6 +44,8 @@ DeviceTask::DeviceTask(Type type_)
void DeviceTask::split(ThreadQueue<DeviceTask>& tasks, int num)
{
if(type == DISPLACE) {
+ num = min(displace_w, num);
+
for(int i = 0; i < num; i++) {
int tx = displace_x + (displace_w/num)*i;
int tw = (i == num-1)? displace_w - i*(displace_w/num): displace_w/num;
@@ -56,6 +59,8 @@ void DeviceTask::split(ThreadQueue<DeviceTask>& tasks, int num)
}
}
else {
+ num = min(h, num);
+
for(int i = 0; i < num; i++) {
int ty = y + (h/num)*i;
int th = (i == num-1)? h - i*(h/num): h/num;
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index 7066efee547..3a3ae685395 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -194,10 +194,9 @@ public:
void task_add(DeviceTask& task)
{
- if(task.type == DeviceTask::TONEMAP)
- tasks.push(task);
- else
- task.split(tasks, threads.size());
+ /* split task into smaller ones, more than number of threads for uneven
+ workloads where some parts of the image render slower than others */
+ task.split(tasks, threads.size()*10);
}
void task_wait()
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index b4467c24223..93cd61c43ca 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -246,7 +246,9 @@ typedef struct ShaderData {
* memory usage, svm_closure_data contains closure parameters. */
ClosureType svm_closure;
float3 svm_closure_weight;
- float svm_closure_data[3]; /* CUDA gives compile error if out of bounds */
+ float svm_closure_data0;
+ float svm_closure_data1;
+ float svm_closure_data2;
#if !defined(__KERNEL_GPU__) && defined(WITH_OSL)
/* OSL closure data and context. we store all closures flattened into
diff --git a/intern/cycles/kernel/svm/bsdf_ashikhmin_velvet.h b/intern/cycles/kernel/svm/bsdf_ashikhmin_velvet.h
index a04f4e2b076..e94b33efaae 100644
--- a/intern/cycles/kernel/svm/bsdf_ashikhmin_velvet.h
+++ b/intern/cycles/kernel/svm/bsdf_ashikhmin_velvet.h
@@ -42,15 +42,13 @@ typedef struct BsdfAshikhminVelvetClosure {
__device void bsdf_ashikhmin_velvet_setup(ShaderData *sd, float3 N, float sigma)
{
- BsdfAshikhminVelvetClosure *self = (BsdfAshikhminVelvetClosure*)sd->svm_closure_data;
-
sigma = fmaxf(sigma, 0.01f);
- //self->m_N = N;
- self->m_invsigma2 = 1.0f/(sigma * sigma);
+ float m_invsigma2 = 1.0f/(sigma * sigma);
sd->svm_closure = CLOSURE_BSDF_ASHIKHMIN_VELVET_ID;
sd->flag |= SD_BSDF|SD_BSDF_HAS_EVAL;
+ sd->svm_closure_data0 = m_invsigma2;
}
__device void bsdf_ashikhmin_velvet_blur(ShaderData *sd, float roughness)
@@ -59,7 +57,7 @@ __device void bsdf_ashikhmin_velvet_blur(ShaderData *sd, float roughness)
__device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- const BsdfAshikhminVelvetClosure *self = (const BsdfAshikhminVelvetClosure*)sd->svm_closure_data;
+ float m_invsigma2 = sd->svm_closure_data0;
float3 m_N = sd->N;
float cosNO = dot(m_N, I);
@@ -80,7 +78,7 @@ __device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderData *sd, const f
float sinNH4 = sinNH2 * sinNH2;
float cotangent2 = (cosNH * cosNH) / sinNH2;
- float D = expf(-cotangent2 * self->m_invsigma2) * self->m_invsigma2 * M_1_PI_F / sinNH4;
+ float D = expf(-cotangent2 * m_invsigma2) * m_invsigma2 * M_1_PI_F / sinNH4;
float G = min(1.0f, min(fac1, fac2)); // TODO: derive G from D analytically
float out = 0.25f * (D * G) / cosNO;
@@ -103,7 +101,7 @@ __device float bsdf_ashikhmin_velvet_albedo(const ShaderData *sd, const float3 I
__device int bsdf_ashikhmin_velvet_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- const BsdfAshikhminVelvetClosure *self = (const BsdfAshikhminVelvetClosure*)sd->svm_closure_data;
+ float m_invsigma2 = sd->svm_closure_data0;
float3 m_N = sd->N;
// we are viewing the surface from above - send a ray out with uniform
@@ -128,7 +126,7 @@ __device int bsdf_ashikhmin_velvet_sample(const ShaderData *sd, float randu, flo
float sinNH4 = sinNH2 * sinNH2;
float cotangent2 = (cosNH * cosNH) / sinNH2;
- float D = expf(-cotangent2 * self->m_invsigma2) * self->m_invsigma2 * M_1_PI_F / sinNH4;
+ float D = expf(-cotangent2 * m_invsigma2) * m_invsigma2 * M_1_PI_F / sinNH4;
float G = min(1.0f, min(fac1, fac2)); // TODO: derive G from D analytically
float power = 0.25f * (D * G) / cosNO;
diff --git a/intern/cycles/kernel/svm/bsdf_diffuse.h b/intern/cycles/kernel/svm/bsdf_diffuse.h
index dcd29534109..a917db86ff5 100644
--- a/intern/cycles/kernel/svm/bsdf_diffuse.h
+++ b/intern/cycles/kernel/svm/bsdf_diffuse.h
@@ -43,9 +43,6 @@ typedef struct BsdfDiffuseClosure {
__device void bsdf_diffuse_setup(ShaderData *sd, float3 N)
{
- //BsdfDiffuseClosure *self = (BsdfDiffuseClosure*)sd->svm_closure_data;
- //self->m_N = N;
-
sd->svm_closure = CLOSURE_BSDF_DIFFUSE_ID;
sd->flag |= SD_BSDF|SD_BSDF_HAS_EVAL;
}
@@ -56,7 +53,6 @@ __device void bsdf_diffuse_blur(ShaderData *sd, float roughness)
__device float3 bsdf_diffuse_eval_reflect(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- //const BsdfDiffuseClosure *self = (const BsdfDiffuseClosure*)sd->svm_closure_data;
float3 m_N = sd->N;
float cos_pi = fmaxf(dot(m_N, omega_in), 0.0f) * M_1_PI_F;
@@ -76,7 +72,6 @@ __device float bsdf_diffuse_albedo(const ShaderData *sd, const float3 I)
__device int bsdf_diffuse_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- //const BsdfDiffuseClosure *self = (const BsdfDiffuseClosure*)sd->svm_closure_data;
float3 m_N = sd->N;
// distribution over the hemisphere
@@ -106,9 +101,6 @@ typedef struct BsdfTranslucentClosure {
__device void bsdf_translucent_setup(ShaderData *sd, float3 N)
{
- //BsdfTranslucentClosure *self = (BsdfTranslucentClosure*)sd->svm_closure_data;
- //self->m_N = N;
-
sd->svm_closure = CLOSURE_BSDF_TRANSLUCENT_ID;
sd->flag |= SD_BSDF|SD_BSDF_HAS_EVAL;
}
@@ -124,7 +116,6 @@ __device float3 bsdf_translucent_eval_reflect(const ShaderData *sd, const float3
__device float3 bsdf_translucent_eval_transmit(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- //const BsdfTranslucentClosure *self = (const BsdfTranslucentClosure*)sd->svm_closure_data;
float3 m_N = sd->N;
float cos_pi = fmaxf(-dot(m_N, omega_in), 0.0f) * M_1_PI_F;
@@ -139,7 +130,6 @@ __device float bsdf_translucent_albedo(const ShaderData *sd, const float3 I)
__device int bsdf_translucent_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- //const BsdfTranslucentClosure *self = (const BsdfTranslucentClosure*)sd->svm_closure_data;
float3 m_N = sd->N;
// we are viewing the surface from the right side - send a ray out with cosine
diff --git a/intern/cycles/kernel/svm/bsdf_microfacet.h b/intern/cycles/kernel/svm/bsdf_microfacet.h
index c98092b2f8f..595182d90de 100644
--- a/intern/cycles/kernel/svm/bsdf_microfacet.h
+++ b/intern/cycles/kernel/svm/bsdf_microfacet.h
@@ -46,12 +46,13 @@ typedef struct BsdfMicrofacetGGXClosure {
__device void bsdf_microfacet_ggx_setup(ShaderData *sd, float3 N, float ag, float eta, bool refractive)
{
- BsdfMicrofacetGGXClosure *self = (BsdfMicrofacetGGXClosure*)sd->svm_closure_data;
+ float m_ag = clamp(ag, 1e-5f, 1.0f);
+ float m_eta = eta;
+ int m_refractive = (refractive)? 1: 0;
- //self->m_N = N;
- self->m_ag = clamp(ag, 1e-5f, 1.0f);
- self->m_eta = eta;
- self->m_refractive = (refractive)? 1: 0;
+ sd->svm_closure_data0 = m_ag;
+ sd->svm_closure_data1 = m_eta;
+ sd->svm_closure_data2 = __int_as_float(m_refractive);
if(refractive)
sd->svm_closure = CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
@@ -63,16 +64,19 @@ __device void bsdf_microfacet_ggx_setup(ShaderData *sd, float3 N, float ag, floa
__device void bsdf_microfacet_ggx_blur(ShaderData *sd, float roughness)
{
- BsdfMicrofacetGGXClosure *self = (BsdfMicrofacetGGXClosure*)sd->svm_closure_data;
- self->m_ag = fmaxf(roughness, self->m_ag);
+ float m_ag = sd->svm_closure_data0;
+ m_ag = fmaxf(roughness, m_ag);
+ sd->svm_closure_data0 = m_ag;
}
__device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- const BsdfMicrofacetGGXClosure *self = (const BsdfMicrofacetGGXClosure*)sd->svm_closure_data;
+ float m_ag = sd->svm_closure_data0;
+ //float m_eta = sd->svm_closure_data1;
+ int m_refractive = __float_as_int(sd->svm_closure_data2);
float3 m_N = sd->N;
- if(self->m_refractive == 1) return make_float3 (0, 0, 0);
+ if(m_refractive == 1) return make_float3 (0, 0, 0);
float cosNO = dot(m_N, I);
float cosNI = dot(m_N, omega_in);
if(cosNI > 0 && cosNO > 0) {
@@ -80,7 +84,7 @@ __device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderData *sd, const flo
float3 Hr = normalize(omega_in + I);
// eq. 20: (F*G*D)/(4*in*on)
// eq. 33: first we calculate D(m) with m=Hr:
- float alpha2 = self->m_ag * self->m_ag;
+ float alpha2 = m_ag * m_ag;
float cosThetaM = dot(m_N, Hr);
float cosThetaM2 = cosThetaM * cosThetaM;
float tanThetaM2 = (1 - cosThetaM2) / cosThetaM2;
@@ -104,22 +108,24 @@ __device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderData *sd, const flo
__device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- const BsdfMicrofacetGGXClosure *self = (const BsdfMicrofacetGGXClosure*)sd->svm_closure_data;
+ float m_ag = sd->svm_closure_data0;
+ float m_eta = sd->svm_closure_data1;
+ int m_refractive = __float_as_int(sd->svm_closure_data2);
float3 m_N = sd->N;
- if(self->m_refractive == 0) return make_float3 (0, 0, 0);
+ if(m_refractive == 0) return make_float3 (0, 0, 0);
float cosNO = dot(m_N, I);
float cosNI = dot(m_N, omega_in);
if(cosNO <= 0 || cosNI >= 0)
return make_float3 (0, 0, 0); // vectors on same side -- not possible
// compute half-vector of the refraction (eq. 16)
- float3 ht = -(self->m_eta * omega_in + I);
+ float3 ht = -(m_eta * omega_in + I);
float3 Ht = normalize(ht);
float cosHO = dot(Ht, I);
float cosHI = dot(Ht, omega_in);
// eq. 33: first we calculate D(m) with m=Ht:
- float alpha2 = self->m_ag * self->m_ag;
+ float alpha2 = m_ag * m_ag;
float cosThetaM = dot(m_N, Ht);
float cosThetaM2 = cosThetaM * cosThetaM;
float tanThetaM2 = (1 - cosThetaM2) / cosThetaM2;
@@ -131,8 +137,8 @@ __device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderData *sd, const fl
float G = G1o * G1i;
// probability
float invHt2 = 1 / dot(ht, ht);
- *pdf = D * fabsf(cosThetaM) * (fabsf(cosHI) * (self->m_eta * self->m_eta)) * invHt2;
- float out = (fabsf(cosHI * cosHO) * (self->m_eta * self->m_eta) * (G * D) * invHt2) / cosNO;
+ *pdf = D * fabsf(cosThetaM) * (fabsf(cosHI) * (m_eta * m_eta)) * invHt2;
+ float out = (fabsf(cosHI * cosHO) * (m_eta * m_eta) * (G * D) * invHt2) / cosNO;
return make_float3 (out, out, out);
}
@@ -143,7 +149,9 @@ __device float bsdf_microfacet_ggx_albedo(const ShaderData *sd, const float3 I)
__device int bsdf_microfacet_ggx_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- const BsdfMicrofacetGGXClosure *self = (const BsdfMicrofacetGGXClosure*)sd->svm_closure_data;
+ float m_ag = sd->svm_closure_data0;
+ float m_eta = sd->svm_closure_data1;
+ int m_refractive = __float_as_int(sd->svm_closure_data2);
float3 m_N = sd->N;
float cosNO = dot(m_N, sd->I);
@@ -154,7 +162,7 @@ __device int bsdf_microfacet_ggx_sample(const ShaderData *sd, float randu, float
// eq. 35,36:
// we take advantage of cos(atan(x)) == 1/sqrt(1+x^2)
//tttt and sin(atan(x)) == x/sqrt(1+x^2)
- float alpha2 = self->m_ag * self->m_ag;
+ float alpha2 = m_ag * m_ag;
float tanThetaM2 = alpha2 * randu / (1 - randu);
float cosThetaM = 1 / sqrtf(1 + tanThetaM2);
float sinThetaM = cosThetaM * sqrtf(tanThetaM2);
@@ -162,7 +170,7 @@ __device int bsdf_microfacet_ggx_sample(const ShaderData *sd, float randu, float
float3 m = (cosf(phiM) * sinThetaM) * X +
(sinf(phiM) * sinThetaM) * Y +
cosThetaM * Z;
- if(self->m_refractive == 0) {
+ if(m_refractive == 0) {
float cosMO = dot(m, sd->I);
if(cosMO > 0) {
// eq. 39 - compute actual reflected direction
@@ -208,7 +216,7 @@ __device int bsdf_microfacet_ggx_sample(const ShaderData *sd, float randu, float
float3 dRdx, dRdy, dTdx, dTdy;
#endif
bool inside;
- fresnel_dielectric(self->m_eta, m, sd->I, &R, &T,
+ fresnel_dielectric(m_eta, m, sd->I, &R, &T,
#ifdef __RAY_DIFFERENTIALS__
sd->dI.dx, sd->dI.dy, &dRdx, &dRdy, &dTdx, &dTdy,
#endif
@@ -235,11 +243,11 @@ __device int bsdf_microfacet_ggx_sample(const ShaderData *sd, float randu, float
// eq. 21
float cosHI = dot(m, *omega_in);
float cosHO = dot(m, sd->I);
- float Ht2 = self->m_eta * cosHI + cosHO;
+ float Ht2 = m_eta * cosHI + cosHO;
Ht2 *= Ht2;
- float out = (fabsf(cosHI * cosHO) * (self->m_eta * self->m_eta) * (G * D)) / (cosNO * Ht2);
+ float out = (fabsf(cosHI * cosHO) * (m_eta * m_eta) * (G * D)) / (cosNO * Ht2);
// eq. 38 and eq. 17
- *pdf = pm * (self->m_eta * self->m_eta) * fabsf(cosHI) / Ht2;
+ *pdf = pm * (m_eta * m_eta) * fabsf(cosHI) / Ht2;
*eval = make_float3(out, out, out);
#ifdef __RAY_DIFFERENTIALS__
// Since there is some blur to this refraction, make the
@@ -252,7 +260,7 @@ __device int bsdf_microfacet_ggx_sample(const ShaderData *sd, float randu, float
}
}
}
- return (self->m_refractive == 1) ? LABEL_TRANSMIT|LABEL_GLOSSY : LABEL_REFLECT|LABEL_GLOSSY;
+ return (m_refractive == 1) ? LABEL_TRANSMIT|LABEL_GLOSSY : LABEL_REFLECT|LABEL_GLOSSY;
}
/* BECKMANN */
@@ -266,12 +274,13 @@ typedef struct BsdfMicrofacetBeckmannClosure {
__device void bsdf_microfacet_beckmann_setup(ShaderData *sd, float3 N, float ab, float eta, bool refractive)
{
- BsdfMicrofacetBeckmannClosure *self = (BsdfMicrofacetBeckmannClosure*)sd->svm_closure_data;
+ float m_ab = clamp(ab, 1e-5f, 1.0f);
+ float m_eta = eta;
+ float m_refractive = (refractive)? 1: 0;
- //self->m_N = N;
- self->m_ab = clamp(ab, 1e-5f, 1.0f);
- self->m_eta = eta;
- self->m_refractive = (refractive)? 1: 0;
+ sd->svm_closure_data0 = m_ab;
+ sd->svm_closure_data1 = m_eta;
+ sd->svm_closure_data2 = __int_as_float(m_refractive);
if(refractive)
sd->svm_closure = CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
@@ -283,16 +292,19 @@ __device void bsdf_microfacet_beckmann_setup(ShaderData *sd, float3 N, float ab,
__device void bsdf_microfacet_beckmann_blur(ShaderData *sd, float roughness)
{
- BsdfMicrofacetBeckmannClosure *self = (BsdfMicrofacetBeckmannClosure*)sd->svm_closure_data;
- self->m_ab = fmaxf(roughness, self->m_ab);
+ float m_ab = sd->svm_closure_data0;
+ m_ab = fmaxf(roughness, m_ab);
+ sd->svm_closure_data0 = m_ab;
}
__device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- const BsdfMicrofacetBeckmannClosure *self = (const BsdfMicrofacetBeckmannClosure*)sd->svm_closure_data;
+ float m_ab = sd->svm_closure_data0;
+ //float m_eta = sd->svm_closure_data1;
+ int m_refractive = __float_as_int(sd->svm_closure_data2);
float3 m_N = sd->N;
- if(self->m_refractive == 1) return make_float3 (0, 0, 0);
+ if(m_refractive == 1) return make_float3 (0, 0, 0);
float cosNO = dot(m_N, I);
float cosNI = dot(m_N, omega_in);
if(cosNO > 0 && cosNI > 0) {
@@ -300,15 +312,15 @@ __device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderData *sd, cons
float3 Hr = normalize(omega_in + I);
// eq. 20: (F*G*D)/(4*in*on)
// eq. 25: first we calculate D(m) with m=Hr:
- float alpha2 = self->m_ab * self->m_ab;
+ float alpha2 = m_ab * m_ab;
float cosThetaM = dot(m_N, Hr);
float cosThetaM2 = cosThetaM * cosThetaM;
float tanThetaM2 = (1 - cosThetaM2) / cosThetaM2;
float cosThetaM4 = cosThetaM2 * cosThetaM2;
float D = expf(-tanThetaM2 / alpha2) / (M_PI_F * alpha2 * cosThetaM4);
// eq. 26, 27: now calculate G1(i,m) and G1(o,m)
- float ao = 1 / (self->m_ab * sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
- float ai = 1 / (self->m_ab * sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
+ float ao = 1 / (m_ab * sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
+ float ai = 1 / (m_ab * sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
float G1o = ao < 1.6f ? (3.535f * ao + 2.181f * ao * ao) / (1 + 2.276f * ao + 2.577f * ao * ao) : 1.0f;
float G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
float G = G1o * G1i;
@@ -326,37 +338,39 @@ __device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderData *sd, cons
__device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- const BsdfMicrofacetBeckmannClosure *self = (const BsdfMicrofacetBeckmannClosure*)sd->svm_closure_data;
+ float m_ab = sd->svm_closure_data0;
+ float m_eta = sd->svm_closure_data1;
+ int m_refractive = __float_as_int(sd->svm_closure_data2);
float3 m_N = sd->N;
- if(self->m_refractive == 0) return make_float3 (0, 0, 0);
+ if(m_refractive == 0) return make_float3 (0, 0, 0);
float cosNO = dot(m_N, I);
float cosNI = dot(m_N, omega_in);
if(cosNO <= 0 || cosNI >= 0)
return make_float3 (0, 0, 0);
// compute half-vector of the refraction (eq. 16)
- float3 ht = -(self->m_eta * omega_in + I);
+ float3 ht = -(m_eta * omega_in + I);
float3 Ht = normalize(ht);
float cosHO = dot(Ht, I);
float cosHI = dot(Ht, omega_in);
// eq. 33: first we calculate D(m) with m=Ht:
- float alpha2 = self->m_ab * self->m_ab;
+ float alpha2 = m_ab * m_ab;
float cosThetaM = dot(m_N, Ht);
float cosThetaM2 = cosThetaM * cosThetaM;
float tanThetaM2 = (1 - cosThetaM2) / cosThetaM2;
float cosThetaM4 = cosThetaM2 * cosThetaM2;
float D = expf(-tanThetaM2 / alpha2) / (M_PI_F * alpha2 * cosThetaM4);
// eq. 26, 27: now calculate G1(i,m) and G1(o,m)
- float ao = 1 / (self->m_ab * sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
- float ai = 1 / (self->m_ab * sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
+ float ao = 1 / (m_ab * sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
+ float ai = 1 / (m_ab * sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
float G1o = ao < 1.6f ? (3.535f * ao + 2.181f * ao * ao) / (1 + 2.276f * ao + 2.577f * ao * ao) : 1.0f;
float G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
float G = G1o * G1i;
// probability
float invHt2 = 1 / dot(ht, ht);
- *pdf = D * fabsf(cosThetaM) * (fabsf(cosHI) * (self->m_eta * self->m_eta)) * invHt2;
- float out = (fabsf(cosHI * cosHO) * (self->m_eta * self->m_eta) * (G * D) * invHt2) / cosNO;
+ *pdf = D * fabsf(cosThetaM) * (fabsf(cosHI) * (m_eta * m_eta)) * invHt2;
+ float out = (fabsf(cosHI * cosHO) * (m_eta * m_eta) * (G * D) * invHt2) / cosNO;
return make_float3 (out, out, out);
}
@@ -367,7 +381,9 @@ __device float bsdf_microfacet_beckmann_albedo(const ShaderData *sd, const float
__device int bsdf_microfacet_beckmann_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- const BsdfMicrofacetBeckmannClosure *self = (const BsdfMicrofacetBeckmannClosure*)sd->svm_closure_data;
+ float m_ab = sd->svm_closure_data0;
+ float m_eta = sd->svm_closure_data1;
+ int m_refractive = __float_as_int(sd->svm_closure_data2);
float3 m_N = sd->N;
float cosNO = dot(m_N, sd->I);
@@ -378,7 +394,7 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderData *sd, float randu,
// eq. 35,36:
// we take advantage of cos(atan(x)) == 1/sqrt(1+x^2)
//tttt and sin(atan(x)) == x/sqrt(1+x^2)
- float alpha2 = self->m_ab * self->m_ab;
+ float alpha2 = m_ab * m_ab;
float tanThetaM = sqrtf(-alpha2 * logf(1 - randu));
float cosThetaM = 1 / sqrtf(1 + tanThetaM * tanThetaM);
float sinThetaM = cosThetaM * tanThetaM;
@@ -387,7 +403,7 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderData *sd, float randu,
(sinf(phiM) * sinThetaM) * Y +
cosThetaM * Z;
- if(self->m_refractive == 0) {
+ if(m_refractive == 0) {
float cosMO = dot(m, sd->I);
if(cosMO > 0) {
// eq. 39 - compute actual reflected direction
@@ -408,8 +424,8 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderData *sd, float randu,
// Eval BRDF*cosNI
float cosNI = dot(m_N, *omega_in);
// eq. 26, 27: now calculate G1(i,m) and G1(o,m)
- float ao = 1 / (self->m_ab * sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
- float ai = 1 / (self->m_ab * sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
+ float ao = 1 / (m_ab * sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
+ float ai = 1 / (m_ab * sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
float G1o = ao < 1.6f ? (3.535f * ao + 2.181f * ao * ao) / (1 + 2.276f * ao + 2.577f * ao * ao) : 1.0f;
float G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
float G = G1o * G1i;
@@ -436,7 +452,7 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderData *sd, float randu,
float3 dRdx, dRdy, dTdx, dTdy;
#endif
bool inside;
- fresnel_dielectric(self->m_eta, m, sd->I, &R, &T,
+ fresnel_dielectric(m_eta, m, sd->I, &R, &T,
#ifdef __RAY_DIFFERENTIALS__
sd->dI.dx, sd->dI.dy, &dRdx, &dRdy, &dTdx, &dTdy,
#endif
@@ -459,19 +475,19 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderData *sd, float randu,
// eval BRDF*cosNI
float cosNI = dot(m_N, *omega_in);
// eq. 26, 27: now calculate G1(i,m) and G1(o,m)
- float ao = 1 / (self->m_ab * sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
- float ai = 1 / (self->m_ab * sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
+ float ao = 1 / (m_ab * sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
+ float ai = 1 / (m_ab * sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
float G1o = ao < 1.6f ? (3.535f * ao + 2.181f * ao * ao) / (1 + 2.276f * ao + 2.577f * ao * ao) : 1.0f;
float G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
float G = G1o * G1i;
// eq. 21
float cosHI = dot(m, *omega_in);
float cosHO = dot(m, sd->I);
- float Ht2 = self->m_eta * cosHI + cosHO;
+ float Ht2 = m_eta * cosHI + cosHO;
Ht2 *= Ht2;
- float out = (fabsf(cosHI * cosHO) * (self->m_eta * self->m_eta) * (G * D)) / (cosNO * Ht2);
+ float out = (fabsf(cosHI * cosHO) * (m_eta * m_eta) * (G * D)) / (cosNO * Ht2);
// eq. 38 and eq. 17
- *pdf = pm * (self->m_eta * self->m_eta) * fabsf(cosHI) / Ht2;
+ *pdf = pm * (m_eta * m_eta) * fabsf(cosHI) / Ht2;
*eval = make_float3(out, out, out);
#ifdef __RAY_DIFFERENTIALS__
// Since there is some blur to this refraction, make the
@@ -484,7 +500,7 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderData *sd, float randu,
}
}
}
- return (self->m_refractive == 1) ? LABEL_TRANSMIT|LABEL_GLOSSY : LABEL_REFLECT|LABEL_GLOSSY;
+ return (m_refractive == 1) ? LABEL_TRANSMIT|LABEL_GLOSSY : LABEL_REFLECT|LABEL_GLOSSY;
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/svm/bsdf_reflection.h b/intern/cycles/kernel/svm/bsdf_reflection.h
index 2c49eb7ef24..4dad61704df 100644
--- a/intern/cycles/kernel/svm/bsdf_reflection.h
+++ b/intern/cycles/kernel/svm/bsdf_reflection.h
@@ -43,9 +43,6 @@ typedef struct BsdfReflectionClosure {
__device void bsdf_reflection_setup(ShaderData *sd, float3 N)
{
- //BsdfReflectionClosure *self = (BsdfReflectionClosure*)sd->svm_closure_data;
- //self->m_N = N;
-
sd->svm_closure = CLOSURE_BSDF_REFLECTION_ID;
sd->flag |= SD_BSDF;
}
diff --git a/intern/cycles/kernel/svm/bsdf_refraction.h b/intern/cycles/kernel/svm/bsdf_refraction.h
index 534945f4f0b..93bd747eb31 100644
--- a/intern/cycles/kernel/svm/bsdf_refraction.h
+++ b/intern/cycles/kernel/svm/bsdf_refraction.h
@@ -43,9 +43,7 @@ typedef struct BsdfRefractionClosure {
__device void bsdf_refraction_setup(ShaderData *sd, float3 N, float eta)
{
- BsdfRefractionClosure *self = (BsdfRefractionClosure*)sd->svm_closure_data;
-
- self->m_eta = eta;
+ sd->svm_closure_data0 = eta;
sd->svm_closure = CLOSURE_BSDF_REFRACTION_ID;
sd->flag |= SD_BSDF;
@@ -72,7 +70,7 @@ __device float bsdf_refraction_albedo(const ShaderData *sd, const float3 I)
__device int bsdf_refraction_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- const BsdfRefractionClosure *self = (const BsdfRefractionClosure*)sd->svm_closure_data;
+ float m_eta = sd->svm_closure_data0;
float3 m_N = sd->N;
float3 R, T;
@@ -80,7 +78,7 @@ __device int bsdf_refraction_sample(const ShaderData *sd, float randu, float ran
float3 dRdx, dRdy, dTdx, dTdy;
#endif
bool inside;
- fresnel_dielectric(self->m_eta, m_N, sd->I, &R, &T,
+ fresnel_dielectric(m_eta, m_N, sd->I, &R, &T,
#ifdef __RAY_DIFFERENTIALS__
sd->dI.dx, sd->dI.dy, &dRdx, &dRdy, &dTdx, &dTdy,
#endif
diff --git a/intern/cycles/kernel/svm/bsdf_ward.h b/intern/cycles/kernel/svm/bsdf_ward.h
index 6680644a1a7..18967b3981e 100644
--- a/intern/cycles/kernel/svm/bsdf_ward.h
+++ b/intern/cycles/kernel/svm/bsdf_ward.h
@@ -46,12 +46,11 @@ typedef struct BsdfWardClosure {
__device void bsdf_ward_setup(ShaderData *sd, float3 N, float3 T, float ax, float ay)
{
- BsdfWardClosure *self = (BsdfWardClosure*)sd->svm_closure_data;
+ float m_ax = clamp(ax, 1e-5f, 1.0f);
+ float m_ay = clamp(ay, 1e-5f, 1.0f);
- //self->m_N = N;
- //self->m_T = T;
- self->m_ax = clamp(ax, 1e-5f, 1.0f);
- self->m_ay = clamp(ay, 1e-5f, 1.0f);
+ sd->svm_closure_data0 = m_ax;
+ sd->svm_closure_data1 = m_ay;
sd->svm_closure = CLOSURE_BSDF_WARD_ID;
sd->flag |= SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
@@ -59,35 +58,35 @@ __device void bsdf_ward_setup(ShaderData *sd, float3 N, float3 T, float ax, floa
__device void bsdf_ward_blur(ShaderData *sd, float roughness)
{
- BsdfWardClosure *self = (BsdfWardClosure*)sd->svm_closure_data;
-
- self->m_ax = fmaxf(roughness, self->m_ax);
- self->m_ay = fmaxf(roughness, self->m_ay);
+ sd->svm_closure_data0 = fmaxf(roughness, sd->svm_closure_data0);
+ sd->svm_closure_data1 = fmaxf(roughness, sd->svm_closure_data1);
}
__device float3 bsdf_ward_eval_reflect(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- const BsdfWardClosure *self = (const BsdfWardClosure*)sd->svm_closure_data;
+ float m_ax = sd->svm_closure_data0;
+ float m_ay = sd->svm_closure_data1;
float3 m_N = sd->N;
float3 m_T = normalize(sd->dPdu);
float cosNO = dot(m_N, I);
float cosNI = dot(m_N, omega_in);
+
if(cosNI > 0 && cosNO > 0) {
// get half vector and get x,y basis on the surface for anisotropy
float3 H = normalize(omega_in + I); // normalize needed for pdf
float3 X, Y;
make_orthonormals_tangent(m_N, m_T, &X, &Y);
// eq. 4
- float dotx = dot(H, X) / self->m_ax;
- float doty = dot(H, Y) / self->m_ay;
+ float dotx = dot(H, X) / m_ax;
+ float doty = dot(H, Y) / m_ay;
float dotn = dot(H, m_N);
float exp_arg = (dotx * dotx + doty * doty) / (dotn * dotn);
- float denom = (4 * M_PI_F * self->m_ax * self->m_ay * sqrtf(cosNO * cosNI));
+ float denom = (4 * M_PI_F * m_ax * m_ay * sqrtf(cosNO * cosNI));
float exp_val = expf(-exp_arg);
float out = cosNI * exp_val / denom;
float oh = dot(H, I);
- denom = 4 * M_PI_F * self->m_ax * self->m_ay * oh * dotn * dotn * dotn;
+ denom = 4 * M_PI_F * m_ax * m_ay * oh * dotn * dotn * dotn;
*pdf = exp_val / denom;
return make_float3 (out, out, out);
}
@@ -106,7 +105,8 @@ __device float bsdf_ward_albedo(const ShaderData *sd, const float3 I)
__device int bsdf_ward_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- const BsdfWardClosure *self = (const BsdfWardClosure*)sd->svm_closure_data;
+ float m_ax = sd->svm_closure_data0;
+ float m_ay = sd->svm_closure_data1;
float3 m_N = sd->N;
float3 m_T = normalize(sd->dPdu);
@@ -120,7 +120,7 @@ __device int bsdf_ward_sample(const ShaderData *sd, float randu, float randv, fl
//ttoutput angle in the right quadrant)
// we take advantage of cos(atan(x)) == 1/sqrt(1+x^2)
//tttt and sin(atan(x)) == x/sqrt(1+x^2)
- float alphaRatio = self->m_ay / self->m_ax;
+ float alphaRatio = m_ay / m_ax;
float cosPhi, sinPhi;
if(randu < 0.25f) {
float val = 4 * randu;
@@ -149,7 +149,7 @@ __device int bsdf_ward_sample(const ShaderData *sd, float randu, float randv, fl
// eq. 6
// we take advantage of cos(atan(x)) == 1/sqrt(1+x^2)
//tttt and sin(atan(x)) == x/sqrt(1+x^2)
- float thetaDenom = (cosPhi * cosPhi) / (self->m_ax * self->m_ax) + (sinPhi * sinPhi) / (self->m_ay * self->m_ay);
+ float thetaDenom = (cosPhi * cosPhi) / (m_ax * m_ax) + (sinPhi * sinPhi) / (m_ay * m_ay);
float tanTheta2 = -logf(1 - randv) / thetaDenom;
float cosTheta = 1 / sqrtf(1 + tanTheta2);
float sinTheta = cosTheta * sqrtf(tanTheta2);
@@ -159,8 +159,8 @@ __device int bsdf_ward_sample(const ShaderData *sd, float randu, float randv, fl
h.y = sinTheta * sinPhi;
h.z = cosTheta;
// compute terms that are easier in local space
- float dotx = h.x / self->m_ax;
- float doty = h.y / self->m_ay;
+ float dotx = h.x / m_ax;
+ float doty = h.y / m_ay;
float dotn = h.z;
// transform to world space
h = h.x * X + h.y * Y + h.z * m_N;
@@ -172,10 +172,10 @@ __device int bsdf_ward_sample(const ShaderData *sd, float randu, float randv, fl
if(cosNI > 0) {
// eq. 9
float exp_arg = (dotx * dotx + doty * doty) / (dotn * dotn);
- float denom = 4 * M_PI_F * self->m_ax * self->m_ay * oh * dotn * dotn * dotn;
+ float denom = 4 * M_PI_F * m_ax * m_ay * oh * dotn * dotn * dotn;
*pdf = expf(-exp_arg) / denom;
// compiler will reuse expressions already computed
- denom = (4 * M_PI_F * self->m_ax * self->m_ay * sqrtf(cosNO * cosNI));
+ denom = (4 * M_PI_F * m_ax * m_ay * sqrtf(cosNO * cosNI));
float power = cosNI * expf(-exp_arg) / denom;
*eval = make_float3(power, power, power);
#ifdef __RAY_DIFFERENTIALS__
diff --git a/intern/cycles/kernel/svm/bsdf_westin.h b/intern/cycles/kernel/svm/bsdf_westin.h
index 55fc8286529..0f38deb0885 100644
--- a/intern/cycles/kernel/svm/bsdf_westin.h
+++ b/intern/cycles/kernel/svm/bsdf_westin.h
@@ -44,25 +44,24 @@ typedef struct BsdfWestinBackscatterClosure {
__device void bsdf_westin_backscatter_setup(ShaderData *sd, float3 N, float roughness)
{
- BsdfWestinBackscatterClosure *self = (BsdfWestinBackscatterClosure*)sd->svm_closure_data;
-
- //self->m_N = N;
roughness = clamp(roughness, 1e-5f, 1.0f);
- self->m_invroughness = 1.0f/roughness;
+ float m_invroughness = 1.0f/roughness;
sd->svm_closure = CLOSURE_BSDF_WESTIN_BACKSCATTER_ID;
sd->flag |= SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
+ sd->svm_closure_data0 = m_invroughness;
}
__device void bsdf_westin_backscatter_blur(ShaderData *sd, float roughness)
{
- BsdfWestinBackscatterClosure *self = (BsdfWestinBackscatterClosure*)sd->svm_closure_data;
- self->m_invroughness = min(1.0f/roughness, self->m_invroughness);
+ float m_invroughness = sd->svm_closure_data0;
+ m_invroughness = min(1.0f/roughness, m_invroughness);
+ sd->svm_closure_data0 = m_invroughness;
}
__device float3 bsdf_westin_backscatter_eval_reflect(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- const BsdfWestinBackscatterClosure *self = (const BsdfWestinBackscatterClosure*)sd->svm_closure_data;
+ float m_invroughness = sd->svm_closure_data0;
float3 m_N = sd->N;
// pdf is implicitly 0 (no indirect sampling)
@@ -70,7 +69,7 @@ __device float3 bsdf_westin_backscatter_eval_reflect(const ShaderData *sd, const
float cosNI = dot(m_N, omega_in);
if(cosNO > 0 && cosNI > 0) {
float cosine = dot(I, omega_in);
- *pdf = cosine > 0 ? (self->m_invroughness + 1) * powf(cosine, self->m_invroughness) : 0;
+ *pdf = cosine > 0 ? (m_invroughness + 1) * powf(cosine, m_invroughness) : 0;
*pdf *= 0.5f * M_1_PI_F;
return make_float3 (*pdf, *pdf, *pdf);
}
@@ -89,7 +88,7 @@ __device float bsdf_westin_backscatter_albedo(const ShaderData *sd, const float3
__device int bsdf_westin_backscatter_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- const BsdfWestinBackscatterClosure *self = (const BsdfWestinBackscatterClosure*)sd->svm_closure_data;
+ float m_invroughness = sd->svm_closure_data0;
float3 m_N = sd->N;
float cosNO = dot(m_N, sd->I);
@@ -101,7 +100,7 @@ __device int bsdf_westin_backscatter_sample(const ShaderData *sd, float randu, f
float3 T, B;
make_orthonormals (sd->I, &T, &B);
float phi = 2 * M_PI_F * randu;
- float cosTheta = powf(randv, 1 / (self->m_invroughness + 1));
+ float cosTheta = powf(randv, 1 / (m_invroughness + 1));
float sinTheta2 = 1 - cosTheta * cosTheta;
float sinTheta = sinTheta2 > 0 ? sqrtf(sinTheta2) : 0;
*omega_in = (cosf(phi) * sinTheta) * T +
@@ -114,8 +113,8 @@ __device int bsdf_westin_backscatter_sample(const ShaderData *sd, float randu, f
// make sure the direction we chose is still in the right hemisphere
if(cosNI > 0)
{
- *pdf = 0.5f * M_1_PI_F * powf(cosTheta, self->m_invroughness);
- *pdf = (self->m_invroughness + 1) * (*pdf);
+ *pdf = 0.5f * M_1_PI_F * powf(cosTheta, m_invroughness);
+ *pdf = (m_invroughness + 1) * (*pdf);
*eval = make_float3(*pdf, *pdf, *pdf);
#ifdef __RAY_DIFFERENTIALS__
// Since there is some blur to this reflection, make the
@@ -140,13 +139,9 @@ typedef struct BsdfWestinSheenClosure {
__device void bsdf_westin_sheen_setup(ShaderData *sd, float3 N, float edginess)
{
- BsdfWestinSheenClosure *self = (BsdfWestinSheenClosure*)sd->svm_closure_data;
-
- //self->m_N = N;
- self->m_edginess = edginess;
-
sd->svm_closure = CLOSURE_BSDF_WESTIN_SHEEN_ID;
sd->flag |= SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
+ sd->svm_closure_data0 = edginess;
}
__device void bsdf_westin_sheen_blur(ShaderData *sd, float roughness)
@@ -155,7 +150,7 @@ __device void bsdf_westin_sheen_blur(ShaderData *sd, float roughness)
__device float3 bsdf_westin_sheen_eval_reflect(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- const BsdfWestinSheenClosure *self = (const BsdfWestinSheenClosure*)sd->svm_closure_data;
+ float m_edginess = sd->svm_closure_data0;
float3 m_N = sd->N;
// pdf is implicitly 0 (no indirect sampling)
@@ -164,7 +159,7 @@ __device float3 bsdf_westin_sheen_eval_reflect(const ShaderData *sd, const float
if(cosNO > 0 && cosNI > 0) {
float sinNO2 = 1 - cosNO * cosNO;
*pdf = cosNI * M_1_PI_F;
- float westin = sinNO2 > 0 ? powf(sinNO2, 0.5f * self->m_edginess) * (*pdf) : 0;
+ float westin = sinNO2 > 0 ? powf(sinNO2, 0.5f * m_edginess) * (*pdf) : 0;
return make_float3 (westin, westin, westin);
}
return make_float3 (0, 0, 0);
@@ -182,7 +177,7 @@ __device float bsdf_westin_sheen_albedo(const ShaderData *sd, const float3 I)
__device int bsdf_westin_sheen_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- const BsdfWestinSheenClosure *self = (const BsdfWestinSheenClosure*)sd->svm_closure_data;
+ float m_edginess = sd->svm_closure_data0;
float3 m_N = sd->N;
// we are viewing the surface from the right side - send a ray out with cosine
@@ -192,7 +187,7 @@ __device int bsdf_westin_sheen_sample(const ShaderData *sd, float randu, float r
// TODO: account for sheen when sampling
float cosNO = dot(m_N, sd->I);
float sinNO2 = 1 - cosNO * cosNO;
- float westin = sinNO2 > 0 ? powf(sinNO2, 0.5f * self->m_edginess) * (*pdf) : 0;
+ float westin = sinNO2 > 0 ? powf(sinNO2, 0.5f * m_edginess) * (*pdf) : 0;
*eval = make_float3(westin, westin, westin);
#ifdef __RAY_DIFFERENTIALS__
// TODO: find a better approximation for the diffuse bounce
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index d3482e7f92f..f66c4a64b0b 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -79,6 +79,8 @@ Session::~Session()
}
if(params.output_path != "") {
+ tonemap();
+
progress.set_status("Writing Image", params.output_path);
display->write(device, params.output_path);
}
@@ -352,7 +354,8 @@ void Session::run_cpu()
/* update status and timing */
update_status_time();
- need_tonemap = true;
+ if(!params.background)
+ need_tonemap = true;
}
device->task_wait();
diff --git a/intern/cycles/util/util_cuda.cpp b/intern/cycles/util/util_cuda.cpp
index 15ce7efd9ee..b371f4e9499 100644
--- a/intern/cycles/util/util_cuda.cpp
+++ b/intern/cycles/util/util_cuda.cpp
@@ -19,6 +19,8 @@
#include "util_cuda.h"
#include "util_debug.h"
#include "util_dynlib.h"
+#include "util_path.h"
+#include "util_string.h"
/* function defininitions */
@@ -375,5 +377,17 @@ bool cuLibraryInit()
return result;
}
+string cuCompilerPath()
+{
+ /* todo: better nvcc detection */
+#ifdef _WIN32
+ string nvcc = "C:/CUDA/bin/nvcc.exe";
+#else
+ string nvcc = "/usr/local/cuda/bin/nvcc";
+#endif
+
+ return (path_exists(nvcc))? nvcc: "";
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_cuda.h b/intern/cycles/util/util_cuda.h
index ecfaddf43cb..3674c65bd93 100644
--- a/intern/cycles/util/util_cuda.h
+++ b/intern/cycles/util/util_cuda.h
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include "util_opengl.h"
+#include "util_string.h"
CCL_NAMESPACE_BEGIN
@@ -29,6 +30,7 @@ CCL_NAMESPACE_BEGIN
* matrixMulDynlinkJIT in the CUDA SDK. */
bool cuLibraryInit();
+string cuCompilerPath();
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_opencl.h b/intern/cycles/util/util_opencl.h
index d3c95289101..08694874ac1 100755
--- a/intern/cycles/util/util_opencl.h
+++ b/intern/cycles/util/util_opencl.h
@@ -75,13 +75,7 @@ extern "C" {
#define CL_API_CALL
#endif
-#if defined(__APPLE__)
-#define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
-#define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
-#else
#define CL_API_SUFFIX__VERSION_1_0
-#define CL_EXTENSION_WEAK_LINK
-#endif
#if defined(_WIN32) && defined(_MSC_VER)
diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp
index 6f76e378dc2..086063bcb81 100644
--- a/intern/cycles/util/util_path.cpp
+++ b/intern/cycles/util/util_path.cpp
@@ -27,6 +27,7 @@ OIIO_NAMESPACE_USING
#define BOOST_FILESYSTEM_VERSION 2
#include <boost/filesystem.hpp>
+#include <boost/algorithm/string.hpp>
CCL_NAMESPACE_BEGIN
@@ -60,6 +61,18 @@ string path_join(const string& dir, const string& file)
return (boost::filesystem::path(dir) / boost::filesystem::path(file)).string();
}
+string path_escape(const string& path)
+{
+ string result = path;
+ boost::replace_all(result, " ", "\\ ");
+ return result;
+}
+
+bool path_exists(const string& path)
+{
+ return boost::filesystem::exists(path);
+}
+
string path_files_md5_hash(const string& dir)
{
/* computes md5 hash of all files in the directory */
diff --git a/intern/cycles/util/util_path.h b/intern/cycles/util/util_path.h
index 4be0cb86f56..3e07f9524bf 100644
--- a/intern/cycles/util/util_path.h
+++ b/intern/cycles/util/util_path.h
@@ -35,6 +35,8 @@ string path_filename(const string& path);
string path_dirname(const string& path);
string path_join(const string& dir, const string& file);
+string path_escape(const string& path);
+bool path_exists(const string& path);
string path_files_md5_hash(const string& dir);
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index 77a1b1ffb75..8b09f227a74 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -113,5 +113,10 @@ string system_cpu_brand_string()
return "Unknown CPU";
}
+int system_cpu_bits()
+{
+ return (sizeof(void*)*8);
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_system.h b/intern/cycles/util/util_system.h
index 49a798acf03..214b3a18ca3 100644
--- a/intern/cycles/util/util_system.h
+++ b/intern/cycles/util/util_system.h
@@ -25,6 +25,7 @@ CCL_NAMESPACE_BEGIN
int system_cpu_thread_count();
string system_cpu_brand_string();
+int system_cpu_bits();
CCL_NAMESPACE_END