Skip to content

Commit

Permalink
Release - 1.3 addition#2
Browse files Browse the repository at this point in the history
  • Loading branch information
simon50keda committed Mar 24, 2016
1 parent 69b9ac5 commit a587cfb
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 112 deletions.
35 changes: 17 additions & 18 deletions addon/io_scs_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"name": "SCS Tools",
"description": "Setup models, Import-Export SCS data format",
"author": "Simon Lusenc (50keda), Milos Zajic (4museman)",
"version": (1, 3, "5621931"),
"version": (1, 3, "588c66f"),
"blender": (2, 75, 0),
"location": "File > Import-Export",
"wiki_url": "https://github.com/SCSSoftware/BlenderTools/wiki",
Expand Down Expand Up @@ -137,14 +137,25 @@ def draw(self, context):

# importer_version = round(import_pix.version(), 2)
layout = self.layout

# SCS Project Path
box1 = layout.box()
layout_box_col = box1.column(align=True)
layout_box_col.label('SCS Project Base Path:', icon='FILE_FOLDER')

row = box1.row()
row.prop(scs_globals, "import_scale")
layout_box_row = layout_box_col.row(align=True)
layout_box_row.alert = not os.path.isdir(scs_globals.scs_project_path)
layout_box_row.prop(scs_globals, 'scs_project_path', text='')

box2 = layout.box()
layout_box_row = layout_box_col.row(align=True)
layout_box_row.prop(self, "scs_project_path_mode", toggle=True, text="Set Current Dir as Project Base", icon='SCREEN_BACK')

# import settings
box2 = layout.box()
col = box2.column(align=True)

col.row().prop(scs_globals, "import_scale")
col.row().separator()
col.row().prop(scs_globals, "import_pim_file", toggle=True, icon="FILE_TICK" if scs_globals.import_pim_file else "X")
if scs_globals.import_pim_file:
col.row().prop(scs_globals, "use_normals")
Expand All @@ -155,7 +166,7 @@ def draw(self, context):
col.row().prop(scs_globals, "import_pit_file", toggle=True, icon="FILE_TICK" if scs_globals.import_pit_file else "X")
if scs_globals.import_pit_file:
col.row().prop(scs_globals, "load_textures")
col.row().separator()
col.row().separator()
col.row().prop(scs_globals, "import_pic_file", toggle=True, icon="FILE_TICK" if scs_globals.import_pic_file else "X")
col.row().separator()
col.row().prop(scs_globals, "import_pip_file", toggle=True, icon="FILE_TICK" if scs_globals.import_pip_file else "X")
Expand All @@ -168,20 +179,8 @@ def draw(self, context):
if scs_globals.import_pia_file:
col.row().prop(scs_globals, "include_subdirs_for_pia")

# SCS Project Path
box3 = layout.box()
layout_box_col = box3.column(align=True)
layout_box_col.label('SCS Project Base Path:', icon='FILE_FOLDER')

layout_box_row = layout_box_col.row(align=True)
layout_box_row.alert = not os.path.isdir(scs_globals.scs_project_path)
layout_box_row.prop(scs_globals, 'scs_project_path', text='')

layout_box_row = layout_box_col.row(align=True)
layout_box_row.prop(self, "scs_project_path_mode", toggle=True, text="Set Current Dir as Project Base", icon='SAVE_COPY')

# Common global settings
ui.shared.draw_common_settings(layout)
ui.shared.draw_common_settings(layout, log_level_only=True)


class ExportSCS(bpy.types.Operator, ExportHelper):
Expand Down
165 changes: 78 additions & 87 deletions addon/io_scs_tools/internals/shaders/flavors/nmap/scale_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@
TSNMAP_SCALE_G = _MAT_consts.node_group_prefix + "TSNMapScaleGroup"

_NMAP_TEX_SEP_NODE = "SeparateNMapTexRGB"
_ORIG_NOR_SEP_NODE = "SeparateNorRGB"
_MODIF_NOR_SEP_NODE = "SeparateNorRGB"
_RED_CHANNEL_MATH_UPPER_NODE = "RedUpper"
_RED_CHANNEL_MATH_LOWER_NODE = "RedLower"
_GREEN_CHANNEL_MATH_UPPER_NODE = "GreenUpper"
_GREEN_CHANNEL_MATH_LOWER_NODE = "GreenLower"
_RED_MAX_MATH_NODE = "RedMax"
_GREEN_MAX_MATH_NODE = "GreenMax"
_RED_MIX_NODE = "RedMix"
_GREEN_MIX_NODE = "GreenMix"
_COMBINE_NORMAL_NODE = "NormalCombine"
_RED_CHANNEL_MATH_SUB_NODE = "RedOffset"
_RED_CHANNEL_MATH_MULT_NODE = "RedScale"
_RED_CHANNEL_MATH_ABS_NODE = "RedAbsolute"
_GREEN_CHANNEL_MATH_SUB_NODE = "GreenOffset"
_GREEN_CHANNEL_MATH_MULT_NODE = "GreenScale"
_GREEN_CHANNEL_MATH_ABS_NODE = "GreenAbsolute"
_COMBINE_RED_NODE = "RedCombine"
_COMBINE_GREEN_NODE = "GreenCombine"


