kemu Posted December 20, 2019 Share Posted December 20, 2019 Hi, I'd like to render points with PIXI.DRAW_MODES.POINTS and shaders. But I am not successful in displaying it. A minimul example is shown below.(https://codepen.io/raycast/pen/eYmvRoW) const renderer = new PIXI.autoDetectRenderer(); renderer.view.id = 'pixi-canvas'; document.body.appendChild(renderer.view); const geometry = new PIXI.Geometry() .addAttribute('aVertexPosition', [100, 100, // x, y 100, 200, // x, y 300, 200], // x, y 2) const vertexSrc = ` precision mediump float; attribute vec2 aVertexPosition; uniform mat3 translationMatrix; uniform mat3 projectionMatrix; void main() { gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); }`; const fragmentSrc = ` precision mediump float; void main() { gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); }`; const shader = PIXI.Shader.from(vertexSrc, fragmentSrc, null); const mesh = new PIXI.Mesh(geometry, shader); mesh.drawMode = PIXI.DRAW_MODES.POINTS; // doesn't work // mesh.drawMode = PIXI.DRAW_MODES.TRIANGLES; // works fine const stage = new PIXI.Container(); stage.addChild(mesh); renderer.render(stage); This code in any other PIXI.DRAW_MODE works fine. WebGL Points exsample(https://codepen.io/duhaime/pen/YaRaNX) works too, so I think that the cause of this problem is not my environment. ----- pixi v5.2.0 Windows10 / Chrome79.0.3945.88 ----- I'd really appreciate it if you could give me your advice. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 20, 2019 Share Posted December 20, 2019 (edited) Honestly, I have no idea what can be wrong here. I used POINTS with pixi before , but not in v5. I traced execution flow, placed breakpoints, and it all looks good. https://www.pixiplayground.com/#/edit/jJFqCi-UjS52XYR7VAGyD Spector shows completely normal frame commands: Edited December 20, 2019 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 20, 2019 Share Posted December 20, 2019 Spector output for original codepen is almost the same, so it must be something with initialization process: maybe it doesn't work with VAO's somehow? however early versions of pixi-tilemap used POINTS just fine and they used VAO... Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 20, 2019 Share Posted December 20, 2019 (edited) Oh i've got it. That's what we forgot: gl_PointSize = 1.0; // or 2.0 , or 4.0 https://www.pixiplayground.com/#/edit/jJFqCi-UjS52XYR7VAGyD Edited December 20, 2019 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
kemu Posted December 20, 2019 Author Share Posted December 20, 2019 Oh! Great!! I also confirmed that it works perfectly. Thank you for your prompt support! ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 20, 2019 Share Posted December 20, 2019 (edited) Mine is bigger. Welcome to the forums! Edited December 20, 2019 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.