I'm currently excited about SpriteBatch:attachAttribute function and i'm trying to mock-up some kind of silly mesh instancing based on that function. Now, while attaching VertexColor attribute works completely as i was expecting (i created helper class which allows me to change colors of already existing sprites, for example), i cannot get my head on VertexPosition and VertexTexCoord (sprites become heavily distorted due to wrong vertex attributes).
From what i understand, SpriteBatch itself works as big mesh, but i'm not sure what math should i use to modify VertexPosition and VertexTexCoord.
However, i do get that each time we add new quad or sprite to spritebatch its vertex texture coordinates are calculated based from quad viewport (something like UV = TextureSize/QuadViewportSize ?).
I also would like to know how SpriteBatch mesh works, which mesh type is it (in terms of LOVE mesh type constants), what vertex order each sprite has, or if i ask wrong questions about wrong things.
And yes, i do want to refrain from vertex shader magic for what i want to do.
I saw NoGame screen of 0.10.1 and i can tell that mosaic sprite tinting can be achieved with attachAttribute, but i've tried too look at source code of that screen and found no usage of said function =(
Sorry if i wasn't able to make a clear point, but i'm really interested in how all this work and i think it can be useful to someone else here.
Edit:
I think i've got vertex order, so now i should be able to calculate UV coordinates properly, but i'm still stuck with vertex position transformations with rotation and skew because of my lack of CGI math knowledge
SpriteBatch:attachAttribute() and geometry instancing [SOLVED]
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
SpriteBatch:attachAttribute() and geometry instancing [SOLVED]
Last edited by cval on Wed Apr 27, 2016 7:59 pm, edited 2 times in total.
Re: SpriteBatch:attachAttribute() and geometry instancing
I think i actually made it to work the way i want. However shearing is still unavailable, but feel free to modify code to add shear transormation - i personally have never used it.
Previously i've been asked about why i need anything like that (geometry instancing) in LÖVE, here is an example video:
https://www.youtube.com/watch?v=ySB7Rqo ... e=youtu.be
Those white webbings are actually sprites in the spritebatch, however without geometry instancing or vertex shader magic i couldn't do fade-in of each independent sprite like that. Other way to achieve that is to draw each web segment independently with their own transparency values, but obviously, that is not the most optimal way to draw tons of same sprites.
And yes, those connected with joints to simulate chain-like behavior.
The only problem right now is to deal with situations when SpriteBatch sprite count reaches its buffer limit. In vanilla SpriteBatch you could just set new buffer size, hovewer here i'm forced to recreate internal mesh so that it's vertex count match required SpriteBatch buffer size in order to attachAttribute function to work.
Previously i've been asked about why i need anything like that (geometry instancing) in LÖVE, here is an example video:
https://www.youtube.com/watch?v=ySB7Rqo ... e=youtu.be
Those white webbings are actually sprites in the spritebatch, however without geometry instancing or vertex shader magic i couldn't do fade-in of each independent sprite like that. Other way to achieve that is to draw each web segment independently with their own transparency values, but obviously, that is not the most optimal way to draw tons of same sprites.
And yes, those connected with joints to simulate chain-like behavior.
The only problem right now is to deal with situations when SpriteBatch sprite count reaches its buffer limit. In vanilla SpriteBatch you could just set new buffer size, hovewer here i'm forced to recreate internal mesh so that it's vertex count match required SpriteBatch buffer size in order to attachAttribute function to work.
Re: SpriteBatch:attachAttribute() and geometry instancing
Have you ever thought about bringing your sprite to front or to back relatively to another sprite? Well, now you can.
In the example below, when you use function swapSpriteGeometry() you can switch two sprites with each other and it will bring one to front and one to back without re-creating them.
I think this is going to be last bump of this thread, since i no longer seek help on this matter, can i ask moderator to move thread to appropriate board? Like, "projects and demos" maybe?
In the example below, when you use function swapSpriteGeometry() you can switch two sprites with each other and it will bring one to front and one to back without re-creating them.
I think this is going to be last bump of this thread, since i no longer seek help on this matter, can i ask moderator to move thread to appropriate board? Like, "projects and demos" maybe?
Who is online
Users browsing this forum: YaCy [Bot] and 3 guests