Skip to content

Commit

Permalink
Set default renderer to 'Cycles' and add option for GI params
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonzkiller committed Dec 19, 2022
1 parent 968e6d0 commit 82a4c1f
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions i_scene_cp77_gltf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@
icons_dir = os.path.join(os.path.dirname(__file__), "icons")
custom_icon_col = {}

def SetCyclesRenderer(set_gi_params=False):
# set the render engine for all scenes to Cycles
for scene in bpy.data.scenes:
scene.render.engine = 'CYCLES'

if set_gi_params:
cycles = bpy.context.scene.cycles
cycles.max_bounces = 32
cycles.caustics_reflective = True
cycles.caustics_refractive = True
cycles.diffuse_bounces = 32
cycles.glossy_bounces = 32
cycles.transmission_bounces = 32
cycles.volume_bounces = 32
cycles.transparent_max_bounces = 32
cycles.use_fast_gi = False
cycles.ao_bounces = 1
cycles.ao_bounces_render = 1

class CP77EntityImport(bpy.types.Operator,ImportHelper):

bl_idname = "io_scene_gltf.cp77entity"
Expand All @@ -50,8 +69,12 @@ class CP77EntityImport(bpy.types.Operator,ImportHelper):
description="Meshes to skip during import",
default="",
options={'HIDDEN'})

update_gi: BoolProperty(name="Update Global Illumination",default=True,description="Update Cycles global illumination options for transparency fixes and higher quality renders")

def execute(self, context):
SetCyclesRenderer(self.update_gi)

apps=self.appearances.split(",")
print('apps - ',apps)
excluded=self.appearances.split(",")
Expand Down Expand Up @@ -98,6 +121,7 @@ def draw(self, context):
layout.prop(operator, 'exclude_unused_mats')
layout.prop(operator, 'image_format')
layout.prop(operator, 'hide_armatures')
layout.prop(operator, 'update_gi')


class CP77Import(bpy.types.Operator,ImportHelper):
Expand All @@ -124,6 +148,8 @@ class CP77Import(bpy.types.Operator,ImportHelper):
with_materials: BoolProperty(name="With Materials",default=True,description="Import mesh with Wolvenkit-exported materials")

hide_armatures: BoolProperty(name="Hide Armatures",default=True,description="Hide the armatures on imported meshes")

update_gi: BoolProperty(name="Update Global Illumination",default=True,description="Update Cycles global illumination options for transparency fixes and higher quality renders")

filepath: StringProperty(subtype = 'FILE_PATH')

Expand All @@ -140,10 +166,9 @@ class CP77Import(bpy.types.Operator,ImportHelper):
def draw(self, context):
pass




def execute(self, context):
SetCyclesRenderer(self.update_gi)

loadfiles=self.files
appearances=self.appearances.split(",")
for f in appearances:
Expand Down Expand Up @@ -244,8 +269,7 @@ def execute(self, context):


Builder = MaterialBuilder(obj,BasePath,str(self.image_format))

usedMaterials = {}

counter = 0
bpy_mats=bpy.data.materials
for name in bpy.data.meshes.keys():
Expand Down Expand Up @@ -287,22 +311,7 @@ def execute(self, context):
if rawmat["Name"] not in bpy.data.materials.keys() and ((rawmat["Name"] in MatImportList) or len(MatImportList)<1):
Builder.create(index)
index = index + 1









'''
for name in bpy.data.objects.keys():
if name not in existingObjects:
for parent in bpy.data.objects[name].users_collection:
parent.objects.unlink(bpy.data.objects[name])
collection.objects.link(bpy.data.objects[name])
'''

return {'FINISHED'}

def menu_func_import(self, context):
Expand Down

0 comments on commit 82a4c1f

Please sign in to comment.