diff --git a/data/blender/mitsuba/export/__init__.py b/data/blender/mitsuba/export/__init__.py index ca948ffe..892ba7a5 100644 --- a/data/blender/mitsuba/export/__init__.py +++ b/data/blender/mitsuba/export/__init__.py @@ -458,7 +458,7 @@ class MtsExporter: self.closeElement() def exportMediumReference(self, scene, obj, role, mediumName): - if medium == "": + if mediumName == "": return if obj.data.users > 1: MtsLog("Error: medium transitions cannot be instantiated (at least for now)!") @@ -473,10 +473,11 @@ class MtsExporter: mmat = material.mitsuba_material lamp = material.mitsuba_emission if mmat.is_medium_transition: + mainScene = bpy.data.scenes[0] if mmat.interior_medium != '': - self.exportMedium(scene.mitsuba_media.media[mmat.interior_medium]) + self.exportMedium(mainScene.mitsuba_media.media[mmat.interior_medium]) if mmat.exterior_medium != '': - self.exportMedium(scene.mitsuba_media.media[mmat.exterior_medium]) + self.exportMedium(mainScene.mitsuba_media.media[mmat.exterior_medium]) self.openElement('shape', {'id' : 'Exterior-mesh_0', 'type' : 'serialized'}) self.parameter('string', 'filename', {'value' : 'matpreview.serialized'}) self.parameter('integer', 'shapeIndex', {'value' : '1'}) @@ -512,7 +513,7 @@ class MtsExporter: def exportMedium(self, medium): if medium.name in self.exported_media: return - self.exported_media += [mat.name] + self.exported_media += [medium.name] self.openElement('medium', {'id' : medium.name, 'type' : medium.type}) if medium.g == 0: self.element('phase', {'type' : 'isotropic'}) @@ -520,6 +521,18 @@ class MtsExporter: self.openElement('phase', {'type' : 'hg'}) self.parameter('float', 'g', {'value' : str(medium.g)}) self.closeElement() + if medium.type == 'homogeneous': + self.parameter('float', 'densityMultiplier', {'value' : + str(medium.densityMultiplier)}) + self.parameter('rgb', 'sigmaA', {'value' : '%f %f %f' % ( + (1-medium.albedo.r) * medium.sigmaT[0], + (1-medium.albedo.g) * medium.sigmaT[1], + (1-medium.albedo.b) * medium.sigmaT[2])}) + self.parameter('rgb', 'sigmaS', {'value' : '%f %f %f' % ( + medium.albedo.r * medium.sigmaT[0], + medium.albedo.g * medium.sigmaT[1], + medium.albedo.b * medium.sigmaT[2])}) + self.closeElement() def export(self, scene): diff --git a/data/blender/mitsuba/properties/integrator.py b/data/blender/mitsuba/properties/integrator.py index 7f5b61ea..4d552474 100644 --- a/data/blender/mitsuba/properties/integrator.py +++ b/data/blender/mitsuba/properties/integrator.py @@ -48,9 +48,9 @@ class mitsuba_integrator(declarative_property_group): 'description': 'Specifies the type of integrator to use', 'default': 'direct', 'items': [ - ('direct', 'Direct Illumination', 'direct'), + ('volpath', 'Volumetric path tracer', 'volpath'), ('path', 'Path tracer', 'path'), - ('volpath', 'Volumetric path tracer', 'volpath') + ('direct', 'Direct Illumination', 'direct') ], 'save_in_preset': True }, diff --git a/data/blender/mitsuba/properties/material.py b/data/blender/mitsuba/properties/material.py index 11576e50..25441cc5 100644 --- a/data/blender/mitsuba/properties/material.py +++ b/data/blender/mitsuba/properties/material.py @@ -93,7 +93,7 @@ class mitsuba_material(declarative_property_group): { 'type': 'bool', 'attr': 'twosided', - 'name': 'Use two-sided shading?', + 'name': 'Use two-sided shading', 'description': 'Use two-sided shading for this material? This only makes sense for non-transparent/translucent materials.', 'default': False, 'save_in_preset': True @@ -101,7 +101,7 @@ class mitsuba_material(declarative_property_group): { 'type': 'bool', 'attr': 'is_medium_transition', - 'name': 'Mark as medium transition?', + 'name': 'Mark as medium transition', 'description': 'Activate this property if the material specifies a transition from one participating medium to another.', 'default': False, 'save_in_preset': True @@ -513,7 +513,7 @@ class mitsuba_mat_roughmetal(declarative_property_group): 'name' : 'IOR', 'description' : 'Per-channel index of refraction of the conductor', 'default' : (0.370, 0.370, 0.370), - 'min': 1.0, + 'min': 0.1, 'max': 10.0, 'expand' : False, 'save_in_preset': True diff --git a/data/blender/mitsuba/properties/world.py b/data/blender/mitsuba/properties/world.py index 81e53e5a..503624f7 100644 --- a/data/blender/mitsuba/properties/world.py +++ b/data/blender/mitsuba/properties/world.py @@ -52,9 +52,9 @@ class mitsuba_medium_data(declarative_property_group): ef_attach_to = [] # not attached controls = [ - 'type', 'g' + 'type', 'g', 'densityMultiplier', 'sigmaT', 'albedo' ] - + properties = [ { 'type': 'enum', @@ -78,6 +78,41 @@ class mitsuba_medium_data(declarative_property_group): 'soft_max': 1.0, 'precision': 4, 'save_in_preset': True + }, + { + 'type': 'float', + 'attr': 'densityMultiplier', + 'name': 'Density', + 'description': 'In conjunction with the scattering and absorption coefficients, this number determines the optical density of the medium', + 'default': 1.0, + 'min': 0, + 'max': 10000, + 'precision': 4, + 'save_in_preset': True + }, + { + 'type': 'float_vector', + 'attr': 'sigmaT', + 'name' : 'Extinction', + 'description' : 'Extinction due to scattering and absorption. Please ' + + 'keep these value roughly equal across color channels (or expect noise).', + 'default' : (1.0, 1.0, 1.0), + 'min': 0.0, + 'max': 1.0, + 'expand' : False, + 'save_in_preset': True + }, + { + 'type': 'float_vector', + 'attr': 'albedo', + 'subtype': 'COLOR', + 'name' : 'Single-scattering albedo', + 'description' : 'Specifies the albedo of a single scattering interaction', + 'default' : (0.8, 0.8, 0.8), + 'min': 0.0, + 'max': 1.0, + 'expand' : False, + 'save_in_preset': True } ]