1

I'm attempting to plot an iterative function in OpenGL ES. An array of ints is being updated with how often a given pixel is hit by the iterative function. I'd like to pass this density array to a fragment shader and use it to plot the result on a simple quad covering the whole screen.

My question is: can I pass this array directly to the shader as a uniform and generate pixels by using gl_FragCoord to look up the density for the given position

or

should I rather use the array to create a texture with one channel using GL_LUMINANCE and pass that to the shader?

1 Answer 1

4

You have a limited number of uniforms available, and the indexing might be troubling since not all GPUs support non-constant indexing. A 2D Nx1 texture doesn't have any of these issues but will return values into the [0, 1] range. You can scale back this values to obtain the original integer and use it.

Sign up to request clarification or add additional context in comments.

2 Comments

Why not use a 1D texture instead of 2D 1xN texture? BTW- Could you specify which GPUs don't support non-constant indexing? Would sure be useful to know :)
@Kos: Because OpenGL ES 2.0 doesn't support 1D textures.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.