简体   繁体   English

点光源不渲染

[英]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. 我在GLSL中的计算是正确的,并且我的制服也被正确阅读。 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_pointLight[0].DiffuseIntensity不会记录更改,但是如果使用注释的AmbientIntensity ,则场景将AmbientIntensity红色。

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. 我最初将相机位置设置为(0,100,75) 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. 将一小段代码移到II设定我的视角和其他制服的位置后,一点光开始从点光源开始显示。 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). 因此,从摄像机位置(0、100、75)开始 ,我决定从地板的整个相对端(z轴为-75 进行观察 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. 如果有人可以解释发生了什么,将不胜感激。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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