Skip to content

Commit

Permalink
Interim Submit
Browse files Browse the repository at this point in the history
  • Loading branch information
oRazeD committed Jan 4, 2024
1 parent 65665c6 commit eeb4828
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 65 deletions.
10 changes: 8 additions & 2 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Global:
MATERIAL_ID = "id"
ALPHA_ID = "alpha"
COLOR_ID = "color"
EMISSIVE_ID = "emissive"
ROUGHNESS_ID = "roughness"
METALNESS_ID = "metalness"

Expand All @@ -37,6 +38,7 @@ class Global:
MATERIAL_NAME = "Material ID"
ALPHA_NAME = ALPHA_ID.capitalize()
COLOR_NAME = "Base Color"
EMISSIVE_NAME = EMISSIVE_ID.capitalize()
ROUGHNESS_NAME = ROUGHNESS_ID.capitalize()
METALNESS_NAME = METALNESS_ID.capitalize()

Expand All @@ -45,6 +47,7 @@ class Global:
HEIGHT_NODE = GD_PREFIX + HEIGHT_NAME
ALPHA_NODE = GD_PREFIX + ALPHA_NAME
COLOR_NODE = GD_PREFIX + COLOR_NAME
EMISSIVE_NODE = GD_PREFIX + EMISSIVE_NAME
ROUGHNESS_NODE = GD_PREFIX + ROUGHNESS_NAME
METALNESS_NODE = GD_PREFIX + METALNESS_NAME

Expand All @@ -56,6 +59,7 @@ class Global:
MATERIAL_ID,
ALPHA_ID,
COLOR_ID,
EMISSIVE_ID,
ROUGHNESS_ID,
METALNESS_ID
)
Expand All @@ -68,15 +72,17 @@ class Global:
MATERIAL_NAME,
ALPHA_NAME,
COLOR_NAME,
EMISSIVE_NAME,
ROUGHNESS_NAME,
METALNESS_NAME
)

SHADER_MAP_NAMES = (
NORMAL_NODE,
COLOR_NODE,
EMISSIVE_NODE,
ROUGHNESS_NODE,
METALNESS_NODE,
NORMAL_NODE
METALNESS_NODE
)

INVALID_BAKE_TYPES = (
Expand Down
2 changes: 1 addition & 1 deletion operators/marmoset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import bpy
from bpy.types import Context, Operator

from .operators import OpInfo
from ..constants import Global, Error
from ..utils.generic import (
OpInfo,
bad_setup_check,
export_plane,
get_create_addon_temp_dir
Expand Down
3 changes: 1 addition & 2 deletions operators/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import bpy
from bpy.types import Context, Operator

from .operators import OpInfo
from ..constants import Global
from ..utils.generic import UseSelectedOnly
from ..utils.generic import UseSelectedOnly, OpInfo
from ..utils.render import get_rendered_objects


Expand Down
4 changes: 1 addition & 3 deletions operators/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ..utils.node import apply_node_to_objects, node_cleanup
from ..utils.scene import scene_setup, remove_setup
from ..utils.generic import (
OpInfo,
proper_scene_setup,
bad_setup_check,
export_plane,
Expand All @@ -25,9 +26,6 @@
)


class OpInfo:
bl_options = {'REGISTER', 'UNDO'}
bl_label = ""


################################################
Expand Down
7 changes: 5 additions & 2 deletions preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
FloatProperty
)

from .__init__ import bl_info
from .constants import Global
from .utils.scene import scene_setup
#from .utils.render import get_rendered_objects, set_guide_height
Expand All @@ -38,6 +37,7 @@
Metalness,
Normals,
Occlusion,
Emissive,
Roughness
)

Expand Down Expand Up @@ -113,6 +113,7 @@ class GRABDOC_OT_add_preset(AddPresetBase, Operator):
"gd.alpha",
"gd.id",
"gd.color",
"gd.emissive",
"gd.roughness",
"gd.metalness",
]
Expand Down Expand Up @@ -183,6 +184,7 @@ class GRABDOC_property_group(PropertyGroup):
('id', "Material ID", ""),
('alpha', "Alpha", ""),
('color', "Base Color", ""),
('emissive', "Emissive", ""),
('roughness', "Roughness", ""),
('metalness', "Metalness", "")
)
Expand Down Expand Up @@ -390,6 +392,7 @@ def update_scale(self, context: Context):
id: CollectionProperty(type=Id)
alpha: CollectionProperty(type=Alpha)
color: CollectionProperty(type=Color)
emissive: CollectionProperty(type=Emissive)
roughness: CollectionProperty(type=Roughness)
metalness: CollectionProperty(type=Metalness)