def get_node_group():
Expand All @@ -55,12 +52,22 @@ def get_node_group():
def __create_nmap_scale_group__():
"""Creates tangent space normal map scale group.
Current implementation tries to mix normals instead of
ignoring modified normal by nmap texture if R or G is 128.
Mixing is done by subtracting middle point nmap texture value (128 -> 0.502)
and then scaling it by scale factor so for values 128 only
unmodified geometry normal is used and for values neear middle point
both normals are mixed depending on distance from 128 ( the bigger the
distance from 128 is more of modified normal is used).
And by enough big distance (currently 20) effect of mixing completely
fades out and only modified normal is used.
Inputs: NMap Tex Color, Original Normal, Modified Normal
Outputs: Normal
"""

_NMAP_MIDDLE_VALUE = 128.0 / 255.0
_EPSILON = 0.0000003
_SCALE_FACTOR = 20.0

nmap_scale_g = bpy.data.node_groups.new(type="ShaderNodeTree", name=TSNMAP_SCALE_G)

Expand All @@ -74,93 +81,77 @@ def __create_nmap_scale_group__():
# outputs defining
nmap_scale_g.outputs.new("NodeSocketVector", "Normal")
output_n = nmap_scale_g.nodes.new("NodeGroupOutput")
output_n.location = (185 * 6, 0)
output_n.location = (185 * 7, 0)

# group nodes
separate_rgb_n = nmap_scale_g.nodes.new("ShaderNodeSeparateRGB")
separate_rgb_n.name = separate_rgb_n.label = _NMAP_TEX_SEP_NODE
separate_rgb_n.location = (185 * 1, 400)

sep_orig_nor_n = nmap_scale_g.nodes.new("ShaderNodeSeparateRGB")
sep_orig_nor_n.name = sep_orig_nor_n.label = _ORIG_NOR_SEP_NODE
sep_orig_nor_n.location = (185 * 1, -100)

sep_modif_nor_n = nmap_scale_g.nodes.new("ShaderNodeSeparateRGB")
sep_modif_nor_n.name = sep_modif_nor_n.label = _MODIF_NOR_SEP_NODE
sep_modif_nor_n.location = (185 * 1, -300)

red_math_upper_n = nmap_scale_g.nodes.new("ShaderNodeMath")
red_math_upper_n.name = red_math_upper_n.label = _RED_CHANNEL_MATH_UPPER_NODE
red_math_upper_n.location = (185 * 2, 700)
red_math_upper_n.operation = "GREATER_THAN"
red_math_upper_n.inputs[1].default_value = _NMAP_MIDDLE_VALUE + _EPSILON

red_math_lower_n = nmap_scale_g.nodes.new("ShaderNodeMath")
red_math_lower_n.name = red_math_lower_n.label = _RED_CHANNEL_MATH_LOWER_NODE
red_math_lower_n.location = (185 * 2, 500)
red_math_lower_n.operation = "LESS_THAN"
red_math_lower_n.inputs[1].default_value = _NMAP_MIDDLE_VALUE - _EPSILON

green_math_upper_n = nmap_scale_g.nodes.new("ShaderNodeMath")
green_math_upper_n.name = green_math_upper_n.label = _GREEN_CHANNEL_MATH_UPPER_NODE
green_math_upper_n.location = (185 * 2, 300)
green_math_upper_n.operation = "GREATER_THAN"
green_math_upper_n.inputs[1].default_value = _NMAP_MIDDLE_VALUE + _EPSILON

green_math_lower_n = nmap_scale_g.nodes.new("ShaderNodeMath")
green_math_lower_n.name = green_math_lower_n.label = _GREEN_CHANNEL_MATH_LOWER_NODE
green_math_lower_n.location = (185 * 2, 100)
green_math_lower_n.operation = "LESS_THAN"
green_math_lower_n.inputs[1].default_value = _NMAP_MIDDLE_VALUE - _EPSILON

