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:
authorThomas Dinges <blender@dingto.org>2014-10-30 13:33:27 +0300
committerThomas Dinges <blender@dingto.org>2014-10-30 13:33:27 +0300
commitd5ed153760d32ca6c5f6ca5acc5ec6126a7f3eee (patch)
tree0ae45be30e6d8a203d4a68f2cf6982318fb0b3a8 /intern/cycles/kernel
parent0414ed1c480fa53a057a0b2077122e27ffd058fd (diff)
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); }
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r--intern/cycles/kernel/shaders/stdosl.h41
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;