简体   繁体   中英

Point Light not rendering

I'm trying to render a couple point lights in my scene, but having trouble getting the actual lights to illuminate. The only light I got to work is a directional light which lights up the scene initially:

没有点光源渲染的定向光

Where the two rocks are displayed are the same positions as the two point lights. I've toyed around with the diffuse, color and attenuation values, but got the same results. But when changed the ambiance of either light, the color changed:

具有环境强度的定向光

My calculations within GLSL are correct and my uniforms are read correctly as well. But somehow I lost my diffuse intensity. m_pointLight[0].DiffuseIntensity doesn't registers a change, but if the commented AmbientIntensity is used, the scene is tinted red.

m_scale += 0.0057f;

// changing the value makes scene red
m_pointLight[0].AmbientIntensity = 0.5f;
// changing the value does nothing 
m_pointLight[0].DiffuseIntensity = 1.5f; 
// light color is red
m_pointLight[0].Color = glm::vec3(1.0f, 0.0f, 0.0f);
// position of light (same as rock) 
m_pointLight[0].Position = glm::vec3(3.0f, 1.0f, FieldDepth * (cosf(m_scale) + 1.0f) / 2.0f);
// Light decay
m_pointLight[0].Attenuation.Linear = 0.01f;

Not a real answer but I figured out part of what my problem was:

The problem was the angle I was looking from. Something is quite wrong with my code. I set my camera position to (0, 100, 75) originally. After moving the a small block of code to where II set my perspective and other uniforms, a bit of light started to show from the point light. The problem then was when the two rocks moved, closer to the center of the floor, the point light of the first rock started to glow red. Same goes for the second rock, but it was set to blue. But as the rocks moved closer to the camera, the colors faded gradually until it appeared off. Then when it moved back to the center, the colors gradually got brighter to full capacity.

So then I was thinking this may have to do with the angle that I'm at. So from the camera position (0, 100, 75) , I decided to look from the complete opposite end of the floor (-75 for the z-axis). And this is what I got:

在此处输入图片说明

The only problem remaining is that depending on where the camera is, the point light closest to the camera doesn't show (other than on the underside of the closest rock). The bottom right image is the only one displaying all lights correctly:

在此处输入图片说明

If some could explain what is going on, it would be greatly appreciated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM