How can I do these image processing tasks using OpenGL ES 2.0 shaders?

I just added filters to my open source GPUImage framework that perform three of the four processing tasks you describe (swirling, sketch filtering, and converting to an oil painting). While I don’t yet have colorspace transforms as filters, I do have the ability to apply a matrix to transform colors. As examples of these filters … Read more

How to debug a GLSL shader?

You can’t easily communicate back to the CPU from within GLSL. Using glslDevil or other tools is your best bet. A printf would require trying to get back to the CPU from the GPU running the GLSL code. Instead, you can try pushing ahead to the display. Instead of trying to output text, output something … Read more

What is state-of-the-art for text rendering in OpenGL as of version 4.1? [closed]

Rendering outlines, unless you render only a dozen characters total, remains a “no go” due to the number of vertices needed per character to approximate curvature. Though there have been approaches to evaluate bezier curves in the pixel shader instead, these suffer from not being easily antialiased, which is trivial using a distance-map-textured quad, and … Read more

How to calculate Tangent and Binormal?

The relevant input data to your problem are the texture coordinates. Tangent and Binormal are vectors locally parallel to the object’s surface. And in the case of normal mapping they’re describing the local orientation of the normal texture. So you have to calculate the direction (in the model’s space) in which the texturing vectors point. … Read more

In a fragment shader, why can’t I use a flat input integer to index a uniform array of sampler2D?

[…] but can’t use it to index an array of samplers as expected because compiler sees it as “non-constant” […] In GLSL up to version 3.30 respectively GLSL ES up to version 3.00, the index of an array of texture samplers has to be a constant expression: GLSL 3.30 Specification – 4.1.7 Samplers (page 21) … Read more

Why is the sprite not rendering in OpenGL?

You have to initialize the model matrix variable glm::mat4 model. The glm API documentation refers to The OpenGL Shading Language specification 4.20. 5.4.2 Vector and Matrix Constructors If there is a single scalar parameter to a vector constructor, it is used to initialize all components of the constructed vector to that scalar’s value. If there … Read more

How to recover view space position given view space depth value and ndc xy

3 Solutions to recover view space position in perspective projection The projection matrix describes the mapping from 3D points of a scene, to 2D points of the viewport. It transforms from view (eye) space to the clip space, and the coordinates in the clip space are transformed to the normalized device coordinates (NDC) by dividing … Read more

Passing a list of values to fragment shader

There are currently 4 ways to do this: standard 1D textures, buffer textures, uniform buffers, and shader storage buffers. 1D Textures With this method, you use glTex(Sub)Image1D to fill a 1D texture with your data. Since your data is just an array of floats, your image format should be GL_R32F. You then access it in … Read more

How does the calculation of the light model work in a shader program?

Lambertian reflectance model To model the reflection of light in computer graphics is used a Bidirectional reflectance distribution function (BRDF). BRDF is a function that gives the relation between the light reflected along an outgoing direction and the light incident from an incoming direction. A perfect diffuse surface has a BRDF that has the same … Read more