Skip to content

Commit

Permalink
Added per object control for Checker Map scale
Browse files Browse the repository at this point in the history
Formerly controlled with the TexTools global resolution, now a Custom Property is added to every Object which has a Checker Map applied to tune the tiling (or projection Scale) of the Checker texture. For convenience, the value of this property for the Active Object is exposed in the Textools UI below the Checker Map button.
Now, the Viewport Shading Modes "Material Preview" or "Rendered" need to be in use to view the effect of the Checker Map Tiling.
  • Loading branch information
franMarz committed Jun 5, 2024
1 parent 3167130 commit 12e501a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,9 @@ def get_UDIM_image():
row.scale_y = 1.75
row.operator(op_texel_checker_map.op.bl_idname, text ="Checker Map", icon_value = icon_get("op_texel_checker_map"))
row.operator(op_texel_checker_map_cleanup.op.bl_idname, text ="", icon = 'TRASH')
if 'TT_CM_Scale' in context.active_object:
row = col.row(align = True)
row.prop(context.active_object, "TT_CM_Scale", text="Tiling")



Expand Down Expand Up @@ -1761,6 +1764,7 @@ def register():

# Register settings
bpy.types.Scene.texToolsSettings = PointerProperty(type=TexToolsSettings)
bpy.types.Object.TT_CM_Scale = bpy.props.FloatProperty(name="Tiling", description="Checker Map scale for the Active Object", default=1, min=0.0001, max=1000)

# GUI Utilities
utilities_ui.register()
Expand Down Expand Up @@ -1850,6 +1854,7 @@ def unregister():

# Unregister Settings
# del bpy.types.Scene.texToolsSettings
del bpy.types.Object.TT_CM_Scale

# GUI Utilities
utilities_ui.unregister()
Expand Down
9 changes: 6 additions & 3 deletions op_texel_checker_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def execute(self, context):
premode = bpy.context.active_object.mode
utilities_uv.multi_object_loop(assign_checker_map)
bpy.ops.object.mode_set(mode=premode)
# Change View mode to TEXTURED
# Change Viewport Shading Type to MATERIAL
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
for space in area.spaces:
if space.type == 'VIEW_3D':
if space.shading.type == 'SOLID':
space.shading.color_type = 'TEXTURE'
space.shading.type = 'MATERIAL'
#space.shading.color_type = 'TEXTURE'
# Force redraw of viewport to update texture
bpy.context.view_layer.update()
return {'FINISHED'}
Expand Down Expand Up @@ -69,7 +69,10 @@ def assign_checker_map():
obj.modifiers.new(name='TT-checker-override', type='NODES')
obj.modifiers.active.node_group = get_nodegroup('TT-checker-override-uvgrid')
obj.modifiers.active.show_render = False

bpy.ops.object.modifier_move_to_index(modifier='TT-checker-override', index=len(obj.modifiers)-1)
if 'TT_CM_Scale' not in obj:
obj.TT_CM_Scale = 1



Expand Down
1 change: 1 addition & 0 deletions op_texel_checker_map_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def execute(self, context):
for m in obj.modifiers:
if m.name == 'TT-checker-override':
obj.modifiers.remove(m)
del obj['TT_CM_Scale']

for nodegroup in bpy.data.node_groups:
if nodegroup and 'TT-checker-override' in nodegroup.name:
Expand Down

0 comments on commit 12e501a

Please sign in to comment.