Explosion shader (code & video)

@yojimbo2000 i did not manage to make it work. No error message, but does not do what i hoped. I set the m.texCoords=verts is that right?

no, m.vertices is for verts, m.texCoords is for texture positions

@yojimbo2000 If i use verts = m:buffer(“position”) to get the vertex positions. I don’t seem to be able to use #verts to count the number of vertices. Any ideas why that does not work?

No, don’t use a buffer for position. Buffers are only for custom attributes, not the built-in ones that the Codea api sets up for you (vertices → position, texCoords, normals, colors). Use myMesh.vertices or the vertex method to access the position attribute.

To get the size, you can use myMesh.size or #myMesh.vertices

That’s so you can change them dynamically, eg if you have a set of separate objects in a single mesh and need to change their positions each frame

Ahhh, thanks

@yojimbo2000 - that’s not right - buffers are available for all the built in attributes, see the examples in the reference

https://codea.io/reference/Shaders.html#buffer

Oh ok. Not sure why you’d want to for the built-in attributes.

Sure, but you can do that by referring directly to the built-in myMesh.vertices table, or using the vertex command. I don’t see any need to set up another buffer variable.

you might want to check comparative speed. My understanding is that buffers allow you to change values “in place” which should be faster