Im trying to use a 1D texture from Opengl
to fill it with the position of the particles to be rendred by the shader . I have no i idea how to do it , can someone tell me ( or give me a code example in C/C++
/ glsl-glsl-es
) how to define a 1D texture with the reqiured properities and how to fill it with a float array and how to use it from the shader .
Asked
Active
Viewed 48 times
0

Dhia Hassen
- 508
- 4
- 20
-
Why are you using a 1D texture as the source for particle positions, instead of vertex attributes? – Nicol Bolas Oct 14 '16 at 05:55
-
because i will send an array of positions to the shaders , i will compile it on android ( trying to target all gles versions) , and mainly im doing this method because that is what i have been told from here : http://stackoverflow.com/questions/7954927/glsl-passing-a-list-of-values-to-fragment-shader# , or should i do something else ? – Dhia Hassen Oct 14 '16 at 05:57
-
2That was a question about sending arrays to *fragment shaders*. The positions of particles are processed by *vertex shaders*. You have access to vertex attributes in a vertex shader. Why would you not simply pass the positions as [per-vertex data](https://www.opengl.org/wiki/Vertex_Specification)? – Nicol Bolas Oct 14 '16 at 06:07
-
dude im the asking here , just tell me how hh XD – Dhia Hassen Oct 14 '16 at 08:32
-
note im using opengl 4 on desktop & gles 2.x on android – Dhia Hassen Oct 14 '16 at 08:33
-
i understand what u mean , i thought that i have to use the fragment shader by drawing circle in each particle's position , by computing the distance between the current fragment and the each particle and if it is less than particle_size i put a color if not i leave it blank and i have to do that to all screen fragments , any better method ? – Dhia Hassen Oct 14 '16 at 11:45
-
Yes, e.g. render a point sprite for each particle. – Nico Schertler Oct 14 '16 at 18:56
-
thank you , i found that on google , but no details , where can i find an example or a tutorial plz – Dhia Hassen Oct 14 '16 at 21:13