-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathff_rend.py
257 lines (234 loc) · 9.89 KB
/
ff_rend.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
import bpy
from bpy import context as context
from pathlib import Path
# import PrismCore
# global pcore
# pcore = PrismCore.PrismCore(app="Blender")
# def renderPngPasses(context):
# '''
# this function will setup PNG and output passes as well
# '''
# pcore.projectPath
# pcore.scenePath # points to workflow dir
# pcore.shotPath # points to shots folder
# pcore.fileInPipeline(bpy.data.filepath)
# bfp = Path(bpy.data.filepath)
# #filename = bpy.path.basename(bpy.data.filepath)
# filename = bfp.name
# filepath = bfp.parent
# shotdir = bfp.parent.parent.parent.parent
# if shotdir.is_dir():
# rendDir = shotdir.joinpath("Rendering","3dRender")
# # now get file version string
# verInfo = filename.split(pcore.filenameSeparator)[4] # .sequenceSeparato
# verFormat = pcore.versionFormat
# # create / output dir exists
# print ("RENDERING DIR EXPECTED PATH:", rendDir)
# print ("RENDERING DIR FOUND:", rendDir.exists())
# renderer = context.scene.render.engine #.split('_')[1]
# rendDir = rendDir.joinpath(renderer)
# rendDir.mkdir(parents=True, exist_ok=True) # will create EEVEE or CYCLES Directory
# # set relative path in output (main area)
# #fo = C.scene.render.filepath
# #bpy.path.abspath, to replace os.path.abspath
# #bpy.path.relpath, to replace os.path.relpath
# context.scene.render.filepath = rendDir.as_posix() + '/'+verInfo+'/beauty/image_'
# context.scene.render.image_settings.file_format = 'PNG'
# context.scene.render.image_settings.color_mode = 'RGBA'
# context.scene.render.image_settings.color_depth = '8'
# context.scene.render.use_file_extension = True
# context.scene.render.use_compositing = True
# context.scene.render.resolution_percentage = 100
# # remove all fileoutput nodes in comp area
# context.scene.use_nodes = True
# outputNodes = [x for x in context.scene.node_tree.nodes if x.type == 'OUTPUT_FILE']
# for node in outputNodes:
# context.scene.node_tree.nodes.remove(node)
# # setup new output comp nodes in comp area
# #n = bpy.context.scene.node_tree.nodes.new(type='CompositorNodeOutputFile')
# # set new node location >> n.location = ((50,50))
# # Get Render Layer
# rendLyrNodes = [x for x in context.scene.node_tree.nodes if x.type == 'R_LAYERS']
# if len(rendLyrNodes) ==1:
# rendLyrNode = rendLyrNodes[0]
# else:
# rendLyrNode = rendLyrNodes[0]
# # get output passes list from node or blender
# #rendLyrNode.outputs # all possible passes here (todo)
# tree = context.scene.node_tree
# print ("TREE:", tree)
# #np = rendLyrNode.viewLocation
# np = rendLyrNode.location # since 2.92 (above failed)
# iteration = 1
# renderPasses = {
# "DiffCol": context.scene.view_layers[0].use_pass_diffuse_color,
# "DiffDir": context.scene.view_layers[0].use_pass_diffuse_direct,
# "GlossCol": context.scene.view_layers[0].use_pass_glossy_color,
# "GlossDir": context.scene.view_layers[0].use_pass_glossy_direct,
# "Shadow": context.scene.view_layers[0].use_pass_shadow,
# "AO": context.scene.view_layers[0].use_pass_ambient_occlusion,
# "Mist": context.scene.view_layers[0].use_pass_mist,
# "Emit": context.scene.view_layers[0].use_pass_emit,
# "Normal": context.scene.view_layers[0].use_pass_normal,
# "Depth": context.scene.view_layers[0].use_pass_z
# }
# #if context.scene.view_layers[0].use_pass_diffuse_color:
# # n = context.scene.node_tree.nodes.new(type='CompositorNodeOutputFile')
# # tree.links.new(rendLyrNode.outputs['DiffCol'], n.inputs[0])
# for each in renderPasses:
# if renderPasses[each]:
# n = context.scene.node_tree.nodes.new(type='CompositorNodeOutputFile')
# tree.links.new(rendLyrNode.outputs[each], n.inputs[0])
# n.base_path = rendDir.as_posix() + '/'+verInfo+'/'+each
# npx = np.x + 800
# npy = np.y - (iteration * 100)
# n.location = ((npx,npy))
# iteration = iteration + 1
# # create links
# # C.scene.node_tree.links.new('','')
# aovs = context.scene.view_layers[0].aovs
# for aov in aovs:
# print (aov.name)
# # create output node for AOV
# n = context.scene.node_tree.nodes.new(type='CompositorNodeOutputFile')
# tree.links.new(rendLyrNode.outputs[aov.name], n.inputs[0])
# n.base_path = rendDir.as_posix() + '/'+verInfo+'/'+aov.name
# npx = np.x + 800
# npy = np.y - (iteration * 100)
# n.location = ((npx,npy))
# iteration = iteration + 1
# # todo fix depth reduction
# # todo make sure compositing is ticked
# # todo fix all layers ( currently 0 is hardcoded :( )
# def renderPreviewMp4(context,res=100):
# '''
# this function will setup preview mp4
# '''
# pcore.projectPath
# pcore.scenePath # points to workflow dir
# pcore.shotPath # points to shots folder
# pcore.fileInPipeline(bpy.data.filepath)
# bfp = Path(bpy.data.filepath)
# basefilename = bpy.path.basename(bpy.data.filepath).split('.')[0]
# filename = bfp.name
# filepath = bfp.parent
# shotdir = bfp.parent.parent.parent.parent
# stepdir = pcore.getCurrentFileName().split('/')[-2]
# if shotdir.is_dir():
# rendDir = shotdir.joinpath("Playblasts",stepdir)
# # now get file version string
# verInfo = filename.split(pcore.filenameSeparator)[4] # .sequenceSeparato
# verFormat = pcore.versionFormat
# # create / output dir exists
# print ("Preview DIR EXPECTED PATH:", rendDir)
# print ("Preview DIR FOUND:", rendDir.exists())
# #renderer = context.scene.render.engine #.split('_')[1]
# rendDir = rendDir.joinpath(verInfo)
# rendDir.mkdir(parents=True, exist_ok=True) # will create EEVEE or CYCLES Directory
# # set relative path in output (main area)
# #fo = C.scene.render.filepath
# #bpy.path.abspath, to replace os.path.abspath
# #bpy.path.relpath, to replace os.path.relpath
# #context.scene.render.filepath = rendDir.as_posix() + '/'+verInfo+'/beauty/image_'
# context.scene.render.filepath = rendDir.as_posix() + '/'+ basefilename + '.mp4'
# context.scene.render.image_settings.file_format = 'FFMPEG'
# context.scene.render.ffmpeg.format = 'MPEG4'
# context.scene.render.ffmpeg.constant_rate_factor = 'HIGH'
# context.scene.render.ffmpeg.gopsize = 4
# context.scene.render.resolution_percentage = 50
def useCompositing_toggle():
C.scene.render.use_compositing = not C.scene.render.use_compositing
def getRenderInfo():
fo = C.scene.render.filepath
#bpy.path.abspath, to replace os.path.abspath
#bpy.path.relpath, to replace os.path.relpath
def setRP_FileOuts(type='png'):
pass
def updateRP_FileOuts(type='png'):
for node in C.scene.node_tree.nodes:
if node.type == 'OUTPUT_FILE':
no = node.base_path
# OPERATORS HERE
class setupPrismOutput_OT_Operator (bpy.types.Operator):
'''setup local png render'''
bl_idname = "ffrend.setup_prism_output"
bl_label = "ffrend_setupPrismOutput"
bl_options = {"REGISTER","UNDO"}
'''
@classmethod
def poll(cls,context):
if context.area.type=='VIEW_3D':
if ((context.object) and context.object.type =="ARMATURE" and ('rig_id' in context.object.data)):
return (1)
else:
return(0)
'''
def execute(self, context):
renderPngPasses(context)
self.report({'INFO'}, "Done.")
return{"FINISHED"}
class setupPrismPreview_OT_Operator (bpy.types.Operator):
'''setup local mp4 preview'''
bl_idname = "ffrend.setup_prism_preview"
bl_label = "ffrend_setupPrismPreview"
bl_options = {"REGISTER","UNDO"}
'''
@classmethod
def poll(cls,context):
if context.area.type=='VIEW_3D':
if ((context.object) and context.object.type =="ARMATURE" and ('rig_id' in context.object.data)):
return (1)
else:
return(0)
'''
def execute(self, context):
renderPreviewMp4(context)
self.report({'INFO'}, "Done.")
return{"FINISHED"}
class setupBackGroundRender_OT_Operator (bpy.types.Operator):
'''setup background render command'''
bl_idname = "ffrend.setup_bg_render"
bl_label = "ffrend_setupBackGroundRender"
bl_options = {"REGISTER","UNDO"}
'''
@classmethod
def poll(cls,context):
if context.area.type=='VIEW_3D':
if ((context.object) and context.object.type =="ARMATURE" and ('rig_id' in context.object.data)):
return (1)
else:
return(0)
'''
def execute(self, context):
renderPreviewMp4(context)
self.report({'INFO'}, "Done.")
return{"FINISHED"}
class FfPollRend():
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
@classmethod
def poll(cls, context):
return(context.scene.ff_rend == True)
class FF_PT_Rend(FfPollRend, bpy.types.Panel):
bl_idname = "FF_PT_Rend"
bl_label = "Rendering"
bl_category = "FF_Tools"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
def draw(self, context):
active_obj = context.active_object
layout = self.layout
# new stuff
box = layout.box()
col = box.column(align = True)
col.label(text='PRISM ASSIST')
row = col.row(align=True)
row.operator("ffrend.setup_prism_output", text="Setup Masks AOV")
row = col.row(align=True)
row.operator("ffrend.setup_prism_output", text="PNG Render")
row = col.row(align=True)
row.operator("ffrend.setup_prism_output", text="EXR RENDER")
row = col.row(align=True)
row.operator("ffrend.setup_prism_preview", text="Setup Playblast mp4")
row = col.row(align=True)
row.operator("ffrend.setup_bg_render", text="BG Render Cmd")