立方体上无光斑

问题描述:

我已经制作了三种光源和一个立方体

I have made three sources of light and one cube

我在脸上看不到一点光亮.好像整个多边形都被照亮了. 而且我不知道这是可能的并且多维数据集需要更多的多边形,或者mayby的灯光设置是不好的. 我使用的设置.

I don't see a spot of light on faces. It's look like entire polygon is lit. And i don't know is this posible and cube need more polygons or mayby light settings are bad. Settings i use.

glShadeModel(GL_SMOOTH);
glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, 150.0f);
glLightf(GL_LIGHT2, GL_SPOT_EXPONENT, 15.0f);

请记住,固定功能照明方程式仅在三角形的顶点处求值并在片段上进行插值.除非您具有GL_DOT3_RGB纹理的创意,否则不会按像素进行照明.

Remember that the fixed-function lighting equation is only evaluated at the vertices of a triangle and interpolated across the fragment. No per-pixel lighting unless you get creative with GL_DOT3_RGB textures.

因此,如果要在多维数据集上看到漂亮的聚光灯亮点,则需要细分多维数据集的面,使其更接近像素大小:

Therefore if you want to see a nice spotlight highlight on your cube you'll need to subdivide your cube faces so that they're closer to pixel-sized:

还请记住传递合理的每个顶点法线.没有它们,照明效果会不佳:)

Also remember to pass in reasonable per-vertex normals. Lighting doesn't work too well without them :)