Beispiel #1
0
def check_renderer_settings(context):
    lre = context.scene.luxrender_rendermode
    lri = context.scene.luxrender_integrator

    def clear_renderer_alert():
        if 'surfaceintegrator' in lri.alert.keys():
            del lri.alert['surfaceintegrator']
        if 'lightstrategy' in lri.alert.keys(): del lri.alert['lightstrategy']
        if 'advanced' in lri.alert.keys(): del lri.alert['advanced']

    # Check hybrid renderer and surfaceintegrator compatibility
    hybrid_valid = (lri.surfaceintegrator == 'path'
                    and lri.lightstrategy in ['one', 'all', 'auto'])
    if ((lre.renderer == 'hybrid' and hybrid_valid)
            or lre.renderer != 'hybrid'):
        clear_renderer_alert()
    elif lre.renderer == 'hybrid' and not hybrid_valid:
        # These logical tests should evaluate to True if the setting is incompatible
        lri.alert['surfaceintegrator'] = {
            'surfaceintegrator': LO({'!=': ['path', 'bidirectional']})
        }
        lri.alert['lightstrategy'] = {
            'lightstrategy': LO({'!=': ['one', 'all', 'auto']})
        }
        return

    # check compatible SPPM mode
    sppm_valid = lri.surfaceintegrator == 'sppm'
    if ((lre.renderer == 'sppm' and sppm_valid) or lre.renderer != 'sppm'):
        clear_renderer_alert()
    elif lre.renderer == 'sppm' and not sppm_valid:
        lri.alert['surfaceintegrator'] = {
            'surfaceintegrator': LO({'!=': 'sppm'})
        }
        return
Beispiel #2
0
class luxrender_lamp_hemi(declarative_property_group):
    ef_attach_to = ['luxrender_lamp']

    controls = [
        'infinite_map', 'mapping_type', 'nsamples', 'gamma',
        [0.323, 'L_colorlabel', 'L_color'], 'hdri_multiply',
        'hdri_infinitesample'
    ]

    visibility = {
        'mapping_type': {
            'infinite_map': LO({'!=': ''})
        },
        'hdri_multiply': {
            'infinite_map': LO({'!=': ''})
        },
        'gamma': {
            'infinite_map': LO({'!=': ''})
        },
        'nsamples': {
            'infinite_map': LO({'!=': ''})
        },
        'hdri_infinitesample': {
            'infinite_map': LO({'!=': ''})
        },
    }

    properties = TC_L.properties[:] + [
        {
            'type': 'bool',
            'attr': 'hdri_multiply',
            'name': 'Multiply by colour',
            'description': 'Mutiply the HDRI map by the lamp colour',
            'default': False
        },
        {
            'type': 'string',
            'subtype': 'FILE_PATH',
            'attr': 'infinite_map',
            'name': 'HDRI Map',
            'description': 'HDR image to use for lighting',
            'default': ''
        },
        {
            'type':
            'enum',
            'attr':
            'mapping_type',
            'name':
            'Map Type',
            'default':
            'latlong',
            'items': [('latlong', 'Equirectangular (lat long)', 'latlong'),
                      ('angular', 'Angular (light probe)', 'angular'),
                      ('vcross', 'Vertical Cross (skybox)', 'vcross')]
        },
        {
            'type': 'float',
            'attr': 'gamma',
            'name': 'Gamma',
            'description': 'Reverse gamma correction value for HDRI map',
            'default': 1.0,
            'min': 0.0,
            'soft_min': 0.0,
            'max': 6,
            'soft_max': 6,
        },
        {
            'type': 'bool',
            'attr': 'hdri_infinitesample',
            'name': 'Intensity Sampling',
            'description':
            'Use intensity based sampling for hemi texture, recommended for high contrast HDR images. Will disable use of portals for this light!',
            'default': False
        },
        {
            'type': 'int',
            'attr': 'nsamples',
            'name': 'Shadow ray samples',
            'description': 'The suggested number of shadow samples',
            'default': 1,
            'min': 1,
            'soft_min': 1,
            'max': 100,
            'soft_max': 100,
        },
    ]

    def get_paramset(self, lamp_object):
        params = ParamSet()

        if self.infinite_map != '':
            if lamp_object.library is not None:
                hdri_path = bpy.path.abspath(self.infinite_map,
                                             lamp_object.library.filepath)
            else:
                hdri_path = self.infinite_map
            params.add_string('mapname',
                              efutil.path_relative_to_export(hdri_path))
            params.add_string('mapping', self.mapping_type)
            params.add_float('gamma', self.gamma)
            params.add_integer('nsamples', self.nsamples)

        if self.infinite_map == '' or self.hdri_multiply:
            params.add_color('L', self.L_color)

        return params