red_max_n = nmap_scale_g.nodes.new("ShaderNodeMath")
red_max_n.name = red_max_n.label = _RED_MAX_MATH_NODE
red_max_n.location = (185 * 3, 600)
red_max_n.operation = "MAXIMUM"

green_max_n = nmap_scale_g.nodes.new("ShaderNodeMath")
green_max_n.name = green_max_n.label = _GREEN_MAX_MATH_NODE
green_max_n.location = (185 * 3, 200)
green_max_n.operation = "MAXIMUM"
red_math_sub_n = nmap_scale_g.nodes.new("ShaderNodeMath")
red_math_sub_n.name = red_math_sub_n.label = _RED_CHANNEL_MATH_SUB_NODE
red_math_sub_n.location = (185 * 2, 700)
red_math_sub_n.operation = "SUBTRACT"
red_math_sub_n.inputs[1].default_value = _NMAP_MIDDLE_VALUE

red_math_mult_n = nmap_scale_g.nodes.new("ShaderNodeMath")
red_math_mult_n.name = red_math_mult_n.label = _RED_CHANNEL_MATH_MULT_NODE
red_math_mult_n.location = (185 * 3, 700)
red_math_mult_n.operation = "MULTIPLY"
red_math_mult_n.inputs[1].default_value = _SCALE_FACTOR

red_math_abs_n = nmap_scale_g.nodes.new("ShaderNodeMath")
red_math_abs_n.name = red_math_abs_n.label = _RED_CHANNEL_MATH_ABS_NODE
red_math_abs_n.location = (185 * 4, 700)
red_math_abs_n.operation = "ABSOLUTE"
red_math_abs_n.use_clamp = True

green_math_sub_n = nmap_scale_g.nodes.new("ShaderNodeMath")
green_math_sub_n.name = green_math_sub_n.label = _GREEN_CHANNEL_MATH_SUB_NODE
green_math_sub_n.location = (185 * 2, 500)
green_math_sub_n.operation = "SUBTRACT"
green_math_sub_n.inputs[1].default_value = _NMAP_MIDDLE_VALUE

green_math_mult_n = nmap_scale_g.nodes.new("ShaderNodeMath")
green_math_mult_n.name = green_math_mult_n.label = _GREEN_CHANNEL_MATH_MULT_NODE
green_math_mult_n.location = (185 * 3, 500)
green_math_mult_n.operation = "MULTIPLY"
green_math_mult_n.inputs[1].default_value = _SCALE_FACTOR

green_math_abs_n = nmap_scale_g.nodes.new("ShaderNodeMath")
green_math_abs_n.name = green_math_abs_n.label = _GREEN_CHANNEL_MATH_ABS_NODE
green_math_abs_n.location = (185 * 4, 500)
green_math_abs_n.operation = "ABSOLUTE"
green_math_abs_n.use_clamp = True

red_mix_n = nmap_scale_g.nodes.new("ShaderNodeMixRGB")
red_mix_n.name = red_mix_n.label = _RED_MIX_NODE
red_mix_n.location = (185 * 4, 100)
red_mix_n.name = red_mix_n.label = _COMBINE_RED_NODE
red_mix_n.location = (185 * 5, 100)
red_mix_n.blend_type = "MIX"

green_mix_n = nmap_scale_g.nodes.new("ShaderNodeMixRGB")
green_mix_n.name = green_mix_n.label = _GREEN_MIX_NODE
green_mix_n.location = (185 * 4, -100)
green_mix_n.name = green_mix_n.label = _COMBINE_GREEN_NODE
green_mix_n.location = (185 * 6, -100)
green_mix_n.blend_type = "MIX"

combine_nor_n = nmap_scale_g.nodes.new("ShaderNodeCombineRGB")
combine_nor_n.name = combine_nor_n.label = _COMBINE_NORMAL_NODE
combine_nor_n.location = (185 * 5, -250)

# group links
nmap_scale_g.links.new(separate_rgb_n.inputs['Image'], input_n.outputs['NMap Tex Color'])
nmap_scale_g.links.new(sep_orig_nor_n.inputs['Image'], input_n.outputs['Original Normal'])
nmap_scale_g.links.new(sep_modif_nor_n.inputs['Image'], input_n.outputs['Modified Normal'])

nmap_scale_g.links.new(red_math_upper_n.inputs[0], separate_rgb_n.outputs['R'])
nmap_scale_g.links.new(red_math_lower_n.inputs[0], separate_rgb_n.outputs['R'])
nmap_scale_g.links.new(green_math_upper_n.inputs[0], separate_rgb_n.outputs['G'])
nmap_scale_g.links.new(green_math_lower_n.inputs[0], separate_rgb_n.outputs['G'])

