MtsBlend: support for most material types

metadata
Wenzel Jakob 2010-11-14 16:52:28 +01:00
parent c82899de89
commit e5b707df11
29 changed files with 915 additions and 37 deletions

View File

@ -44,9 +44,9 @@ public:
/* B term from Cauchy's equation (units: um^2) - external */
m_extB = props.getFloat("extB", 0);
/* Reflectance modulation term */
m_reflectance = props.getSpectrum("reflectance", Spectrum(1.0f));
m_reflectance = props.getSpectrum("specularReflectance", Spectrum(1.0f));
/* Transmittance modulation term */
m_transmittance = props.getSpectrum("transmittance", Spectrum(1.0f));
m_transmittance = props.getSpectrum("specularTransmittance", Spectrum(1.0f));
m_componentCount = 2;
m_type = new unsigned int[m_componentCount];

View File

@ -27,7 +27,7 @@ class Mirror : public BSDF {
public:
Mirror(const Properties &props)
: BSDF(props) {
m_reflectance = props.getSpectrum("reflectance", Spectrum(0.8f));
m_reflectance = props.getSpectrum("specularReflectance", Spectrum(0.8f));
m_componentCount = 1;
m_type = new unsigned int[m_componentCount];
m_type[0] = EDeltaReflection;

View File

@ -31,21 +31,21 @@ public:
GridTexture(const Properties &props) : Texture2D(props) {
m_brightColor = props.getSpectrum("brightColor", Spectrum(.4f));
m_darkColor = props.getSpectrum("darkColor", Spectrum(.2f));
m_width = props.getFloat("width", .01f);
m_lineWidth = props.getFloat("lineWidth", .01f);
}
GridTexture(Stream *stream, InstanceManager *manager)
: Texture2D(stream, manager) {
m_brightColor = Spectrum(stream);
m_darkColor = Spectrum(stream);
m_width = stream->readFloat();
m_lineWidth = stream->readFloat();
}
void serialize(Stream *stream, InstanceManager *manager) const {
Texture2D::serialize(stream, manager);
m_brightColor.serialize(stream);
m_darkColor.serialize(stream);
stream->writeFloat(m_width);
stream->writeFloat(m_lineWidth);
}
inline Spectrum getValue(const Point2 &uv) const {
@ -57,7 +57,7 @@ public:
if (y > .5)
y-=1;
if (std::abs(x) < m_width || std::abs(y) < m_width)
if (std::abs(x) < m_lineWidth || std::abs(y) < m_lineWidth)
return m_darkColor;
else
return m_brightColor;
@ -90,7 +90,7 @@ public:
protected:
Spectrum m_brightColor;
Spectrum m_darkColor;
Float m_width;
Float m_lineWidth;
};
// ================ Hardware shader implementation ================
@ -98,10 +98,10 @@ protected:
class GridTextureShader : public Shader {
public:
GridTextureShader(Renderer *renderer, const Spectrum &brightColor,
const Spectrum &darkColor, Float width, const Point2 &uvOffset,
const Spectrum &darkColor, Float lineWidth, const Point2 &uvOffset,
const Vector2 &uvScale) : Shader(renderer, ETextureShader),
m_brightColor(brightColor), m_darkColor(darkColor),
m_width(width), m_uvOffset(uvOffset), m_uvScale(uvScale) {
m_lineWidth(lineWidth), m_uvOffset(uvOffset), m_uvScale(uvScale) {
}
void generateCode(std::ostringstream &oss,
@ -109,7 +109,7 @@ public:
const std::vector<std::string> &depNames) const {
oss << "uniform vec3 " << evalName << "_brightColor;" << endl
<< "uniform vec3 " << evalName << "_darkColor;" << endl
<< "uniform float " << evalName << "_width;" << endl
<< "uniform float " << evalName << "_lineWidth;" << endl
<< "uniform vec2 " << evalName << "_uvOffset;" << endl
<< "uniform vec2 " << evalName << "_uvScale;" << endl
<< endl
@ -121,7 +121,7 @@ public:
<< " float y = uv.y - floor(uv.y);" << endl
<< " if (x > .5) x -= 1.0;" << endl
<< " if (y > .5) y -= 1.0;" << endl
<< " if (abs(x) < " << evalName << "_width || abs(y) < " << evalName << "_width)" << endl
<< " if (abs(x) < " << evalName << "_lineWidth || abs(y) < " << evalName << "_lineWidth)" << endl
<< " return " << evalName << "_darkColor;" << endl
<< " else" << endl
<< " return " << evalName << "_brightColor;" << endl
@ -131,7 +131,7 @@ public:
void resolve(const GPUProgram *program, const std::string &evalName, std::vector<int> &parameterIDs) const {
parameterIDs.push_back(program->getParameterID(evalName + "_brightColor", false));
parameterIDs.push_back(program->getParameterID(evalName + "_darkColor", false));
parameterIDs.push_back(program->getParameterID(evalName + "_width", false));
parameterIDs.push_back(program->getParameterID(evalName + "_lineWidth", false));
parameterIDs.push_back(program->getParameterID(evalName + "_uvOffset", false));
parameterIDs.push_back(program->getParameterID(evalName + "_uvScale", false));
}
@ -140,7 +140,7 @@ public:
int &textureUnitOffset) const {
program->setParameter(parameterIDs[0], m_brightColor);
program->setParameter(parameterIDs[1], m_darkColor);
program->setParameter(parameterIDs[2], m_width);
program->setParameter(parameterIDs[2], m_lineWidth);
program->setParameter(parameterIDs[3], m_uvOffset);
program->setParameter(parameterIDs[4], m_uvScale);
}
@ -149,14 +149,14 @@ public:
private:
Spectrum m_brightColor;
Spectrum m_darkColor;
Float m_width;
Float m_lineWidth;
Point2 m_uvOffset;
Vector2 m_uvScale;
};
Shader *GridTexture::createShader(Renderer *renderer) const {
return new GridTextureShader(renderer, m_brightColor, m_darkColor,
m_width, m_uvOffset, m_uvScale);
m_lineWidth, m_uvOffset, m_uvScale);
}
MTS_IMPLEMENT_CLASS(GridTextureShader, false, Shader)

View File

@ -31,19 +31,24 @@ from mitsuba.properties.engine import mitsuba_engine
from mitsuba.properties.lamp import mitsuba_lamp
from mitsuba.properties.texture import mitsuba_texture, \
mitsuba_tex_ldrtexture, mitsuba_tex_checkerboard, \
mitsuba_tex_mapping
mitsuba_tex_gridtexture, mitsuba_tex_mapping
from mitsuba.properties.material import mitsuba_material, \
mitsuba_mat_lambertian
mitsuba_mat_lambertian, mitsuba_mat_phong, mitsuba_mat_ward, \
mitsuba_mat_microfacet, mitsuba_mat_roughglass, \
mitsuba_mat_roughmetal, mitsuba_mat_dielectric, \
mitsuba_mat_mirror, mitsuba_mat_difftrans
from mitsuba.operators import MITSUBA_OT_preset_engine_add, EXPORT_OT_mitsuba
from mitsuba.outputs import MtsLog, MtsFilmDisplay
from mitsuba.export.film import resolution
from mitsuba.ui import render_panels
from mitsuba.ui import lamps
from mitsuba.ui.textures import TEXTURE_PT_context_texture_mts
from mitsuba.ui.textures import main, ldrtexture, checkerboard, mapping
from mitsuba.ui.materials import main, lambertian
from mitsuba.ui.textures import main, ldrtexture, checkerboard, \
gridtexture, mapping
from mitsuba.ui.materials import MATERIAL_PT_context_material_mts
from mitsuba.ui.materials import main, lambertian, phong, ward, \
microfacet, roughglass, roughmetal, dielectric, \
mirror, difftrans
def compatible(mod):
mod = __import__(mod)
@ -77,9 +82,18 @@ class RENDERENGINE_mitsuba(bpy.types.RenderEngine, engine_base):
('Texture', mitsuba_texture),
('mitsuba_texture', mitsuba_tex_ldrtexture),
('mitsuba_texture', mitsuba_tex_checkerboard),
('mitsuba_texture', mitsuba_tex_gridtexture),
('mitsuba_texture', mitsuba_tex_mapping),
('Material', mitsuba_material),
('mitsuba_material', mitsuba_mat_lambertian)
('mitsuba_material', mitsuba_mat_lambertian),
('mitsuba_material', mitsuba_mat_phong),
('mitsuba_material', mitsuba_mat_ward),
('mitsuba_material', mitsuba_mat_microfacet),
('mitsuba_material', mitsuba_mat_roughglass),
('mitsuba_material', mitsuba_mat_roughmetal),
('mitsuba_material', mitsuba_mat_dielectric),
('mitsuba_material', mitsuba_mat_difftrans),
('mitsuba_material', mitsuba_mat_mirror)
]
render_lock = threading.Lock()

View File

@ -40,8 +40,14 @@ class ParamSetItem(list):
elif self.type == "integer" or self.type == "float" \
or self.type == "string":
return '\t\t<%s name="%s" value="%s"/>\n' % (self.type, self.name, self.value)
elif self.type == "reference_texture" or self.type == "reference_material":
else:
return ""
def to_string_ref(self):
if self.type == "reference_texture" or self.type == "reference_material":
return '\t\t<ref name="%s" id="%s"/>\n' % (self.name, self.value)
else:
return ""
class ParamSet(list):
names = []
@ -97,3 +103,6 @@ class ParamSet(list):
def to_string(self):
return ''.join(item.to_string() for item in self)
def to_string_ref(self):
return ''.join(item.to_string_ref() for item in self)

View File

@ -136,6 +136,7 @@ class MtsAdjustments:
adjfile.write('\t<texture id="%s" type="%s">\n' % (mat.name, mat.mitsuba_texture.type))
adjfile.write(params.to_string())
adjfile.write(params.to_string_ref())
adjfile.write('\t</texture>\n')
def export_material(self, adjfile, mat):
@ -152,6 +153,7 @@ class MtsAdjustments:
adjfile.write('\t<bsdf id="%s" type="%s">\n' % (mat.name, mat.mitsuba_material.type))
adjfile.write(params.to_string())
adjfile.write(params.to_string_ref())
adjfile.write('\t</bsdf>\n')
def export(self, scene):

View File

@ -63,7 +63,7 @@ class mitsuba_lamp(declarative_property_group):
'attr': 'intensity',
'name': 'Intensity',
'description': 'Specifies the intensity of the light source',
'default': 1.0,
'default': 10.0,
'min': 1e-3,
'soft_min': 1e-3,
'max': 1e3,

View File

@ -10,6 +10,10 @@ from mitsuba.export import ParamSet
param_reflectance = TextureParameter('reflectance', 'Reflectance', \
'Diffuse reflectance value', default=(0.5, 0.5, 0.5))
param_diffuseReflectance = TextureParameter('diffuseReflectance', 'Diffuse reflectance', \
'Diffuse reflectance value', default=(0.5, 0.5, 0.5))
param_specularReflectance = TextureParameter('specularReflectance', 'Specular reflectance', \
'Specular reflectance value', default=(1.0, 1.0, 1.0))
def dict_merge(*args):
vis = {}
@ -38,7 +42,15 @@ class mitsuba_material(declarative_property_group):
'description': 'Mitsuba material type',
'default': 'matte',
'items': [
('lambertian', 'Lambertian', 'Lambertian (i.e. ideally diffuse) material')
('lambertian', 'Lambertian', 'Lambertian (i.e. ideally diffuse) material'),
('phong', 'Phong', 'Modified Phong BRDF'),
('ward', 'Anisotropic Ward', 'Anisotropic Ward BRDF'),
('dielectric', 'Ideal dielectric', 'Ideal dielectric material (e.g. glass)'),
('mirror', 'Ideal mirror', 'Ideal mirror material'),
('roughglass', 'Rough glass', 'Rough dielectric material (e.g. sand-blasted glass)'),
('roughmetal', 'Rough metal', 'Rough conductor (e.g. sand-blasted metal)'),
('difftrans', 'Diffuse transmitter', 'Material with an ideally diffuse transmittance'),
('microfacet', 'Microfacet', 'Microfacet material (like the rough glass material, but without transmittance)')
],
'save_in_preset': True
}
@ -49,18 +61,446 @@ class mitsuba_material(declarative_property_group):
return sub_type.get_params()
class mitsuba_mat_lambertian(declarative_property_group):
controls = [
] + param_reflectance.controls
controls = param_reflectance.controls
properties = [
] + param_reflectance.properties
properties = param_reflectance.properties
visibility = dict_merge(
param_reflectance.visibility
)
visibility = dict_merge(param_reflectance.visibility)
def get_params(self):
params = ParamSet()
params.update(param_reflectance.get_params(self))
return params
class mitsuba_mat_phong(declarative_property_group):
controls = [
'diffuseAmount',
'specularAmount',
'exponent'
] + param_diffuseReflectance.controls \
+ param_specularReflectance.controls
properties = [
{
'attr': 'diffuseAmount',
'type': 'float',
'description' : 'Diffuse reflection lobe multiplier',
'name' : 'Diffuse amount',
'default' : 1.0,
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'specularAmount',
'type': 'float',
'description' : 'Specular reflection lobe multiplier',
'name' : 'Specular amount',
'default' : 1.0,
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'exponent',
'type': 'float',
'description' : 'Phong exponent',
'name' : 'Exponent',
'default' : 10.0,
'min': 0.001,
'max': 10000.0,
'save_in_preset': True
}
] + param_diffuseReflectance.properties \
+ param_specularReflectance.properties
visibility = dict_merge(
param_diffuseReflectance.visibility,
param_specularReflectance.visibility
)
def get_params(self):
params = ParamSet()
params.update(param_diffuseReflectance.get_params(self))
params.update(param_specularReflectance.get_params(self))
params.add_float('diffuseAmount', self.diffuseAmount)
params.add_float('specularAmount', self.specularAmount)
params.add_float('exponent', self.exponent)
return params
class mitsuba_mat_ward(declarative_property_group):
controls = [
'diffuseAmount',
'specularAmount',
['alphaX', 'alphaY']
] + param_diffuseReflectance.controls \
+ param_specularReflectance.controls
properties = [
{
'attr': 'diffuseAmount',
'type': 'float',
'description' : 'Diffuse reflection lobe multiplier',
'name' : 'Diffuse amount',
'default' : 1.0,
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'specularAmount',
'type': 'float',
'description' : 'Specular reflection lobe multiplier',
'name' : 'Specular amount',
'default' : 1.0,
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'alphaX',
'type': 'float',
'description' : 'Roughness value along U (0.3=coarse, 0.001=very fine)',
'name' : 'U Roughness',
'default' : 0.1,
'min': 0.001,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'alphaY',
'type': 'float',
'description' : 'Roughness value along V (0.3=coarse, 0.001=very fine)',
'name' : 'V Roughness',
'default' : 0.1,
'min': 0.001,
'max': 1.0,
'save_in_preset': True
}
] + param_diffuseReflectance.properties \
+ param_specularReflectance.properties
visibility = dict_merge(
param_diffuseReflectance.visibility,
param_specularReflectance.visibility
)
def get_params(self):
params = ParamSet()
params.update(param_diffuseReflectance.get_params(self))
params.update(param_specularReflectance.get_params(self))
params.add_float('diffuseAmount', self.diffuseAmount)
params.add_float('specularAmount', self.specularAmount)
params.add_float('alphaX', self.alphaX)
params.add_float('alphaY', self.alphaY)
return params
class mitsuba_mat_microfacet(declarative_property_group):
controls = [
'diffuseAmount',
'specularAmount',
'alphaB',
['extIOR', 'intIOR']
] + param_diffuseReflectance.controls \
+ param_specularReflectance.controls
properties = [
{
'attr': 'diffuseAmount',
'type': 'float',
'description' : 'Diffuse reflection lobe multiplier',
'name' : 'Diffuse amount',
'default' : 0.0,
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'specularAmount',
'type': 'float',
'description' : 'Specular reflection lobe multiplier',
'name' : 'Specular amount',
'default' : 1.0,
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'alphaB',
'type': 'float',
'name': 'Roughness',
'description' : 'Roughness value (0.3=coarse, 0.001=very fine)',
'default' : 0.1,
'min': 0.001,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'extIOR',
'type': 'float',
'name' : 'Ext. IOR',
'description' : 'Exterior index of refraction (e.g. air=1, glass=1.5 approximately)',
'default' : 1,
'min': 1.0,
'max': 10.0,
'save_in_preset': True
},
{
'attr': 'intIOR',
'type': 'float',
'name' : 'Int. IOR',
'description' : 'Interior index of refraction (e.g. air=1, glass=1.5 approximately)',
'default' : 1.5,
'min': 1.0,
'max': 10.0,
'save_in_preset': True
}
] + param_diffuseReflectance.properties \
+ param_specularReflectance.properties
visibility = dict_merge(
param_diffuseReflectance.visibility,
param_specularReflectance.visibility
)
def get_params(self):
params = ParamSet()
params.update(param_diffuseReflectance.get_params(self))
params.update(param_specularReflectance.get_params(self))
params.add_float('diffuseAmount', self.diffuseAmount)
params.add_float('specularAmount', self.specularAmount)
params.add_float('alphaB', self.alphaB)
params.add_float('extIOR', self.extIOR)
params.add_float('intIOR', self.intIOR)
return params
class mitsuba_mat_roughglass(declarative_property_group):
controls = [
'specularReflectance',
'specularTransmittance',
'alphaB',
['extIOR', 'intIOR']
]
properties = [
{
'attr': 'specularReflectance',
'type': 'float_vector',
'subtype': 'COLOR',
'description' : 'Weight of the specular reflectance',
'name' : 'Specular reflectance',
'default' : (1.0, 1.0, 1.0),
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'specularTransmittance',
'type': 'float_vector',
'subtype': 'COLOR',
'description' : 'Weight of the specular transmittance',
'name' : 'Specular transmittance',
'default' : (1.0, 1.0, 1.0),
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'alphaB',
'type': 'float',
'name' : 'Roughness',
'description' : 'Roughness value (0.3=coarse, 0.001=very fine)',
'default' : 0.1,
'min': 0.001,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'extIOR',
'type': 'float',
'name' : 'Ext. IOR',
'description' : 'Exterior index of refraction (e.g. air=1, glass=1.5 approximately)',
'default' : 1,
'min': 1.0,
'max': 10.0,
'save_in_preset': True
},
{
'attr': 'intIOR',
'type': 'float',
'name' : 'Int. IOR',
'description' : 'Interior index of refraction (e.g. air=1, glass=1.5 approximately)',
'default' : 1.5,
'min': 1.0,
'max': 10.0,
'save_in_preset': True
}
]
def get_params(self):
params = ParamSet()
params.add_color('specularReflectance', self.specularReflectance)
params.add_color('specularTransmittance', self.specularTransmittance)
params.add_float('alphaB', self.alphaB)
params.add_float('extIOR', self.extIOR)
params.add_float('intIOR', self.intIOR)
return params
class mitsuba_mat_roughmetal(declarative_property_group):
controls = [
'alphaB',
'ior', 'k'
] + param_specularReflectance.controls
properties = [
{
'attr': 'alphaB',
'type': 'float',
'name' : 'Roughness',
'description' : 'Roughness value (0.3=coarse, 0.001=very fine)',
'default' : 0.1,
'min': 0.001,
'max': 1.0,
'expand' : False,
'save_in_preset': True
},
{
'attr': 'ior',
'type': 'float_vector',
'name' : 'IOR',
'description' : 'Per-channel index of refraction of the conductor',
'default' : (0.370, 0.370, 0.370),
'min': 1.0,
'max': 10.0,
'expand' : False,
'save_in_preset': True
},
{
'attr': 'k',
'type': 'float_vector',
'name' : 'Absorption coefficient',
'description' : 'Per-channel absorption coefficient of the conductor',
'default' : (2.820, 2.820, 2.820),
'min': 1.0,
'max': 10.0,
'save_in_preset': True
}
] + param_specularReflectance.properties
visibility = dict_merge(param_specularReflectance.visibility)
def get_params(self):
params = ParamSet()
params.update(param_specularReflectance.get_params(self))
params.add_float('alphaB', self.alphaB)
params.add_color('ior', self.ior)
params.add_color('k', self.k)
return params
class mitsuba_mat_dielectric(declarative_property_group):
controls = [
'specularReflectance',
'specularTransmittance',
['extIOR', 'intIOR']
]
properties = [
{
'attr': 'specularReflectance',
'type': 'float_vector',
'subtype': 'COLOR',
'description' : 'Weight of the specular reflectance',
'name' : 'Specular reflectance',
'default' : (1.0, 1.0, 1.0),
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'specularTransmittance',
'type': 'float_vector',
'subtype': 'COLOR',
'description' : 'Weight of the specular transmittance',
'name' : 'Specular transmittance',
'default' : (1.0, 1.0, 1.0),
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'extIOR',
'type': 'float',
'name' : 'Ext. IOR',
'description' : 'Exterior index of refraction (e.g. air=1, glass=1.5 approximately)',
'default' : 1,
'min': 1.0,
'max': 10.0,
'save_in_preset': True
},
{
'attr': 'intIOR',
'type': 'float',
'name' : 'Int. IOR',
'description' : 'Interior index of refraction (e.g. air=1, glass=1.5 approximately)',
'default' : 1.5,
'min': 1.0,
'max': 10.0,
'save_in_preset': True
}
]
def get_params(self):
params = ParamSet()
params.add_color('specularReflectance', self.specularReflectance)
params.add_color('specularTransmittance', self.specularTransmittance)
params.add_float('extIOR', self.extIOR)
params.add_float('intIOR', self.intIOR)
return params
class mitsuba_mat_mirror(declarative_property_group):
controls = [
'specularReflectance',
]
properties = [
{
'attr': 'specularReflectance',
'type': 'float_vector',
'subtype': 'COLOR',
'description' : 'Weight of the specular reflectance',
'name' : 'Specular reflectance',
'default' : (1.0, 1.0, 1.0),
'min': 0.0,
'max': 1.0,
'save_in_preset': True
}
]
def get_params(self):
params = ParamSet()
params.add_color('specularReflectance', self.specularReflectance)
return params
class mitsuba_mat_difftrans(declarative_property_group):
controls = [
'transmittance',
]
properties = [
{
'attr': 'transmittance',
'type': 'float_vector',
'subtype': 'COLOR',
'description' : 'Diffuse transmittance value',
'name' : 'Diffuse transmittance',
'default' : (0.5, 0.5, 0.5),
'min': 0.0,
'max': 1.0,
'save_in_preset': True
}
]
def get_params(self):
params = ParamSet()
params.add_color('transmittance', self.transmittance)
return params

