-
Notifications
You must be signed in to change notification settings - Fork 356
/
glass.osl
35 lines (33 loc) · 1.16 KB
/
glass.osl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
surface
glass
[[ string help = "Simple dielectric material" ]]
(
float Ks = 1
[[ string help = "Color scaling of the refraction",
float min = 0, float max = 1 ]],
color Cs = 1
[[ string help = "Base color",
float min = 0, float max = 1 ]],
float eta = 1.5
[[ string help = "Index of refraction",
float min = 1, float max = 3 ]],
int TIR = 0
[[ string help = "Enable Total Internal Reflection",
string widget = "checkBox" ]]
)
{
// Take into account backfacing to invert eta accordingly
if (backfacing()) {
Ci = Cs * refraction(N, 1.0 / eta);
// If Total Internal Reflection is enabled, we also return a
// reflection closure, which might make rays bounce too much
// inside an object. That's why we make it optional.
if (TIR)
Ci += Ks * reflection(N, 1.0 / eta);
} else {
Ci = Ks * reflection(N, eta) + Cs * refraction(N, eta);
}
}