Commit: d5ed153760d32ca6c5f6ca5acc5ec6126a7f3eee
Author: Thomas Dinges
Date:   Thu Oct 30 11:33:27 2014 +0100
Branches: master
https://developer.blender.org/rBd5ed153760d32ca6c5f6ca5acc5ec6126a7f3eee

Cycles / OSL: Support microfacet() closure color function from OSL 1.5

This is basically just a wrapper class, which maps the generic call from the 
OSL spec to our closures.

Example usage:

shader microfacet_osl(
    color Color = color(0.8),
    int Distribution = 0,
    normal Normal = N,
    vector Tangent = normalize(dPdu),
    float RoughnessU = 0.0,
    float RoughnessV = 0.0,
    float IOR = 1.4,
    int Refract = 0,
    output closure color BSDF = 0)
{
    if (Distribution == 0)
        BSDF = Color * microfacet("ggx", Normal, Tangent, RoughnessU, 
RoughnessV, IOR, Refract);
    else
        BSDF = Color * microfacet("beckmann", Normal, Tangent, RoughnessU, 
RoughnessV, IOR, Refract);
}

===================================================================

M       intern/cycles/kernel/shaders/stdosl.h

===================================================================

diff --git a/intern/cycles/kernel/shaders/stdosl.h 
b/intern/cycles/kernel/shaders/stdosl.h
index 1ff8f36..6babe98 100644
--- a/intern/cycles/kernel/shaders/stdosl.h
+++ b/intern/cycles/kernel/shaders/stdosl.h
@@ -505,6 +505,47 @@ closure color hair_transmission(normal N, float 
roughnessu, float roughnessv, ve
 closure color henyey_greenstein(float g) BUILTIN;
 closure color absorption() BUILTIN;
 
+// OSL 1.5 Microfacet functions
+closure color microfacet(string distribution, normal N, vector U, float 
xalpha, float yalpha, float eta, int refract) {
+       /* GGX */
+       if (distribution == "ggx" || distribution == "default") {
+               if (!refract) {
+                       if (xalpha == yalpha) {
+                               /* Isotropic */
+                               return microfacet_ggx(N, xalpha);
+                       }
+                       else {
+                               /* Anisotropic */
+                               return microfacet_ggx_aniso(N, U, xalpha, 
yalpha);
+                       }
+               }
+               else {
+                       return microfacet_ggx_refraction(N, xalpha, eta);
+               }
+       }
+       /* Beckmann */
+       else {
+               if (!refract) {
+                       if (xalpha == yalpha) {
+                               /* Isotropic */
+                               return microfacet_beckmann(N, xalpha);
+                       }
+                       else {
+                               /* Anisotropic */
+                               return microfacet_beckmann_aniso(N, U, xalpha, 
yalpha);
+                       }
+               }
+               else {
+                       return microfacet_beckmann_refraction(N, xalpha, eta);
+               }
+       }
+}
+
+closure color microfacet (string distribution, normal N, float alpha, float 
eta, int refract) {
+       return microfacet(distribution, N, vector(0), alpha, alpha, eta, 
refract);
+}
+
+
 // Renderer state
 int backfacing () BUILTIN;
 int raytype (string typename) BUILTIN;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to