View File

@ -126,7 +126,15 @@ class TextureParameter(TextureParameterBase):
# colour for each material type. If the property name is
# not set, then the color won't be changed.
master_color_map = {
'lambertian': 'reflectance'
'lambertian': 'reflectance',
'difftrans': 'transmittance',
'ward': 'diffuseReflectance',
'phong': 'diffuseReflectance',
'microfacet': 'diffuseReflectance',
'mirror': 'specularReflectance',
'dielectric': 'specularReflectance',
'roughglass': 'specularReflectance',
'roughmetal': 'specularReflectance'
}
def set_master_colour(self, s, c):
@ -223,8 +231,9 @@ class mitsuba_texture(declarative_property_group):
'name': 'Texture type',
'type': 'enum',
'items': [
('ldrtexture', 'Bitmap', 'ldrtexture'),
('checkerboard', 'Checkerboard', 'checkerboard')
('ldrtexture', 'Bitmap', 'Low dynamic-range texture'),
('checkerboard', 'Checkerboard', 'Procedural checkerboard texture'),
('gridtexture', 'Grid texture', 'Procedural grid texture')
],
'default' : 'ldrtexture',
'save_in_preset': True
@ -429,3 +438,54 @@ class mitsuba_tex_checkerboard(declarative_property_group):
return params
class mitsuba_tex_gridtexture(declarative_property_group):
controls = [
'darkColor',
'brightColor',
'lineWidth'
]
properties = [
{
'attr': 'darkColor',
'type': 'float_vector',
'subtype': 'COLOR',
'name' : 'Dark color',
'description' : 'Color of the dark patches',
'default' : (0.2, 0.2, 0.2),
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'brightColor',
'type': 'float_vector',
'subtype': 'COLOR',
'description' : 'Color of the bright patches',
'name' : 'Bright color',
'default' : (0.4, 0.4, 0.4),
'min': 0.0,
'max': 1.0,
'save_in_preset': True
},
{
'attr': 'lineWidth',
'type': 'float',
'description' : 'Size of the grid lines in UV space',
'name' : 'Line width',
'default' : 0.01,
'min': 0.0,
'max': 1.0,
'save_in_preset': True
}
]
def get_params(self):
params = ParamSet()
params.add_color('darkColor', self.darkColor)
params.add_color('brightColor', self.brightColor)
params.add_float('lineWidth', self.lineWidth)
return params

