Skip to content

Instantly share code, notes, and snippets.

@behreajj
Last active May 23, 2021 17:40
Show Gist options
  • Save behreajj/3dbb436c7af3c6657e69f210cdda8a7e to your computer and use it in GitHub Desktop.
Save behreajj/3dbb436c7af3c6657e69f210cdda8a7e to your computer and use it in GitHub Desktop.
Closure Example
shader closureExample(
normal Normal = N,
float DiffuseRoughness = 0.01,
color DiffuseColor = 0.0,
float GlassRoughness = 0.125,
float GlassIor = 1.45,
float GlassReflectivity = 0.125,
color GlassColor = 1.0,
float Pattern = 0.5,
output closure color Surface = diffuse(N)) {
closure color diff = DiffuseColor * oren_nayar(Normal, DiffuseRoughness);
closure color refl = reflection(Normal);
closure color beck = GlassColor * microfacet_beckmann_refraction(
Normal, GlassRoughness, GlassIor);
closure color glass = (1.0 - GlassReflectivity) * beck
+ GlassReflectivity * refl;
Surface = (1.0 - Pattern) * diff + Pattern * glass;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment