Skip to content

Commit

Permalink
Fix color transform issues, add saved properties
Browse files Browse the repository at this point in the history
  • Loading branch information
oRazeD committed Jan 15, 2024
1 parent 15ac24d commit c187553
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions utils/baker.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class Normals(Baker, PropertyGroup):
NAME = Global.NORMAL_NAME
NODE = Global.NORMAL_NODE
COLOR_SPACE = "sRGB"
VIEW_TRANSFORM = "Standard"
VIEW_TRANSFORM = "Raw"
MARMOSET_COMPATIBLE = True
SUPPORTED_ENGINES = (
('blender_eevee', "Eevee", ""),
Expand Down Expand Up @@ -396,11 +396,11 @@ class Occlusion(Baker, PropertyGroup):
NAME = Global.OCCLUSION_NAME
NODE = Global.OCCLUSION_NODE
COLOR_SPACE = "sRGB"
VIEW_TRANSFORM = "Standard"
VIEW_TRANSFORM = "Raw"
MARMOSET_COMPATIBLE = True
SUPPORTED_ENGINES = (
('blender_eevee', "Eevee", ""),
('cycles', "Cycles", "")
('blender_eevee', "Eevee", ""),
('cycles', "Cycles", "")
)

def setup(self) -> None:
Expand Down Expand Up @@ -472,7 +472,7 @@ class Height(Baker, PropertyGroup):
NAME = Global.HEIGHT_NAME
NODE = Global.HEIGHT_NODE
COLOR_SPACE = "sRGB"
VIEW_TRANSFORM = "Standard"
VIEW_TRANSFORM = "Raw"
MARMOSET_COMPATIBLE = True
SUPPORTED_ENGINES = (
('blender_eevee', "Eevee", ""),
Expand Down Expand Up @@ -559,11 +559,11 @@ class Alpha(Baker, PropertyGroup):
NAME = Global.ALPHA_NAME
NODE = Global.ALPHA_NODE
COLOR_SPACE = "sRGB"
VIEW_TRANSFORM = "Standard"
VIEW_TRANSFORM = "Raw"
MARMOSET_COMPATIBLE = True
SUPPORTED_ENGINES = (
('blender_eevee', "Eevee", ""),
('cycles', "Cycles", "")
('blender_eevee', "Eevee", ""),
('cycles', "Cycles", "")
)

def draw_properties(self, context: Context, layout: UILayout):
Expand Down Expand Up @@ -675,11 +675,11 @@ class Color(Baker, PropertyGroup):
NAME = Global.COLOR_NAME
NODE = Global.COLOR_NODE
COLOR_SPACE = "sRGB"
VIEW_TRANSFORM = "Standard"
VIEW_TRANSFORM = "Raw"
MARMOSET_COMPATIBLE = False
SUPPORTED_ENGINES = (
('blender_eevee', "Eevee", ""),
('cycles', "Cycles", "")
('blender_eevee', "Eevee", ""),
('cycles', "Cycles", "")
)

engine: EnumProperty(
Expand All @@ -694,7 +694,7 @@ class Emissive(Baker, PropertyGroup):
NAME = Global.EMISSIVE_NAME
NODE = Global.EMISSIVE_NODE
COLOR_SPACE = "sRGB"
VIEW_TRANSFORM = "Standard"
VIEW_TRANSFORM = "Raw"
MARMOSET_COMPATIBLE = False
SUPPORTED_ENGINES = (
('blender_eevee', "Eevee", ""),
Expand All @@ -713,7 +713,7 @@ class Roughness(Baker, PropertyGroup):
NAME = Global.ROUGHNESS_NAME
NODE = Global.ROUGHNESS_NODE
COLOR_SPACE = "sRGB"
VIEW_TRANSFORM = "Standard"
VIEW_TRANSFORM = "Raw"
MARMOSET_COMPATIBLE = False
SUPPORTED_ENGINES = (
('blender_eevee', "Eevee", ""),
Expand Down Expand Up @@ -746,7 +746,7 @@ class Metalness(Baker, PropertyGroup):
NAME = Global.METALNESS_NAME
NODE = Global.METALNESS_NODE
COLOR_SPACE = "sRGB"
VIEW_TRANSFORM = "Standard"
VIEW_TRANSFORM = "Raw"
MARMOSET_COMPATIBLE = False
SUPPORTED_ENGINES = (
('blender_eevee', "Eevee", ""),
Expand Down Expand Up @@ -779,6 +779,8 @@ def set_color_management(
view_settings.look = look
view_settings.exposure = 0
view_settings.gamma = 1
view_settings.use_curve_mapping = False
view_settings.use_hdr_view = False


def get_bakers() -> list[Baker]:
Expand Down Expand Up @@ -939,6 +941,8 @@ def baker_init(self, context: Context):
self.savedExposure = view_settings.exposure
self.savedGamma = view_settings.gamma
self.savedTransparency = render.film_transparent
self.savedCurveMapping = view_settings.use_curve_mapping
self.savedHdrView = view_settings.use_hdr_view

# Performance
if bpy.app.version >= (2, 83, 0):
Expand Down Expand Up @@ -1058,6 +1062,9 @@ def baker_cleanup(self, context: Context) -> None:
view_settings.exposure = self.savedExposure
view_settings.gamma = self.savedGamma

view_settings.use_curve_mapping = self.savedCurveMapping
view_settings.use_hdr_view = self.savedHdrView

scene.render.film_transparent = self.savedTransparency

# Performance
Expand Down

0 comments on commit c187553

Please sign in to comment.