Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是初学者。我注意到旧代码
// Calculate the light position for this vertex vec3 vertex_light_position = gl_LightSource[0].position.xyz;
我认为这是动态变化的,因此不能仅使用静态 vec3 对其进行测试。
如何在现代 OpenGL 中替换上述内容?一个例子将不胜感激。
gl_LightSource 只是一个统一数组,对于现代代码,您只需传递一个包含光照数据的统一结构数组。
它很可能是静态的。这段代码是获取光的位置,而不是从顶点到光的向量。
对于当前的渲染过程,它也是静态的。顶点在帧的持续时间内位于一个位置。
要在现代 OpenGL 中检索有关灯光的信息,请参阅文档。