forked from bartvdbraak/blender
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); }
This commit is contained in:
parent
0414ed1c48
commit
d5ed153760
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user