I am trying to do a 2D fluid simulation by OpenGL ES 2.0. After reading some books and searching on internet for while. I have some basic ideas, but I am not sure if it's correct. Maybe you can help me on it.
Firstly, I read some book says we can use the Texture as a 2D array, we can get/set the data in fragment shader. Is this what the FBO doing? We can set and get the data by gl_FragData[n]? However, if we store a integer in a texture, how can we set/get data by float?
Secondly, how can we get the right 2D index by gl_FragCoord? As we know, we use the (s,t) to represent the texture coord, but it between [0,1]. If I just want to draw a rectangle, which is (0,0) (0,1) (1,0) (1,0) and the texture is 512*512. How can we get the right 2d index in the fragment shader?
After question is coming from shader Toy http://www.iquilezles.org/apps/shadertoy/
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
I don't quite understand what this line means. I know this is about the position, I think. However, I don't understand why.
Sorry for my poor english.