Project UV from Camera v1.60

Project UV from Camera” is a new Asset that allow you to project gameObject(s) UVs from camera screen space. This can be usefull if you want the gamer to project a precise planar mapping over one or many meshes. This package was done in C#. A full API support is available, but no need to have specials developer skills to use it… One button, and it’s done. This asset can be used for camera mapping in Unity.

Works on Unity pro and free (mobile and desktop)

Features :

  • Project with one button the UVs from camera to object(s)
  • Realtime or manual projection (even in editor)
  • Planar and spherical projection
  • Precise projection for spherical mapping
  • UV Tiling
  • Project from whatever camera
  • Project on single or multiple sub-objects
  • Optional GUI watermark to preview the projection over the object(s)
  • Keep the watermark texture aspect ratio or fill the entire screen
  • Set up watermark opacity
  • Restore original UVs with a single backup button or by deleting component
  • Instantiate meshes if needed
  • Full script API support
  • Minimum updates mode (optimize CPU usage)
  • Layer filter
  • Mirror UVs
  • UV channel choice to project (UV1 to UV4)
  • SkinMesh support

Video demo 1 / Video demo 2
Webplayer demo

EDIT v1.2 : NEW SPHERICAL PROJECTION for spherical environment mapping.
Spherical projection
EDIT v1.23 : NEW MINIMUM UPDATES MODE (avoid useless cpu peaks when possible)
LAYER FILTER (filter sub-objects projection by layer)
EDIT v1.3 : Nth FRAME PROJECTION MODE : allow to project every nth frames. This ensure to spare cpu for realtime projections that doesn’t need very high frequencies.
SPECIAL OCULUS RIFT MODE
EDIT v1.5 : Full source code included
EDIT v1.55 : SkinMesh support

Available on Asset Store : Unity Asset Store - The Best Assets for Game Making

Feel free to suggest new features…

1585651--94873--$Screenshot1.jpg 1585651--94875--$Screenshot2.jpg 1585651--94876--$Screenshot3.jpg

Hi !
awesome script ! I 'm very interested by a additional spherical and panorama mapping project uv, it’s possible ? thanks
(sorry if my english is bad im french )

This is really cool, do you think an automatic mapping function similar to the generate UVs function within the import mesh options would be possible?

Projecting cylindrical or spherical mapping from camera screen space strictly is impossible (camera screen space is flat, not spherical or cylindrical).
But, projecting a classical cylindrical or spherical mapping on the object might be possible. I will consider this feature may be for a next version.

(I’m french too)

You mean an automatic projection on mesh import ?

This could be interesting for the projection mapping research I’m doing.
Is it possible to have the projection cast shadows?

No. It’s not possible to project shadows like a light would do.The package project UV coordinates, not a texture. So your textures (whatever it is) will “look like” it’s projected from the camera. The main advantage is that you can keep every texture you like, and every shader you wish. And above all, you can do camera mapping.

The UV projected does not condition the contents of the texture the mesh has. It just drives the way the texture is wrapped on it.

I suspected as much, thanks for explaining.
So in theory I could render a depth texture from the projector camera and use a shader on the object(s) that does depth testing to achieve shadows.

Yes, this might be possible. I’ve quickly “photoshoped” a process which could work also :

That’s a serie of render to texture, then processing the bitmap (via shader) to obtain a product of two bitmaps that you can easily use as a texture mapping on your object(s). You then only need to project UVs with “Project UV from Camera” to camera map the view. Et voilà.

Didn’t tried, but theoricaly this should do the trick… at least it works in Photoshop.

Hehehe, awesome gfx!
If I get things to work I’ll definitely post about it here.

New to v1.2 : SPHERICAL PROJECTION added.

(Thanks to Alex)

Nice effect!
Btw, in that video it looks like your camera control and uv scripts have a little execution order problem, causing the uv’s to shake when you move the camera.

Nothing really fancy. Everything is computed by CPU (+ the video capture). The scene has nearly 30 000 vertices to reset UVs each frame. This is quite expansive.

This asset is great; thanks for all your hard work!

Do you plan to create a version that utilizes the GPU instead of the CPU? This would be much better for real-time use.

Yes, I plan it, but not everything will be possible (precise spherical mapping for example since it need the mesh to be altered). The gain of speed would be very interesting but there is an ugly drawback from my point of view : this would need a specific shader to operate. With the actual “cpu version”, there is no need to change the scene, the mesh or the materials to work. For non realtime projection, this “cpu version” is perfect, but for realtime… yes I would definitively think about a “gpu mode” (with some disadvantages it would bring). the next version will certainly bring this enhancement, but I try to maintain the usability Project UV already has.

… Do not hesitate to give 5 stars if you like it :wink:
Many thanks !

@Cec,
Can you add OnDemand realtime projection. I do not want to update the UVs every frame. I want to Project UV once and use it. Is this possible in current version ?

Thanks.

This feature already exists… you just need to read the doc :
http://projectuv.graphiste3d.net/class_project_u_v.htm#ab443fb85be3e5d5b2a08f8869973fe19
Project() method let you project manually on demand the UV set.

New features in v1.23 :
Minumum updates mode : Optimize CPU usage when possible, and limit projections if not necessary. This avoid dramatical useless CPU peaks.
Layer filter : Allow you to filter projection of some sub-objects by layer. This feature is quite usefull when there is a complex nested parenting of sub-objects whom UV projections need to be filtered.

New feature in v1.25 :
Mirror UVs : You can mirror etiher on X, Y or both axis the UV layout.

Thanks to Patrik for suggesting this feature. Do not hesitate to suggest some new ones.