def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    o = bus['output']
    scene = bus['scene']
    camera = bus['camera']

    VRayCamera = camera.data.vray
    CameraStereoscopic = VRayCamera.CameraStereoscopic

    # XXX: Some code is broken in VRayStereoscopicSettings
    # Export it only if we are use CameraStereoscopic to calculate views
    #
    if not CameraStereoscopic.use:
        return

    cam = bpy.data.objects.get(CameraStereoscopic.LeftCam)
    if cam:
        overrideParams['left_camera'] = LibUtils.CleanString(cam.name)

    cam = bpy.data.objects.get(CameraStereoscopic.RightCam)
    if cam:
        overrideParams['right_camera'] = LibUtils.CleanString(cam.name)

    # NOTE: Shademap is currently broken
    overrideParams['sm_mode'] = 0
    overrideParams['shademap_file'] = None

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName,
                                         propGroup, overrideParams)
Ejemplo n.º 2
0
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    scene = bus['scene']
    o = bus['output']

    if not propGroup.use:
        return

    if not propGroup.bake_node:
        Debug("Bake object is not set!", msgType='ERROR')
        return

    bakeObject = BlenderUtils.GetSceneObject(scene, propGroup.bake_node)
    if not bakeObject:
        Debug("Bake object \"%s\" not found!" % propGroup.bake_node,
              msgType='ERROR')
        return

    o.set('SETTINGS', 'UVWGenChannel', 'UVWbakeView')
    o.writeHeader()
    o.writeAttibute('uvw_channel', propGroup.uv_channel)
    o.writeAttibute('uvw_transform', mathutils.Matrix.Identity(4))
    o.writeFooter()

    overrideParams.update({
        'bake_node': BlenderUtils.GetObjectName(bakeObject),
        'bake_uvwgen': "UVWbakeView",
    })

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName,
                                         propGroup, overrideParams)
Ejemplo n.º 3
0
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    unit_settings = bpy.context.scene.unit_settings

    if unit_settings.system != 'NONE':
        overrideParams['meters_scale'] = unit_settings.scale_length

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName,
                                         propGroup, overrideParams)
