how to do particles texture mapping with three.js shaderMaterial?

我与影子孤独终老i 提交于 2019-12-13 06:14:09

问题


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?

来源:https://stackoverflow.com/questions/16436967/how-to-do-particles-texture-mapping-with-three-js-shadermaterial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!