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


C++ ShaderLoader::create方法代码示例

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


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

示例1: shaderSetup

const Shader::Setup *CurvesPrimitive::shaderSetup( const Shader *shader, State *state ) const
{
	bool linear, ribbons;
	renderMode( state, linear, ribbons );

	if( linear && !ribbons  )
	{
		// we just render in the standard way.
		return Primitive::shaderSetup( shader, state );
	}
		
	// we're rendering with ribbons and/or cubic interpolation. we need
	// to substitute in a geometry shader to do the work.
	
	for( MemberData::GeometrySetupVector::const_iterator it = m_memberData->geometrySetups.begin(), eIt = m_memberData->geometrySetups.end(); it != eIt; it++ )
	{
		if( it->originalShader == shader && it->linear == linear && it->ribbons == ribbons )
		{
			return it->shaderSetup.get();
		}
	}

	ConstShaderPtr geometryShader = shader;
	ShaderStateComponent *shaderStateComponent = state->get<ShaderStateComponent>();
	if( geometryShader->geometrySource() == "" )
	{
		// if the current shader has a specific geometry shader component,
		// then we assume the user has provided one capable of doing the tesselation,
		// but if not then we substitute in our own geometry shader.
		ShaderLoader *shaderLoader = shaderStateComponent->shaderLoader();
		if( ribbons )
		{
			if( linear )
			{
				geometryShader = shaderLoader->create( geometryShader->vertexSource(), linearRibbonsGeometrySource(), geometryShader->fragmentSource() );		
			}
			else
			{
				geometryShader = shaderLoader->create( geometryShader->vertexSource(), cubicRibbonsGeometrySource(), geometryShader->fragmentSource() );		
			}
		}
		else
		{
			geometryShader = shaderLoader->create( geometryShader->vertexSource(), cubicLinesGeometrySource(), geometryShader->fragmentSource() );
		}
	}

	Shader::SetupPtr geometryShaderSetup = new Shader::Setup( geometryShader );
	shaderStateComponent->addParametersToShaderSetup( geometryShaderSetup.get() );
	addPrimitiveVariablesToShaderSetup( geometryShaderSetup.get() );
	geometryShaderSetup->addUniformParameter( "basis", new IECore::M44fData( m_memberData->basis.matrix ) );
	geometryShaderSetup->addUniformParameter( "width", new IECore::M44fData( m_memberData->width ) );

	m_memberData->geometrySetups.push_back( MemberData::GeometrySetup( shader, geometryShaderSetup, linear, ribbons ) );
	
	return geometryShaderSetup.get();
}
开发者ID:AtomicFiction,项目名称:cortex,代码行数:57,代码来源:CurvesPrimitive.cpp

示例2: shaderSetup

const Shader::Setup *PointsPrimitive::shaderSetup( const Shader *shader, State *state ) const
{
	Type type = effectiveType( state );
	if( type == Point )
	{
		// rendering as gl points goes through the normal process
		return Primitive::shaderSetup( shader, state );
	}
	else
	{
		// for rendering as disks, quads or spheres, we build a custom setup which we use
		// for instancing primitives onto our points.
		for( MemberData::InstancingSetupVector::const_iterator it = m_memberData->instancingSetups.begin(), eIt = m_memberData->instancingSetups.end(); it != eIt; it++ )
		{
			if( it->originalShader == shader && it->type == type )
			{
				return it->shaderSetup.get();
			}
		}

		ConstShaderPtr instancingShader = shader;
		ShaderStateComponent *shaderStateComponent = state->get<ShaderStateComponent>();
		if( instancingShader->vertexSource() == "" )
		{
			// if the current shader has specific vertex source, then we assume the user has provided
			// a shader capable of performing the instancing, but if not then we substitute in our own
			// instancing vertex shader.
			ShaderLoader *shaderLoader = shaderStateComponent->shaderLoader();
			instancingShader = shaderLoader->create( instancingVertexSource(), "", shader->fragmentSource() );
		}

		Shader::SetupPtr instancingShaderSetup = new Shader::Setup( instancingShader );
		shaderStateComponent->addParametersToShaderSetup( instancingShaderSetup.get() );
		addPrimitiveVariablesToShaderSetup( instancingShaderSetup.get(), "vertex", 1 );

		instancingShaderSetup->addUniformParameter( "useWidth", new BoolData( static_cast<bool>( m_memberData->widths ) ) );
		if( !m_memberData->constantWidth )
		{
			instancingShaderSetup->addUniformParameter( "constantwidth", new FloatData( 1.0f ) );
		}
		instancingShaderSetup->addUniformParameter( "useAspectRatio", new BoolData( static_cast<bool>( m_memberData->patchAspectRatio ) ) );
		instancingShaderSetup->addUniformParameter( "useRotation", new BoolData( static_cast<bool>( m_memberData->rotations ) ) );

		switch( type )
		{
			case Disk :
				if( !m_memberData->diskPrimitive )
				{
					m_memberData->diskPrimitive = new DiskPrimitive( 0.5f );
				}
				m_memberData->diskPrimitive->addPrimitiveVariablesToShaderSetup( instancingShaderSetup.get(), "instance" );
				break;
			case Sphere :
				if( !m_memberData->spherePrimitive )
				{
					m_memberData->spherePrimitive = new SpherePrimitive( 0.5f );
				}
				m_memberData->spherePrimitive->addPrimitiveVariablesToShaderSetup( instancingShaderSetup.get(), "instance" );
				break;
			case Quad :
				if( !m_memberData->quadPrimitive )
				{
					m_memberData->quadPrimitive = new QuadPrimitive();
				}
				m_memberData->quadPrimitive->addPrimitiveVariablesToShaderSetup( instancingShaderSetup.get(), "instance" );
				break;
			default :
				break;
		}

		m_memberData->instancingSetups.push_back( MemberData::InstancingSetup( shader, type, instancingShaderSetup ) );

		return instancingShaderSetup.get();
	}
}
开发者ID:ImageEngine,项目名称:cortex,代码行数:75,代码来源:PointsPrimitive.cpp


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