本文整理汇总了C++中PointLight::GetAttenuationLinear方法的典型用法代码示例。如果您正苦于以下问题:C++ PointLight::GetAttenuationLinear方法的具体用法?C++ PointLight::GetAttenuationLinear怎么用?C++ PointLight::GetAttenuationLinear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointLight
的用法示例。
在下文中一共展示了PointLight::GetAttenuationLinear方法的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);
}