Beispiel #3
0
class luxrender_lamp_sun(declarative_property_group):
    ef_attach_to = ['luxrender_lamp']

    controls = [
        'sunsky_type', 'nsamples', 'turbidity', 'legacy_sky',
        'sunsky_advanced', 'relsize', 'horizonbrightness', 'horizonsize',
        'sunhalobrightness', 'sunhalosize', 'backscattering', 'theta'
    ] + TC_L.controls[:]  #Pin this at the end so the sun type menu isn't jumping around when you select the distant lamp

    visibility = { #Do L visibility manually because we only need it for distant
     'L_colorlabel':   { 'sunsky_type': 'distant'},
     'L_color':     { 'sunsky_type': 'distant'},
     'L_usecolortexture': { 'sunsky_type': 'distant'},
     'L_colortexture':  { 'sunsky_type': 'distant', 'L_usecolortexture': True },
     'L_multiplycolor':  { 'sunsky_type': 'distant', 'L_usecolortexture': True },
     'sunsky_advanced':  { 'sunsky_type': O(['sun', 'sky', 'sunsky']) },
     'legacy_sky':   { 'sunsky_type': O(['sunsky', 'sky']) },
     'turbidity':   { 'sunsky_type': LO({'!=':'distant'})},
     'theta':    { 'sunsky_type': 'distant'},
     'relsize':    { 'sunsky_advanced': True, 'sunsky_type': O(['sunsky', 'sun']) },
     'horizonbrightness': { 'sunsky_advanced': True, 'legacy_sky': True, 'sunsky_type': O(['sunsky', 'sky']) },
     'horizonsize':   { 'sunsky_advanced': True, 'legacy_sky': True, 'sunsky_type': O(['sunsky', 'sky']) },
     'sunhalobrightness': { 'sunsky_advanced': True, 'legacy_sky': True, 'sunsky_type': O(['sunsky', 'sky']) },
     'sunhalosize':   { 'sunsky_advanced': True, 'legacy_sky': True, 'sunsky_type': O(['sunsky', 'sky']) },
     'backscattering':  { 'sunsky_advanced': True, 'legacy_sky': True, 'sunsky_type': O(['sunsky', 'sky']) },
    }

    properties = TC_L.properties[:] + [
        {
            'type': 'float',
            'attr': 'turbidity',
            'name': 'turbidity',
            'default': 2.2,
            'min': 1.2,
            'soft_min': 1.2,
            'max': 30.0,
            'soft_max': 30.0,
        },
        {
            'type':
            'enum',
            'attr':
            'sunsky_type',
            'name':
            'Sky Type',
            'default':
            'sunsky',
            'items': [
                ('sunsky', 'Sun & Sky', 'Physical sun with sky'),
                ('sun', 'Sun Only', 'Physical sun without sky'),
                ('sky', 'Sky Only', 'Physical sky without sun'),
                ('distant', 'Distant', 'Generic directional light'),
            ]
        },
        {
            'type': 'bool',
            'attr': 'sunsky_advanced',
            'name': 'Advanced',
            'description': 'Configure advanced sun and sky parameters',
            'default': False
        },
        {
            'type': 'bool',
            'attr': 'legacy_sky',
            'name': 'Use Legacy Sky Spectrum',
            'description':
            'Use legacy Preetham sky model instead of Hosek and Wilkie model',
            'default': False
        },
        {
            'type': 'float',
            'attr': 'relsize',
            'name': 'Relative sun disk size',
            'default': 1.0,
            'min': 0.0,
            'soft_min': 0.0,
            'max': 100.0,
            'soft_max': 100.0
        },
        {
            'type': 'float',
            'attr': 'horizonbrightness',
            'name': 'Horizon brightness',
            'default': 1.0,
            'min': 0.0,
            'soft_min': 0.0,
            'max': 1.32,  # anything greater than this causes sky to break
            'soft_max': 1.32
        },
        {
            'type': 'float',
            'attr': 'horizonsize',
            'name': 'Horizon size',
            'default': 1.0,
            'min': 0.0,
            'soft_min': 0.0,
            'max': 10.0,
            'soft_max': 10.0
        },
        {
            'type': 'float',
            'attr': 'sunhalobrightness',
            'name': 'Sun halo brightness',
            'default': 1.0,
            'min': 0.0,
            'soft_min': 0.0,
            'max': 10.0,
            'soft_max': 10.0
        },
        {
            'type': 'float',
            'attr': 'sunhalosize',
            'name': 'Sun halo size',
            'default': 1.0,
            'min': 0.0,
            'soft_min': 0.0,
            'max': 10.0,
            'soft_max': 10.0
        },
        {
            'type': 'float',
            'attr': 'backscattering',
            'name': 'Back scattering',
            'default': 1.0,
            'min': 0.0,
            'soft_min': 0.0,
            'max': 10.0,
            'soft_max': 10.0
        },
        {
            'type': 'int',
            'attr': 'nsamples',
            'name': 'Shadow ray samples',
            'description': 'The suggested number of shadow samples',
            'default': 1,
            'min': 1,
            'soft_min': 1,
            'max': 100,
            'soft_max': 100,
        },
        {
            'type': 'float',
            'attr': 'theta',
            'name': 'Theta',
            'description':
            'Size of the lamp, set as the half-angle of the light source',
            'default': 0.0,
            'min': 0.0,
            'soft_min': 0.0,
            'max': math.pi,
            'soft_max': math.pi,
            'subtype':
            'ANGLE',  #Angle params are already in radians, which is what theta is, so no conversion is necessary
            'unit': 'ROTATION'
        },
    ]

    def get_paramset(self, lamp_object):
        params = ParamSet()
        #params = super().get_paramset(lamp_object)
        params.add_integer('nsamples', self.nsamples)

        if self.sunsky_type == 'distant':
            params.add_float('theta', self.theta),
            params.update(TC_L.get_paramset(self))

        if self.sunsky_type != 'distant':
            params.add_float('turbidity', self.turbidity)

        if self.sunsky_advanced and self.sunsky_type in ['sun', 'sunsky']:
            params.add_float('relsize', self.relsize)

        if self.sunsky_advanced and self.sunsky_type in ['sky', 'sunsky'
                                                         ] and self.legacy_sky:
            params.add_float('horizonbrightness', self.horizonbrightness)
            params.add_float('horizonsize', self.horizonsize)
            params.add_float('sunhalobrightness', self.sunhalobrightness)
            params.add_float('sunhalosize', self.sunhalosize)
            params.add_float('backscattering', self.backscattering)

        return params