Ejemplo n.º 4
0
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    scene = bus['scene']

    overrideParams.update({
        'noise_threshold' : 0.0 if scene.render.engine == 'VRAY_RENDER_RT' else propGroup.noise_threshold,
    })

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName, propGroup, overrideParams)
Ejemplo n.º 5
0
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    o = bus['output']

    scene, ca = BlenderUtils.GetSceneAndCamera(bus)

    VRayScene = scene.vray
    VRayBake  = VRayScene.BakeView

    if VRayBake.use:
        return

    VRayCamera = ca.data.vray
    RenderView = VRayCamera.RenderView
    SettingsCamera = VRayCamera.SettingsCamera
    SettingsCameraDof = VRayCamera.SettingsCameraDof
    CameraStereoscopic = VRayCamera.CameraStereoscopic
    VRayStereoscopicSettings = VRayScene.VRayStereoscopicSettings

    fov, orthoWidth = BlenderUtils.GetCameraFOV(scene, ca)

    overrideParams['use_scene_offset'] = SysUtils.IsGPUEngine(bus)
    overrideParams['clipping'] = RenderView.clip_near or RenderView.clip_far

    # if SettingsCamera.type not in {'SPHERIFICAL', 'BOX'}:
    if RenderView.clip_near:
        overrideParams['clipping_near'] = ca.data.clip_start
    if RenderView.clip_far:
        overrideParams['clipping_far'] = ca.data.clip_end

    if 'fov' not in overrideParams:
        overrideParams['fov'] = fov
    if 'transform' not in overrideParams:
        overrideParams['transform'] = ca.matrix_world.normalized()
    if 'orthographic' not in overrideParams:
        overrideParams['orthographic'] = ca.data.type == 'ORTHO'
    overrideParams['orthographicWidth'] = orthoWidth

    overrideParams['focalDistance'] = BlenderUtils.GetCameraDofDistance(ca)
    overrideParams['aperture']      = SettingsCameraDof.aperture

    if VRayStereoscopicSettings.use and not CameraStereoscopic.use:
        overrideParams['stereo_on']                 = True
        overrideParams['stereo_eye_distance']       = VRayStereoscopicSettings.eye_distance
        overrideParams['stereo_interocular_method'] = VRayStereoscopicSettings.interocular_method
        overrideParams['stereo_specify_focus']      = VRayStereoscopicSettings.specify_focus
        overrideParams['stereo_focus_distance']     = VRayStereoscopicSettings.focus_distance
        overrideParams['stereo_focus_method']       = VRayStereoscopicSettings.focus_method
        overrideParams['stereo_view']               = VRayStereoscopicSettings.view
    else:
        overrideParams['stereo_on']                 = None
        overrideParams['stereo_eye_distance']       = None
        overrideParams['stereo_interocular_method'] = None
        overrideParams['stereo_specify_focus']      = None
        overrideParams['stereo_focus_distance']     = None
        overrideParams['stereo_focus_method']       = None
        overrideParams['stereo_view']               = None

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName, propGroup, overrideParams)
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    current_scene_cm = bpy.context.scene.vray.SettingsColorMapping

    if bus['preview'] and current_scene_cm.preview_use_scene_cm:
        # Use color mapping settings from current scene not from preview scene
        propGroup = current_scene_cm

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName,
                                         propGroup, overrideParams)
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    scene = bus['scene']

    VRayScene = scene.vray
    SettingsVFB = VRayScene.SettingsVFB

    if SettingsVFB.use:
        return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName,
                                             propGroup, overrideParams)
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    scene = bus['scene']

    VRayExporter = scene.vray.Exporter

    if propGroup.num_passes_auto:
        overrideParams['num_passes'] = bpy.context.scene.render.threads

    if VRayExporter.draft:
        overrideParams['subdivs'] = propGroup.subdivs / 10.0

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName, propGroup, overrideParams)
Ejemplo n.º 9
0
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    scene = bus['scene']

    VRayScene = scene.vray
    SettingsDMCSampler = VRayScene.SettingsDMCSampler

    if propGroup.use_dmc_treshhold:
        overrideParams['dmc_threshold'] = SettingsDMCSampler.adaptive_threshold

    if propGroup.progressive_minSubdivs > propGroup.progressive_maxSubdivs:
        overrideParams[
            'progressive_minSubdivs'] = propGroup.progressive_maxSubdivs
        overrideParams[
            'progressive_maxSubdivs'] = propGroup.progressive_minSubdivs

    if propGroup.dmc_minSubdivs > propGroup.dmc_maxSubdivs:
        overrideParams['dmc_minSubdivs'] = propGroup.dmc_maxSubdivs
        overrideParams['dmc_maxSubdivs'] = propGroup.dmc_minSubdivs

    if propGroup.subdivision_minRate > propGroup.subdivision_maxRate:
        overrideParams['subdivision_minRate'] = propGroup.subdivision_maxRate
        overrideParams['subdivision_maxRate'] = propGroup.subdivision_minRate

    if propGroup.render_mask_mode == '2':
        ob_names = []
        if propGroup.render_mask_objects_selected:
            for obb in bpy.context.scene.object_bases:
                if obb.select:
                    ob_names.append(BlenderUtils.GetObjectName(obb.object))
        else:
            if propGroup.render_mask_objects:
                ob_names = BlenderUtils.GetGroupObjectsNames(
                    propGroup.render_mask_objects)

        if not ob_names:
            overrideParams['render_mask_mode'] = '0'
        else:
            overrideParams['render_mask_objects'] = "List(%s)" % ",".join(
                ob_names)

    elif propGroup.render_mask_mode == '3':
        if not propGroup.render_mask_object_ids:
            overrideParams['render_mask_mode'] = '0'
        else:
            mask_object_ids = propGroup.render_mask_object_ids.split(";")
            overrideParams[
                'render_mask_object_ids'] = "ListInt(%s)" % ",".join(
                    mask_object_ids)

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName,
                                         propGroup, overrideParams)
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    if not propGroup.use:
        return

    scene, camera = BlenderUtils.GetSceneAndCamera(bus)

    VRayScene = scene.vray

    VRayCamera = camera.data.vray
    StereoSettings = VRayScene.VRayStereoscopicSettings

    fov, orthoWidth = BlenderUtils.GetCameraFOV(scene, camera)

    focus_distance = BlenderUtils.GetCameraDofDistance(camera)
    if focus_distance < 0.001:
        focus_distance = 5.0

    horizontal_offset = -camera.data.shift_x
    vertical_offset = -camera.data.shift_y

    imageAspect = scene.render.resolution_x / scene.render.resolution_y
    if imageAspect < 1.0:
        offset_fix = 1.0 / imageAspect
        horizontal_offset *= offset_fix
        vertical_offset *= offset_fix

    if StereoSettings.use:
        vertical_offset /= 2.0

    overrideParams.update({
        'fov':
        fov,
        'focus_distance':
        focus_distance,
        'specify_focus':
        True,
        'lens_shift':
        GetLensShift(camera)
        if propGroup.auto_lens_shift else propGroup.lens_shift,
        'horizontal_offset':
        horizontal_offset,
        'vertical_offset':
        vertical_offset,
    })

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName,
                                         propGroup, overrideParams)
