-
Notifications
You must be signed in to change notification settings - Fork 1
/
ior.py
31 lines (25 loc) · 925 Bytes
/
ior.py
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
import mitsuba as mi
from typing import Tuple
def ior_from_file(filename: str) -> mi.Texture:
is_spectral = "spectral" in mi.variant()
is_mono = "mono" in mi.variant()
assert not is_spectral, "Spectral mode is not supported"
assert not is_mono, "Mono mode is not supported"
wavelengths, values = mi.spectrum_from_file(filename)
unit_conversion = mi.MI_CIE_Y_NORMALIZATION
for k in range(len(wavelengths)):
values[k] *= unit_conversion
color = mi.spectrum_list_to_srgb(wavelengths, values, False, False)
return color
def complex_ior_from_file(material: str) -> Tuple[mi.Texture, mi.Texture]:
eta = ior_from_file("data/ior/" + material + ".eta.spd")
k = ior_from_file("data/ior/" + material + ".k.spd")
eta = mi.load_dict({
"type": "d65",
"color": eta
})
k = mi.load_dict({
"type": "d65",
"color": k
})
return eta, k