0

what I'm trying to achieve is having a particle system where each particle have a portion of a given texture. Below is a example of a particles's buffergeometry using a shader material. so far I can make it look almost as it should, nonetheless, I dont know how to properly program the fragment shader in order to have the correct offset of the texture on each particle. the texture is 500x500px which is the same amount of particles.

http://www.pruebasmemo.co.nf/

fragment shader code:

 uniform sampler2D map;


      void main() {



                vec2 T = gl_FragCoord.xy;

                gl_FragColor = texture2D( map, gl_PointCoord / T + 0.5);
        }

a bonus question is: why the particles get smaller as you zoom in?

bytecode77
  • 14,163
  • 30
  • 110
  • 141
Memo Lestas
  • 393
  • 1
  • 4
  • 13
  • I guess it is impossible to achieve this (http://stackoverflow.com/questions/15697898/why-particle-system-with-shader-doesnt-work-three-js) Answer for your second question - they don't get smaller, they preserve same size on all zoom levels, if you want them to get bigger you have to implement it manually using shader. – dIsoVi May 08 '13 at 10:11
  • Sorry, I haven't noticed that it was your post. ParticleSystem reference in this question had confused me. In previous question it was mentionted that you shouldn't use ParticleSystem in this case. That means also not to use it together with BufferedGeometry. If you wish to have different texture for each particle, use simple mesh and shaders. Here is a great tutorial to achieve what you want http://www.html5rocks.com/en/tutorials/webgl/million_letters/?redirect_from_locale=de. – dIsoVi May 08 '13 at 11:54
  • @dlsoVi So I udpate the fragment shader code and now it looks a little bit more like what am looking for – Memo Lestas May 09 '13 at 10:44
  • @Tapio can you tell me what am I doing wrong? cheers – Memo Lestas May 09 '13 at 12:31

0 Answers0