Rendering spheres (or points) in a particle system

后端 未结 3 767
失恋的感觉
失恋的感觉 2021-01-06 19:45

I am using the Three.JS library to display a point cloud in a web brower. The point cloud is generated once at start up and no further points are added or removed. But it do

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-06 20:05

    When comparing my code to http://threejs.org/examples/#webgl_custom_attributes_particles3 I saw the only difference was:

    vec4 outColor = texture2D( texture, gl_PointCoord );
    if ( outColor.a < 0.5 ) discard;
    gl_FragColor = outColor;

    Added to the fragment shader, fixed this problem for me.

    It wasn't z fighting because randomly, some corners would overlap distant particles. material.alphaTest = 0.5 didn't work and turning off depth writes/tests messed up the viewing order.

提交回复
热议问题