Ejemplo n.º 11
0
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    ca = bus['camera']

    VRayCamera = ca.data.vray
    if VRayCamera.CameraPhysical.use:
        return

    cameraType = propGroup.type
    if ca.data.type == 'ORTHO':
        cameraType = 7

    overrideParams.update({
        'fov'    : -1,
        'type'   : cameraType,
        'height' : ca.data.ortho_scale,
    })

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName, propGroup, overrideParams)
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    scene = bus['scene']
    o     = bus['output']

    VRayScene = scene.vray
    VRayExporter = VRayScene.Exporter
    VRayDR       = VRayScene.VRayDR

    if VRayDR.on:
        if VRayDR.assetSharing == 'TRANSFER':
            overrideParams['misc_transferAssets'] = True

    propGroup = getattr(VRayScene, pluginName)
    attributes = sorted(pluginModule.PluginParams, key=lambda t: t['attr'])

    for attrDesc in attributes:
        key = attrDesc['attr']
        if key in propGroup and attrDesc['default'] != getattr(propGroup, key):
            overrideParams[key] = getattr(propGroup, key)

    if 'mtl_override' in overrideParams:
        del overrideParams['mtl_override']

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName, propGroup, overrideParams)
Ejemplo n.º 13
0
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    scene = bus['scene']
    o = bus['output']
    camera = bus['camera']

    VRayScene = scene.vray
    VRayExporter = VRayScene.Exporter
    BakeView = VRayScene.BakeView
    img_width = int(scene.render.resolution_x *
                    scene.render.resolution_percentage * 0.01)
    img_height = int(scene.render.resolution_y *
                     scene.render.resolution_percentage * 0.01)

    # NOTE: Camera could be None when saving a preset, for example
    if camera:
        VRayCamera = camera.data.vray
        CameraStereoscopic = VRayCamera.CameraStereoscopic

        if SysUtils.IsGPUEngine(bus):
            if VRayScene.SettingsRTEngine.stereo_mode:
                img_width *= 2
        else:
            if VRayScene.VRayStereoscopicSettings.use and not CameraStereoscopic.use:
                if VRayScene.VRayStereoscopicSettings.adjust_resolution:
                    img_width *= 2

    if BakeView.use:
        if BakeView.square_resolution:
            img_height = img_width

    overrideParams['img_width'] = img_width
    overrideParams['img_height'] = img_height
    overrideParams['bmp_width'] = img_width
    overrideParams['bmp_height'] = img_height
    overrideParams['rgn_width'] = img_width
    overrideParams['rgn_height'] = img_height
    overrideParams['r_width'] = img_width
    overrideParams['r_height'] = img_height

    if not (o.isPreviewRender() or VRayExporter.auto_save_render):
        overrideParams['img_file'] = ""
        overrideParams['img_dir'] = ""
    else:
        # NOTE: Could happen when saving preset
        if hasattr(o, 'getFileManager'):
            pm = o.getFileManager().getPathManager()
            img_file = pm.getImgFilename()
            img_dir = pm.getImgDirpath()

            if not img_file:
                debug.PrintError("Image output filename is not set!")
                return None

            if not img_dir:
                debug.PrintError("Image output directory is not set!")
                return None

            # In case filename is setup as some filepath
            img_file = os.path.basename(bpy.path.abspath(img_file))

            overrideParams['img_file'] = img_file
            overrideParams['img_dir'] = img_dir

            if o.isPreviewRender():
                overrideParams['img_file_needFrameNumber'] = False

            if propGroup.img_format in {'EXR', 'VRST'}:
                if not propGroup.relements_separateFiles:
                    overrideParams['img_rawFile'] = True

    # Animation
    overrideParams['anim_start'] = o.frameStart
    overrideParams['anim_end'] = o.frameEnd
    overrideParams['frame_start'] = o.frameStart

    # NOTE: When loading preview image for World
    # image alpha will be replaced with black color.
    # We don't want this, so simply use JPEG,
    # that doesn't have alpha channel
    if o.isPreviewRender():
        overrideParams['img_noAlpha'] = True

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName,
                                         propGroup, overrideParams)
Ejemplo n.º 14
0
def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    ca = bus['camera']

    overrideParams['focal_dist'] = BlenderUtils.GetCameraDofDistance(ca)

    return ExportUtils.WritePluginCustom(bus, pluginModule, pluginName, propGroup, overrideParams)