MtsBlend: initial support for adjusting the sampler/integrator, etc.
parent
5f39a33fc6
commit
0778c6e4ef
|
@ -1177,7 +1177,7 @@ void loadCamera(ColladaContext &ctx, Transform transform, domCamera &camera) {
|
|||
ctx.os << "\t\t<transform name=\"toWorld\">" << endl;
|
||||
ctx.os << "\t\t\t<matrix value=\"" << matrixValues.substr(0, matrixValues.length()-1) << "\"/>" << endl;
|
||||
ctx.os << "\t\t</transform>" << endl << endl;
|
||||
ctx.os << "\t\t<sampler type=\"ldsampler\">" << endl;
|
||||
ctx.os << "\t\t<sampler id=\"sampler\" type=\"ldsampler\">" << endl;
|
||||
ctx.os << "\t\t\t<integer name=\"sampleCount\" value=\"" << ctx.cvt->m_samplesPerPixel << "\"/>" << endl;
|
||||
ctx.os << "\t\t</sampler>" << endl << endl;
|
||||
ctx.os << "\t\t<film id=\"film\" type=\"" << ctx.cvt->m_filmType << "\">" << endl;
|
||||
|
|
|
@ -198,9 +198,11 @@ void GeometryConverter::convert(const fs::path &inputFile,
|
|||
DOMNode *node = nodeMap[id];
|
||||
for (DOMNode *child2 = child->getFirstChild(); child2 != 0; child2=child2->getNextSibling())
|
||||
node->insertBefore(doc->importNode(child2, true), NULL);
|
||||
} else {
|
||||
} else if (parent == insertBeforeNode->getParentNode()) {
|
||||
parent->removeChild(node);
|
||||
docRoot->insertBefore(doc->importNode(child, true), insertBeforeNode);
|
||||
} else {
|
||||
parent->replaceChild(doc->importNode(child, true), node);
|
||||
}
|
||||
} else {
|
||||
docRoot->insertBefore(doc->importNode(child, true), insertBeforeNode);
|
||||
|
|
|
@ -29,6 +29,8 @@ from extensions_framework import util as efutil
|
|||
# Mitsuba-related classes
|
||||
from mitsuba import plugin_path
|
||||
from mitsuba.properties.engine import mitsuba_engine
|
||||
from mitsuba.properties.sampler import mitsuba_sampler
|
||||
from mitsuba.properties.integrator import mitsuba_integrator
|
||||
from mitsuba.properties.lamp import mitsuba_lamp
|
||||
from mitsuba.properties.texture import mitsuba_texture, \
|
||||
mitsuba_tex_ldrtexture, mitsuba_tex_checkerboard, \
|
||||
|
@ -45,8 +47,7 @@ from mitsuba.export.adjustments import MtsAdjustments
|
|||
from mitsuba.export import translate_id
|
||||
from mitsuba.export.film import resolution
|
||||
from mitsuba.export import get_instance_materials
|
||||
from mitsuba.ui import render_panels
|
||||
from mitsuba.ui import lamps
|
||||
from mitsuba.ui import render_panels, lamps
|
||||
from mitsuba.ui.textures import TEXTURE_PT_context_texture_mts
|
||||
from mitsuba.ui.textures import main, ldrtexture, checkerboard, \
|
||||
gridtexture, mapping
|
||||
|
@ -84,6 +85,8 @@ class RENDERENGINE_mitsuba(bpy.types.RenderEngine, engine_base):
|
|||
|
||||
property_groups = [
|
||||
('Scene', mitsuba_engine),
|
||||
('Scene', mitsuba_integrator),
|
||||
('Scene', mitsuba_sampler),
|
||||
('Lamp', mitsuba_lamp),
|
||||
('Texture', mitsuba_texture),
|
||||
('mitsuba_texture', mitsuba_tex_ldrtexture),
|
||||
|
@ -214,7 +217,7 @@ class RENDERENGINE_mitsuba(bpy.types.RenderEngine, engine_base):
|
|||
output_dir = scene_path
|
||||
else:
|
||||
output_dir = os.path.dirname(scene_path)
|
||||
if self.output_dir[-1] != '/':
|
||||
if output_dir[-1] != '/':
|
||||
output_dir += '/'
|
||||
efutil.export_path = output_dir
|
||||
os.chdir(output_dir)
|
||||
|
|
|
@ -63,11 +63,11 @@ class MtsAdjustments:
|
|||
size_y = lamp.data.size
|
||||
if lamp.data.shape == 'RECTANGLE':
|
||||
size_y = lamp.data.size_y
|
||||
path = os.path.join(os.path.join(self.target_dir, 'meshes'), "_area_luminaire_%d.obj" % idx)
|
||||
mts_meshes_dir = os.path.join(self.target_dir, 'meshes')
|
||||
filename = "area_luminaire_%d.obj" % idx
|
||||
|
||||
self.out.write('\t\t<string name="filename" value="%s"/>\n' % path)
|
||||
self.out.write('\t\t<string name="filename" value="meshes/%s"/>\n' % filename)
|
||||
self.exportWorldtrafo(lamp.matrix_world)
|
||||
|
||||
self.out.write('\n\t\t<luminaire id="%s-light" type="area">\n' % name)
|
||||
mult = lamp.data.mitsuba_lamp.intensity / (2 * size_x * size_y)
|
||||
self.out.write('\t\t\t<rgb name="intensity" value="%f %f %f"/>\n'
|
||||
|
@ -75,6 +75,12 @@ class MtsAdjustments:
|
|||
self.out.write('\t\t\t<float name="samplingWeight" value="%f"/>\n' % lamp.data.mitsuba_lamp.samplingWeight)
|
||||
self.out.write('\t\t</luminaire>\n')
|
||||
self.out.write('\t</shape>\n')
|
||||
|
||||
try:
|
||||
os.mkdir(mts_meshes_dir)
|
||||
except OSError:
|
||||
pass
|
||||
path = os.path.join(mts_meshes_dir, filename)
|
||||
objFile = open(path, 'w')
|
||||
objFile.write('v %f %f 0\n' % (-size_x/2, -size_y/2))
|
||||
objFile.write('v %f %f 0\n' % ( size_x/2, -size_y/2))
|
||||
|
@ -116,6 +122,15 @@ class MtsAdjustments:
|
|||
self.out.write('\t\t<float name="intensityScale" value="%f"/>\n' % lamp.data.mitsuba_lamp.intensity)
|
||||
self.out.write('\t</luminaire>\n')
|
||||
|
||||
def exportIntegrator(self, integrator):
|
||||
self.out.write('\t<integrator id="integrator" type="%s">\n' % integrator.type)
|
||||
self.out.write('\t</integrator>\n')
|
||||
|
||||
def exportSampler(self, sampler):
|
||||
self.out.write('\t<sampler id="sampler" type="%s">\n' % sampler.type)
|
||||
self.out.write('\t\t<integer name="sampleCount" value="%i"/>\n' % sampler.sampleCount)
|
||||
self.out.write('\t</sampler>\n')
|
||||
|
||||
def findTexture(self, name):
|
||||
if name in self.textures:
|
||||
return self.textures[name]
|
||||
|
@ -203,6 +218,8 @@ class MtsAdjustments:
|
|||
def export(self, scene):
|
||||
idx = 0
|
||||
self.writeHeader()
|
||||
self.exportIntegrator(scene.mitsuba_integrator)
|
||||
self.exportSampler(scene.mitsuba_sampler)
|
||||
for obj in scene.objects:
|
||||
if obj.type == 'LAMP':
|
||||
self.exportLamp(obj, idx)
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
# ##### 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 #####
|
||||
|
||||
from extensions_framework import declarative_property_group
|
||||
from extensions_framework import util as efutil
|
||||
|
||||
class mitsuba_integrator(declarative_property_group):
|
||||
'''
|
||||
Storage class for Mitsuba Integrator settings.
|
||||
This class will be instantiated within a Blender scene
|
||||
object.
|
||||
'''
|
||||
|
||||
controls = [
|
||||
'type',
|
||||
'sampleCount'
|
||||
]
|
||||
|
||||
properties = [
|
||||
{
|
||||
'type': 'enum',
|
||||
'attr': 'type',
|
||||
'name': 'Type',
|
||||
'description': 'Specifies the type of integrator to use',
|
||||
'default': 'ldintegrator',
|
||||
'items': [
|
||||
('direct', 'Direct Illumination', 'direct'),
|
||||
('path', 'Path tracer', 'path'),
|
||||
],
|
||||
'save_in_preset': True
|
||||
}
|
||||
]
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
# ##### 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 #####
|
||||
|
||||
from extensions_framework import declarative_property_group
|
||||
from extensions_framework import util as efutil
|
||||
|
||||
class mitsuba_sampler(declarative_property_group):
|
||||
'''
|
||||
Storage class for Mitsuba Sampler settings.
|
||||
This class will be instantiated within a Blender scene
|
||||
object.
|
||||
'''
|
||||
|
||||
controls = [
|
||||
'type',
|
||||
'sampleCount'
|
||||
]
|
||||
|
||||
properties = [
|
||||
{
|
||||
'type': 'enum',
|
||||
'attr': 'type',
|
||||
'name': 'Type',
|
||||
'description': 'Specifies the type of sampler to use',
|
||||
'default': 'ldsampler',
|
||||
'items': [
|
||||
('independent', 'Independent', 'independent'),
|
||||
('stratified', 'Stratified', 'stratified'),
|
||||
('ldsampler', 'Low discrepancy', 'ldsampler')
|
||||
],
|
||||
'save_in_preset': True
|
||||
},
|
||||
{
|
||||
'type': 'int',
|
||||
'attr': 'sampleCount',
|
||||
'name': 'Pixel samples',
|
||||
'description': 'Number of samples to use for estimating the illumination at each pixel',
|
||||
'default': 8,
|
||||
'min': 1,
|
||||
'max': 10240,
|
||||
'save_in_preset': True
|
||||
}
|
||||
]
|
||||
|
|
@ -51,7 +51,7 @@ class engine(render_described_context, bpy.types.Panel):
|
|||
Engine settings UI Panel
|
||||
'''
|
||||
|
||||
bl_label = 'Mitsuba Engine Configuration'
|
||||
bl_label = 'Mitsuba Engine Settings'
|
||||
|
||||
display_property_groups = [
|
||||
( ('scene',), 'mitsuba_engine' )
|
||||
|
@ -67,3 +67,26 @@ class engine(render_described_context, bpy.types.Panel):
|
|||
cached_binary_path = binary_path
|
||||
super().draw(context)
|
||||
|
||||
class integrator(render_described_context, bpy.types.Panel):
|
||||
'''
|
||||
Integrator settings UI Panel
|
||||
'''
|
||||
|
||||
bl_label = 'Mitsuba Integrator Settings'
|
||||
|
||||
display_property_groups = [
|
||||
( ('scene',), 'mitsuba_integrator' )
|
||||
]
|
||||
|
||||
|
||||
class sampler(render_described_context, bpy.types.Panel):
|
||||
'''
|
||||
Sampler settings UI Panel
|
||||
'''
|
||||
|
||||
bl_label = 'Mitsuba Sampler Settings'
|
||||
|
||||
display_property_groups = [
|
||||
( ('scene',), 'mitsuba_sampler' )
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue