- Home /
Mobile camera, take picture and map image to uv coordinates on a model at runtime.
Hey guys, I've been trying to wrap my head around runtime texture swapping. I'd like to be able to access the device's camera, both android and IOS and allow the user to take pictures and map portions of their camera shots to a model, like mapping different user-taken pictures to walls of a level. My initial thought is to create a texture atlas of the different pictures the user takes, maybe save as a texture and allow for swapping/choosing different textures to apply to level geometry.
My questions are as follows:
What's best practice in accessing devices camera's (cross platform) to take pictures? I actually don't mind buying something off the asset store if it's relatively performance-friendly and works across IOS and android.
How should I be planning my code to account for different screen/device resolutions to create a consistent texture atlas across different phones?
Lastly, how do you suggest I approach swapping uv coordinates at runtime to choose different textures for different geometry?
Also I'm thinking of having just a portion of the picture the players take be saved for the texture atlas. Like, maybe the center of the image and the rest get dropped.
Answer by rushikesh988 · Feb 26, 2016 at 06:00 AM
For your first question you can use something called as WebcamTexture . http://docs.unity3d.com/ScriptReference/WebCamTexture.html
To take photo and use its texture you can use:
WebCamTexture webCamTexture = new WebCamTexture();
webCamTexture.Play();
Texture2D PhotoTaken= new Texture2D(webCamTexture.width, webCamTexture.height);
PhotoTaken.SetPixels(webCamTexture.GetPixels());
PhotoTaken.Apply();
Here PhotoTaken is the texture of photo.
Answer by Lanre · May 26, 2016 at 07:16 PM
Although I don't know the answer to most of your questions, I surely know the answer to the first: NatCam. It is a fully cross-platform camera solution specialized for iOS and Android. It is blazing fast, has a ton of normal camera controls (like flash, focus, zoom, torch, and so on) and has amazing support.
Answer by dhruv1905 · Aug 05, 2017 at 10:11 AM
Did you figure this thing? Actually I am working on the same concept in bit different way. If you can help! Thanks.
Your answer
Follow this Question
Related Questions
Blending between two parts of a texture atlas, using another texture atlas as an Alpha Channel 0 Answers
Can someone help me understand Unity uvs? 1 Answer
Do objects have to be UV mapped? 0 Answers
Procedural Mesh UV Problem (UVs 'mirrored' instead of 'repeating') 0 Answers
Creating a mesh programatically for a tile-based 2D game 1 Answer