Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'roughness' (blender native) and 'smoothness' (unity compatible) bake modes #43

Merged
merged 1 commit into from Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions op_bake.py
Expand Up @@ -27,7 +27,9 @@
'ao_legacy': ub.BakeMode('', type='AO', params=["bake_samples"], engine='CYCLES'),
'position': ub.BakeMode('bake_position', type='EMIT'),
'curvature': ub.BakeMode('', type='NORMAL', use_project=True, params=["bake_curvature_size"], composite="curvature"),
'wireframe': ub.BakeMode('bake_wireframe', type='EMIT', color=(0, 0, 0, 1), params=["bake_wireframe_size"])
'wireframe': ub.BakeMode('bake_wireframe', type='EMIT', color=(0, 0, 0, 1), params=["bake_wireframe_size"]),
'roughness': ub.BakeMode('', type='ROUGHNESS'),
'smoothness': ub.BakeMode('', type='ROUGHNESS', invert=True)
}

if hasattr(bpy.types,"ShaderNodeBevel"):
Expand Down Expand Up @@ -541,7 +543,7 @@ def cycles_bake(mode, padding, sampling_scale, samples, ray_distance, is_multi,
bpy.context.scene.cycles.samples = samples

# Speed up samples for simple render modes
if modes[mode].type == 'EMIT' or modes[mode].type == 'DIFFUSE':
if modes[mode].type == 'EMIT' or modes[mode].type == 'DIFFUSE' or modes[mode].type == 'ROUGHNESS':
bpy.context.scene.cycles.samples = 1

# Pixel Padding
Expand Down Expand Up @@ -577,5 +579,7 @@ def cycles_bake(mode, padding, sampling_scale, samples, ray_distance, is_multi,
use_cage=True,
cage_object=obj_cage.name
)
if modes[mode].invert:
bpy.ops.image.invert(invert_r=True, invert_g=True, invert_b=True)

bpy.utils.register_class(op)
Binary file added resources/bake_modes/roughness.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/bake_modes/smoothness.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion utilities_bake.py
Expand Up @@ -30,9 +30,10 @@ class BakeMode:
engine = 'CYCLES' #render engine, by default CYCLES
composite = None #use composite scene to process end result
use_project = False #Bake projected?
invert = False
params = [] #UI Parameters from scene settings

def __init__(self, material="", type='EMIT', normal_space='TANGENT', setVColor=None, color= (0.23, 0.23, 0.23, 1), engine='CYCLES', params = [], composite=None, use_project=False):
def __init__(self, material="", type='EMIT', normal_space='TANGENT', setVColor=None, color= (0.23, 0.23, 0.23, 1), engine='CYCLES', params = [], composite=None, use_project=False, invert=False):
self.material = material
self.type = type
self.normal_space = normal_space
Expand All @@ -42,6 +43,7 @@ def __init__(self, material="", type='EMIT', normal_space='TANGENT', setVColor=N
self.params = params
self.composite = composite
self.use_project = use_project
self.invert = invert



Expand Down