# Projecting Texture onto surface from point

I am wanting to know if I can use blender to project a texture (from a plane, UV Sphere, object, etc) to another object in a silhouette style?

I have tried to accomplish this with transforming texture coordinates as the attached image shows. (the attached image shows the cycles shader used on Suzanne)

What I would like to do is project the plane onto Suzanne (given here as a reference) so that it is projected from a point (the circle on the right).

I know there are powerful remapping and baking features in Blender, however I am a bit stumped with this one.

Basically I want the rays to hit Suzanne, from a single point, then I can bake them into Suzanne's texture.

I want to do this so I can generate a Matte from a 360º photograph onto a surface. So that I can then composite effects to that surface. Such as crumbling etc. I know that I can accomplish this with texture painting in overlay mode, however I don't think that works with equirectangular images yet.

In the example shown I was thinking I could use an empty as a reference point for the projection, (hence using texture coordinate - which allows access to object) but this isn't working.

I have experimented with UVProject, but this doesn't look to handle 360 textures? http://blenderprops.altervista.org/blender-cycles-double-texture-uvproject-example/

Any help would be most fantastic! You can project an image from a point onto a surface using Vector Maths.

Start with two reference points - one for the source of the projection (L) and another for the centre of the plane (O). The reference points can be defined in the material using a couple of Combine XYZ nodes to generate each as a Vector (representing the position in relating to the world origin). In addition, a third Combine XYZ node can be used to indicate the orientation of the image used in the projection. You can use Drivers to automatically set each of the XYZ elements of the vectors based on the location of an Empty positioned within the scene. In this way you can easily change the reference points simply by re-positioning those reference Emptys rather than having to manually adjust the vectors. For each sample point on the surface we need to determine the vector of the ray from the projection source, through the image plane and to the surface. This can be achieved by subtracting the vector representing the source of the projection from the point on the surface. However, in order to calculate the vector of the ray we need to ensure that each of the points are in the same 'space'. The two reference points are in world space whereas the sample point Object output from the Texture Coordinate node) is in Object space. The Vector Transform node can be used to translate from Object space to World space and we can then simply Subtracting the vectors to calculate the vector of the ray. Note : You must use the Vector Math Subtract node - not the Math Subtract node - for this.

To determine the point in the image texture that would be projected onto any particular point on the surface we need to be able to measure how far the ray travels in specific directions - in the Y direction of the image plane, in the X direction of the image plane, and also the distance travelled perpendicular to the image plane.

The vector between the two reference points (LO) can be used as the 'centreline' of the projection and this will be perpendicular to the image place. It can be calculated simply by subtracting one vector from the other.

The X and Y vectors need to both be perpendicular to the 'centreline' and to each other - to ensure they are independent (ie, at 90 degrees to each other, in the same way as for the the usual X,Y,Z axes in World or Object space). These can be generated by using the Cross Product Vector Math node; the Cross Product takes two vectors and generates a vector that is perpendicular to both of the input vectors. Passing the 'centreline' vector and the Orientation vector into a Cross Product will generate the X vector. Passing the generated X vector and the 'centreline' vector into another Cross Product wiil generate the Y vector. Passing the X and Y vectors through a Vector Math Normalize node ensures they are of unit length (important to ensure the projection is not distorted). To measure each ray we use the Dot Product to determine how far the ray travels in the direction of each of the 3 reference vectors (X,Y,centreline). ie, To measure the distance to the plane where the ray intersects the mesh we can combine the ray with the 'centreline' vector; in the X direction we combine with the X reference vector; in the Y direction we combine with the Y reference vector. All that remains is to scale the measured distances based on the relative distances between the source, the projection plane, and the plane at the intersection of the mesh. ie, if the distance between the source and the plane (L->O) is 1/3 the distance from the source to the plane at the mesh (L->Q) then the vector in the texture plane (O->t) will be 1/3 the length of the equivalent vector (Q->P) at the mesh. This can be achieved using maths nodes to calculate the ratio (the Dot Product and first Divide) and applying the ratio to the measured coordinates (the other Divide nodes). The results are combined into a Vector. The resultant coordinates will be centred around 0,0 but the texture space is from 0.0 to 1.0 - so an additional MixRGB node set to Add is used to add 0.5,0.5,0.5 to the vector to adjust. The result can be used in a Texture node to apply the actual image to the projection. The final material should look something like this :  In the attached Blend file, move the empties to move the reference points of the projection.

The material can be used to drive the surface for a surface projection as shown above, but can also be used to drive Volumetrics which can show the path of the projected rays. I may have found a solution:

Use the image below for the node group of the object to be projection mapped to.

Load into the 'environment texture' node a equirectangular image. Then by using the camera texture co-ordinates as the vector we get the image projected correctly onto any object in camera space.

Then bake the texture to the object by selecting the 'image texture' node (after generating a texture & unwrapping) and select bake from the render menu.

If there are other ways to achieve this let me know.

I am also interested in using non-equirectangular images as well, so I don't know how well this technique would work for that.  