Single surface help !
Blitz3D Forums/Blitz3D Programming/Single surface help !
| ||
Hi :) Here is the code i have find : But i need two stuff - Delete a sprite - Hide a sprite Anybody can help me ? |
| ||
Well, i think in a single surface code, you shouldn't really try and delete sprites. Since, you will need to re-build the entire surfaces again. Best to just hide it and mark it for non-use, until you need to spawn a new sprite. As for hiding a sprite, simply get all the four verticex and use vertex alpha on them, via the vertexcolor command :o) |
| ||
I have try to make this function but don't work :( I haite single surface system :/ Function AlphaSprite(sprite,Alpha#) s.sprite = Object.sprite(sprite) VertexColor s\surf,s\verti[0],s\r,s\g,s\b,Alpha# VertexColor s\surf,s\verti[1],s\r,s\g,s\b,Alpha# VertexColor s\surf,s\verti[2],s\r,s\g,s\b,Alpha# VertexColor s\surf,s\verti[3],s\r,s\g,s\b,Alpha# End Function |
| ||
I have find it's the entityfx the problem :/ must be 2+32 |
| ||
Oh yeah, you must have that to enable the vertex alpha. Sorry ^_^ |
| ||
You should simply position the unused sprite outside the camera range. Even when not visible vertex alpha 0 quads seems to slow down quite a bit when directly in front of the camera. Strange I know but this is what I've experienced. Stevie |
| ||
Ok many thanks :) |
| ||
Or you can simply place all the vertices for the quad/sprite at a single point and it will not appear, or you could move them out of the view of the camera (behind). |
| ||
Filax, now the z-order is all messed up by using flag 2! =( |
| ||
Ok :) |
| ||
REMOVE THIS |
| ||
Remove what? |
| ||
filax did you get the z-order thing fixed? |
| ||
you might want to test alpha based hiding - im pretty sure when i looked at this a while back - it only worked when you used entity alpha - vertex alpha does not prevent the data being processed..which results in card processing & rejecting or whatever it does with alpha 0 triangles.. Worst case - the card blends the quad triangles - wasting gfx processor time on unseen geom.. Also transparent surfaces are subject to sorting..another slow down.. I very much doubt that mark has a mechanism built in to determine if all the verts have alpha 0! the simplest solution as stated above - move the quad to some insane position - far outside of the view range.. this will result in it being culled..quick n easy.. - dont assume anything ;) |
| ||
It won't be culled. Single surface renders everything in that mesh no matter where it is. I've tried it and the Tris count does not go down. |
| ||
Chroma - b3d will report the tri as being rendered yes.. but infact the card will cull it..b3d reports all the tris in a mesh..when the mesh is in view..it does not and cannot determine which tris are culled by the card without intensive software processing.. When tris are rendered they will be clipped by the gfx card based on the viewing frustrum...per tri.. Dont confuse whats going on in software with whats going on in hardware.. |
| ||
Well that's excellent news then. That means if you want to hide a single surface quad then you could place it at say -50000 on the y axis and it would not be drawn correct? |
| ||
assuming the tri/quad is not within the viewing frustrum, it will be culled by the hardware - so yes... for large complicated meshes leaving this to gfx card is not a good idea - blitz uses bounding volumes to ensure that only meshes in view are sent to gfx card for drawing..the card then determines which tris will be rendered.. Keeping this in mind - one single single surface for all your particles may not be a good idea - instead you might want to consider clusters - consider the max number particles needed for your fx + create single surface groups. When you alter the position of one quad in mesh..the entire mesh is uploaded to the card..nastey.. this is not good, to be fair this will happen only once per render when you are using a single mesh to store your particles. BUT..if the number particles is too high, you will cause a stall. Not that this wont happen with clusters..but you lessen the chances of the stall, you probably wont be using all the clusters at the same time. Note:- you dont need to have create all your quads for a surface before you start - adding tris isnt expensive..3 points are uploaded.. editing vertex data causes the entire surface/mesh to be uploaded..this can be expensive.. you might want to try clusters vs one large surface.. |
| ||
Good advice. May even have a seperate surface for each emittor or area, depending on the particle count. A good way to make sure the quad is out of view, is to take the cameras position and place the quad behind it, or just outside the camera views range, as long as your co-ords are relative to the cameras, to be doubly sure your camera won't see the hidden particles. I wasn't actually aware that the vertex alpha didn't stop the quad from being rendered. Thanks :o) |
| ||
Good advice. May even have a seperate surface for each emittor or area, depending on the particle count. A good way to make sure the quad is out of view, is to take the cameras position and place the quad behind it, or just outside the camera view range, as long as your co-ords are relative to the cameras, to be doubly sure your camera won't see the hidden particles. I wasn't actually aware that the vertex alpha didn't stop the quad from being rendered. Thanks :o) |
| ||
Hi ! Thanks for reply's guys ! i have get a good french single surface library here is the code : But i have alway my Zorder problem :( i have try sort method from code archive (fredborg etc) but nothing work with this library ??? If anybody can help me ? i'll give a TerraEd pro licence to the guy wo can solve Zorder problem :) Here is the particle sprite used : ![]() And an example with Zorder problem : |
| ||
> Delete a sprite > Hide a sprite I switched to rebuilding the mesh each frame. Didn't notice any performance issues and I didn't have to worry about hiding\removing sprites. Nor did I have to set a maximum number of sprites (other than the limit to the number of triangle in a surface). |
| ||
Any idea for Zorder problem ? (sprite behind other's) ? |
| ||
. Last edited 2012 |
| ||
?? Sorry i don't understand, my problem come from my sprite Zorder, there are refresh from the order creation ! I think a solution is to sort the sprite list with a method to sort them with a distance => camera (addfirst & addlast) but all my tests are bugged :( if anybody can help me with this, i'll give to the winner a TerraEd Pro :) |
| ||
. Last edited 2012 |
| ||
. Last edited 2012 |
| ||
Hi :) Thanks for reply ! But, if i understand your function your quad are made with a function, and this function return a 'mesh' (like a sprite) and i can't use this because in a particle engine imagine you have 8000 quad entity ! Under my lib you have only one mesh with dynamic vertex and triangle creation, it's not the same thing ! i have only one entity ! All my vertex are stored under the list, imo the solution is to sort the list from the distance between my vertex => camera ?? Maybe i'm wrong ? but i become crazy with this stuff :/ |
| ||
. Last edited 2012 |
| ||
. Last edited 2012 |
| ||
RGR the serial deleter... :\ Not good man ! |
| ||
RemiD the 10 years old threads Spammer ;-) Even worse man! It is amazing that nowadays everybody knows what other people should do ... |
| ||
Sometimes some people say that i am harsh but i am an amateur compared to you... |
| ||
You will improve ... no doubt ... nobody is a born professional ;-) |
| ||
I try to moderate myself to not be banned ;) |