Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0793fe5 authored by Chris Craik's avatar Chris Craik Committed by Android Git Automerger
Browse files

am 8191effc: Merge "Map shadow light position globally"

* commit '8191effc':
  Map shadow light position globally
parents 79d3c59c 8191effc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;
+8 −1
Original line number Diff line number Diff line
@@ -85,7 +85,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];
@@ -101,6 +101,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;

+1 −1
Original line number Diff line number Diff line
@@ -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: