fragment-shader

Can someone please explain this Fragment Shader? It is a Chroma Key Filter (Green screen effect)

徘徊边缘 提交于 2019-11-27 06:09:07
问题 I'm trying to understand how this chroma key filter works. Chroma Key, if you don't know, is a green screen effect. Would someone be able to explain how some of these functions work and what they are doing exactly? float maskY = 0.2989 * colorToReplace.r + 0.5866 * colorToReplace.g + 0.1145 * colorToReplace.b; float maskCr = 0.7132 * (colorToReplace.r - maskY); float maskCb = 0.5647 * (colorToReplace.b - maskY); float Y = 0.2989 * textureColor.r + 0.5866 * textureColor.g + 0.1145 *

How exactly does OpenGL do perspectively correct linear interpolation?

有些话、适合烂在心里 提交于 2019-11-27 01:13:05
If linear interpolation happens during the rasterization stage in the OpenGL pipeline, and the vertices have already been transformed to screen-space, where does the depth information used for perspectively correct interpolation come from? Can anybody give a detailed description of how OpenGL goes from screen-space primitives to fragments with correctly interpolated values? The output of a vertex shader is a four component vector, vec4 gl_Position . From Section 13.6 Coordinate Transformations of core GL 4.4 spec: Clip coordinates for a vertex result from shader execution, which yields a

Drawing a border on a 2d polygon with a fragment shader

大城市里の小女人 提交于 2019-11-26 19:20:02
问题 I have some simple polygons (fewer than 20 vertices) rendering flat on a simple xy plane, using GL_TRIANGLES and a flat color, a 2d simulation. I would like to add a border of variable thickness and a different color to these polygons. I have something implemented using the same vertices and glLineWidth/GL_LINE_LOOP, which works, but is another rendering pass and repeats all the vertex transforms. I think I should be able to do this in the fragment shader using gl_FragCoord and the vertex

Draw Quadratic Curve on GPU

谁说胖子不能爱 提交于 2019-11-26 14:23:56
问题 My task is to render quadratic Bezier curve (path) via Stage3d (Adobe Flash) technology, which have no any extensions for that drawing out-of-the box (while OpenGl have it, as I know). Yea, there is a Starling-Extension-Graphics, but it uses simple method to divide a curve segment to many straight lines, that generates very many triangles for my long curve path. So.. There is a perfect way for rendering resolution independed shapes for Loop and Blinn. I've read GPUGems3 article (gpugems3_ch25