How to project a 3D object to a 2D plane?

Hi!
I have a 3D object, and I want to project it to the ground from above. I want to have a 2D representation of it, like an outline. How can I do this?

The typical approach to this is very similar to how lights work. What you’re effectively wanting is to project a special type of shadow, for just 1 object, onto the scene. Unlike spot lights however you don’t want the shadow to shrink as the object moves further from the light.

While its entirely doable, what it involves is rendering the object into a texture to give you silhouette of the object from a certain angle (in your case this would be a top down camera as you are projecting onto the ground). You then have a post processing shader that calculates the world space location of each pixel on the screen, works out if that is inside the bounds of the projected object, samples your generated texture at the correct point and chooses whether to colour the pixel differently based on whether it sits below the silhoutte of the object!

I explained that very quick, cos the main thing I was gonna say was that for effects like this you really need unity pro (as you need to do render to texture and post effect based shaders). I’m happy to explain in more detail, but thought I’d check first!

If you don’t have unity pro I’d recommend messing around with positioning a light above your object so that its shadow is projected onto the ground.

(edit) thinking about it, if you don’t have unity pro you might start by making a copy of the mesh and creating a pair of shaders that:

  • squash every vertex so its flat!
  • colour every pixel black (or your colour of choice)

Then position your mesh just above the ground. If the ground is flat it just might work!

(double edit!) and to prototype that idea without messing around with shaders - copy your mesh, give it a material that is totally black and scale it really small in the y axis.