stencil-buffer

Use of GL_STENCIL_TEST to render concave polygons

余生长醉 提交于 2019-12-17 16:53:30
问题 I'm working on a custom geometry library adapted to Quartz Composer and trying to draw some concave polygons in a Plug In. I implemented the poly2tri library, so the user can choose to triangulate or not, but it's not suitable for a per-frame polygon transformations rendering. I'm a noob in OpenGL and I've been reading and testing a lot, about stencil buffer and odd/even operations, but even code that seem to work for other people, doesn't work for me. The render context is a CGLContextObj,

libgdx open gles 2.0 stencil alpha masking

孤者浪人 提交于 2019-12-13 20:43:21
问题 I'm looking for a solution to implement alpha masking with stencil buffer in libgdx with open gles 2.0. I have managed to implement simple alpha masking with stencil buffer and shaders, where if alpha channel of fragment is greater then some specified value it gets discarted. That works fine. The problem is when I want to use some gradient image mask, or fethered png mask, I don't get what I wanned (I get "filled" rectangle mask with no alpha channel), instead I want smooth fade out mask. I

OpenGL Stenciling, separating ref from value written?

喜你入骨 提交于 2019-12-13 01:14:42
问题 The following code sets up the stencil test to see if ref is greater than the stored value in the stencil buffer, and if it is, it'll write ref to the stencil buffer unsigned int ref = 42; glStencilFunc(GL_GREATER, ref, 0xFF); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); The problem is that while I do want to test the stencil buffer against ref , I don't want to write ref to it if it succeeds, I want to write a totally different value. The only option I've found is GL_INCR which can take the

How to use depth texture with stencil, OpenGL ES 3.0

为君一笑 提交于 2019-12-12 02:38:00
问题 I have an application where I want to render depth to a texture using stencil mask. I try GL_DEPTH_STENCIL_OES: Creating texture: glGenFramebuffers(1, fbo); glBindFramebuffer(GL_FRAMEBUFFER, *fbo); glGenTextures(1, depthTexture); glBindTexture(GL_TEXTURE_2D, *depthTexture); // using combined format: depth + stencil glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, w, h, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR

Issue with masking using Open GL 1.0 stencil buffer in iOs

ε祈祈猫儿з 提交于 2019-12-12 01:52:42
问题 I have been struggling to find a solution for a simple masking using Stencil Buffer in OPEN GL 1.0 on the iOs. I draw the background and then I draw on top of it using glPushMatrix a frame which is drawn using drawFrame. My frame is made of a VideoFrameTexture which I try to mask using maskTexture using the stencil buffer. My objective is to draw only part of the videoFrameTexture (which is defined by the white area of my mask and which corresponds to a circle shape) onto the background. I

Java Using OpenGL Stencil to create Outline

风流意气都作罢 提交于 2019-12-10 20:02:52
问题 I'm trying to render an outline of an object over the top of it but I'm having some difficulties. I'm not too good with OpenGL so most of it was from following tutorials. The desired effect is supposed to be something like this: But this is the outcome at the moment: The code I'm using to do this is: GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_LIGHTING); GL11.glClearStencil(0); GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); GL11.glEnable(GL11.GL_STENCIL_TEST); GL11

Early stencil culling

假如想象 提交于 2019-12-10 17:22:46
问题 I'm trying to get early fragment culling to work, based on the stencil test. My scenario is the following: I have a fragment shader that does a lot of work, but needs to be run only on very few fragments when I render my scene. These fragments can be located pretty much anywhere on the screen (I can't use a scissor to quickly filter out these fragments). In rendering pass 1, I generate a stencil buffer with two possible values. Values will have the following meaning for pass 2: 0: do not do

LibGDX Stencil Buffers while using SpriteBatch

不想你离开。 提交于 2019-12-10 11:17:01
问题 This is a continuation of my previous problem and post, seen here. Thanks to the answer I received there I feel I was able to get a little closer to my goal, as well as further my learning of OpenGL, but shortly after figuring out the basics of working with stencil buffers, I've run into a problem. It seems that when I draw a sprite to the stencil buffer, it draws the entire square area, rather than just the pixels that aren't fully transparent as I had ignorantly hoped. I vaguely understand

OpenGL stencil buffer OR operation?

余生颓废 提交于 2019-12-09 11:59:25
问题 I'm not sure if this is possible to do, but it's worth a shot. I'm using the stencil buffer to reduce overdraw for light volumes in a deferred renderer using this algorithm (when the camera is outside the volume): Using a cheap shader, draw back faces with depth testing set to LEQUAL, marking them in the stencil buffer. Using the expensive lighting shader, draw front faces with depth testing set to GEQUAL. This will cause only pixels within the light volume to be shaded. The problem with this

Does iOS5 support both GL_STENCIL_INDEX and GL_STENCIL_INDEX8?

烈酒焚心 提交于 2019-12-08 20:10:44
With the following code: GLuint viewRenderbuffer, viewFramebuffer, viewDepthbuffer, stencilBuffer; // Create the framebuffer object glGenFramebuffers(1, &viewFramebuffer); glBindFramebuffer(GL_FRAMEBUFFER, viewFramebuffer); // Create a render buffer and bind it to the FBO. glGenRenderbuffers(1, &viewRenderbuffer); glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer); [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)self.layer]; glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, viewRenderbuffer); glGetRenderbufferParameteriv(GL_RENDERBUFFER