コード例 #1
0
void BlenderSync::sync_camera(BL::Object b_override, int width, int height)
{
	BlenderCamera bcam;
	blender_camera_init(&bcam, b_scene);

	/* pixel aspect */
	BL::RenderSettings r = b_scene.render();

	bcam.pixelaspect.x = r.pixel_aspect_x();
	bcam.pixelaspect.y = r.pixel_aspect_y();
	bcam.shuttertime = r.motion_blur_shutter();

	/* border */
	if(r.use_border()) {
		bcam.border.left = r.border_min_x();
		bcam.border.right = r.border_max_x();
		bcam.border.bottom = r.border_min_y();
		bcam.border.top = r.border_max_y();
	}

	/* camera object */
	BL::Object b_ob = b_scene.camera();

	if(b_override)
		b_ob = b_override;

	if(b_ob) {
		blender_camera_from_object(&bcam, b_ob);
		bcam.matrix = get_transform(b_ob.matrix_world());
	}

	/* sync */
	Camera *cam = scene->camera;
	blender_camera_sync(cam, &bcam, width, height);
}
コード例 #2
0
void BlenderSync::sync_camera(BL::RenderSettings b_render, BL::Object b_override, int width, int height)
{
	BlenderCamera bcam;
	blender_camera_init(&bcam, b_render);

	/* pixel aspect */
	bcam.pixelaspect.x = b_render.pixel_aspect_x();
	bcam.pixelaspect.y = b_render.pixel_aspect_y();
	bcam.shuttertime = b_render.motion_blur_shutter();

	/* border */
	if(b_render.use_border()) {
		bcam.border.left = b_render.border_min_x();
		bcam.border.right = b_render.border_max_x();
		bcam.border.bottom = b_render.border_min_y();
		bcam.border.top = b_render.border_max_y();
	}

	/* camera object */
	BL::Object b_ob = b_scene.camera();

	if(b_override)
		b_ob = b_override;

	if(b_ob) {
		BL::Array<float, 16> b_ob_matrix;
		blender_camera_from_object(&bcam, b_engine, b_ob);
		b_engine.camera_model_matrix(b_ob, b_ob_matrix);
		bcam.matrix = get_transform(b_ob_matrix);
	}

	/* sync */
	Camera *cam = scene->camera;
	blender_camera_sync(cam, &bcam, width, height);
}
コード例 #3
0
void BlenderSync::sync_camera(BL::RenderSettings& b_render,
                              BL::Object& b_override,
                              int width, int height,
                              const char *viewname)
{
	BlenderCamera bcam;
	blender_camera_init(&bcam, b_render);

	/* pixel aspect */
	bcam.pixelaspect.x = b_render.pixel_aspect_x();
	bcam.pixelaspect.y = b_render.pixel_aspect_y();
	bcam.shuttertime = b_render.motion_blur_shutter();

	BL::CurveMapping b_shutter_curve(b_render.motion_blur_shutter_curve());
	curvemapping_to_array(b_shutter_curve, bcam.shutter_curve, RAMP_TABLE_SIZE);

	PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
	bcam.motion_position =
	        (Camera::MotionPosition)get_enum(cscene,
	                                         "motion_blur_position",
	                                         Camera::MOTION_NUM_POSITIONS,
	                                         Camera::MOTION_POSITION_CENTER);
	bcam.rolling_shutter_type =
		(Camera::RollingShutterType)get_enum(cscene,
		                                     "rolling_shutter_type",
		                                     Camera::ROLLING_SHUTTER_NUM_TYPES,
		                                     Camera::ROLLING_SHUTTER_NONE);
	bcam.rolling_shutter_duration = RNA_float_get(&cscene, "rolling_shutter_duration");

	/* border */
	if(b_render.use_border()) {
		bcam.border.left = b_render.border_min_x();
		bcam.border.right = b_render.border_max_x();
		bcam.border.bottom = b_render.border_min_y();
		bcam.border.top = b_render.border_max_y();
	}

	/* camera object */
	BL::Object b_ob = b_scene.camera();

	if(b_override)
		b_ob = b_override;

	if(b_ob) {
		BL::Array<float, 16> b_ob_matrix;
		blender_camera_from_object(&bcam, b_engine, b_ob);
		b_engine.camera_model_matrix(b_ob, bcam.use_spherical_stereo, b_ob_matrix);
		bcam.matrix = get_transform(b_ob_matrix);
	}

	/* sync */
	Camera *cam = scene->camera;
	blender_camera_sync(cam, &bcam, width, height, viewname);
}
コード例 #4
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Create the Blender session and all Octane session data structures
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void BlenderSession::create_session() {
	SessionParams session_params    = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, interactive);
    session_params.width            = width;
    session_params.height           = height;

    BL::RenderSettings r    = b_scene.render();
    motion_blur             = r.use_motion_blur();
    shuttertime             = r.motion_blur_shutter();
    mb_samples              = r.motion_blur_samples();
    mb_cur_sample           = 0;
    mb_sample_in_work       = 0;

    PointerRNA oct_scene    = RNA_pointer_get(&b_scene.ptr, "octane");
    mb_type                 = static_cast<MotionBlurType>(RNA_enum_get(&oct_scene, "mb_type"));
    mb_direction            = static_cast<MotionBlurDirection>(RNA_enum_get(&oct_scene, "mb_direction"));
    mb_frame_time_sampling  = motion_blur && mb_type == INTERNAL ? 1.0f / session_params.fps : -1.0f;

	// Reset status/progress
	last_status		= "";
	last_progress	= -1.0f;

	// Create session
	string cur_path = blender_absolute_path(b_data, b_scene, b_scene.render().filepath().c_str());
    cur_path += "/alembic_export.abc";
	session = new Session(session_params, cur_path.c_str());
	session->set_blender_session(this);
	session->set_pause(BlenderSync::get_session_pause_state(b_scene, interactive));

	// Create scene
    scene = new Scene(session, interactive || !b_engine.is_animation() ? true : (b_scene.frame_current() == b_scene.frame_start()));
	session->scene = scene;

    scene->server = session->server;

	// Create sync
	sync = new BlenderSync(b_engine, b_data, b_scene, scene, interactive, session->progress);

	if(b_rv3d)
		sync->sync_view(b_v3d, b_rv3d, width, height);
	else
		sync->sync_camera(b_engine.camera_override(), width, height);

	// Set buffer parameters
	BufferParams buffer_params = BlenderSync::get_display_buffer_params(scene->camera, width, height);

    if(interactive || !b_engine.is_animation() || b_scene.frame_current() == b_scene.frame_start())
        session->reset(buffer_params, mb_frame_time_sampling);
} //create_session()
コード例 #5
0
void BlenderSync::sync_camera(BL::RenderSettings& b_render,
                              BL::Object& b_override,
                              int width, int height)
{
	BlenderCamera bcam;
	blender_camera_init(&bcam, b_render);

	/* pixel aspect */
	bcam.pixelaspect.x = b_render.pixel_aspect_x();
	bcam.pixelaspect.y = b_render.pixel_aspect_y();
	bcam.shuttertime = b_render.motion_blur_shutter();

	BL::CurveMapping b_shutter_curve(b_render.motion_blur_shutter_curve());
	curvemapping_to_array(b_shutter_curve, bcam.shutter_curve, RAMP_TABLE_SIZE);

	PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
	switch(RNA_enum_get(&cscene, "motion_blur_position")) {
		case 0:
			bcam.motion_position = Camera::MOTION_POSITION_START;
			break;
		case 1:
			bcam.motion_position = Camera::MOTION_POSITION_CENTER;
			break;
		case 2:
			bcam.motion_position = Camera::MOTION_POSITION_END;
			break;
		default:
			bcam.motion_position = Camera::MOTION_POSITION_CENTER;
			break;
	}

	switch(RNA_enum_get(&cscene, "rolling_shutter_type")) {
		case 0:
			bcam.rolling_shutter_type = Camera::ROLLING_SHUTTER_NONE;
			break;
		case 1:
			bcam.rolling_shutter_type = Camera::ROLLING_SHUTTER_TOP;
			break;
		default:
			bcam.rolling_shutter_type = Camera::ROLLING_SHUTTER_NONE;
			break;
	}
	bcam.rolling_shutter_duration = RNA_float_get(&cscene, "rolling_shutter_duration");

	/* border */
	if(b_render.use_border()) {
		bcam.border.left = b_render.border_min_x();
		bcam.border.right = b_render.border_max_x();
		bcam.border.bottom = b_render.border_min_y();
		bcam.border.top = b_render.border_max_y();
	}

	/* camera object */
	BL::Object b_ob = b_scene.camera();

	if(b_override)
		b_ob = b_override;

	if(b_ob) {
		BL::Array<float, 16> b_ob_matrix;
		blender_camera_from_object(&bcam, b_engine, b_ob);
		b_engine.camera_model_matrix(b_ob, b_ob_matrix);
		bcam.matrix = get_transform(b_ob_matrix);
	}

	/* sync */
	Camera *cam = scene->camera;
	blender_camera_sync(cam, &bcam, width, height);
}
コード例 #6
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get additional Octane scene settings.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void BlenderSync::sync_kernel() {
    PointerRNA oct_scene = RNA_pointer_get(&b_scene.ptr, "octane");

    Kernel *kernel = scene->kernel;
    Kernel prevkernel = *kernel;

    BL::RenderSettings r = b_scene.render();
    if(r.use_motion_blur()) {
        float fps                                           = (float)b_scene.render().fps() / b_scene.render().fps_base();
        float shuttertime                                   = r.motion_blur_shutter();
        BlenderSession::MotionBlurType mb_type              = static_cast<BlenderSession::MotionBlurType>(RNA_enum_get(&oct_scene, "mb_type"));
        float mb_frame_time_sampling                        = mb_type == BlenderSession::INTERNAL ? 1.0f / fps : 0.0f;
        kernel->oct_node->fShutterTime                      = mb_frame_time_sampling != 0.0f ? shuttertime / mb_frame_time_sampling : 0.0f;
        BlenderSession::MotionBlurDirection mb_direction    = static_cast<BlenderSession::MotionBlurDirection>(RNA_enum_get(&oct_scene, "mb_direction"));
        switch(mb_direction) {
            case BlenderSession::BEFORE:
                kernel->oct_node->mbAlignment = ::OctaneEngine::Kernel::BEFORE;
                break;
            case BlenderSession::AFTER:
                kernel->oct_node->mbAlignment = ::OctaneEngine::Kernel::AFTER;
                break;
            case BlenderSession::SYMMETRIC:
                kernel->oct_node->mbAlignment = ::OctaneEngine::Kernel::SYMMETRIC;
                break;
            default:
                break;
        }
    }
    else kernel->oct_node->fShutterTime = 0.0f;

    kernel->oct_node->type = static_cast< ::OctaneEngine::Kernel::KernelType>(RNA_enum_get(&oct_scene, "kernel_type"));
    kernel->oct_node->infoChannelType = channel_translator[RNA_enum_get(&oct_scene, "info_channel_type")];

    ::Octane::RenderPassId cur_pass_type = Passes::pass_type_translator[RNA_enum_get(&oct_scene, "cur_pass_type")];
    if(cur_pass_type == ::Octane::RenderPassId::RENDER_PASS_BEAUTY) {
        kernel->oct_node->iMaxSamples = interactive ? get_int(oct_scene, "max_preview_samples") : get_int(oct_scene, "max_samples");
        //kernel->oct_node->iMaxPreviewSamples = get_int(oct_scene, "max_preview_samples");
        //if(kernel->oct_node->iMaxPreviewSamples == 0) kernel->oct_node->iMaxPreviewSamples = 16000;
    }
    else if(cur_pass_type == ::Octane::RenderPassId::RENDER_PASS_AMBIENT_OCCLUSION) {
        kernel->oct_node->iMaxSamples = get_int(oct_scene, "pass_ao_max_samples");
        //kernel->oct_node->iMaxPreviewSamples = kernel->oct_node->iMaxSamples;
    }
    else {
        kernel->oct_node->iMaxSamples = get_int(oct_scene, "pass_max_samples");
        //kernel->oct_node->iMaxPreviewSamples = kernel->oct_node->iMaxSamples;
    }
    if(scene->session->b_session && scene->session->b_session->motion_blur && scene->session->b_session->mb_type == BlenderSession::SUBFRAME && scene->session->b_session->mb_samples > 1)
        kernel->oct_node->iMaxSamples = kernel->oct_node->iMaxSamples / scene->session->b_session->mb_samples;
    if(kernel->oct_node->iMaxSamples < 1) kernel->oct_node->iMaxSamples = 1;

    kernel->oct_node->fFilterSize = get_float(oct_scene, "filter_size");
    kernel->oct_node->fRayEpsilon = get_float(oct_scene, "ray_epsilon");
    kernel->oct_node->bAlphaChannel = get_boolean(oct_scene, "alpha_channel");
    kernel->oct_node->bAlphaShadows = get_boolean(oct_scene, "alpha_shadows");
    kernel->oct_node->bBumpNormalMapping = get_boolean(oct_scene, "bump_normal_mapping");
    kernel->oct_node->bBkFaceHighlight = get_boolean(oct_scene, "wf_bkface_hl");
    kernel->oct_node->fPathTermPower = get_float(oct_scene, "path_term_power");

    kernel->oct_node->bKeepEnvironment = get_boolean(oct_scene, "keep_environment");

    kernel->oct_node->fCausticBlur = get_float(oct_scene, "caustic_blur");
    kernel->oct_node->iMaxDiffuseDepth = get_int(oct_scene, "max_diffuse_depth");
    kernel->oct_node->iMaxGlossyDepth = get_int(oct_scene, "max_glossy_depth");

    kernel->oct_node->fCoherentRatio = get_float(oct_scene, "coherent_ratio");
    kernel->oct_node->bStaticNoise = get_boolean(oct_scene, "static_noise");

    kernel->oct_node->iSpecularDepth = get_int(oct_scene, "specular_depth");
    kernel->oct_node->iGlossyDepth = get_int(oct_scene, "glossy_depth");
    kernel->oct_node->fAODist = get_float(oct_scene, "ao_dist");
    kernel->oct_node->GIMode = static_cast< ::OctaneEngine::Kernel::DirectLightMode>(RNA_enum_get(&oct_scene, "gi_mode"));
    kernel->oct_node->iDiffuseDepth = get_int(oct_scene, "diffuse_depth");
    kernel->oct_node->sAoTexture = get_string(oct_scene, "ao_texture");

    kernel->oct_node->fExploration = get_float(oct_scene, "exploration");
    kernel->oct_node->fGIClamp = get_float(oct_scene, "gi_clamp");
    kernel->oct_node->fDLImportance = get_float(oct_scene, "direct_light_importance");
    kernel->oct_node->iMaxRejects = get_int(oct_scene, "max_rejects");
    kernel->oct_node->iParallelism = get_int(oct_scene, "parallelism");

    kernel->oct_node->fZdepthMax = get_float(oct_scene, "zdepth_max");
    kernel->oct_node->fUVMax = get_float(oct_scene, "uv_max");
    kernel->oct_node->iSamplingMode = RNA_enum_get(&oct_scene, "sampling_mode");
    kernel->oct_node->fMaxSpeed = get_float(oct_scene, "max_speed");

    kernel->oct_node->bLayersEnable = get_boolean(oct_scene, "layers_enable");
    kernel->oct_node->iLayersCurrent = get_int(oct_scene, "layers_current");
    kernel->oct_node->bLayersInvert = get_boolean(oct_scene, "layers_invert");
    kernel->oct_node->layersMode = static_cast< ::OctaneEngine::Kernel::LayersMode>(RNA_enum_get(&oct_scene, "layers_mode"));

    kernel->oct_node->iParallelSamples = get_int(oct_scene, "parallel_samples");
    kernel->oct_node->iMaxTileSamples = get_int(oct_scene, "max_tile_samples");
    kernel->oct_node->bMinimizeNetTraffic = get_boolean(oct_scene, "minimize_net_traffic");
    kernel->oct_node->bDeepImageEnable = get_boolean(oct_scene, "deep_image");
    kernel->oct_node->iMaxDepthSamples = get_int(oct_scene, "max_depth_samples");
    kernel->oct_node->fDepthTolerance = get_float(oct_scene, "depth_tolerance");
    kernel->oct_node->iWorkChunkSize = get_int(oct_scene, "work_chunk_size");
    kernel->oct_node->bAoAlphaShadows = get_boolean(oct_scene, "ao_alpha_shadows");
    kernel->oct_node->fOpacityThreshold = get_float(oct_scene, "opacity_threshold");

    if(kernel->modified(prevkernel)) kernel->tag_update();

    // GPUs
    int iValues[8] = {0, 0, 0, 0, 0, 0, 0, 0};
    RNA_boolean_get_array(&oct_scene, "devices", iValues);
    kernel->uiGPUs = 0;
    for(int i = 0; i < 8; ++i)
        if(iValues[i]) kernel->uiGPUs |= 0x01 << i;

    if(kernel->uiGPUs != prevkernel.uiGPUs) kernel->tag_updateGPUs();
} //sync_kernel()