Update Files
This commit is contained in:
80
leenkx/Assets/ies/JellyFish.ies
Normal file
80
leenkx/Assets/ies/JellyFish.ies
Normal file
@ -0,0 +1,80 @@
|
||||
IESNA:LM-63-1995
|
||||
[TEST]BALLABS TEST NO. 12788.0
|
||||
[MANUFAC] INFINITY LIGHTING INC - CARTHAGE, MISSOURI
|
||||
[LUMINAIRE] 1/100W ICETRON INDUCTION 20x15"DIRECT AREALIGHT LUMINAIRE
|
||||
[LUMINAIRE] MIRO4 SPEC ALUM TYPE II OPTICS & CLEAR FLAT GLASS LENS
|
||||
[LUMINAIRE] BLACK PANEL STREET SIDE SYLVANIA # QT 1x150 ICE/UNV-T
|
||||
[LUMCAT] ICEAL2-150S-TYPE2/CG1-277
|
||||
[LAMPCAT] ICE100/QT150 2PIN
|
||||
TILT=NONE
|
||||
1 11000. 1.000000 25 21 1 1 .938 1.266 .000
|
||||
1.0000 1.0000 140.0000
|
||||
.0 5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0
|
||||
50.0 55.0 60.0 62.5 65.0 67.5 70.0 72.5 75.0 77.5
|
||||
80.0 82.5 85.0 87.5 90.0
|
||||
.0 5.0 15.0 25.0 35.0 45.0 55.0 65.0 75.0 85.0
|
||||
90.0 95.0 105.0 115.0 125.0 135.0 145.0 155.0 165.0 175.0
|
||||
180.0
|
||||
1789. 1841. 1911. 1979. 2023. 2025. 1994. 1867. 1718. 1551.
|
||||
1374. 1208. 990. 808. 637. 469. 347. 202. 89. 18.
|
||||
9. 7. 7. 6. 0.
|
||||
1789. 1831. 1908. 1969. 2013. 2018. 1983. 1865. 1701. 1548.
|
||||
1353. 1193. 981. 842. 661. 503. 352. 172. 68. 19.
|
||||
8. 6. 6. 5. 0.
|
||||
1789. 1828. 1891. 1939. 1958. 1939. 1908. 1808. 1668. 1559.
|
||||
1428. 1300. 1222. 1161. 999. 778. 580. 318. 129. 39.
|
||||
10. 7. 7. 4. 0.
|
||||
1789. 1818. 1865. 1891. 1942. 1959. 1927. 1843. 1761. 1714.
|
||||
1673. 1599. 1445. 1325. 1165. 948. 668. 400. 186. 75.
|
||||
30. 9. 7. 2. 0.
|
||||
1789. 1811. 1821. 1891. 1941. 1974. 1980. 1943. 1993. 2082.
|
||||
1963. 1808. 1621. 1601. 1424. 1166. 829. 487. 279. 152.
|
||||
65. 15. 8. 2. 0.
|
||||
1789. 1794. 1804. 1893. 1935. 1995. 2020. 2145. 2342. 2221.
|
||||
2063. 2135. 2157. 1694. 948. 340. 101. 8. 0. 185.
|
||||
94. 32. 9. 0. 0.
|
||||
1789. 1775. 1803. 1868. 1931. 1992. 2076. 2357. 2333. 2285.
|
||||
2254. 2608. 2375. 2010. 1722. 1448. 981. 661. 376. 244.
|
||||
122. 38. 8. 0. 0.
|
||||
1789. 1763. 1798. 1839. 1918. 1961. 2151. 2291. 2310. 2263.
|
||||
2575. 2700. 2380. 2075. 1792. 1483. 1102. 702. 430. 298.
|
||||
192. 67. 11. 2. 0.
|
||||
1789. 1746. 1801. 1827. 1871. 1923. 2176. 2119. 2124. 2062.
|
||||
2553. 2596. 2201. 1907. 1678. 1368. 1015. 673. 440. 303.
|
||||
178. 63. 10. 1. 0.
|
||||
1789. 1738. 1788. 1808. 1830. 1895. 2081. 2024. 1953. 1883.
|
||||
2313. 2285. 1854. 1661. 1400. 1139. 833. 577. 404. 267.
|
||||
157. 54. 12. 1. 0.
|
||||
1789. 1735. 1783. 1797. 1812. 1868. 2046. 1983. 1911. 1805.
|
||||
2191. 2151. 1759. 1513. 1288. 1033. 802. 568. 386. 243.
|
||||
134. 56. 10. 3. 0.
|
||||
1789. 1734. 1778. 1786. 1797. 1838. 2016. 1951. 1871. 1766.
|
||||
2128. 2078. 1681. 1474. 1248. 1009. 739. 523. 349. 228.
|
||||
144. 52. 13. 2. 0.
|
||||
1789. 1733. 1774. 1773. 1771. 1777. 1959. 1895. 1811. 1647.
|
||||
2034. 1957. 1595. 1293. 1118. 925. 717. 481. 319. 208.
|
||||
125. 51. 7. 1. 0.
|
||||
1789. 1738. 1763. 1755. 1744. 1704. 1880. 1794. 1752. 1541.
|
||||
1772. 1720. 1427. 1191. 1003. 795. 588. 427. 274. 166.
|
||||
98. 39. 8. 3. 0.
|
||||
1789. 1734. 1744. 1732. 1708. 1647. 1674. 1703. 1620. 1413.
|
||||
1325. 1423. 1205. 983. 808. 642. 464. 312. 192. 107.
|
||||
57. 18. 8. 3. 0.
|
||||
1789. 1735. 1714. 1725. 1673. 1590. 1481. 1511. 1373. 1230.
|
||||
982. 993. 902. 771. 626. 456. 300. 187. 112. 60.
|
||||
31. 14. 8. 4. 0.
|
||||
1789. 1736. 1681. 1700. 1617. 1511. 1381. 1252. 1210. 1043.
|
||||
875. 657. 554. 487. 398. 294. 195. 122. 70. 40.
|
||||
19. 11. 8. 3. 0.
|
||||
1789. 1737. 1666. 1641. 1577. 1471. 1333. 1172. 1015. 890.
|
||||
728. 574. 409. 326. 243. 181. 114. 72. 40. 24.
|
||||
14. 9. 7. 4. 0.
|
||||
1789. 1740. 1679. 1601. 1493. 1388. 1268. 1114. 956. 769.
|
||||
624. 481. 347. 267. 201. 141. 85. 41. 25. 16.
|
||||
10. 7. 6. 3. 0.
|
||||
1789. 1737. 1693. 1616. 1479. 1340. 1187. 1041. 896. 724.
|
||||
572. 431. 303. 233. 167. 117. 62. 29. 18. 12.
|
||||
9. 6. 6. 4. 1.
|
||||
1789. 1742. 1698. 1623. 1491. 1354. 1196. 1040. 894. 722.
|
||||
565. 421. 302. 227. 159. 108. 57. 20. 14. 10.
|
||||
8. 6. 6. 5. 0.
|
173
leenkx/Assets/ies/load_ies.py
Normal file
173
leenkx/Assets/ies/load_ies.py
Normal file
@ -0,0 +1,173 @@
|
||||
# Using IES profiles from http://www.derekjenson.com/3d-blog/ies-light-profiles
|
||||
# IES parser based on:
|
||||
# https://github.com/tobspr/RenderPipeline
|
||||
# Copyright (c) 2014-2016 tobspr <tobias.springer1@gmail.com>
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
import re
|
||||
import os
|
||||
import math
|
||||
import bpy
|
||||
import random
|
||||
|
||||
def load(filepath):
|
||||
global _vertical_angles
|
||||
global _horizontal_angles
|
||||
global _candela_values
|
||||
KEYWORD_REGEX = re.compile(r"\[([A-Za-z0-8_-]+)\](.*)")
|
||||
|
||||
PROFILES = [
|
||||
"IESNA:LM-63-1986",
|
||||
"IESNA:LM-63-1991",
|
||||
"IESNA91",
|
||||
"IESNA:LM-63-1995",
|
||||
"IESNA:LM-63-2002",
|
||||
"ERCO Leuchten GmbH BY: ERCO/LUM650/8701",
|
||||
"ERCO Leuchten GmbH"
|
||||
]
|
||||
|
||||
with open(filepath, "r") as handle:
|
||||
lines = handle.readlines()
|
||||
|
||||
lines = [i.strip() for i in lines]
|
||||
|
||||
# Parse version header
|
||||
first_line = lines.pop(0)
|
||||
if first_line not in PROFILES:
|
||||
raise "Unsupported Profile: " + first_line
|
||||
|
||||
# Extracts the keywords
|
||||
keywords = {}
|
||||
while lines:
|
||||
line = lines.pop(0)
|
||||
if not line.startswith("["):
|
||||
if line != "TILT=NONE":
|
||||
continue
|
||||
lines.insert(0, line)
|
||||
break
|
||||
else:
|
||||
match = KEYWORD_REGEX.match(line)
|
||||
if match:
|
||||
key, val = match.group(1, 2)
|
||||
keywords[key.strip()] = val.strip()
|
||||
else:
|
||||
raise "Invalid keyword line: " + line
|
||||
|
||||
# Next line should be TILT=NONE according to the spec
|
||||
if lines.pop(0) != "TILT=NONE":
|
||||
raise "Expected TILT=NONE line, but none found!"
|
||||
|
||||
# From now on, lines do not matter anymore, instead everything is space seperated
|
||||
new_parts = (' '.join(lines)).replace(",", " ").split()
|
||||
|
||||
def read_int():
|
||||
return int(new_parts.pop(0))
|
||||
|
||||
def read_float():
|
||||
return float(new_parts.pop(0))
|
||||
|
||||
# Amount of Lamps
|
||||
if read_int() != 1:
|
||||
raise "Only 1 Lamp supported!"
|
||||
|
||||
# Extract various properties
|
||||
lumen_per_lamp = read_float()
|
||||
candela_multiplier = read_float()
|
||||
num_vertical_angles = read_int()
|
||||
num_horizontal_angles = read_int()
|
||||
|
||||
if num_vertical_angles < 1 or num_horizontal_angles < 1:
|
||||
raise "Invalid of vertical/horizontal angles!"
|
||||
|
||||
photometric_type = read_int()
|
||||
unit_type = read_int()
|
||||
|
||||
# Check for a correct unit type, should be 1 for meters and 2 for feet
|
||||
if unit_type not in [1, 2]:
|
||||
raise "Invalid unit type"
|
||||
|
||||
width = read_float()
|
||||
length = read_float()
|
||||
height = read_float()
|
||||
ballast_factor = read_float()
|
||||
future_use = read_float()
|
||||
input_watts = read_float()
|
||||
|
||||
_vertical_angles = [read_float() for i in range(num_vertical_angles)]
|
||||
_horizontal_angles = [read_float() for i in range(num_horizontal_angles)]
|
||||
|
||||
_candela_values = []
|
||||
candela_scale = 0.0
|
||||
|
||||
for i in range(num_horizontal_angles):
|
||||
vertical_data = [read_float() for i in range(num_vertical_angles)]
|
||||
candela_scale = max(candela_scale, max(vertical_data))
|
||||
_candela_values += vertical_data
|
||||
|
||||
# Rescale values, divide by maximum
|
||||
_candela_values = [i / candela_scale for i in _candela_values]
|
||||
generate_texture()
|
||||
|
||||
def generate_texture():
|
||||
tex = bpy.data.images.new("iestexture", width=128, height=128, float_buffer=True) # R16
|
||||
resolution_vertical = 128
|
||||
resolution_horizontal = 128
|
||||
|
||||
for vert in range(resolution_vertical):
|
||||
for horiz in range(resolution_horizontal):
|
||||
vert_angle = vert / (resolution_vertical - 1.0)
|
||||
vert_angle = math.cos(vert_angle * math.pi) * 90.0 + 90.0
|
||||
horiz_angle = horiz / (resolution_horizontal - 1.0) * 360.0
|
||||
candela = get_candela_value(vert_angle, horiz_angle)
|
||||
x = vert
|
||||
y = horiz
|
||||
i = x + y * resolution_horizontal
|
||||
tex.pixels[i * 4] = candela
|
||||
tex.pixels[i * 4 + 1] = candela
|
||||
tex.pixels[i * 4 + 2] = candela
|
||||
tex.pixels[i * 4 + 3] = 1.0
|
||||
|
||||
def get_candela_value(vertical_angle, horizontal_angle):
|
||||
# Assume a dataset without horizontal angles
|
||||
return get_vertical_candela_value(0, vertical_angle)
|
||||
|
||||
def get_vertical_candela_value(horizontal_angle_idx, vertical_angle):
|
||||
if vertical_angle < 0.0:
|
||||
return 0.0
|
||||
|
||||
if vertical_angle > _vertical_angles[len(_vertical_angles) - 1]:
|
||||
return 0.0
|
||||
|
||||
for vertical_index in range(1, len(_vertical_angles)):
|
||||
curr_angle = _vertical_angles[vertical_index]
|
||||
if curr_angle > vertical_angle:
|
||||
prev_angle = _vertical_angles[vertical_index - 1]
|
||||
prev_value = get_candela_value_from_index(vertical_index - 1, horizontal_angle_idx)
|
||||
curr_value = get_candela_value_from_index(vertical_index, horizontal_angle_idx)
|
||||
lerp = (vertical_angle - prev_angle) / (curr_angle - prev_angle)
|
||||
assert lerp >= 0.0 and lerp <= 1.0
|
||||
return curr_value * lerp + prev_value * (1.0 - lerp)
|
||||
return 0.0
|
||||
|
||||
def get_candela_value_from_index(vertical_angle_idx, horizontal_angle_idx):
|
||||
index = vertical_angle_idx + horizontal_angle_idx * len(_vertical_angles)
|
||||
return _candela_values[index]
|
||||
|
||||
filepath = "/Users/onek8/Desktop/ies/JellyFish.ies"
|
||||
load(filepath)
|
Reference in New Issue
Block a user