1

我正在尝试显示一些带有纹理的简单对象并在我的场景中启用聚光灯。我使用GLKBaseEffect's纹理和光线。

当纹理被禁用时 - 我可以看到灯光效果(当我旋转对象时,它部分变暗,正如预期的那样)。但是当我启用纹理(加载它们GLKTextureInfo并绑定-(void)glkView:drawInRect:)时 - 灯光效果消失了。

我尝试在 Google 中搜索并重新阅读 Apple 的文档,但仍然找不到答案。

更新:

这是我用来设置灯光的代码:

_effect.lightingType = GLKLightingTypePerPixel;
_effect.lightModelAmbientColor = GLKVector4Make(.3f, .3f, .3f, 1);
_effect.colorMaterialEnabled = GL_TRUE;

_effect.light0.enabled = GL_TRUE;
_effect.light0.spotCutoff = [[PRSettings instance] floatForKey:PRSettingsKeyLightSpotCutoff];
_effect.light0.spotExponent = [[PRSettings instance] floatForKey:PRSettingsKeyLightExponent];
_effect.light0.diffuseColor = _effect.light0.specularColor = GLKVector4Make(1, 1, 1, 1);
_effect.light0.position = GLKVector4Make(0, 0, 0, 1);
[_effect prepareToDraw];

如果我两次调用此代码 - 灯会以某种方式被禁用。即使没有纹理 - 第二次调用 - 我根本没有光。

4

1 回答 1

2

简单的答案...应该_effect.texture2d0.envMode = GLKTextureEnvModeModulate;用来混合输入颜色(灯光)和纹理。

于 2012-09-14T08:42:08.583 回答