在OpenGL ES的裁剪对象 [英] Clipping object in openGL ES

查看:859
本文介绍了在OpenGL ES的裁剪对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要裁剪和反对我的的OpenGL ES 应用程序,就应该按以下方式进行:

I want to crop and object my openGL ES application, it should be done in the following manner:

左边是原始图像,中间是模板缓存矩阵,右边是结果。

The left is the initial image, middle is the stencil buffer matrix, and right is the result.

从我读到这里:<一href=\"http://stackoverflow.com/questions/8509051/is-discard-bad-for-program-performance-in-opengl?lq=1\">Discard与模板可能有性能问题,
而且从此将被剪切的模型将被旋转和平移,我真的不知道,如果绘制模型将在这些操作之后错误的地方被剪辑了。
会吗?

From what i have read here: Discard with stencil might have performance issues, and since the model that will be clipped is going to be rotated and translated, i honestly don't know if the drawn model will be clipped out in the wrong places after these actions. will it?

于是,我想到了深度缓冲。
同样,一个例子:

So, i thought about depth buffer. Again, an example:

(此照片是由这个<一所href=\"http://stackoverflow.com/questions/11055050/stenciling-using-opengl-es-2-0?rq=1\">question.)

假设黑方是可移动的,并且可能不只是一个简单的方形,而是一个复杂的 UIBezierPath

Assume that the black square is movable, and might not be just a simple square, but a complex UIBezierPath.

我想知道如何使用深度缓冲,让所有的绘制外广场(或 UIBezierPath )将被裁剪掉,意义,调整所有的Z左外像素某一阈值,即不会被显示在屏幕上的数值。

I was wondering about how to use the depth buffer, so that all that is drawn outside the square (or UIBezierPath) will be clipped out, meaning, adjusting all z values of the left out pixels to some threshold value, that wont be shown on screen.

总结一下:

1)将使用模板会作为陈述是昂贵?

1) Will using stencil is going to be expensive as stated?

2)是否有可能一个旋转和平移对象使用的模板,这样它会永远将被吸引?

2) Is it possible to use stencil on a rotated and translated object so that it will always will be drawn?

3)使用深度缓冲,是否有可能发现里面是什么,什么是外广场(或 UIBezierPath ),以及如何?在某种程度上掩盖了?

3) Using depth buffer, Is it possible to find out what is inside and what is outside the square (or UIBezierPath) and how? masking it somehow?

4)什么是更好的方法?

我知道这是一个很多回答,但因为它们都涉及到彼此我认为最好在同样的问题问。

I know it's a lot to answer on but since they all relate to each other i thought it better be asked at the same question.

推荐答案

模板缓存是去这里的道路。在丢弃回答你指的是有关在片段着色器丢弃功能,这是瓷砖基于延迟非常昂贵渲染的GPU(即基本上每个移动GPU)。

The stencil buffer is the way to go here. The discard answer you refer to is about using the discard function in fragment shaders, which is very expensive for tile based deferred rendering GPUs (ie basically every mobile GPU).

使用模板缓存但是很便宜,因为它是在芯片上的每个瓦片present,并且不会延迟渲染干扰。

Using the stencil buffer however is very cheap, as it is present on chip for each tile and does not interfere with deferred rendering.

要总结一下:


  1. 无。

  2. 是,模板缓冲区二维过的转化顶点整个视口工作。已应用它的模型转换后,将夹多维数据集。

  3. 是的,但不用说,这是复杂的,莫名其妙的声音类似体积阴影。

  4. 使用模板缓存。

这篇关于在OpenGL ES的裁剪对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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