凹凸映射在iPhone相机的顶部 [英] Bump Mapping on top of iPhone Camera

查看:218
本文介绍了凹凸映射在iPhone相机的顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我找到了以下主题:
iPhone上的凹凸贴图



映射技术。但他们没有真正有例子或教程如何做。



现在,为了防万一,任何人都知道如何颠簸映射的好教程iphone或者如何使用openGL修改iPhone相机源?



PS:最后最终做了不同的事情,即使用OpenGL ES 2.0折射函数折射我的图像

解决方案

响应你的评论,要添加OpenGL效果到相机输出,你需要使用AVFoundation,这是在iOS 4中引入的。这可以用于获得一个活馈像素数据从相机,你可以上传到OpenGL作为纹理 - 允许你做任何你想要的随后。



如果你会原谅我引用答案我在过去提供的基本资料,开始接收合适的缓冲区是这里



您将在委托方法中的辅助线程上收到CMSampleBuffers:

   - (void)captureOutput: (AVCaptureOutput *)captureOutput 
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection



您可以使用 CMSampleBufferGetImageBuffer 获取 CVImageBuffer ,从中使用 CVPixelBufferLockBaseAddress CVPixelBufferGetBaseAddress CVPixelBufferGetBytesPerRow ,可能还有 CVPixelBufferGetWidth CVPixelBufferGetHeight 以获得像素的C数组。在我测试的iPhone 4和iPhone 3GS,缓冲区只有回来紧凑包装(所以,线之间没有填充),意味着它可以立即上传为GL_BGRA,因为APPLE_texture_format_BGRA8888扩展是支持所有iPhone日期。



从那里,你明显需要弄明白在顶点和片段着色器上做什么,取决于你是否有一个法线贴图,凹凸贴图实际上想要影响可见形状(如果是,是否通过顶点扰动或通过光线投射)或其他。


I want to bump-map the cameras images with a fixed texture...

I found the following thread: Bump Mapping on the iPhone

on general bump-mapping techniques. But they didn't really have examples or tutorials on how to do it.

Now , just in case, does anyone know about good tutorials on how to bump-map on the iphone or on how to modify the iPhone Camera feed with openGL?

PS: Finally ended up doing something different, i.e. refracting my Image using the OpenGL ES 2.0 refract function.

解决方案

Responding to your comment, to add OpenGL effects to camera outputs you need to use AVFoundation, which was introduced in iOS 4. That can be used to get a live feed of pixel data from the camera, which you can upload to OpenGL as a texture — allowing you to do whatever you want subsequently.

If you'll forgive me referencing an answer I've supplied in the past, basic stuff to start receiving a suitable buffer is here.

You'll receive CMSampleBuffers on a secondary thread in your delegate method:

- (void)captureOutput:(AVCaptureOutput *)captureOutput 
     didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer 
     fromConnection:(AVCaptureConnection *)connection

You can use CMSampleBufferGetImageBuffer to get a CVImageBuffer and from that use a combination of CVPixelBufferLockBaseAddress CVPixelBufferGetBaseAddress, CVPixelBufferGetBytesPerRow, and possibly CVPixelBufferGetWidth and CVPixelBufferGetHeight to get at a C array of the pixels. In my testing across an iPhone 4 and an iPhone 3GS, the buffer has only ever come back tightly packed (so, no padding between lines), meaning that it can be uploaded immediately as GL_BGRA, since the APPLE_texture_format_BGRA8888 extension is supported on all iPhones to date.

From there you obviously need to figure out what to do in terms of vertex and fragment shaders, depending on whether you have a normal map, a bump map that you actually want to affect visible shape (and, if so, whether by vertex perturbance or by ray casting) or something else.

这篇关于凹凸映射在iPhone相机的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