Question

I need to set const spot light position with GLKBaseEffect: so when I change modelview, light stays in the same place. How can I achieve this?

Était-ce utile?

La solution 2

The only solution helped me here was to make own shaders.

Autres conseils

When you set the position of a light using GLKBaseEffect, it uses the value currently stored in its modelviewMatrix property. So, you need to set this value twice, once for the light and once for your object:

self.effect.transform.modelviewMatrix = GLKMatrix4Identity;
self.effect.light1.position = GLKVector4Make(0.0, 1.0, 3.0, 1);

GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -3.0f);
modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, GLKMathDegreesToRadians(90), 0, 1, 0);
self.effect.transform.modelviewMatrix = modelViewMatrix;

That should do the trick

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top