Skip to content

Commit

Permalink
Interim Submit
Browse files Browse the repository at this point in the history
  • Loading branch information
oRazeD committed Jan 3, 2024
1 parent 01fe25f commit 65665c6
Show file tree
Hide file tree
Showing 13 changed files with 341 additions and 603 deletions.
19 changes: 0 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,3 @@ This list is oversimplified... I will eventually do a pass to be more verbose ab
2. Follow this video for the rest of the simple instructions

https://user-images.githubusercontent.com/31065180/137642217-d51470d3-a243-438f-8c49-1e367a8972ab.mp4


# TODO / Future Update Paths

- [ ] Painter Bridge Support (Baking and or just setting up a project file)
- [ ] Extending Albedo/Roughness/Metallic/Mixed Normals bake functionality to the bridge exporter
- [ ] Rewrite of "Re-import as Material" feature as a whole with bridge exporter support
- [ ] A general feature parity pass between the different baking engines
- [ ] Improved multiple viewport support
- [ ] A more dynamic method of generating a bake setup, for things like exporting multiple bake maps of the same type (very cool, but very unlikely)
- [ ] Improved offline render (internal rendering) support:
- [ ] Allow compositing from this render type (for overlaying things like Ambient Occlusion)
- [ ] Support "Re-import as Material" feature
- [ ] Support correct default color spaces

# Known Issues / Limitations

- If you create a new object or unhide objects not originally visible while in a Map Preview mode, the object will be black.
- SOLUTION: GrabDoc is material based and does not update materials constantly, so just leaving Map Preview mode and re entering it will refresh the scene materials.
38 changes: 13 additions & 25 deletions constants.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
# NOTE: This is a basic grouping of constants for specific object
# names that are frequently reused. An improved approach would
# be to make a system that doesn't rely on naming conventions and
# instead reads GD-specific attributes, or whatever alternative relies
# on just using less constants. This is more a temp cope for old code.

# from .constants import GlobalVariableConstants as Global


NAME = "GrabDoc Pro"
VERSION = (1, 4, 0)
BLENDER_VERSION = (4, 0, 2)


class GlobalVariableConstants:
class Global:
"""A collection of constants used for global variable standardization"""
ID_PREFIX = "grab_doc" # TODO: wrong prefix?

GD_PREFIX = "GD_"
GD_FLAG_PREFIX = "[GrabDoc] "
GD_LOW_PREFIX = GD_PREFIX + "low"
Expand All @@ -37,7 +22,7 @@ class GlobalVariableConstants:

NORMAL_ID = "normals"
CURVATURE_ID = "curvature"
AO_ID = "occlusion"
OCCLUSION_ID = "occlusion"
HEIGHT_ID = "height"
MATERIAL_ID = "id"
ALPHA_ID = "alpha"
Expand All @@ -47,7 +32,7 @@ class GlobalVariableConstants:

NORMAL_NAME = NORMAL_ID.capitalize()
CURVATURE_NAME = CURVATURE_ID.capitalize()
AO_NAME = "Ambient Occlusion"
OCCLUSION_NAME = "Ambient Occlusion"
HEIGHT_NAME = HEIGHT_ID.capitalize()
MATERIAL_NAME = "Material ID"
ALPHA_NAME = ALPHA_ID.capitalize()
Expand All @@ -56,7 +41,7 @@ class GlobalVariableConstants:
METALNESS_NAME = METALNESS_ID.capitalize()

