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


C++ GrGLFragmentBuilder::appendTextureLookupAndModulate方法代码示例

本文整理汇总了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");
 }
开发者ID:Just-D,项目名称:skia,代码行数:9,代码来源:GrSimpleTextureEffect.cpp

示例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(";");
        }
    }
开发者ID:mariospr,项目名称:chromium-browser,代码行数:53,代码来源:GrBitmapTextGeoProc.cpp

示例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");
 }
开发者ID:BenzoRoms,项目名称:external_skia,代码行数:14,代码来源:GrSimpleTextureEffect.cpp

示例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);
        }
开发者ID:mariospr,项目名称:chromium-browser,代码行数:43,代码来源:SampleLighting.cpp


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