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


C++ PointLight::GetAttenuationExponential方法代码示例

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


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

示例1: DoLightingPass

// ===================
// Point lights
// ===================
void World::DoLightingPass(const PointLight& l)
{
    gbuffer.StartLightingPass();

    // Disable depth test.
    glDisable(GL_DEPTH_TEST);

    // Setup for lighting pass.
    glStencilFunc(GL_NOTEQUAL, 0, 0xFF);

    glEnable(GL_BLEND);

    glEnable(GL_CULL_FACE);
    glCullFace(GL_FRONT);

    // Bind pass 2 shader.
    Shader* lpassShader = &pointLightShader;
    Shader::Bind(lpassShader);

    // Activate gbuffer textures.
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, gbuffer.GetColorID());
    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, gbuffer.GetNormalID());
    glActiveTexture(GL_TEXTURE2);
    glBindTexture(GL_TEXTURE_2D, gbuffer.GetPositionID());

    // Matrices
    Matrix pmat = cam.GetProjectionMatrix();
    Matrix vmat = cam.GetViewMatrix();

    lpassShader->SetParameter("projectionMatrix", &pmat[0][0]);
    lpassShader->SetParameter("viewMatrix", &vmat[0][0]);
    lpassShader->SetParameter("screenSize", WINDOW_WIDTH, WINDOW_HEIGHT);

    // Set the eye position to the camera position.
    Vector3 cpos = cam.GetPosition();
    lpassShader->SetParameter("eyePosition", cpos.x, cpos.y, cpos.z);
    lpassShader->SetParameter("farClipDistance", cam.GetFarClippingPlane());

    // Texture locations
    lpassShader->SetParameter("difftex", 0);
    lpassShader->SetParameter("normtex", 1);
    lpassShader->SetParameter("postex", 2);

    // Draw point lights.
    Matrix lmat = l.GetMatrix();
    lpassShader->SetParameter("modelMatrix", &lmat[0][0]);

    const Vector3& pos = l.GetPosition();
    lpassShader->SetParameter("lightPos", pos.x, pos.y, pos.z);

    // Itensity.
    lpassShader->SetParameter("ambientIntensity", l.GetAmbientIntensity());
    lpassShader->SetParameter("diffuseIntensity", l.GetDiffuseIntensity());

    // Attenuation.
    lpassShader->SetParameter("attenuationConstant", l.GetAttenuationConstant());
    lpassShader->SetParameter("attenuationLinear", l.GetAttenuationLinear());
    lpassShader->SetParameter("attenuationExponential", l.GetAttenuationExponential());

    Color diffuseColor = l.GetColor();
    lpassShader->SetParameter("lightColor", diffuseColor.R(), diffuseColor.G(), diffuseColor.B());

    pointLightMesh.Draw();

    glCullFace(GL_BACK);
    glDisable(GL_BLEND);
}
开发者ID:aleios,项目名称:3dapp,代码行数:72,代码来源:World.cpp


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