Unity projector projecting on other side of object [math required]

I’ve been going over some shader code for projector here and also in the shader code for projector in Unity standard assets and they both have a flaw that they project also on the other side of object like this:

this could be solved if I would check for

dot(normal, vector_to_projector) > 0

however I don’t know of any Unity shader var that would give me projector position. There is unity_Projector matrix but that’s for object->projector space transformation. Now I suspect there might a way to extract the projector world basis vector from that because we also know object->world matrix but my math is not that strong so I could do that.

Any math guru out there or is there more elegant way to check for not-projector-facing fragments?

do you not have the normal in object space ?

i’d consider going a step beyond and multiplying the color by the dot of the normal with the direction vector to the projector clamped to [0, 1]. that way you’ll get the projection fading out as the surface it’s projecting on becomes tangent to the direction of projection.

i’m unfamiliar w/ the matrices involved, but it seems like if you have the normal in object space and a matrix from object space to projector space, you’re good ?