Beispiel #4
0
class mitsuba_lamp_sun(declarative_property_group):
    ef_attach_to = ['mitsuba_lamp']

    controls = [
        'sunsky_type', 'albedo', 'turbidity', 'sunsky_advanced', 'stretch',
        'skyScale', 'sunScale', 'sunRadiusScale', 'resolution'
    ]

    visibility = {
        'albedo': {
            'sunsky_type': LO({'sky', 'sunsky'})
        },
        'stretch': {
            'sunsky_advanced': True,
            'sunsky_type': LO(['sky', 'sunsky'])
        },
        'skyScale': {
            'sunsky_advanced': True,
            'sunsky_type': LO({'sky', 'sunsky'})
        },
        'sunScale': {
            'sunsky_advanced': True,
            'sunsky_type': LO({'sun', 'sunsky'})
        },
        'sunRadiusScale': {
            'sunsky_advanced': True,
            'sunsky_type': LO({'sun', 'sunsky'})
        },
        'resolution': {
            'sunsky_advanced': True
        }
    }

    properties = [{
        'type':
        'enum',
        'attr':
        'sunsky_type',
        'name':
        'Sky Type',
        'default':
        'sunsky',
        'items': [
            ('sunsky', 'Sun & Sky', 'sunsky'),
            ('sun', 'Sun Only', 'sun'),
            ('sky', 'Sky Only', 'sky'),
        ]
    }, {
        'type': 'float',
        'attr': 'turbidity',
        'name': 'Turbidity',
        'default': 3,
        'min': 1.2,
        'soft_min': 1.2,
        'max': 30.0,
        'soft_max': 30.0,
    }, {
        'type': 'float_vector',
        'attr': 'albedo',
        'subtype': 'COLOR',
        'description': 'Specifes the ground albedo. (Default:0.15)',
        'name': 'Ground Albedo',
        'default': (0.15, 0.15, 0.15),
        'min': 0.0,
        'max': 1.0,
        'save_in_preset': True
    }, {
        'type': 'bool',
        'attr': 'sunsky_advanced',
        'name': 'Advanced',
        'default': False
    }, {
        'type': 'float',
        'attr': 'stretch',
        'name': 'Stretch Sky',
        'description':
        'Stretch factor to extend emitter below the horizon, must be in [1,2]. Default{1}, i.e. not used}',
        'default': 1.0,
        'min': 1.0,
        'soft_min': 1.0,
        'max': 2.0,
        'soft_max': 2.0,
    }, {
        'type': 'float',
        'attr': 'skyScale',
        'name': 'Sky Intensity',
        'description':
        'This parameter can be used to scale the the amount of illumination emitted by the sky emitter. \default{1}',
        'default': 1.0,
        'min': 0.0,
        'soft_min': 0.0,
        'max': 10.0,
        'soft_max': 10.0
    }, {
        'type': 'float',
        'attr': 'sunScale',
        'name': 'Sun Intensity',
        'description':
        'This parameter can be used to scale the the amount of illumination emitted by the sky emitter. \default{1}',
        'default': 1.0,
        'min': 0.0,
        'soft_min': 0.0,
        'max': 10.0,
        'soft_max': 10.0
    }, {
        'type': 'float',
        'attr': 'sunRadiusScale',
        'name': 'Sun Radius',
        'description':
        'Scale factor to adjust the radius of the sun, while preserving its power. Set to 0 to turn it into a directional light source',
        'default': 1.0,
        'min': 0.0,
        'soft_min': 0.0,
        'max': 10.0,
        'soft_max': 10.0
    }, {
        'attr': 'resolution',
        'type': 'int',
        'name': 'Resolution',
        'description':
        'Specifies the horizontal resolution of the precomputed image that is used to represent the sun/sky environment map \default{512, i.e. 512x256}',
        'default': 512,
        'min': 128,
        'max': 2048,
        'save_in_preset': True
    }]

    def get_paramset(self, lamp_object):
        params = ParamSet()

        params.add_float('turbidity', self.turbidity)
        if self.sunsky_advanced and self.sunsky_type != 'sun':
            params.add_float('stretch', self.stretch)
            params.add_color('albedo', self.albedo)
        if self.sunsky_advanced and self.sunsky_type == 'sky':
            params.add_float('scale', self.skyScale)
        elif self.sunsky_advanced and self.sunsky_type == 'sun':
            params.add_float('scale', self.sunScale)
            params.add_float('sunRadiusScale', self.sunScale)
        elif self.sunsky_advanced and self.sunsky_type == 'sunsky':
            params.add_float('skyScale', self.skyScale)
            params.add_float('sunScale', self.sunScale)
            params.add_float('sunRadiusScale', self.sunRadiusScale)
        if self.sunsky_advanced:
            params.add_integer('resolution', self.resolution)

        #if self.sunsky_advanced and self.sunsky_type != 'sun':
        #params.add_float('horizonbrightness', self.horizonbrightness)
        #params.add_float('horizonsize', self.horizonsize)

        return params
