-
Notifications
You must be signed in to change notification settings - Fork 0
/
render-settings-addon.py
158 lines (130 loc) · 5.44 KB
/
render-settings-addon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
from bpy.props import (StringProperty, PointerProperty, BoolProperty)
from bpy.types import Operator
from re import split
import bpy
bl_info = {
"name": "WEAVER Render Settings Manager",
"author": "Alex Vuong",
"version": (1, 0, 3),
"blender": (4, 0, 0),
"location": "N-panel in 3D viewport",
"category": "Generic"
}
class WEAVER_OT_popup(bpy.types.Operator):
bl_label = "WEAVER render manager message box"
bl_idname = "weaver.debug_popup"
message: StringProperty(default="empty message")
icon_type: StringProperty(default="INFO")
def draw(self, context):
layout = self.layout
split_message = split("\n| - ", self.message)
print(split_message)
if split_message[-1] == "":
split_message.pop()
for i, line in enumerate(split_message):
if i == 0:
layout.label(text=line, icon=self.icon_type)
else:
layout.label(text=line)
def execute(self, context):
return {'FINISHED'}
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self, width=500)
class OBJECT_PT_weaver_panel_ui(bpy.types.Panel):
bl_label = "WEAVER"
bl_idname = "OBJECT_PT_weaver_panel_ui"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "WEAVER"
def draw(self, context):
layout = self.layout
layout.operator("weaver.set_render_settings")
layout.operator("weaver.set_playblast_settings")
class WEAVER_OT_set_playblast_settings(bpy.types.Operator):
bl_label = "Set playblast settings"
bl_idname = "weaver.set_playblast_settings"
bl_description = "Set render to playblast WEBM settings"
def execute(self, context):
bpy.ops.weaver.set_render_settings()
bpy.context.scene.render.ffmpeg.format = 'WEBM'
bpy.context.scene.render.ffmpeg.codec = 'WEBM'
bpy.context.scene.render.ffmpeg.constant_rate_factor = 'LOWEST'
bpy.context.scene.render.ffmpeg.ffmpeg_preset = 'BEST'
bpy.context.scene.render.ffmpeg.audio_codec = 'OPUS'
return {'FINISHED'}
class WEAVER_OT_set_render_settings(bpy.types.Operator):
bl_label = "Set render settings"
bl_idname = "weaver.set_render_settings"
bl_description = "Set render to Quicktime MOV settings, set output path to //../../../Renders/ShotNumber/ViewLayer_"
def execute(self, context):
filename = bpy.path.basename(bpy.context.blend_data.filepath)
filename = filename.split('_')
shotname = filename[1].split('.')
shotname = shotname[0]
viewlayername = bpy.context.view_layer.name
bpy.context.scene.render.filepath = f"//../../../Renders/{shotname}/{viewlayername}_"
if "editing" in viewlayername:
show_panel_helper(f"Are you sure you want to render \"{viewlayername}\"?")
if "ALL" in viewlayername or "GP" in viewlayername:
bpy.context.view_layer.use_pass_z = True
else:
bpy.context.view_layer.use_pass_z = False
bpy.context.scene.render.image_settings.file_format = 'FFMPEG'
bpy.context.scene.render.use_render_cache = False
bpy.context.scene.render.use_file_extension = True
bpy.context.scene.render.ffmpeg.format = 'QUICKTIME'
bpy.context.scene.render.ffmpeg.codec = 'QTRLE'
bpy.context.scene.render.ffmpeg.ffmpeg_preset = 'BEST'
bpy.context.scene.render.use_compositing = False
bpy.context.scene.render.use_sequencer = False
bpy.context.scene.render.image_settings.color_mode = 'RGBA'
bpy.context.scene.render.film_transparent = True
bpy.context.view_layer.use = True
bpy.context.scene.render.use_single_layer = True
bpy.context.scene.eevee.use_bloom = True
bpy.context.scene.render.ffmpeg.audio_codec = 'NONE'
return {'FINISHED'}
class WEAVER_OT_playblast_current_viewlayer(bpy.types.Operator):
bl_label = "Playblast this layer"
bl_idname = "weaver.playblast_active_layer"
bl_description = "Runs \"Viewport Render Animation\""
def execute(self, context):
bpy.ops.wm.save_mainfile()
bpy.ops.render.opengl(animation=True)
return {'FINISHED'}
# class WEAVER_OT_timescale_normal(bpy.types.Operator):
# bl_label = "Set FPS to 24 (normal)"
# bl_idname = "weaver.timescale_24fps"
# bl_description = "Runs \"Viewport Render Animation\""
# def execute(self, context):
# scn = bpy.context.scene
# frame_end = scn.frame_end
# scn.render.fps = 24
# class WEAVER_OT_timescale_scene_4(bpy.types.Operator):
# bl_label = "Set FPS for scene 4"
# bl_idname = "weaver.timescale_scene_4"
# bl_description = "Runs \"Viewport Render Animation\""
classes = (
OBJECT_PT_weaver_panel_ui,
WEAVER_OT_set_render_settings,
WEAVER_OT_playblast_current_viewlayer,
WEAVER_OT_popup,
WEAVER_OT_set_playblast_settings
)
def show_panel_helper(text):
bpy.ops.weaver.debug_popup('INVOKE_DEFAULT', message=text, icon_type='INFO')
print(text)
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
# bpy.types.WindowManager.p4_tracking = PointerProperty(
# type=PerforceTracking)
def unregister():
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
# del bpy.types.WindowManager.p4_tracking
if __name__ == "__main__":
register()