iPhone 相机顶部的凹凸贴图
我想用固定纹理对相机图像进行凹凸贴图...
我发现了以下线程: iPhone 上的凹凸贴图
介绍一般凹凸贴图技术。但他们并没有真正提供如何做到这一点的示例或教程。
现在,以防万一,有人知道如何在 iphone 上进行凹凸贴图或如何使用 openGL 修改 iPhone 相机源的好教程吗?
PS:最后最终做了一些不同的事情,即 折射我的图像使用OpenGL ES 2.0折射函数。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
响应您的评论,要将 OpenGL 效果添加到相机输出,您需要使用 AVFoundation,该工具是在 iOS 4 中引入的。它可用于从相机获取实时像素数据,您可以将其作为纹理上传到 OpenGL - 让您随后可以做任何您想做的事情。
如果您原谅我引用我过去提供的答案,开始接收合适缓冲区的基本内容是此处 。
您将在委托方法的辅助线程上接收 CMSampleBuffers:
您可以使用 CMSampleBufferGetImageBuffer 来获取 CVImageBuffer 并从中使用
CVPixelBufferLockBaseAddress
CVPixelBufferGetBaseAddress
,的组合CVPixelBufferGetBytesPerRow
,可能还有CVPixelBufferGetWidth
和CVPixelBufferGetHeight
来获取像素的 C 数组。在我对 iPhone 4 和 iPhone 3GS 进行的测试中,缓冲区仅返回紧密包装(因此,行之间没有填充),这意味着它可以立即作为 GL_BGRA 上传,因为所有 iPhone 都支持 APPLE_texture_format_BGRA8888 扩展日期。从这里开始,您显然需要弄清楚在顶点和片段着色器方面要做什么,具体取决于您是否有法线贴图、您实际上想要影响可见形状的凹凸贴图(如果是的话,是否通过顶点扰动或通过光线投射)或其他方式。
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:
You can use
CMSampleBufferGetImageBuffer
to get a CVImageBuffer and from that use a combination ofCVPixelBufferLockBaseAddress
CVPixelBufferGetBaseAddress
,CVPixelBufferGetBytesPerRow
, and possiblyCVPixelBufferGetWidth
andCVPixelBufferGetHeight
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.