本文整理汇总了C++中GrGLFragmentBuilder::appendTextureLookupAndModulate方法的典型用法代码示例。如果您正苦于以下问题:C++ GrGLFragmentBuilder::appendTextureLookupAndModulate方法的具体用法?C++ GrGLFragmentBuilder::appendTextureLookupAndModulate怎么用?C++ GrGLFragmentBuilder::appendTextureLookupAndModulate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrGLFragmentBuilder
的用法示例。
在下文中一共展示了GrGLFragmentBuilder::appendTextureLookupAndModulate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emitCode
virtual void emitCode(EmitArgs& args) override {
GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\t%s = ", args.fOutputColor);
fsBuilder->appendTextureLookupAndModulate(args.fInputColor,
args.fSamplers[0],
args.fCoords[0].c_str(),
args.fCoords[0].getType());
fsBuilder->codeAppend(";\n");
}
示例2: onEmitCode
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
GrGLGPBuilder* pb = args.fPB;
GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
// emit attributes
vsBuilder->emitAttributes(cte);
GrGLVertToFrag v(kVec2f_GrSLType);
pb->addVarying("TextureCoords", &v);
// this is only used with text, so our texture bounds always match the glyph atlas
if (cte.maskFormat() == kA8_GrMaskFormat) {
vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_A8_RECIP_WIDTH ", "
GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", v.vsOut(),
cte.inTextureCoords()->fName);
} else {
vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_RECIP_WIDTH ", "
GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", v.vsOut(),
cte.inTextureCoords()->fName);
}
// Setup pass through color
if (!cte.colorIgnored()) {
if (cte.hasVertexColor()) {
pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor);
} else {
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
}
}
// Setup position
this->setupPosition(pb, gpArgs, cte.inPosition()->fName);
// emit transforms
this->emitTransforms(args.fPB, gpArgs->fPositionVar, cte.inPosition()->fName,
cte.localMatrix(), args.fTransformsIn, args.fTransformsOut);
GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
if (cte.maskFormat() == kARGB_GrMaskFormat) {
fsBuilder->codeAppendf("%s = ", args.fOutputColor);
fsBuilder->appendTextureLookupAndModulate(args.fOutputColor,
args.fSamplers[0],
v.fsIn(),
kVec2f_GrSLType);
fsBuilder->codeAppend(";");
fsBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
} else {
fsBuilder->codeAppendf("%s = ", args.fOutputCoverage);
fsBuilder->appendTextureLookup(args.fSamplers[0], v.fsIn(), kVec2f_GrSLType);
fsBuilder->codeAppend(";");
}
}
示例3: emitCode
virtual void emitCode(GrGLFPBuilder* builder,
const GrFragmentProcessor& fp,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) override {
GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\t%s = ", outputColor);
fsBuilder->appendTextureLookupAndModulate(inputColor,
samplers[0],
coords[0].c_str(),
coords[0].getType());
fsBuilder->codeAppend(";\n");
}
示例4: emitCode
void emitCode(GrGLFPBuilder* builder,
const GrFragmentProcessor& fp,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) override {
GrGLFragmentBuilder* fpb = builder->getFragmentShaderBuilder();
// add uniforms
const char* lightDirUniName = NULL;
fLightDirUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec3f_GrSLType, kDefault_GrSLPrecision,
"LightDir", &lightDirUniName);
const char* lightColorUniName = NULL;
fLightColorUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"LightColor", &lightColorUniName);
const char* ambientColorUniName = NULL;
fAmbientColorUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"AmbientColor", &ambientColorUniName);
fpb->codeAppend("vec4 diffuseColor = ");
fpb->appendTextureLookupAndModulate(inputColor, samplers[0],
coords[0].c_str(), coords[0].getType());
fpb->codeAppend(";");
fpb->codeAppend("vec4 normalColor = ");
fpb->appendTextureLookup(samplers[1], coords[0].c_str(), coords[0].getType());
fpb->codeAppend(";");
fpb->codeAppend("vec3 normal = normalize(2.0*(normalColor.rgb - vec3(0.5)));");
fpb->codeAppendf("vec3 lightDir = normalize(%s);", lightDirUniName);
fpb->codeAppend("float NdotL = dot(normal, lightDir);");
// diffuse light
fpb->codeAppendf("vec3 result = %s.rgb*diffuseColor.rgb*NdotL;", lightColorUniName);
// ambient light
fpb->codeAppendf("result += %s.rgb;", ambientColorUniName);
fpb->codeAppendf("%s = vec4(result.rgb, diffuseColor.a);", outputColor);
}