diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-12-23 08:04:03 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-12-23 08:04:03 +0300 |
commit | 9282d305bdc56522543129436db1e8a5d19cf39f (patch) | |
tree | b6d0cdcc7dd3f4113cf9e4f9813c40f44d29746e /intern/cycles/kernel/shaders/stdosl.h | |
parent | de724a258eda45d1fed2b2176006c3b2df8abea2 (diff) | |
parent | 646a96bf8edc211a06f3df652101c265ee166e8d (diff) |
Merge branch 'master' into texture_nodes_refactortexture_nodes_refactor
Conflicts:
source/blender/nodes/texture/nodes/node_texture_math.c
Diffstat (limited to 'intern/cycles/kernel/shaders/stdosl.h')
-rw-r--r-- | intern/cycles/kernel/shaders/stdosl.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/intern/cycles/kernel/shaders/stdosl.h b/intern/cycles/kernel/shaders/stdosl.h index 1ff8f363b49..6babe98717c 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; |