Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1.             shaderLightingPass.setVec3("lights[" + std::to_string(i) + "].Position", lightPositions[i]);
  2.             shaderLightingPass.setVec3("lights[" + std::to_string(i) + "].Color", lightColors[i]);
  3.             // update attenuation parameters and calculate radius
  4.             const float constant = 1.0; // note that we don't send this to the shader, we assume it is always 1.0 (in our case)
  5.             const float linear = 0.7;
  6.             const float quadratic = 1.8;
  7.             shaderLightingPass.setFloat("lights[" + std::to_string(i) + "].Linear", linear);
  8.             shaderLightingPass.setFloat("lights[" + std::to_string(i) + "].Quadratic", quadratic);
  9.             // then calculate radius of light volume/sphere
  10.             const float maxBrightness = std::fmaxf(std::fmaxf(lightColors[i].r, lightColors[i].g), lightColors[i].b);
  11.             float radius = (-linear + std::sqrt(linear * linear - 4 * quadratic * (constant - (256.0f / 5.0f) * maxBrightness))) / (2.0f * quadratic);
  12.             shaderLightingPass.setFloat("lights[" + std::to_string(i) + "].Radius", radius);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement