further work on the blender plugin

metadata
Wenzel Jakob 2010-11-10 22:40:21 +01:00
parent 8d959971c5
commit d573371e82
3 changed files with 61 additions and 157 deletions

View File

@ -27,7 +27,7 @@ bl_addon_info = {
"warning": "",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
"Scripts/Render/Mitsuba",
"tracker_url": "Unavailable",
"tracker_url": "https://www.mitsuba-renderer.org/bugtracker/projects/mitsuba",
"category": "Render"}
@ -41,89 +41,19 @@ else:
from render_mitsuba import render
from render_mitsuba import ui
def register():
Scene = bpy.types.Scene
# Not a real pov option, just to know if we should write
Scene.mts_radio_enable = BoolProperty(
name="Enable Radiosity",
description="Enable mitsubas radiosity calculation",
default=False)
Scene.mts_radio_display_advanced = BoolProperty(
name="Advanced Options",
description="Show advanced options",
default=False)
# Real pov options
Scene.mts_radio_adc_bailout = FloatProperty(
name="ADC Bailout", description="The adc_bailout for radiosity rays. Use adc_bailout = 0.01 / brightest_ambient_object for good results",
min=0.0, max=1000.0, soft_min=0.0, soft_max=1.0, default=0.01)
Scene.mts_radio_always_sample = BoolProperty(
name="Always Sample", description="Only use the data from the pretrace step and not gather any new samples during the final radiosity pass",
default=True)
Scene.mts_radio_brightness = FloatProperty(
name="Brightness", description="Amount objects are brightened before being returned upwards to the rest of the system",
min=0.0, max=1000.0, soft_min=0.0, soft_max=10.0, default=1.0)
Scene.mts_radio_count = IntProperty(
name="Ray Count", description="Number of rays that are sent out whenever a new radiosity value has to be calculated",
min=1, max=1600, default=35)
Scene.mts_radio_error_bound = FloatProperty(
name="Error Bound", description="One of the two main speed/quality tuning values, lower values are more accurate",
min=0.0, max=1000.0, soft_min=0.1, soft_max=10.0, default=1.8)
Scene.mts_radio_gray_threshold = FloatProperty(
name="Gray Threshold", description="One of the two main speed/quality tuning values, lower values are more accurate",
min=0.0, max=1.0, soft_min=0, soft_max=1, default=0.0)
Scene.mts_radio_low_error_factor = FloatProperty(
name="Low Error Factor", description="If you calculate just enough samples, but no more, you will get an image which has slightly blotchy lighting",
min=0.0, max=1.0, soft_min=0.0, soft_max=1.0, default=0.5)
# max_sample - not available yet
Scene.mts_radio_media = BoolProperty(
name="Media", description="Radiosity estimation can be affected by media",
default=False)
Scene.mts_radio_minimum_reuse = FloatProperty(
name="Minimum Reuse", description="Fraction of the screen width which sets the minimum radius of reuse for each sample point (At values higher than 2% expect errors)",
min=0.0, max=1.0, soft_min=0.1, soft_max=0.1, default=0.015)
Scene.mts_radio_nearest_count = IntProperty(
name="Nearest Count", description="Number of old ambient values blended together to create a new interpolated value",
min=1, max=20, default=5)
Scene.mts_radio_normal = BoolProperty(
name="Normals", description="Radiosity estimation can be affected by normals",
default=False)
Scene.mts_radio_recursion_limit = IntProperty(
name="Recursion Limit", description="how many recursion levels are used to calculate the diffuse inter-reflection",
min=1, max=20, default=3)
Scene.mts_path = bpy.props.StringProperty(
name = "mts_path",
description="Full path to the 'mitsuba' executable",
default = "", subtype = "FILE_PATH", maxlen=1024)
Scene.mts_gui = bpy.props.BoolProperty(
name = "mts_gui",
description="Should the Mitsuba user interface be launched?",
default = False)
def unregister():
import bpy
Scene = bpy.types.Scene
del Scene.mts_radio_enable
del Scene.mts_radio_display_advanced
del Scene.mts_radio_adc_bailout
del Scene.mts_radio_always_sample
del Scene.mts_radio_brightness
del Scene.mts_radio_count
del Scene.mts_radio_error_bound
del Scene.mts_radio_gray_threshold
del Scene.mts_radio_low_error_factor
del Scene.mts_radio_media
del Scene.mts_radio_minimum_reuse
del Scene.mts_radio_nearest_count
del Scene.mts_radio_normal
del Scene.mts_radio_recursion_limit
del Scene.mts_path
if __name__ == "__main__":
register()

View File

