Commit ef6df8f0 by Nicolas Capens

Fix the light position transformation.

OpenGL transforms the light position by the model-view matrix at the time when that position is specified. Bug 22124687 Change-Id: Ia6bb711c9eb20348faec45c46e45ee9f6ef92112 Reviewed-on: https://swiftshader-review.googlesource.com/3524Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 09cb08b9
......@@ -581,11 +581,17 @@ void Context::setLightSpecular(int index, float r, float g, float b, float a)
void Context::setLightPosition(int index, float x, float y, float z, float w)
{
light[index].position = {x, y, z, w};
sw::float4 v = {x, y, z, w};
// Transform from object coordinates to eye coordinates
v = modelViewStack.current() * v;
light[index].position = {v.x, v.y, v.z, v.w};
}
void Context::setLightDirection(int index, float x, float y, float z)
{
// FIXME: Transform by inverse of 3x3 model-view matrix
light[index].direction = {x, y, z};
}
......@@ -1800,7 +1806,7 @@ void Context::applyState(GLenum drawMode)
device->setEmissiveMaterialSource(sw::MATERIAL_MATERIAL);
device->setProjectionMatrix(projectionStack.current());
device->setViewMatrix(modelViewStack.current());
device->setModelMatrix(modelViewStack.current());
device->setTextureMatrix(0, textureStack0.current());
device->setTextureMatrix(1, textureStack1.current());
device->setTextureTransform(0, textureStack0.isIdentity() ? 0 : 4, false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment