2012-09-08 27 views
1

我試圖顯示一些簡單的物體紋理,並啓用我的場景中的聚光燈。我用GLKBaseEffect's紋理&燈。GLKBaseEffect:light + textures

當紋理被禁用 - 我可以看到燈光效果(當我旋轉對象時,它會部分變暗,如預期的那樣)。但是,當我啓用紋理(使用GLKTextureInfo加載紋理並綁定到-(void)glkView:drawInRect:)時,燈光效果消失。

我試過在谷歌搜索和重新閱讀蘋果的文檔,但仍然無法找到答案。

UPDATE:

下面是代碼,我用它來設置光:

_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]; 

如果我兩次撥打該代碼 - 光也會莫名其妙地被禁用。即使沒有紋理 - 第二個電話 - 我根本沒有光。

回答

2

簡單的答案...應該使用_effect.texture2d0.envMode = GLKTextureEnvModeModulate;混合輸入顏色(光的一個)和紋理。

相關問題