- Home /
WebCamTexture and VSync (iPhone 4)
I've got the camera displaying using the WebCamTexture class, and with a bit of tweaking to the requested width, height and FPS, it everything seemed to run very nicely on an iPhone 4S and an iPad 2.
HOWEVER, the very same code on an iPhone 4 results in horrendous screen tearing. This ONLY affects the WebCamTexture, not other game elements, so it's not a VSync problem with the actual screen, but rather between the camera and the WebCamTexture.
There is a minor amount of tearing on the iPad 2 and iPhone 4S, as well, but it's quite bearable.
I have tried adjusting the WebCamTexture settings available to me, but none seem to affect this.
Is there any way to force a WebCamTexture to only update when the camera has gotten a complete frame? Or am I missing something else that might be causing this?
Answer by cbaltzer · Mar 20, 2012 at 10:08 PM
I've had this issue as well. Performance seems to be very poor with it. The only way I've been able to avoid tearing is to not provide a requested width/height, but only set the frame rate to 30 fps. As a result, the texture ends up being very small (192x144 or something), but doesn't tear.
I'm just curious what settings you've been using if you can get a smooth video feed at a higher resolution?
Answer by Jason-RT-Bond · Mar 21, 2012 at 12:07 AM
I get fairly smooth performance on the iPhone 4S and iPad 2 with the size of the texture set to the screen size (which seems appropriate for AR apps to me) and the frame-rate set to 30 (which I think is the max for those devices).
On the iPhone 4 (not S), I had to set the desired width and height to 16 (which oddly produces something much larger than 16x16 in appearance, though noticeably blurry) in order to avoid the tearing issue. I consider this a bit of a hacky fix (especially since I don't see the direct correspondence between set size and appearance), though, and can't see why we are unable to pull the full camera resolution at 30 FPS without tearing like other camera-centric apps. Maybe this feature is simply buggy as it is new with 3.5? It might explain the sparse (some would say "well-buried") documentation on the subject, although I was hoping that I was just missing something.
Hey. Im trying to display the camera texture in a way that will fill the screen but Im not being able to get it right. Can you share any indication on how you did it?
Answer by cenk5355 · Dec 04, 2012 at 10:30 AM
You can specify the desired dimensions-->new WebcamTexture(Screen.width,Screen.height).After applying this I got the good results. Also you should apply the right values for your background and cam,here is the link that u can have an idea about it:
http://answers.unity3d.com/questions/280467/ipad-camera-aspect-ratio.html#answer-358311
Your answer
Follow this Question
Related Questions
,iOS WebCamera Texture GetPixels() call returns only black colours? 1 Answer
iPad Camera Aspect Ratio 2 Answers
iOS camera and terrain size 0 Answers
How to access Camera Feed (iOS and Android) 1 Answer
Mini Mac - Can this Compile Unity? 2 Answers