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>2014-06-08 14:46:12 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2014-06-14 15:49:57 +0400
commitb12151eceb76cab4a49f9df661ce6156bbeaaa21 (patch)
treec2815e24e4bc45e840efc6ff1069684c5c4a3049 /intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
parentceb68e809edf37ea3fd010692dc3f4367b78cf61 (diff)
Cycles: glossy and anisotropic BSDF changes
* Anisotropic BSDF now supports GGX and Beckmann distributions, Ward has been removed because other distributions are superior. * GGX is now the default distribution for all glossy and anisotropic nodes, since it looks good, has low noise and is fast to evaluate. * Ashikhmin-Shirley is now available in the Glossy BSDF.
Diffstat (limited to 'intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h')
-rw-r--r--intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
index ea5b610ae56..6a5d0410e01 100644
--- a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
+++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h
@@ -31,16 +31,28 @@ Other than that, the implementation directly follows the paper.
CCL_NAMESPACE_BEGIN
-
ccl_device int bsdf_ashikhmin_shirley_setup(ShaderClosure *sc)
{
- sc->data0 = clamp(sc->data0, 1e-4f, 1.0f); /* store roughness. could already convert to exponent to save some cycles in eval, */
- sc->data1 = clamp(sc->data1, 1e-4f, 1.0f); /* but this is more consistent with other bsdfs and shader_blur. */
+ /* store roughness. could already convert to exponent to save some cycles
+ * in eval, but this is more consistent with other bsdfs and shader_blur. */
+ sc->data0 = clamp(sc->data0, 1e-4f, 1.0f);
+ sc->data1 = sc->data0;
sc->type = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID;
return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY;
}
+ccl_device int bsdf_ashikhmin_shirley_aniso_setup(ShaderClosure *sc)
+{
+ /* store roughness. could already convert to exponent to save some cycles
+ * in eval, but this is more consistent with other bsdfs and shader_blur. */
+ sc->data0 = clamp(sc->data0, 1e-4f, 1.0f);
+ sc->data1 = clamp(sc->data1, 1e-4f, 1.0f);
+
+ sc->type = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID;
+ return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY;
+}
+
ccl_device void bsdf_ashikhmin_shirley_blur(ShaderClosure *sc, float roughness)
{
sc->data0 = fmaxf(roughness, sc->data0); /* clamp roughness */
@@ -55,7 +67,6 @@ ccl_device_inline float bsdf_ashikhmin_shirley_roughness_to_exponent(float rough
ccl_device float3 bsdf_ashikhmin_shirley_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float3 N = sc->N;
- float3 T = sc->T;
float NdotI = dot(N, I); /* in Cycles/OSL convention I is omega_out */
float NdotO = dot(N, omega_in); /* and consequently we use for O omaga_in ;) */
@@ -85,7 +96,7 @@ ccl_device float3 bsdf_ashikhmin_shirley_eval_reflect(const ShaderClosure *sc, c
}
else { /* => ANisotropic case */
float3 X, Y;
- make_orthonormals_tangent(N, T, &X, &Y);
+ make_orthonormals_tangent(N, sc->T, &X, &Y);
float HdotX = dot(H, X);
float HdotY = dot(H, Y);
@@ -117,7 +128,6 @@ ccl_device_inline void bsdf_ashikhmin_shirley_sample_first_quadrant(float n_x, f
ccl_device int bsdf_ashikhmin_shirley_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float3 N = sc->N;
- float3 T = sc->T;
float NdotI = dot(N, I);
if (NdotI > 0.0f) {
@@ -127,7 +137,11 @@ ccl_device int bsdf_ashikhmin_shirley_sample(const ShaderClosure *sc, float3 Ng,
/* get x,y basis on the surface for anisotropy */
float3 X, Y;
- make_orthonormals_tangent(N, T, &X, &Y);
+
+ if(n_x == n_y)
+ make_orthonormals(N, &X, &Y);
+ else
+ make_orthonormals_tangent(N, sc->T, &X, &Y);
/* sample spherical coords for h in tangent space */
float phi;