Expand Down Expand Up @@ -485,7 +488,7 @@ def register():
# NOTE: Git release tracking
updater.user = "oRazeD"
updater.repo = "grabdoc"
updater.current_version = bl_info["version"]
updater.current_version = (1, 4, 0)
updater.check_for_update_now()
if updater.update_ready:
print("GrabDoc update available!")
Expand Down
12 changes: 11 additions & 1 deletion ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ def draw(self, context: Context):
GRABDOC_PT_alpha.draw(self, context)
elif gd.preview_type == Global.COLOR_ID:
GRABDOC_PT_color.draw(self, context)
elif gd.preview_type == Global.EMISSIVE_ID:
GRABDOC_PT_emissive.draw(self, context)
elif gd.preview_type == Global.ROUGHNESS_ID:
GRABDOC_PT_roughness.draw(self, context)
elif gd.preview_type == Global.METALNESS_ID:
Expand Down Expand Up @@ -588,6 +590,14 @@ def draw_baker_properties(self, context: Context, layout: UILayout):
warn_ui(layout)


class GRABDOC_PT_emissive(BakerPanel, Panel):
ID = Global.EMISSIVE_ID
NAME = Global.EMISSIVE_NAME

def draw_baker_properties(self, context: Context, layout: UILayout):
warn_ui(layout)


class GRABDOC_PT_roughness(BakerPanel, Panel):
ID = Global.ROUGHNESS_ID
NAME = Global.ROUGHNESS_NAME
Expand All @@ -602,7 +612,6 @@ def draw_baker_properties(self, context: Context, layout: UILayout):
col.separator(factor=.5)
if gd.baker_type == 'blender':
col.prop(baker, 'invert', text="Invert")
# col.separator(factor=.5)


class GRABDOC_PT_metalness(BakerPanel, Panel):
Expand Down Expand Up @@ -630,6 +639,7 @@ def draw_baker_properties(self, context: Context, layout: UILayout):
GRABDOC_PT_id,
GRABDOC_PT_alpha,
GRABDOC_PT_color,
GRABDOC_PT_emissive,
GRABDOC_PT_roughness,
GRABDOC_PT_metalness
)
Expand Down
18 changes: 18 additions & 0 deletions utils/baker.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,24 @@ class Color(Baker, PropertyGroup):
)


class Emissive(Baker, PropertyGroup):
ID = Global.EMISSIVE_ID
NAME = Global.EMISSIVE_NAME
NODE = Global.EMISSIVE_NODE
COLOR_SPACE = "sRGB"
MARMOSET_COMPATIBLE = False
SUPPORTED_ENGINES = (
('blender_eevee', "Eevee", ""),
('cycles', "Cycles", "")
)

engine: EnumProperty(
items=SUPPORTED_ENGINES,
name='Render Engine',
update=Baker.update_engine
)


class Roughness(Baker, PropertyGroup):
ID = Global.ROUGHNESS_ID
NAME = Global.ROUGHNESS_NAME
Expand Down
9 changes: 8 additions & 1 deletion utils/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
from ..constants import Global, Error


class OpInfo:
bl_options = {'REGISTER', 'UNDO'}
bl_label = ""


class PanelInfo:
bl_category = 'GrabDoc'
bl_space_type = 'VIEW_3D'
Expand Down Expand Up @@ -88,7 +93,7 @@ def is_pro_version() -> bool:

def format_bl_label(
name: str = bl_info["name"],
bl_version: str = bl_info["name"]
bl_version: str = bl_info["version"]
) -> str:
tuples_version_pattern = r'\((\d+), (\d+), (\d+)\)'
match = re.match(tuples_version_pattern, str(bl_version))
Expand Down Expand Up @@ -185,6 +190,7 @@ def bad_setup_check(
gd.id[0].enabled,
gd.alpha[0].enabled,
gd.color[0].enabled,
gd.emissive[0].enabled,
gd.roughness[0].enabled,
gd.metalness[0].enabled
)
Expand All @@ -197,6 +203,7 @@ def bad_setup_check(
gd.id[0].visibility,
gd.alpha[0].visibility,
gd.color[0].visibility,
gd.emissive[0].visibility,
gd.roughness[0].visibility,
gd.metalness[0].visibility
)
Expand Down
Loading

0 comments on commit eeb4828

Please sign in to comment.