Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions korman/exporter/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ def _convert_lamp_color_animation(self, name, fcurves, lamp, start, end):
self._exporter().report.warn("Cannot animate Lamp color because neither Diffuse nor Specular are enabled")
return None

# OK Specular is easy. We just toss out the color as a point3.
# Specular must be converted to sRGB space (gamma correction).
def convert_specular_animation(color):
if lamp.use_negative:
return map(lambda x: x * -1.0, color)
return map(lambda x: -pow(x, 1 / 2.2), color)
else:
return color
return map(lambda x: pow(x, 1 / 2.2), color)
color_keyframes, color_bez = self._process_keyframes(color_curves, 3, lamp.color,
convert=convert_specular_animation,
start=start, end=end)
Expand All @@ -183,10 +183,11 @@ def convert_specular_animation(color):

# Hey, look, it's a third way to process FCurves. YAY!
def convert_diffuse_animation(color, energy):
# Remember to convert the color to sRGB.
if lamp.use_negative:
proc = lambda x: x * -1.0 * energy[0]
proc = lambda x: -pow(x * energy[0], 1 / 2.2)
else:
proc = lambda x: x * energy[0]
proc = lambda x: pow(x * energy[0], 1 / 2.2)
return map(proc, color)
diffuse_channels = dict(color=3, energy=1)
diffuse_defaults = dict(color=lamp.color, energy=lamp.energy)
Expand Down
9 changes: 5 additions & 4 deletions korman/exporter/rtlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,14 @@ def export_rtlight(self, so, bo):

# Light color nonsense
# Please note that these calculations are duplicated in the AnimationConverter
# Also, Blender lighting is done in linear space, whereas Plasma still uses gamma space, so convert the color to sRGB.
energy = bl_light.energy
if bl_light.use_negative:
diff_color = [(0.0 - i) * energy for i in bl_light.color]
spec_color = [(0.0 - i) for i in bl_light.color]
diff_color = [(0.0 - pow(i * energy, 1 / 2.2)) for i in bl_light.color]
spec_color = [(0.0 - pow(i, 1 / 2.2)) for i in bl_light.color]
else:
diff_color = [i * energy for i in bl_light.color]
spec_color = [i for i in bl_light.color]
diff_color = [pow(i * energy, 1 / 2.2) for i in bl_light.color]
spec_color = [pow(i, 1 / 2.2) for i in bl_light.color]

diff_str = "({:.4f}, {:.4f}, {:.4f})".format(*diff_color)
diff_color.append(energy)
Expand Down