nmap_scale_g.links.new(red_max_n.inputs[0], red_math_upper_n.outputs[0])
nmap_scale_g.links.new(red_max_n.inputs[1], red_math_lower_n.outputs[0])
nmap_scale_g.links.new(green_max_n.inputs[0], green_math_upper_n.outputs[0])
nmap_scale_g.links.new(green_max_n.inputs[1], green_math_lower_n.outputs[0])

nmap_scale_g.links.new(red_mix_n.inputs['Fac'], red_max_n.outputs[0])
nmap_scale_g.links.new(red_mix_n.inputs['Color1'], sep_orig_nor_n.outputs['R'])
nmap_scale_g.links.new(red_mix_n.inputs['Color2'], sep_modif_nor_n.outputs['R'])
nmap_scale_g.links.new(green_mix_n.inputs['Fac'], green_max_n.outputs[0])
nmap_scale_g.links.new(green_mix_n.inputs['Color1'], sep_orig_nor_n.outputs['G'])
nmap_scale_g.links.new(green_mix_n.inputs['Color2'], sep_modif_nor_n.outputs['G'])

nmap_scale_g.links.new(combine_nor_n.inputs['R'], red_mix_n.outputs['Color'])
nmap_scale_g.links.new(combine_nor_n.inputs['G'], green_mix_n.outputs['Color'])
nmap_scale_g.links.new(combine_nor_n.inputs['B'], sep_modif_nor_n.outputs['B'])

nmap_scale_g.links.new(output_n.inputs['Normal'], combine_nor_n.outputs['Image'])

nmap_scale_g.links.new(red_math_sub_n.inputs[0], separate_rgb_n.outputs['R'])
nmap_scale_g.links.new(green_math_sub_n.inputs[0], separate_rgb_n.outputs['G'])

nmap_scale_g.links.new(red_math_mult_n.inputs[0], red_math_sub_n.outputs[0])
nmap_scale_g.links.new(green_math_mult_n.inputs[0], green_math_sub_n.outputs[0])

nmap_scale_g.links.new(red_math_abs_n.inputs[0], red_math_mult_n.outputs[0])
nmap_scale_g.links.new(green_math_abs_n.inputs[0], green_math_mult_n.outputs[0])

nmap_scale_g.links.new(red_mix_n.inputs['Fac'], red_math_abs_n.outputs[0])
nmap_scale_g.links.new(red_mix_n.inputs['Color1'], input_n.outputs['Original Normal'])
nmap_scale_g.links.new(red_mix_n.inputs['Color2'], input_n.outputs['Modified Normal'])

nmap_scale_g.links.new(green_mix_n.inputs['Fac'], green_math_abs_n.outputs[0])
nmap_scale_g.links.new(green_mix_n.inputs['Color1'], red_mix_n.outputs['Color'])
nmap_scale_g.links.new(green_mix_n.inputs['Color2'], input_n.outputs['Modified Normal'])

nmap_scale_g.links.new(output_n.inputs['Normal'], green_mix_n.outputs['Color'])
2 changes: 1 addition & 1 deletion addon/io_scs_tools/ui/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def _draw_global_settings_panel(scene, layout, scs_globals):
# DISPLAY SETTINGS PANEL
_draw_display_settings_panel(scene, layout_box.row(), scs_globals)

_shared.draw_common_settings(layout_box, draw_config_storage_place=True)
_shared.draw_common_settings(layout_box)

else:
layout_box_row = layout_box.row()
Expand Down
13 changes: 7 additions & 6 deletions addon/io_scs_tools/ui/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,24 @@ def draw_export_panel(layout):
'''


def draw_common_settings(layout, draw_config_storage_place=False):
def draw_common_settings(layout, log_level_only=False):
"""Draw common settings panel featuring log level and usage type of global settings if requested
:param layout: Blender UI layout to draw operator to
:type layout: UILayout
:param draw_config_storage_place: draw globals storage type property
:type draw_config_storage_place: bool
:param log_level_only: draw only log level option
:type log_level_only: bool
"""
box4 = layout.box().column()

row = box4.row(align=True)
row.operator("scene.scs_copy_log", icon="COPYDOWN")
if not log_level_only:
row = box4.row(align=True)
row.operator("scene.scs_copy_log", icon="COPYDOWN")

row = box4.row(align=True)
row.prop(_get_scs_globals(), 'dump_level', text="Log Level", icon='MOD_EXPLODE')

if draw_config_storage_place:
if not log_level_only:
row = box4.row(align=True)
row.prop(_get_scs_globals(), 'config_storage_place', icon='NONE')

Expand Down

0 comments on commit a587cfb

Please sign in to comment.