NORMAL_NODE = GD_PREFIX + NORMAL_NAME
AO_NODE = GD_PREFIX + AO_NAME
OCCLUSION_NODE = GD_PREFIX + OCCLUSION_NAME
HEIGHT_NODE = GD_PREFIX + HEIGHT_NAME
ALPHA_NODE = GD_PREFIX + ALPHA_NAME
COLOR_NODE = GD_PREFIX + COLOR_NAME
Expand All @@ -66,7 +51,7 @@ class GlobalVariableConstants:
ALL_MAP_IDS = (
NORMAL_ID,
CURVATURE_ID,
AO_ID,
OCCLUSION_ID,
HEIGHT_ID,
MATERIAL_ID,
ALPHA_ID,
Expand All @@ -78,7 +63,7 @@ class GlobalVariableConstants:
ALL_MAP_NAMES = (
NORMAL_NAME,
CURVATURE_NAME,
AO_NAME,
OCCLUSION_NAME,
HEIGHT_NAME,
MATERIAL_NAME,
ALPHA_NAME,
Expand Down Expand Up @@ -112,9 +97,12 @@ class GlobalVariableConstants:
}

NG_NODE_WARNING = \
"""This is a passthrough node from GrabDoc, once you Exit Map Preview every node link will be returned
to original positions. It's best not to touch the contents of the node group (or material) but if you
do anyways it shouldn't be overwritten by GrabDoc until the node group is removed from file, which
"""This is a passthrough node from GrabDoc, once you
Exit Map Preview every node link will be returned
to original positions. It's best not to touch the
contents of the node group (or material) but if you
do anyways it shouldn't be overwritten by GrabDoc
until the node group is removed from file, which
only happens when you use the `Remove Setup` operator."""

PACK_MAPS_WARNING = \
Expand All @@ -141,7 +129,7 @@ class GlobalVariableConstants:
\u2022 Pressing OK will dismiss this warning permanently for the project."""


class ErrorCodeConstants:
class Error:
"""A collection of constants used for error code/message standardization"""

NO_OBJECTS_SELECTED = "There are no objects selected"
Expand Down
29 changes: 14 additions & 15 deletions operators/marmoset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from bpy.types import Context, Operator

from .operators import OpInfo
from ..constants import GlobalVariableConstants as Global
from ..constants import ErrorCodeConstants as Error
from ..constants import Global, Error
from ..utils.generic import (
bad_setup_check,
export_plane,
Expand Down Expand Up @@ -41,28 +40,28 @@ class GrabDoc_OT_send_to_marmo(OpInfo, Operator):
def poll(cls, context: Context) -> bool:
package = __package__.split('.', maxsplit=1)[0]
return os.path.exists(
context.preferences.addons[package].preferences.marmoset_executable
context.preferences.addons[package].preferences.marmo_executable
)

def open_marmoset(self, context: Context, temps_path, addon_path):
def open_marmoset(self, context: Context, temp_path, addon_path):
gd = context.scene.gd
package = __package__.split('.', maxsplit=1)[0]
executable = context.preferences.addons[package].preferences.marmoset_executable
executable = context.preferences.addons[package].preferences.marmo_executable

# Create a dictionary of variables to transfer into Marmoset
marmo_vars = {
'file_path': f'{bpy.path.abspath(gd.export_path)}{gd.export_name}.{gd.marmoset_format.lower()}',
'file_ext': gd.marmoset_format.lower(),
'file_path': f'{bpy.path.abspath(gd.export_path)}{gd.export_name}.{gd.marmo_format.lower()}',
'file_ext': gd.marmo_format.lower(),
'file_path_no_ext': bpy.path.abspath(gd.export_path),
'marmo_sky_path': f'{os.path.dirname(executable)}\\data\\sky\\Evening Clouds.tbsky',

'resolution_x': gd.resolution_x,
'resolution_y': gd.resolution_y,
'bits_per_channel': int(gd.depth),
'samples': int(gd.marmoset_samples),
'samples': int(gd.marmo_samples),

'auto_bake': gd.metalness_auto_bake,
'close_after_bake': gd.marmoset_auto_close,
'close_after_bake': gd.marmo_auto_close,

'export_normal': gd.normals[0].enabled & gd.normals[0].visibility,
'flipy_normal': gd.normals[0].flip_y,
Expand All @@ -72,7 +71,7 @@ def open_marmoset(self, context: Context, temps_path, addon_path):
'suffix_curvature': gd.curvature[0].suffix,

'export_occlusion': gd.occlusion[0].enabled & gd.occlusion[0].visibility,
'ray_count_occlusion': gd.marmoset_occlusion_ray_count,
'ray_count_occlusion': gd.marmo_occlusion_ray_count,
'suffix_occlusion': gd.occlusion[0].suffix,

'export_height': gd.height[0].enabled & gd.height[0].visibility,
Expand All @@ -98,7 +97,7 @@ def open_marmoset(self, context: Context, temps_path, addon_path):

# Writing
with open(
os.path.join(temps_path, "marmo_vars.json"), "w", encoding="utf-8"
os.path.join(temp_path, "marmo_vars.json"), "w", encoding="utf-8"
) as outfile:
outfile.write(marmo_json)

Expand All @@ -109,7 +108,7 @@ def open_marmoset(self, context: Context, temps_path, addon_path):

subproc_args = [
executable,
os.path.join(addon_path, "marmoset_utils.py")
os.path.join(addon_path, "marmo_utils.py")
]

if self.send_type == 'refresh':
Expand Down Expand Up @@ -137,7 +136,7 @@ def execute(self, context: Context):
self.report({'ERROR'}, report_string)
return {'CANCELLED'}

addon_path, temps_path = get_create_addon_temp_dir()
addon_path, temp_path = get_create_addon_temp_dir()

saved_selected = context.view_layer.objects.selected.keys()

Expand Down Expand Up @@ -178,7 +177,7 @@ def execute(self, context: Context):

# Export models
bpy.ops.export_scene.fbx(
filepath=f"{temps_path}\\GD_temp_model.fbx",
filepath=f"{temp_path}\\GD_temp_model.fbx",
use_selection=True,
path_mode='ABSOLUTE'
)
Expand All @@ -203,7 +202,7 @@ def execute(self, context: Context):
if ob.visible_get():
ob.select_set(True)

self.open_marmoset(context, temps_path, addon_path)
self.open_marmoset(context, temp_path, addon_path)
return {'FINISHED'}


Expand Down
2 changes: 1 addition & 1 deletion operators/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from bpy.types import Context, Operator

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

Expand Down
Loading

0 comments on commit 65665c6

Please sign in to comment.