View File

@ -35,3 +35,56 @@ class mitsuba_material_sub(MaterialButtonsPanel, property_group_renderer):
'''
return super().poll(context) and context.material.mitsuba_material.type in cls.MTS_COMPAT
class MATERIAL_PT_context_material_mts(MaterialButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
COMPAT_ENGINES = {'mitsuba'}
@classmethod
def poll(cls, context):
# An exception, dont call the parent poll func because
# this manages materials for all engine types
engine = context.scene.render.engine
return (context.material or context.object) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material
ob = context.object
slot = context.material_slot
space = context.space_data
if ob:
row = layout.row()
row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
col = row.column(align=True)
col.operator("object.material_slot_add", icon='ZOOMIN', text="")
col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
if ob.mode == 'EDIT':
row = layout.row(align=True)
row.operator("object.material_slot_assign", text="Assign")
row.operator("object.material_slot_select", text="Select")
row.operator("object.material_slot_deselect", text="Deselect")
split = layout.split(percentage=0.65)
if ob:
split.template_ID(ob, "active_material", new="material.new")
row = split.row()
if slot:
row.prop(slot, "link", text="")
else:
row.label()
elif mat:
split.template_ID(space, "pin_id")
split.separator()

Binary file not shown.

View File

@ -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_dielectric(mitsuba_material_sub, bpy.types.Panel):
bl_label = 'Mitsuba Dielectric Material'
MTS_COMPAT = {'dielectric'}
display_property_groups = [
( ('material', 'mitsuba_material'), 'mitsuba_mat_dielectric' )
]

View File

@ -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_difftrans(mitsuba_material_sub, bpy.types.Panel):
bl_label = 'Mitsuba Diffuse Transmitter Material'
MTS_COMPAT = {'difftrans'}
display_property_groups = [
( ('material', 'mitsuba_material'), 'mitsuba_mat_difftrans' )
]

Binary file not shown.

Binary file not shown.

View File

@ -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_microfacet(mitsuba_material_sub, bpy.types.Panel):
bl_label = 'Mitsuba Microfacet Material'
MTS_COMPAT = {'microfacet'}
display_property_groups = [
( ('material', 'mitsuba_material'), 'mitsuba_mat_microfacet' )
]

View File

@ -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_mirror(mitsuba_material_sub, bpy.types.Panel):
bl_label = 'Mitsuba Mirror Material'
MTS_COMPAT = {'mirror'}
display_property_groups = [
( ('material', 'mitsuba_material'), 'mitsuba_mat_mirror' )
]

View File

@ -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_phong(mitsuba_material_sub, bpy.types.Panel):
bl_label = 'Mitsuba Phong Material'
MTS_COMPAT = {'phong'}
display_property_groups = [
( ('material', 'mitsuba_material'), 'mitsuba_mat_phong' )
]

View File

@ -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_roughglass(mitsuba_material_sub, bpy.types.Panel):
bl_label = 'Mitsuba Rough Glass Material'
MTS_COMPAT = {'roughglass'}
display_property_groups = [
( ('material', 'mitsuba_material'), 'mitsuba_mat_roughglass' )
]

View File

@ -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_roughmetal(mitsuba_material_sub, bpy.types.Panel):
bl_label = 'Mitsuba Rough Metal Material'
MTS_COMPAT = {'roughmetal'}
display_property_groups = [
( ('material', 'mitsuba_material'), 'mitsuba_mat_roughmetal' )
]

View File

@ -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_ward(mitsuba_material_sub, bpy.types.Panel):
bl_label = 'Mitsuba Ward Material'
MTS_COMPAT = {'ward'}
display_property_groups = [
( ('material', 'mitsuba_material'), 'mitsuba_mat_ward' )
]

View File

@ -55,7 +55,7 @@ class TEXTURE_PT_context_texture_mts(TextureButtonsPanel, bpy.types.Panel):
col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
split = layout.split(percentage=0.65)
split = layout.split(percentage=1)
col = split.column()
if tex_collection:

Binary file not shown.

Binary file not shown.

View File

@ -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.textures import mitsuba_texture_base
class ui_texture_gridtexture(mitsuba_texture_base, bpy.types.Panel):
bl_label = 'Mitsuba Grid Texture'
MTS_COMPAT = {'gridtexture'}
display_property_groups = [
( ('texture', 'mitsuba_texture'), 'mitsuba_tex_gridtexture' )
]

Binary file not shown.

Binary file not shown.

View File

@ -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.textures import mitsuba_texture_base
class ui_texture_mapping(mitsuba_texture_base, bpy.types.Panel):
bl_label = 'Mitsuba UV Mapping'
MTS_COMPAT = {'ldrtexture', 'checkerboard', 'gridtexture'}
display_property_groups = [
( ('texture', 'mitsuba_texture'), 'mitsuba_tex_mapping' )
]

Binary file not shown.