当前位置: 首页>>代码示例>>C++>>正文


C++ ShaderNode::input方法代码示例

本文整理汇总了C++中ShaderNode::input方法的典型用法代码示例。如果您正苦于以下问题:C++ ShaderNode::input方法的具体用法?C++ ShaderNode::input怎么用?C++ ShaderNode::input使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ShaderNode的用法示例。


在下文中一共展示了ShaderNode::input方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sync_lamps

void BlenderSync::sync_lamps(bool update_all)
{
	shader_map.set_default(scene->default_light);

	/* lamp loop */
	BL::BlendData::lamps_iterator b_lamp;

	for(b_data.lamps.begin(b_lamp); b_lamp != b_data.lamps.end(); ++b_lamp) {
		Shader *shader;

		/* test if we need to sync */
		if(shader_map.sync(&shader, *b_lamp) || update_all) {
			ShaderGraph *graph = new ShaderGraph();

			/* create nodes */
			if(b_lamp->use_nodes() && b_lamp->node_tree()) {
				shader->name = b_lamp->name().c_str();

				BL::ShaderNodeTree b_ntree(b_lamp->node_tree());

				add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
			}
			else {
				float strength = 1.0f;

				if(b_lamp->type() == BL::Lamp::type_POINT ||
				   b_lamp->type() == BL::Lamp::type_SPOT ||
				   b_lamp->type() == BL::Lamp::type_AREA)
				{
					strength = 100.0f;
				}

				EmissionNode *emission = new EmissionNode();
				emission->color = get_float3(b_lamp->color());
				emission->strength = strength;
				graph->add(emission);

				ShaderNode *out = graph->output();
				graph->connect(emission->output("Emission"), out->input("Surface"));
			}

			shader->set_graph(graph);
			shader->tag_update(scene);
		}
	}
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:46,代码来源:blender_shader.cpp

示例2: sync_materials

void BlenderSync::sync_materials(bool update_all)
{
	shader_map.set_default(scene->default_surface);

	/* material loop */
	BL::BlendData::materials_iterator b_mat;

	for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_mat) {
		Shader *shader;

		/* test if we need to sync */
		if(shader_map.sync(&shader, *b_mat) || update_all) {
			ShaderGraph *graph = new ShaderGraph();

			shader->name = b_mat->name().c_str();
			shader->pass_id = b_mat->pass_index();

			/* create nodes */
			if(b_mat->use_nodes() && b_mat->node_tree()) {
				BL::ShaderNodeTree b_ntree(b_mat->node_tree());

				add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
			}
			else {
				DiffuseBsdfNode *diffuse = new DiffuseBsdfNode();
				diffuse->color = get_float3(b_mat->diffuse_color());
				graph->add(diffuse);

				ShaderNode *out = graph->output();
				graph->connect(diffuse->output("BSDF"), out->input("Surface"));
			}

			/* settings */
			PointerRNA cmat = RNA_pointer_get(&b_mat->ptr, "cycles");
			shader->use_mis = get_boolean(cmat, "sample_as_light");
			shader->use_transparent_shadow = get_boolean(cmat, "use_transparent_shadow");
			shader->heterogeneous_volume = !get_boolean(cmat, "homogeneous_volume");
			shader->volume_sampling_method = get_volume_sampling(cmat);
			shader->volume_interpolation_method = get_volume_interpolation(cmat);

			shader->set_graph(graph);
			shader->tag_update(scene);
		}
	}
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:45,代码来源:blender_shader.cpp

示例3: server_update

void ShaderManager::server_update(::OctaneEngine::OctaneClient *server, Scene *scene, Progress& progress) {
	if(!need_update) return;

    size_t cnt = scene->shaders.size();
	if(!cnt) return;

	for(size_t i = 0; i < cnt; ++i) {
        Shader *shader = scene->shaders[i];
        if(!shader->need_update) continue;
        if(!shader->graph) continue;

        for(list<ShaderNode*>::iterator it = shader->graph->nodes.begin(); it != shader->graph->nodes.end(); ++it) {
            ShaderNode *node = *it;
            if(node->input("Surface")) continue;

            node->load_to_server(server);
        }
        shader->need_update = false;
	}
	need_update = false;
} //server_update()
开发者ID:JimStar,项目名称:OctaneBlender,代码行数:21,代码来源:shader.cpp

示例4: sync_world

void BlenderSync::sync_world(bool update_all)
{
	Background *background = scene->background;
	Background prevbackground = *background;

	BL::World b_world = b_scene.world();

	if(world_recalc || update_all || b_world.ptr.data != world_map) {
		Shader *shader = scene->default_background;
		ShaderGraph *graph = new ShaderGraph();

		/* create nodes */
		if(b_world && b_world.use_nodes() && b_world.node_tree()) {
			BL::ShaderNodeTree b_ntree(b_world.node_tree());

			add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);

			/* volume */
			PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
			shader->heterogeneous_volume = !get_boolean(cworld, "homogeneous_volume");
			shader->volume_sampling_method = get_volume_sampling(cworld);
			shader->volume_interpolation_method = get_volume_interpolation(cworld);
		}
		else if(b_world) {
			BackgroundNode *background = new BackgroundNode();
			background->color = get_float3(b_world.horizon_color());
			graph->add(background);

			ShaderNode *out = graph->output();
			graph->connect(background->output("Background"), out->input("Surface"));
		}

		if(b_world) {
			/* AO */
			BL::WorldLighting b_light = b_world.light_settings();

			if(b_light.use_ambient_occlusion())
				background->ao_factor = b_light.ao_factor();
			else
				background->ao_factor = 0.0f;

			background->ao_distance = b_light.distance();

			/* visibility */
			PointerRNA cvisibility = RNA_pointer_get(&b_world.ptr, "cycles_visibility");
			uint visibility = 0;

			visibility |= get_boolean(cvisibility, "camera")? PATH_RAY_CAMERA: 0;
			visibility |= get_boolean(cvisibility, "diffuse")? PATH_RAY_DIFFUSE: 0;
			visibility |= get_boolean(cvisibility, "glossy")? PATH_RAY_GLOSSY: 0;
			visibility |= get_boolean(cvisibility, "transmission")? PATH_RAY_TRANSMIT: 0;
			visibility |= get_boolean(cvisibility, "scatter")? PATH_RAY_VOLUME_SCATTER: 0;

			background->visibility = visibility;
		}
		else {
			background->ao_factor = 0.0f;
			background->ao_distance = FLT_MAX;
		}

		shader->set_graph(graph);
		shader->tag_update(scene);
		background->tag_update(scene);
	}

	PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");

	/* when doing preview render check for BI's transparency settings,
	 * this is so because Blender's preview render routines are not able
	 * to tweak all cycles's settings depending on different circumstances
	 */
	if(b_engine.is_preview() == false)
		background->transparent = get_boolean(cscene, "film_transparent");
	else
		background->transparent = b_scene.render().alpha_mode() == BL::RenderSettings::alpha_mode_TRANSPARENT;

	background->use_shader = render_layer.use_background_shader;
	background->use_ao = render_layer.use_background_ao;

	if(background->modified(prevbackground))
		background->tag_update(scene);
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:82,代码来源:blender_shader.cpp


注:本文中的ShaderNode::input方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。