opengl中灯光的区别
我有一个关于创建不同类型的光的问题。全向光和具有小截止角的光之间有什么区别,以及我应该在 OpenGL 中使用什么来实现这些。
I have a question regarding creating different types of light. What would be the difference between omnidirectional light and a light with a small cutoff angle, and what should I use in OpenGL to implement these.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
全向光模型和定向光模型之间的区别在于用于选择哪些片段受光影响的算法。
全向光影响所有方向的所有片段,而定向光有一个方向和一个截止角(光锥)。光通常具有衰减系数,用于限制应用范围。
通常,灯光通过添加颜色分量来贡献片段颜色。颜色分量是环境颜色、漫反射颜色、镜面反射颜色...每个分量都使用一些参数进行缩放,例如添加距视点的距离,或者反射光线相对于视点的角度(使用眼表面矢量和法线) )。
使用固定管道(或兼容性配置文件),定义状态集以启用照明。您可以启用或禁用有限数量的灯光,设置灯光模型和模型参数。光影响顶点颜色,而不影响顶点光栅化导出的片段。
使用可编程管道,灯光由着色器制服定义。由于着色器是可编程的,因此您必须使用着色器源定义自己的照明模型。
这个问题很广泛。
The difference between omnidirectional and directional light models is the algorithm used to select which fragments are affected by the lights.
Omnidirectional lights affect all fragments is all directions, while directional light have a direction and a cut-off angle (the cone of light). Light commonly have a attenuation factors, used to limit the range of the application.
Usually lights contributes to fragment color by adding color components. Color components are ambient color, diffuse color, specular color... Each component is scaled with some parameter, such add the distance from the view point, or the angle of the reflected ray respect the view point (using eye-surface vectore and normal).
Using fixed pipeline (or compatibility profile), a state set is defined for enabling lighting. You can enable or disable a limited number of lights, set the light model and the model parameters. Light affect vertex color, not the fragment derived by vertex rasterization.
Using programmable pipeline, lights are defined by shader uniforms. Since shaders are programmable, you have to define your own lighting model using shader source.
The question is very wide.