#Sprite renderer mesh fun

1 messages ยท Page 1 of 1 (latest)

grizzled notch
#

if you have padding on all sprites yea.
Also have you profiled to confirm your performance issues are really down to these draw calls/ sprites + transform updates?

#

Sprite renderer mesh fun

lament orbit
#

I can gurantee, removing the child object with the second sprite renderer makes an immense difference

#

and the profiler does confirm, rendering takes up a big chunk of frame time

grizzled notch
#

Is it using Full rect or tight for the mesh gen?

lament orbit
#

Tight

lament orbit
grizzled notch
#

well that will grealy increase the triangles per sprite vs full rect
Full rect will be 2 tris. tight will try to make a mesh to fit the sprite and it can get crazy

#

Check in scene with wireframe enabled

#

and you change the setting on the spritesheet asset

lament orbit
#

well even with full rect, it'd probably be helpful to performance to half the gameobject count, no?

#

Ok I ran test with full rect, it seems no different than before. I think the object count being less is what really makes the difference, but again it seems like a very good way to do that is to make this shader

grizzled notch
#

Do you have scripts on each object and do you move them all around a lot?

lament orbit
grizzled notch
#

200 sprites renderered on quads is not an expensive thing

lament orbit
#

200? If I have 10k objects, and each one has a child then thats 20k in total. Removing the child makes it 10k in total, literally 10k sprite renderers less

grizzled notch
#

ha mb i forgot the number
I wonder if the sheer number of transform recalculations is killing it. This is why sprite renderers are good as they are optimised for this

#

you can also draw instanced meshes yourself and bypass having gameobjects

lament orbit
#

yeah transform updates are guranteed part of the problem

grizzled notch
lament orbit
#

but I was thinking of tackling them later, you can update them in jobs which would help

lament orbit
grizzled notch
#

you dont need a custom shader you can use any current one.
there are many examples of how to use these functions to draw lots of meshes cheaper

lament orbit
#

well this stuff comes with loads of its complications, even if you can get it to run, for example animations (scaling, rotation), animated texture, particle emission etc.

grizzled notch
#

if you have like 20k animated things with animators you are toast ๐Ÿ˜

lament orbit
#

and for simple sprite animation I just cycle the frames in code

#

but you know you inspired me to try this stuff again

#

I just really struggled last time with getting layering, everythign drew behind everything else cause it used the default layer and I was unable to change it

grizzled notch
#

yea with this draw order is what matters so if you can get that right that will do it

#

hope you can get something goin

lament orbit
grizzled notch
#

for a sprite renderer, have a layer on top of everything. Or change the render queue to be much later.

lament orbit
#

so Im stuck with a mesh renderer

grizzled notch
#

you can set render layer in code btw for mesh renderers

lament orbit
grizzled notch
#

and it does this because it no longer writes/tests depth

#

its weird. I "think" it does the same as changing the render order on the material but try both

lament orbit
#

ok I set all of the layer stuff, it still sits behind everything

grizzled notch
#

make sure z is the same for them all

lament orbit
#

yeah its 0 for all sprite renderes and the quad

grizzled notch
#

that influences it too its weird
what did you put the render order to? is it atleast transparent?

lament orbit
grizzled notch
lament orbit
#

what value is for transparent?

#

Found, 3000

#

great it actually renders now ๐Ÿ‘

#

but its the entire spritesheet, unless I make my own shader here how can I tell it to render a single sprite?

#

Also this was to be expected:
InvalidOperationException: Material needs to enable instancing for use with DrawMeshInstanced.

Sprites-default never allowed for instancing