Skip to content

Commit

Permalink
added ray count to color/roughness
Browse files Browse the repository at this point in the history
  • Loading branch information
leukbaars committed Jan 13, 2019
1 parent 00268c9 commit 3abac00
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 4 deletions.
74 changes: 70 additions & 4 deletions BRM_BakeUI.py
Expand Up @@ -14,6 +14,12 @@
import bmesh
from bpy.props import EnumProperty, BoolProperty, StringProperty, FloatProperty, IntProperty







class BRM_BakeUIPanel(bpy.types.Panel):
"""BRM_BakeUIPanel Panel"""
bl_label = "BRM Bake"
Expand Down Expand Up @@ -144,10 +150,14 @@ def draw(self, context):
row = col.row(align = True)
row.enabled = not context.scene.UseLowOnly
row.prop(context.scene, "bakeColor", icon="SHADING_TEXTURE", text="Color")
if context.scene.bakeColor:
row.prop(context.scene, "samplesColor", text="")

row = col.row(align = True)
row.enabled = not context.scene.UseLowOnly
row.prop(context.scene, "bakeRoughness", icon="SHADING_TEXTURE", text="Roughness")
if context.scene.bakeRoughness:
row.prop(context.scene, "samplesRoughness", text="")

row = col.row(align = True)
row.prop(context.scene, "bakeUV", icon="SHADING_WIRE", text="UV Snapshot")
Expand All @@ -161,6 +171,16 @@ def draw(self, context):
row.prop(context.scene, "UseLowOnly", icon="MESH_ICOSPHERE", text="")












class BRM_BakeUIToggle(bpy.types.Operator):
"""toggle lowpoly/hipoly"""
bl_idname = "brm.bakeuitoggle"
Expand Down Expand Up @@ -217,6 +237,12 @@ def execute(self, context):

return {'FINISHED'}







class BRM_BakeUIIncrement(bpy.types.Operator):
"""multiply/divide value"""
bl_idname = "brm.bakeuiincrement"
Expand All @@ -235,6 +261,17 @@ def execute(self, context):
context.scene.bakeHeight = context.scene.bakeHeight * 2
return {'FINISHED'}












class BRM_BakeUIHide(bpy.types.Operator):
"""hide object"""
bl_idname = "brm.bakeuihide"
Expand Down Expand Up @@ -302,6 +339,17 @@ def execute(self, context):
return {'FINISHED'}













class BRM_Bake(bpy.types.Operator):
"""Bake and save textures"""
bl_idname = "brm.bake"
Expand Down Expand Up @@ -427,6 +475,7 @@ def execute(self, context):
bpy.context.scene.render.bake.use_cage = False


#bake maps!

if context.scene.bakeNormal and not context.scene.UseLowOnly:

Expand Down Expand Up @@ -459,7 +508,7 @@ def execute(self, context):

if context.scene.bakeColor and not context.scene.UseLowOnly:

bpy.context.scene.cycles.samples = 1
bpy.context.scene.cycles.samples = context.scene.samplesColor
bpy.context.scene.render.bake.use_pass_direct = False
bpy.context.scene.render.bake.use_pass_indirect = False
bpy.context.scene.render.bake.use_pass_color = True
Expand All @@ -472,7 +521,7 @@ def execute(self, context):

if context.scene.bakeRoughness and not context.scene.UseLowOnly:

bpy.context.scene.cycles.samples = 1
bpy.context.scene.cycles.samples = context.scene.samplesRoughness

bpy.ops.object.bake(type='ROUGHNESS', use_clear=True, use_selected_to_active=True)

Expand All @@ -481,13 +530,12 @@ def execute(self, context):
bakeimage.save()


#return
#cleanup
bpy.data.images.remove(bakeimage)
bakemat.node_tree.nodes.remove(node)
bpy.data.materials.remove(bakemat)

#reset
#bpy.data.scenes["Scene"].render.engine = orig_renderer
bpy.context.active_object.data.materials[0] = orig_mat

bpy.ops.object.select_all(action='DESELECT')
Expand Down Expand Up @@ -551,6 +599,18 @@ def execute(self, context):
return {'FINISHED'}














def register():
bpy.utils.register_class(BRM_Bake)
bpy.utils.register_class(BRM_BakeUIHide)
Expand Down Expand Up @@ -653,6 +713,11 @@ def register():
default = 1,
description = "samplesColor",
)
bpy.types.Scene.samplesRoughness = bpy.props.IntProperty (
name = "samplesRoughness",
default = 1,
description = "samplesRoughness",
)
bpy.types.Scene.bakeWidth = bpy.props.IntProperty (
name = "bakeWidth",
default = 512,
Expand Down Expand Up @@ -708,6 +773,7 @@ def unregister():
del bpy.types.Scene.samplesNormal
del bpy.types.Scene.samplesAO
del bpy.types.Scene.samplesColor
del bpy.types.Scene.samplesRoughness
del bpy.types.Scene.samplesObject
del bpy.types.Scene.bakeWidth
del bpy.types.Scene.bakeHeight
Expand Down
Binary file added BRM_bake_instructions.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3abac00

Please sign in to comment.