Beispiel #5
0
class luxrender_mesh(declarative_property_group):
    '''
	Storage class for LuxRender Mesh settings.
	'''

    ef_attach_to = ['Mesh', 'SurfaceCurve', 'TextCurve', 'Curve', 'MetaBall']

    controls = [
     'mesh_type',
     'instancing_mode',
     'portal',
     'generatetangents',
     'subdiv',
     'sublevels',
     'mdsublevels',
     'nsmooth',
     ['sharpbound', 'splitnormal'],
    ] + \
     TF_displacementmap.controls + \
    [
     ['dmscale', 'dmoffset']
    ]

    visibility = dict_merge(
        {
            'nsmooth': {
                'subdiv': 'loop'
            },
            'sharpbound': {
                'subdiv': 'loop'
            },
            'splitnormal': {
                'subdiv': 'loop'
            },
            'sublevels': {
                'subdiv': 'loop'
            },
            'mdsublevels': {
                'subdiv': 'microdisplacement'
            },
            'dmscale': {
                'subdiv': LO({'!=': 'None'}),
                'dm_floattexturename': LO({'!=': ''})
            },
            'dmoffset': {
                'subdiv': LO({'!=': 'None'}),
                'dm_floattexturename': LO({'!=': ''})
            },
        }, TF_displacementmap.visibility)

    visibility = texture_append_visibility(visibility, TF_displacementmap,
                                           {'subdiv': LO({'!=': 'None'})})

    properties = [
     {
      'type': 'enum',
      'attr': 'mesh_type',
      'name': 'Export as',
      'items': [
       ('global', 'Use Default Setting', 'global'),
       ('native', 'LuxRender Mesh', 'native'),
       ('binary_ply', 'Binary PLY', 'binary_ply')
      ],
      'default': 'global'
     },
     {
      'type': 'enum',
      'attr': 'instancing_mode',
      'name': 'Instancing',
      'items': [
       ('auto', 'Automatic', 'Let the exporter code decide'),
       ('always', 'Always', 'Always export this mesh as instances'),
       ('never', 'Never', 'Never export this mesh as instances')
      ],
      'default': 'auto'
     },
     {
      'type': 'bool',
      'attr': 'portal',
      'name': 'Exit Portal',
      'description': 'Use this mesh as an exit portal (geometry should be open/planar)',
      'default': False,
     },
     {
      'type': 'bool',
      'attr': 'generatetangents',
      'name': 'Generate Tangents',
      'description': 'Generate tanget space for this mesh. Enable when using a bake-generated normal map',
      'default': False,
     },
     {
      'type': 'enum',
      'attr': 'subdiv',
      'name': 'Subdivision Scheme',
      'default': 'None',
      'items': [
       ('None', 'None', 'None'),
       ('loop', 'Loop', 'loop'),
       ('microdisplacement', 'Microdisplacement', 'microdisplacement')
      ]
     },
     {
      'type': 'bool',
      'attr': 'nsmooth',
      'name': 'Normal smoothing',
      'description': 'Re-smooth normals after subdividing',
      'default': True,
     },
     {
      'type': 'bool',
      'attr': 'sharpbound',
      'name': 'Sharpen Bounds',
      'description': 'Perserve hard borders in geometry',
      'default': False,
     },
     {
      'type': 'bool',
      'attr': 'splitnormal',
      'name': 'Keep Split Edges',
      'default': False,
      'description': 'Preserves effects of split-edges by splitting at breaks in the normal. WARNING: This will cause solid-shaded meshes to rip open!'},
     {
      'type': 'int',
      'attr': 'sublevels',
      'name': 'Subdivision Levels',
      'default': 2,
      'min': 0,
      'soft_min': 0,
      'max': 6,
      'soft_max': 6
     },
     {
      'type': 'int',
      'attr': 'mdsublevels',
      'name': 'Microsubdivision Levels',
      'default': 50,
      'min': 0,
      'soft_min': 0,
      'max': 1000,
      'soft_max': 1000
     },
    ] + \
     TF_displacementmap.properties + \
    [
     {
      'type': 'float',
      'attr': 'dmscale',
      'name': 'Scale',
      'description': 'Displacement Map Scale',
      'default': 1.0,
      'precision': 6,
      'subtype': 'DISTANCE',
      'unit': 'LENGTH'
     },
     {
      'type': 'float',
      'attr': 'dmoffset',
      'name': 'Offset',
      'description': 'Displacement Map Offset',
      'default': 0.0,
      'precision': 6,
      'subtype': 'DISTANCE',
      'unit': 'LENGTH'
     },
    ]

    def get_paramset(self):
        params = ParamSet()

        #Export generatetangents
        params.add_bool('generatetangents', self.generatetangents)

        # check if subdivision is used
        if self.subdiv != 'None':
            params.add_string('subdivscheme', self.subdiv)
            if self.subdiv == 'loop':
                params.add_integer('nsubdivlevels', self.sublevels)
            elif self.subdiv == 'microdisplacement':
                params.add_integer('nsubdivlevels', self.mdsublevels)
            params.add_bool('dmnormalsmooth', self.nsmooth)
            params.add_bool('dmsharpboundary', self.sharpbound)
            params.add_bool('dmnormalsplit', self.splitnormal)

        export_dm = TF_displacementmap.get_paramset(self)

        if self.dm_floattexturename != '' and len(export_dm) > 0:
            texture_name = getattr(self, 'dm_floattexturename')
            texture = get_texture_from_scene(LuxManager.CurrentScene,
                                             texture_name)
            if texture.type in (
                    'IMAGE',
                    'OCEAN') and texture.luxrender_texture.type == 'BLENDER':
                params.add_texture('displacementmap',
                                   '%s_float' % self.dm_floattexturename)
            else:
                params.add_texture('displacementmap', self.dm_floattexturename)
            params.add_float('dmscale', self.dmscale)
            params.add_float('dmoffset', self.dmoffset)

        return params
Beispiel #6
0
def mitsuba_bsdf_mixturebsdf_visibility():
    result = {}
    for i in range(2, 6):
        result["mat%i_material" % i] = {'nElements': LO({'gte': i})}
        result["mat%i_weight" % i] = {'nElements': LO({'gte': i})}
    return result