基本的OpenGL光照问题
我认为这是一个非常愚蠢和新手的问题,但我是图形和 openGL 方面的新手。绘制了一个球体并在附近放置了一个光源,还指定了环境光,我开始尝试光和材质值,并得出了一个令人惊讶的结论:我们用 glColor*
指定的颜色并不重要当照明启用时。相反,等效的是材质的环境成分。这个结论正确吗?谢谢
I think this is an extremely stupid and newbie question, but then I am a newbie in graphics and openGL. Having drawn a sphere and put a light source nearby, also having specified ambient light, I started experimenting with light and material values and came to a surprising conclusion: the colors which we specify with glColor*
do not matter at all when lighting is enabled. Instead, the equivalent is the material's ambient component. Is this conclusion correct? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果启用了照明,则使用材质颜色(嗯,颜色 - 有几种颜色用于不同类型的光响应)来代替顶点颜色 。材质颜色由
glMaterial*
函数指定。如果您想重用代码,可以使用
glEnable(GL_COLOR_MATERIAL)
和glColorMaterial(GL_AMBIENT_AND_DIFFUSE)
将旧的glColor*
调用映射到自动材料颜色。(请尽快切换到着色器 - 着色器方法既简单又更强大)
If the lighting is enabled, then instead of the vertex color, the material color (well, colors - there are several of them for different types of response to light) is used. Material colors are specified by
glMaterial*
functions.If you want to reuse your code, you can use
glEnable(GL_COLOR_MATERIAL)
andglColorMaterial(GL_AMBIENT_AND_DIFFUSE)
to have your oldglColor*
calls mapped to material color automatically.(And please switch to shaders as fast as possible - the shader approach is both easier and more powerful)
我想你还没有使用片段着色器。来自 glprogramming.com:
所以是的,不使用顶点颜色。
编辑:您还可以在 GL 规范中查找 GL 闪电方程(您附近有一个,是吗?^^)
I suppose you don't use fragment shader yet. From glprogramming.com:
So yes, vertex color is not used.
Edit: You can also look for GL lightning equation in GL specification (you have one nearby, do you? ^^)