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


C++ Compositor::getMaterial方法代码示例

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


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

示例1: update

void PostProcessSample::update(float elapsedTime)
{
    _modelNode->rotateY(elapsedTime * MATH_DEG_TO_RAD(0.25f));

    // Only the last sample will check live updating of material parameters
    if (_compositorIndex == _compositors.size() - 1)
    {
        Compositor* compositor = _compositors[_compositorIndex];
        MaterialParameter* elapsedParam  = compositor->getMaterial()->getParameter("u_elapsedTime");
        if (elapsedParam)
            elapsedParam->setValue(elapsedTime);
        MaterialParameter* randomParam = compositor->getMaterial()->getParameter("u_random");
        if (randomParam)
            randomParam->setValue(MATH_RANDOM_0_1());
    }
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例2: initialize

void PostProcessSample::initialize()
{
    _font = Font::create("res/ui/arial.gpb");

    // Load game scene from file
    _scene = Scene::load("res/common/duck.gpb");
    _scene->getActiveCamera()->setAspectRatio(getAspectRatio());

    // Initialize box model
    _modelNode = _scene->findNode("duck");
    Model* model = dynamic_cast<Model*>(_modelNode->getDrawable());
    Material* material = model->setMaterial("res/common/duck.material");
    // Get light node
    Node* lightNode = _scene->findNode("directionalLight1");
    Light* light = lightNode->getLight();
    material->getParameter("u_directionalLightColor[0]")->setValue(light->getColor());
    material->getParameter("u_directionalLightDirection[0]")->setValue(lightNode->getForwardVectorView());

    // Create one frame buffer for the full screen compositerss.
    _frameBuffer = FrameBuffer::create("PostProcessSample", FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT);
    DepthStencilTarget* dst = DepthStencilTarget::create("PostProcessSample", DepthStencilTarget::DEPTH_STENCIL, FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT);
    _frameBuffer->setDepthStencilTarget(dst);
    SAFE_RELEASE(dst);

    // Create our compositors that all output to the default framebuffer.
    Compositor* compositor = NULL;

    compositor = Compositor::create(_frameBuffer, NULL, "res/common/postprocess/postprocess.material", "Passthrough");
    _compositors.push_back(compositor);

    compositor = Compositor::create(_frameBuffer, NULL, "res/common/postprocess/postprocess.material", "Grayscale");
    _compositors.push_back(compositor);

    compositor = Compositor::create(_frameBuffer, NULL, "res/common/postprocess/postprocess.material", "Sepia");
    _compositors.push_back(compositor);

    compositor = Compositor::create(_frameBuffer, NULL, "res/common/postprocess/postprocess.material", "Pixelate");
    _compositors.push_back(compositor);

    compositor = Compositor::create(_frameBuffer, NULL, "res/common/postprocess/postprocess.material", "Sobel Edge");
    _compositors.push_back(compositor);
    compositor->getMaterial()->getParameter("u_width")->setValue((float)FRAMEBUFFER_WIDTH / 2.0f);
    compositor->getMaterial()->getParameter("u_height")->setValue((float)FRAMEBUFFER_HEIGHT / 2.0f);

    compositor = Compositor::create(_frameBuffer, NULL, "res/common/postprocess/postprocess.material", "Gaussian Blur");
    _compositors.push_back(compositor);
    compositor->getMaterial()->getParameter("u_length")->setValue(1.0f / ((float)FRAMEBUFFER_WIDTH / 2.0f));

    compositor = Compositor::create(_frameBuffer, NULL, "res/common/postprocess/postprocess.material", "Old Film");
    _compositors.push_back(compositor);
    compositor->getMaterial()->getParameter("u_sepiaValue")->setValue(0.8f);
    compositor->getMaterial()->getParameter("u_noiseValue")->setValue(0.4f);
    compositor->getMaterial()->getParameter("u_scratchValue")->setValue(0.4f);
    compositor->getMaterial()->getParameter("u_innerVignetting")->setValue(0.9f);
    compositor->getMaterial()->getParameter("u_outerVignetting")->setValue(0.9f);
}
开发者ID:,项目名称:,代码行数:56,代码来源:


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