@ -55,7 +55,8 @@ class MitsubaRender(bpy.types.RenderEngine):
adjfile.close()
def _render(self):
mts_path = '/home/wenzel/mitsuba'
scene = bpy.data.scenes[0]
(mts_path, tail) = os.path.split(bpy.path.abspath(scene.mts_path))
mtsimport_binary = os.path.join(mts_path, "mtsimport")
mitsuba_binary = os.path.join(mts_path, "mitsuba")
mts_render_libpath = os.path.join(mts_path, "src/librender")
@ -63,7 +64,6 @@ class MitsubaRender(bpy.types.RenderEngine):
mts_hw_libpath = os.path.join(mts_path, "src/libhw")
env = copy.copy(os.environ)
env['LD_LIBRARY_PATH'] = mts_core_libpath + ":" + mts_render_libpath + ":" + mts_hw_libpath
scene = bpy.data.scenes[0]
render = scene.render
width = int(render.resolution_x * render.resolution_percentage * 0.01)
height = int(render.resolution_y * render.resolution_percentage * 0.01)
@ -102,6 +102,8 @@ class MitsubaRender(bpy.types.RenderEngine):
if not self._render():
self.update_stats("", "MtsBlend: Unable to render (please check the console)")
return
self.update_stats("", "MtsBlend: Unable to render (please check the console)")
r = scene.render
x = int(r.resolution_x * r.resolution_percentage * 0.01)

View File

@ -37,100 +37,72 @@ del properties_world
# Example of wrapping every class 'as is'
import properties_material
for member in dir(properties_material):
subclass = getattr(properties_material, member)
try:
subclass.COMPAT_ENGINES.add('MITSUBA_RENDER')
except:
pass
subclass = getattr(properties_material, member)
try:
subclass.COMPAT_ENGINES.add('MITSUBA_RENDER')
except:
pass
del properties_material
import properties_data_mesh
for member in dir(properties_data_mesh):
subclass = getattr(properties_data_mesh, member)
try:
subclass.COMPAT_ENGINES.add('MITSUBA_RENDER')
except:
pass
subclass = getattr(properties_data_mesh, member)
try:
subclass.COMPAT_ENGINES.add('MITSUBA_RENDER')
except:
pass
del properties_data_mesh
import properties_texture
for member in dir(properties_texture):
subclass = getattr(properties_texture, member)
try:
subclass.COMPAT_ENGINES.add('MITSUBA_RENDER')
except:
pass
subclass = getattr(properties_texture, member)
try:
subclass.COMPAT_ENGINES.add('MITSUBA_RENDER')
except:
pass
del properties_texture
import properties_data_camera
for member in dir(properties_data_camera):
subclass = getattr(properties_data_camera, member)
try:
subclass.COMPAT_ENGINES.add('MITSUBA_RENDER')
except:
pass
subclass = getattr(properties_data_camera, member)
try:
subclass.COMPAT_ENGINES.add('MITSUBA_RENDER')
except:
pass
del properties_data_camera
import properties_data_lamp
for member in dir(properties_data_lamp):
subclass = getattr(properties_data_lamp, member)
try:
subclass.COMPAT_ENGINES.add('MITSUBA_RENDER')
except:
pass
del properties_data_lamp
class RenderButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "render"
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "render"
@classmethod
def poll(cls, context):
rd = context.scene.render
return (rd.use_game_engine == False) and (rd.engine in cls.COMPAT_ENGINES)
@classmethod
def poll(cls, context):
rd = context.scene.render
return (rd.use_game_engine == False) and (rd.engine in cls.COMPAT_ENGINES)
class RENDER_PT_mitsuba_radiosity(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Radiosity"
COMPAT_ENGINES = {'MITSUBA_RENDER'}
bl_label = "Mitsuba setup"
COMPAT_ENGINES = {'MITSUBA_RENDER'}
def draw_header(self, context):
scene = context.scene
def draw(self, context):
layout = self.layout
scene = context.scene
rd = scene.render
self.layout.prop(scene, "mts_radio_enable", text="")
def draw(self, context):
layout = self.layout
scene = context.scene
rd = scene.render
layout.active = scene.mts_radio_enable
split = layout.split()
col = split.column()
col.prop(scene, "mts_radio_count", text="Rays")
col.prop(scene, "mts_radio_recursion_limit", text="Recursions")
col = split.column()
col.prop(scene, "mts_radio_error_bound", text="Error")
layout.prop(scene, "mts_radio_display_advanced")
if scene.mts_radio_display_advanced:
split = layout.split()
col = split.column()
col.prop(scene, "mts_radio_adc_bailout", slider=True)
col.prop(scene, "mts_radio_gray_threshold", slider=True)
col.prop(scene, "mts_radio_low_error_factor", slider=True)
col = split.column()
col.prop(scene, "mts_radio_brightness")
col.prop(scene, "mts_radio_minimum_reuse", text="Min Reuse")
col.prop(scene, "mts_radio_nearest_count")
split = layout.split()
col = split.column()
col.label(text="Estimation Influence:")
col.prop(scene, "mts_radio_media")
col.prop(scene, "mts_radio_normal")
col = split.column()
col.prop(scene, "mts_radio_always_sample")
split = layout.split()
col = split.column();
col.prop(scene, "mts_path", text="Executable")
row = col.row();
row.prop(scene, "mts_gui", text="In external GUI")
row.operator("wm.save_homefile", text="Save", icon ='FILE_TICK')