Map shadow light position globally

Change-Id: Ic3201cecdf5d2a1dd628e7e40aee912ef516d3b2
This commit is contained in:
Chris Craik
2014-01-16 14:03:39 -08:00
parent c46809e997
commit 3197cded4e
3 changed files with 11 additions and 4 deletions

View File

@@ -3201,8 +3201,8 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp
VertexBuffer spotShadowVertexBuffer;
ShadowTessellator::tessellateSpotShadow(width, height,
getWidth(), getHeight(), casterTransform,
spotShadowVertexBuffer);
*currentTransform(), getWidth(), getHeight(),
casterTransform, spotShadowVertexBuffer);
drawVertexBuffer(spotShadowVertexBuffer, &paint);
return DrawGlInfo::kStatusDrew;

View File

@@ -90,7 +90,7 @@ void ShadowTessellator::tessellateAmbientShadow(float width, float height,
}
void ShadowTessellator::tessellateSpotShadow(float width, float height,
int screenWidth, int screenHeight,
const mat4& receiverTransform, int screenWidth, int screenHeight,
const mat4& casterTransform, VertexBuffer& shadowVertexBuffer) {
const int vertexCount = 4;
Vector3 polygon[vertexCount];
@@ -106,6 +106,13 @@ void ShadowTessellator::tessellateSpotShadow(float width, float height,
#if DEBUG_SHADOW
ALOGD("light center %f %f %f", lightCenter.x, lightCenter.y, lightCenter.z);
#endif
// light position (because it's in local space) needs to compensate for receiver transform
// TODO: should apply to light orientation, not just position
Matrix4 reverseReceiverTransform;
reverseReceiverTransform.loadInverse(receiverTransform);
reverseReceiverTransform.mapPoint3d(lightCenter);
const float lightSize = maximal / 8;
const int lightVertexCount = 16;

View File

@@ -30,7 +30,7 @@ public:
const mat4& casterTransform, VertexBuffer& shadowVertexBuffer);
static void tessellateSpotShadow(float width, float height,
int screenWidth, int screenHeight,
const mat4& receiverTransform, int screenWidth, int screenHeight,
const mat4& casterTransform, VertexBuffer& shadowVertexBuffer);
private: