forked from stig-atle/io_scene_mitsuba2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender_panel.py
162 lines (128 loc) · 7.29 KB
/
render_panel.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
import bpy
from . import render_exporter
class ExportMitsuba2Scene(bpy.types.Operator):
bl_idname = 'scene.export'
bl_label = 'Export Scene'
bl_options = {"REGISTER", "UNDO"}
COMPAT_ENGINES = {'Mitsuba2_Renderer'}
def execute(self, context):
print("Starting calling mitsuba_export")
print("Output path:")
print(bpy.data.scenes[0].exportpath)
for frameNumber in range(bpy.data.scenes['Scene'].batch_frame_start, bpy.data.scenes['Scene'].batch_frame_end +1):
bpy.data.scenes['Scene'].frame_set(frameNumber)
print("Exporting frame: %s" % (frameNumber))
render_exporter.export_Mitsuba(bpy.data.scenes['Scene'].exportpath, bpy.data.scenes['Scene'], '{0:05d}'.format(frameNumber))
self.report({'INFO'}, "Export complete.")
return {"FINISHED"}
class MitsubaRenderSettingsPanel(bpy.types.Panel):
"""Creates a Mitsuba settings panel in the render context of the properties editor"""
bl_label = "Mitsuba Render settings"
bl_idname = "SCENE_PT_layout"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "render"
COMPAT_ENGINES = {'Mitsuba2_Renderer'}
#Hide the Mitsuba render panel if Mitsuba render engine is not currently selected.
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
if engine != 'Mitsuba2_Renderer':
return False
else:
return True
def draw(self, context):
engine = context.scene.render.engine
if engine != 'Mitsuba2_Renderer':
bpy.utils.unregister_class(MitsubaRenderSettingsPanel)
layout = self.layout
scene = context.scene
layout.label(text="Output folder path")
row = layout.row()
row.prop(scene, "exportpath")
layout.label(text="Environment Map")
row = layout.row()
row.prop(scene,"environmentmaptpath")
layout.label(text="Environment map scale:")
row = layout.row()
row.prop(scene, "environmentmapscale")
layout.label(text="Frame settings:")
row = layout.row()
row.prop(scene, "batch_frame_start")
row.prop(scene, "batch_frame_end")
layout.label(text="Resolution:")
row = layout.row()
row.prop(scene, "resolution_x")
row.prop(scene, "resolution_y")
row = layout.row()
row.prop(scene,"spp")
layout.label(text="Depth of field:")
row = layout.row()
row.prop(scene,"dofLookAt")
row = layout.row()
row.prop(scene, "lensradius")
layout.label(text="Integrator settings:")
row = layout.row()
row.prop(scene,"integrators")
if scene.integrators == 'path':
row = layout.row()
row.prop(scene,"path_integrator_hide_emitters")
row = layout.row()
row.prop(scene,"path_integrator_max_depth")
row.prop(scene,"path_integrator_rr_depth")
if scene.integrators == 'volpathsimple':
row = layout.row()
row.prop(scene,"path_integrator_max_depth")
row.prop(scene,"path_integrator_rr_depth")
if scene.integrators == 'volpath':
row = layout.row()
row.prop(scene,"path_integrator_max_depth")
row.prop(scene,"path_integrator_rr_depth")
if scene.integrators == 'direct':
row = layout.row()
row.prop(scene,"path_integrator_hide_emitters")
row = layout.row()
row.prop(scene,"direct_integrator_emitter_samples")
row = layout.row()
row.prop(scene,"direct_integrator_bsdf_samples")
#layout.label(text="Light strategy:")
#row = layout.row()
#row.prop(scene,"lightsamplestrategy")
layout.label(text="Export:")
row = layout.row()
layout.operator("scene.export", icon='MESH_CUBE', text="Export scene")
def register():
bpy.types.Scene.exportpath = bpy.props.StringProperty(
name="",
description="Export folder",
default="",
maxlen=1024,
subtype='DIR_PATH')
bpy.types.Scene.environmentmaptpath = bpy.props.StringProperty(
name="",
description="Environment map",
default="",
maxlen=1024,
subtype='FILE_PATH')
#bpy.types.Scene.outputfilename = bpy.props.StringProperty(
# name="",
# description="Image output file name",
# default="output.exr",
# maxlen=1024,
# subtype='FILE_NAME')
bpy.types.Scene.spp = bpy.props.IntProperty(name = "Samples per pixel", description = "Set spp", default = 100, min = 1, max = 9999)
bpy.types.Scene.environmentmapscale = bpy.props.FloatProperty(name = "Env. map scale", description = "Env. map scale", default = 1, min = 0.001, max = 9999)
bpy.types.Scene.resolution_x = bpy.props.IntProperty(name = "X", description = "Resolution x", default = 1366, min = 1, max = 9999)
bpy.types.Scene.resolution_y = bpy.props.IntProperty(name = "Y", description = "Resolution y", default = 768, min = 1, max = 9999)
bpy.types.Scene.dofLookAt = bpy.props.PointerProperty(name="Target", type=bpy.types.Object)
bpy.types.Scene.lensradius = bpy.props.FloatProperty(name = "Lens radius", description = "Lens radius", default = 0, min = 0.001, max = 9999)
bpy.types.Scene.batch_frame_start = bpy.props.IntProperty(name = "Frame start", description = "Frame start", default = 1, min = 1, max = 9999999)
bpy.types.Scene.batch_frame_end = bpy.props.IntProperty(name = "Frame end", description = "Frame end", default = 1, min = 1, max = 9999999)
integrators = [("direct", "direct", "", 1),("path", "path", "", 2),("volpath", "volpath", "", 3),("volpathsimple", "volpathsimple", "", 4)]
bpy.types.Scene.integrators = bpy.props.EnumProperty(name = "Name", items=integrators , default="path")
#path integrator settings:
bpy.types.Scene.path_integrator_max_depth = bpy.props.IntProperty(name = "Max depth", description = "Specifies the longest path depth in the generated output image (where -1 corresponds to infty). A value of 1 will only render directly visible light sources. 2 will lead to single-bounce (direct-only) illumination, and so on.", default = -1, min = -1, max = 9999)
bpy.types.Scene.path_integrator_rr_depth = bpy.props.IntProperty(name = "Rr depth", description = "Specifies the minimum path depth, after which the implementation will start to use the *russian roulette* path termination criterion.", default = 5, min = 0, max = 9999)
bpy.types.Scene.path_integrator_hide_emitters = bpy.props.BoolProperty(name="Hide emitters", description="Hide directly visible emitters.", default = False)
bpy.types.Scene.direct_integrator_emitter_samples = bpy.props.IntProperty(name = "Emitter samples", description = "specifies the number of samples that should be generated using the direct illumination strategies implemented by the scene's emitters. (Default: set to the value of 'shading samples')", default = 1, min = 1, max = 9999)
bpy.types.Scene.direct_integrator_bsdf_samples = bpy.props.IntProperty(name = "BSDF samples", description = "specifies the number of samples that should be generated using the BSDF sampling strategies implemented by the scene's surfaces.", default = 1, min = 1, max = 9999)