现代 OpenGL 中的 gl_LightSource[0].position.xyz

发布于 2024-09-23 23:58:12 字数 239 浏览 0 评论 0原文

我是初学者。我注意到在旧代码中

// Calculate the light position for this vertex
vec3 vertex_light_position = gl_LightSource[0].position.xyz;

我假设它是动态变化的,因此不能简单地用静态 vec3 来测试它。

我如何在现代 OpenGL 中替换上述内容?一个例子将不胜感激。

I'm a beginner. I noticed in old code

// Calculate the light position for this vertex
vec3 vertex_light_position = gl_LightSource[0].position.xyz;

I assume that's dynamically changing and hence can't test it with simply a static vec3.

How do I go with replacing the above in modern OpenGL? An example would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

時窥 2024-09-30 23:58:12

gl_LightSource 只是一个统一数组,对于现代代码,您只需传递包含灯光数据的统一结构数组即可。

The gl_LightSource is just an uniform array, for modern code you can just pass a uniform array of structures that contains your light data.

满意归宿 2024-09-30 23:58:12

它很可能是静态的。此代码获取光线的位置,而不是从顶点到光线的矢量。

相对于当前渲染通道来说,它也是静态的。在帧的持续时间内,顶点位于一个位置。

要检索有关现代 OpenGL 中灯光的信息,请参阅文档

It's more than likely static. This code is grabbing the position of the light, not the vector to the light from the vertex.

It's also static with respect to the current rendering pass. The vertex is at one location for the duration of the frame.

To retrieve information about lights in modern OpenGL, here is the documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文