本文整理汇总了C++中VertexFormat::getAttributeBySemantic方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexFormat::getAttributeBySemantic方法的具体用法?C++ VertexFormat::getAttributeBySemantic怎么用?C++ VertexFormat::getAttributeBySemantic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexFormat
的用法示例。
在下文中一共展示了VertexFormat::getAttributeBySemantic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateShaders
void ShaderGenerator::generateShaders(Material& mat, const RenderState& rs, const VertexFormat& vf, const FogParameters fogParams) {
bool hasNormalMap = false;
bool hasParallaxMap = false;
ctemplate::TemplateDictionary vertexShaderDict("vertexShader");
ctemplate::TemplateDictionary fragmentShaderDict("fragmentShader");
ctemplate::TemplateDictionary* vertexIoDict = vertexShaderDict.AddIncludeDictionary("VERTEX_INPUTS");
vertexIoDict->SetFilename("shader_templates/ft_vertex_inout.tpl");
ctemplate::TemplateDictionary* fragmentOutDict = vertexShaderDict.AddIncludeDictionary("FRAGMENT_INPUTS");
fragmentOutDict->SetFilename("shader_templates/ft_fragment_inout.tpl");
fragmentOutDict->ShowSection("OUT_DIRECTION");
ctemplate::TemplateDictionary* uniformsDict = vertexShaderDict.AddIncludeDictionary("UNIFORMS");
uniformsDict->SetFilename("shader_templates/uniforms.tpl");
// emit the fog uniforms if necessary
if (fogParams.m_fogMode != FOG_NONE) {
uniformsDict->ShowSection("FOG");
}
// use lighting when material uses shading and we have normals
bool useLighting = !mat.m_shadeless && vf.getAttributeBySemantic(Vertex_Normal);
if (useLighting) {
uniformsDict->ShowSection("USE_LIGHTING");
}
if (vf.getAttributeBySemantic(Vertex_Normal)) {
vertexShaderDict.ShowSection("HAS_NORMALS");
vertexShaderDict.ShowSection("NORMALIZE_NORMALS");
vertexIoDict->ShowSection("HAS_NORMALS");
vertexIoDict->ShowSection("NORMALIZE_NORMALS");
fragmentOutDict->ShowSection("HAS_NORMALS");
uniformsDict->ShowSection("HAS_NORMALS");
}
if (vf.getAttributeBySemantic(Vertex_Tangent)) {
fragmentOutDict->ShowSection("HAS_TANGENTS");
vertexIoDict->ShowSection("HAS_TANGENTS");
}
if (vf.getAttributeBySemantic(Vertex_BiNormal)) {
fragmentOutDict->ShowSection("HAS_BINORMALS");
vertexIoDict->ShowSection("HAS_BINORMALS");
}
if (vf.getAttributeBySemantic(Vertex_Color)) {
vertexShaderDict.ShowSection("HAS_COLORS");
vertexIoDict->ShowSection("HAS_COLORS");
fragmentOutDict->ShowSection("HAS_COLORS");
}
// indicates if the tex coords generation functions declarations template has already been
// included in the vertex shader template
bool texGenDeclIncluded = false;
// number of active texture units
uint activeTextures = 0;
ctemplate::TemplateDictionary* texGenDict = vertexShaderDict.AddIncludeDictionary("TEX_COORDS_GEN");
texGenDict->SetFilename("shader_templates/ft_tex_coords_gen.tpl");
// Loops over all material textures and performs the following:
// 1. Declares a respective uniform sampler object which will be named as u_sampler#,
// where # is the active texture index.
// 2. Emits code for any texture coordinates generation scheme, if not simple UV.
ctemplate::TemplateDictionary* parallaxMapDict = 0;
for (int i = 0; i < MAX_TEXTURES_STACK; i++) {
TexturePtr tex = mat.m_texStack->textures[i];
if (tex) {
// for the fragment shader, here we can fill in the dictionary for the texture application section
// that takes into account the texture's mapTo, environment color, uvset, etc.
ctemplate::TemplateDictionary* texUnitDict = fragmentShaderDict.AddIncludeDictionary(
"SINGLE_TEXTURE_STACK_ENTRY");
texUnitDict->SetFilename("shader_templates/ft_tex_stack_application.tpl");
ctemplate::TemplateDictionary* alphaMapDict = 0;
ctemplate::TemplateDictionary* tangentNormalMapDict = 0;
ctemplate::TemplateDictionary* offsetMappingDict = 0;
// depending on the texture's mapTo, we will emit different sections in the template
ctemplate::TemplateDictionary* texMapToDict = 0;
switch (mat.m_texStack->texOutputs[i].mapTo) {
case TexMapTo_Diffuse:
texMapToDict = texUnitDict->AddSectionDictionary("TEX_MAP_TO_DIFFUSE");
break;
case TexMapTo_CSpecular:
texMapToDict = texUnitDict->AddSectionDictionary("TEX_MAP_TO_SPECULAR");
break;
case TexMapTo_Shininess:
texMapToDict = texUnitDict->AddSectionDictionary("TEX_MAP_TO_SHININESS");
break;
case TexMapTo_Alpha:
//.........这里部分代码省略.........