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 ExportSettings(bus): scene = bus['scene'] VRayScene = scene.vray VRayExporter = VRayScene.Exporter for pluginType in {'SETTINGS', 'SETTINGS_GLOBAL'}: for pluginName in PLUGINS[pluginType]: # NOTE: We will export them later to be sure # they go after SettingsOutput if pluginName in ImageFormatPlugins: continue if pluginName in { # TODO: These plugins have to be implemented 'SettingsPtexBaker', 'SettingsVertexBaker', 'SettingsImageFilter', # These plugins will be exported manually 'Includer', 'SettingsEnvironment', 'OutputDeepWriter', # These plugins are exported from camera export 'BakeView', 'VRayStereoscopicSettings', # Unused plugins for now 'SettingsCurrentFrame', 'SettingsLightTree', 'SettingsColorMappingModo', 'SettingsDR', # Deprecated 'SettingsPhotonMap', 'RTEngine', }: continue if not SysUtils.IsGPUEngine(bus): if pluginName in {'RTEngine', 'SettingsRTEngine'}: continue if not VRayScene.SettingsVFB.use: if pluginName in {'EffectLens'}: continue ExportSettingsPlugin(bus, pluginType, pluginName) for pluginName in ImageFormatPlugins: ExportSettingsPlugin(bus, pluginType, pluginName)
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)
def Run(bus): debug.Debug("Run()") scene = bus['scene'] engine = bus['engine'] o = bus['output'] VRayScene = scene.vray VRayExporter = VRayScene.Exporter VRayDR = VRayScene.VRayDR vrayCmd = SysUtils.GetVRayStandalonePath() if not vrayCmd: raise Exception("V-Ray not found!") imageToBlender = VRayExporter.animation_mode == 'NONE' and not scene.render.use_border and VRayExporter.auto_save_render and VRayExporter.image_to_blender p = VRayProcess() p.setVRayStandalone(vrayCmd) p.setSceneFile(o.fileManager.getOutputFilepath()) p.setAutorun(VRayExporter.autorun) p.setVerboseLevel(VRayExporter.verboseLevel) p.setShowProgress(VRayExporter.showProgress) p.setDisplaySRGB(scene.display_settings.display_device == 'sRGB') p.setDisplayVFB(VRayExporter.display) p.setAutoclose(VRayExporter.autoclose) if SysUtils.IsGPUEngine(bus): p.setRtEngine(VRayExporter.device_gpu_type, VRayScene.SettingsRTEngine) # TODO: Rewrite into 'SettingsOutput' if scene.render.use_border: resolution_x = int(scene.render.resolution_x * scene.render.resolution_percentage * 0.01) resolution_y = int(scene.render.resolution_y * scene.render.resolution_percentage * 0.01) x0 = resolution_x * scene.render.border_min_x y0 = resolution_y * (1.0 - scene.render.border_max_y) x1 = resolution_x * scene.render.border_max_x y1 = resolution_y * (1.0 - scene.render.border_min_y) p.setRegion(x0, y0, x1, y1, useCrop=scene.render.use_crop_to_border) if imageToBlender: p.setWaitExit(True) p.setAutoclose(True) if engine.is_preview: p.setPreview(True) p.setShowProgress(0) p.setVerboseLevel(0) p.setAutoclose(True) p.setDisplayVFB(False) if VRayDR.on: if len(VRayDR.nodes): transferAssets = VRayDR.assetSharing == 'TRANSFER' if transferAssets: if VRayDR.checkAssets: transferAssets = 2 p.setDistributed(2 if VRayDR.renderOnlyOnNodes else 1) hosts = [] for n in VRayDR.nodes: if n.use: hosts.append("%s:%s" % (n.address, n.port) if n.port_override else n.address) p.setRenderhosts(hosts) p.setPortNumber(VRayDR.port) p.setTransferAssets(transferAssets) p.setLimitHosts(VRayDR.limitHosts) if VRayExporter.animation_mode == 'NONE': p.setFrames(scene.frame_current) elif VRayExporter.animation_mode == 'FRAMEBYFRAME': p.setWaitExit(True) p.setAutoclose(True) p.setFrames(scene.frame_current) else: p.setFrames(o.frameStart, o.frameEnd, o.frameStep) if not scene.render.threads_mode == 'AUTO': p.setThreads(scene.render.threads) if bpy.app.background or VRayExporter.wait: p.setWaitExit(True) if bpy.app.background: if not VRayExporter.display_vfb_in_batch: p.setDisplayVFB(False) # Disable VFB p.setAutoclose(True) # Exit on render end if VRayExporter.gen_run_file: p.setGenRunFile(True) if VRayExporter.submit_to_vray_cloud: p.setAutorun(False) exportExitStatus = p.run() if exportExitStatus == 0 and VRayExporter.submit_to_vray_cloud: job = VCloudJob(bus) cloudExitStatus = job.submitToCloud() if cloudExitStatus == -404: print("Chaos Cloud binary is not detected on your system!") webbrowser.open("https://www.chaosgroup.com/cloud") if imageToBlender or engine.is_preview: exp_load.LoadImage(scene, engine, o, p)