composite material support
parent
e5b707df11
commit
5594d2ba5e
|
@ -36,7 +36,8 @@ from mitsuba.properties.material import mitsuba_material, \
|
||||||
mitsuba_mat_lambertian, mitsuba_mat_phong, mitsuba_mat_ward, \
|
mitsuba_mat_lambertian, mitsuba_mat_phong, mitsuba_mat_ward, \
|
||||||
mitsuba_mat_microfacet, mitsuba_mat_roughglass, \
|
mitsuba_mat_microfacet, mitsuba_mat_roughglass, \
|
||||||
mitsuba_mat_roughmetal, mitsuba_mat_dielectric, \
|
mitsuba_mat_roughmetal, mitsuba_mat_dielectric, \
|
||||||
mitsuba_mat_mirror, mitsuba_mat_difftrans
|
mitsuba_mat_mirror, mitsuba_mat_difftrans, \
|
||||||
|
mitsuba_mat_composite
|
||||||
from mitsuba.operators import MITSUBA_OT_preset_engine_add, EXPORT_OT_mitsuba
|
from mitsuba.operators import MITSUBA_OT_preset_engine_add, EXPORT_OT_mitsuba
|
||||||
from mitsuba.outputs import MtsLog, MtsFilmDisplay
|
from mitsuba.outputs import MtsLog, MtsFilmDisplay
|
||||||
from mitsuba.export.film import resolution
|
from mitsuba.export.film import resolution
|
||||||
|
@ -48,7 +49,7 @@ from mitsuba.ui.textures import main, ldrtexture, checkerboard, \
|
||||||
from mitsuba.ui.materials import MATERIAL_PT_context_material_mts
|
from mitsuba.ui.materials import MATERIAL_PT_context_material_mts
|
||||||
from mitsuba.ui.materials import main, lambertian, phong, ward, \
|
from mitsuba.ui.materials import main, lambertian, phong, ward, \
|
||||||
microfacet, roughglass, roughmetal, dielectric, \
|
microfacet, roughglass, roughmetal, dielectric, \
|
||||||
mirror, difftrans
|
mirror, difftrans, composite
|
||||||
|
|
||||||
def compatible(mod):
|
def compatible(mod):
|
||||||
mod = __import__(mod)
|
mod = __import__(mod)
|
||||||
|
@ -93,7 +94,8 @@ class RENDERENGINE_mitsuba(bpy.types.RenderEngine, engine_base):
|
||||||
('mitsuba_material', mitsuba_mat_roughmetal),
|
('mitsuba_material', mitsuba_mat_roughmetal),
|
||||||
('mitsuba_material', mitsuba_mat_dielectric),
|
('mitsuba_material', mitsuba_mat_dielectric),
|
||||||
('mitsuba_material', mitsuba_mat_difftrans),
|
('mitsuba_material', mitsuba_mat_difftrans),
|
||||||
('mitsuba_material', mitsuba_mat_mirror)
|
('mitsuba_material', mitsuba_mat_mirror),
|
||||||
|
('mitsuba_material', mitsuba_mat_composite)
|
||||||
]
|
]
|
||||||
|
|
||||||
render_lock = threading.Lock()
|
render_lock = threading.Lock()
|
||||||
|
|
|
@ -50,7 +50,8 @@ class mitsuba_material(declarative_property_group):
|
||||||
('roughglass', 'Rough glass', 'Rough dielectric material (e.g. sand-blasted glass)'),
|
('roughglass', 'Rough glass', 'Rough dielectric material (e.g. sand-blasted glass)'),
|
||||||
('roughmetal', 'Rough metal', 'Rough conductor (e.g. sand-blasted metal)'),
|
('roughmetal', 'Rough metal', 'Rough conductor (e.g. sand-blasted metal)'),
|
||||||
('difftrans', 'Diffuse transmitter', 'Material with an ideally diffuse transmittance'),
|
('difftrans', 'Diffuse transmitter', 'Material with an ideally diffuse transmittance'),
|
||||||
('microfacet', 'Microfacet', 'Microfacet material (like the rough glass material, but without transmittance)')
|
('microfacet', 'Microfacet', 'Microfacet material (like the rough glass material, but without transmittance)'),
|
||||||
|
('composite', 'Compound material', 'Allows creating mixtures of different materials')
|
||||||
],
|
],
|
||||||
'save_in_preset': True
|
'save_in_preset': True
|
||||||
}
|
}
|
||||||
|
@ -459,7 +460,7 @@ class mitsuba_mat_dielectric(declarative_property_group):
|
||||||
|
|
||||||
class mitsuba_mat_mirror(declarative_property_group):
|
class mitsuba_mat_mirror(declarative_property_group):
|
||||||
controls = [
|
controls = [
|
||||||
'specularReflectance',
|
'specularReflectance'
|
||||||
]
|
]
|
||||||
|
|
||||||
properties = [
|
properties = [
|
||||||
|
@ -483,7 +484,7 @@ class mitsuba_mat_mirror(declarative_property_group):
|
||||||
|
|
||||||
class mitsuba_mat_difftrans(declarative_property_group):
|
class mitsuba_mat_difftrans(declarative_property_group):
|
||||||
controls = [
|
controls = [
|
||||||
'transmittance',
|
'transmittance'
|
||||||
]
|
]
|
||||||
|
|
||||||
properties = [
|
properties = [
|
||||||
|
@ -491,7 +492,7 @@ class mitsuba_mat_difftrans(declarative_property_group):
|
||||||
'attr': 'transmittance',
|
'attr': 'transmittance',
|
||||||
'type': 'float_vector',
|
'type': 'float_vector',
|
||||||
'subtype': 'COLOR',
|
'subtype': 'COLOR',
|
||||||
'description' : 'Diffuse transmittance value',
|
'description' : 'Amount of ideal diffuse transmittance through the surface',
|
||||||
'name' : 'Diffuse transmittance',
|
'name' : 'Diffuse transmittance',
|
||||||
'default' : (0.5, 0.5, 0.5),
|
'default' : (0.5, 0.5, 0.5),
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
|
@ -504,3 +505,63 @@ class mitsuba_mat_difftrans(declarative_property_group):
|
||||||
params = ParamSet()
|
params = ParamSet()
|
||||||
params.add_color('transmittance', self.transmittance)
|
params.add_color('transmittance', self.transmittance)
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
class WeightedMaterialParameter:
|
||||||
|
def __init__(self, name, readableName, propertyGroup):
|
||||||
|
self.name = name
|
||||||
|
self.readableName = readableName
|
||||||
|
self.propertyGroup = propertyGroup
|
||||||
|
|
||||||
|
def get_controls(self):
|
||||||
|
return [ ['%s_material' % self.name, .8, '%s_weight' % self.name ]]
|
||||||
|
|
||||||
|
def get_properties(self):
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'attr': '%s_name' % self.name,
|
||||||
|
'type': 'string',
|
||||||
|
'name': '%s material name' % self.name,
|
||||||
|
'save_in_preset': True
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'attr': '%s_weight' % self.name,
|
||||||
|
'type': 'float',
|
||||||
|
'name': 'Weight',
|
||||||
|
'min': 0.0,
|
||||||
|
'max': 1.0,
|
||||||
|
'default' : 0.0,
|
||||||
|
'save_in_preset': True
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'attr': '%s_material' % self.name,
|
||||||
|
'type': 'prop_search',
|
||||||
|
'src': lambda s, c: s.object,
|
||||||
|
'src_attr': 'material_slots',
|
||||||
|
'trg': lambda s,c: getattr(c, self.propertyGroup),
|
||||||
|
'trg_attr': '%s_name' % self.name,
|
||||||
|
'name': '%s:' % self.readableName
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
param_mat = []
|
||||||
|
for i in range(0, 6):
|
||||||
|
param_mat.append(WeightedMaterialParameter("mat%i" % i, "Material %i" % i, "mitsuba_mat_composite"));
|
||||||
|
|
||||||
|
class mitsuba_mat_composite(declarative_property_group):
|
||||||
|
controls = [
|
||||||
|
'nElements'
|
||||||
|
] + sum(map(lambda x: x.get_controls(), param_mat), [])
|
||||||
|
|
||||||
|
properties = [
|
||||||
|
{
|
||||||
|
'attr': 'nElements',
|
||||||
|
'type': 'int',
|
||||||
|
'name' : 'Components',
|
||||||
|
'description' : 'Number of mixture components',
|
||||||
|
'default' : 2,
|
||||||
|
'min': 2,
|
||||||
|
'max': 5,
|
||||||
|
'save_in_preset': True
|
||||||
|
}
|
||||||
|
] + sum(map(lambda x: x.get_properties(), param_mat), [])
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
# ##### END GPL LICENSE BLOCK #####
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
|
||||||
|
from mitsuba.ui.materials import mitsuba_material_sub
|
||||||
|
|
||||||
|
class ui_material_composite(mitsuba_material_sub, bpy.types.Panel):
|
||||||
|
bl_label = 'Mitsuba Composite Material'
|
||||||
|
|
||||||
|
MTS_COMPAT = {'composite'}
|
||||||
|
|
||||||
|
display_property_groups = [
|
||||||
|
( ('material', 'mitsuba_material'), 'mitsuba_mat_composite' )
|
||||||
|
]
|
Loading…
Reference in New Issue