Add wavelength material node
This commit is contained in:
parent
4ba3847c60
commit
51060d4e95
|
@ -104,6 +104,8 @@ def on_scene_update_post(context):
|
|||
break
|
||||
|
||||
# Auto patch on every operator change
|
||||
if not 'Arm' in bpy.data.worlds:
|
||||
props.create_wrd()
|
||||
wrd = bpy.data.worlds['Arm']
|
||||
if state.krom_running and \
|
||||
wrd.arm_play_live_patch and \
|
||||
|
|
|
@ -693,8 +693,10 @@ def parse_rgb(node, socket):
|
|||
return 'vec3({0}, {1}, {2})'.format(r, g, b)
|
||||
|
||||
elif node.type == 'WAVELENGTH':
|
||||
# Pass constant
|
||||
return tovec3([0.0, 0.27, 0.19])
|
||||
curshader.add_function(c_functions.str_wavelength_to_rgb)
|
||||
wl = parse_value_input(node.inputs[0])
|
||||
# Roughly map to cycles - 450 to 600 nanometers
|
||||
return 'wavelength_to_rgb(({0} - 450.0) / 150.0)'.format(wl)
|
||||
|
||||
def store_var_name(node):
|
||||
return node_name(node.name) + '_store'
|
||||
|
|
|
@ -141,3 +141,11 @@ vec3 rgb_to_hsv(const vec3 c) {
|
|||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
"""
|
||||
|
||||
# https://twitter.com/Donzanoid/status/903424376707657730
|
||||
str_wavelength_to_rgb = """
|
||||
vec3 wavelength_to_rgb(const float t) {
|
||||
vec3 r = t * 2.1 - vec3(1.8, 1.14, 0.3);
|
||||
return 1.0 - r * r;
|
||||
}
|
||||
"""
|
||||
|
|
|
@ -305,6 +305,9 @@ def init_properties():
|
|||
bpy.types.Material.is_cached = bpy.props.BoolProperty(name="Material Cached", description="No need to reexport material data", default=False, update=update_mat_cache)
|
||||
bpy.types.Material.lock_cache = bpy.props.BoolProperty(name="Lock Material Cache", description="Prevent is_cached from updating", default=False)
|
||||
|
||||
create_wrd()
|
||||
|
||||
def create_wrd():
|
||||
if not 'Arm' in bpy.data.worlds:
|
||||
wrd = bpy.data.worlds.new('Arm')
|
||||
wrd.use_fake_user = True # Store data world object, add fake user to keep it alive
|
||||
|
|
|
@ -428,9 +428,11 @@ def draw_traits(layout, obj, is_object):
|
|||
|
||||
if len(obj.arm_traitlist) > 1:
|
||||
col.separator()
|
||||
op = col.operator("arm_traitlist.move_item", icon='TRIA_UP', text="").direction = 'UP'
|
||||
op = col.operator("arm_traitlist.move_item", icon='TRIA_UP', text="")
|
||||
op.direction = 'UP'
|
||||
op.is_object = is_object
|
||||
op = col.operator("arm_traitlist.move_item", icon='TRIA_DOWN', text="").direction = 'DOWN'
|
||||
op = col.operator("arm_traitlist.move_item", icon='TRIA_DOWN', text="")
|
||||
op.direction = 'DOWN'
|
||||
op.is_object = is_object
|
||||
|
||||
if obj.arm_traitlist_index >= 0 and len(obj.arm_traitlist) > 0:
|
||||
|
@ -476,9 +478,11 @@ def draw_traits(layout, obj, is_object):
|
|||
|
||||
if len(item.arm_traitparamslist) > 1:
|
||||
col.separator()
|
||||
op = col.operator("arm_traitparamslist.move_item", icon='TRIA_UP', text="").direction = 'UP'
|
||||
op = col.operator("arm_traitparamslist.move_item", icon='TRIA_UP', text="")
|
||||
op.direction = 'UP'
|
||||
op.is_object = is_object
|
||||
op = col.operator("arm_traitparamslist.move_item", icon='TRIA_DOWN', text="").direction = 'DOWN'
|
||||
op = col.operator("arm_traitparamslist.move_item", icon='TRIA_DOWN', text="")
|
||||
op.direction = 'DOWN'
|
||||
op.is_object = is_object
|
||||
|
||||
if item.arm_traitparamslist_index >= 0 and len(item.arm_traitparamslist) > 0:
|
||||
|
|
Loading…
Reference in a new issue