Hello Guest

Author Topic: Sprite has material?  (Read 4650 times)

moofly

  • Guest
Sprite has material?
« on: May 20, 2015, 09:35:53 pm »
Hello,

I've been adding 2dtoolkit sprites from a sprite collection and now looking back I've found that some sprites seem to have material attached to them and that has a shader.  I don't understand why some do and some do not have material components.  They're all from sprite collections (albeit different ones).  The scene that has sprites that have materials attached to them appear to be running very slowly - I don't understand why that is because identical scenes with these different sprites that don't have materials and shaders attached to them and nice and zippy, and take under half the time to render.

Help !

Matt

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite has material?
« Reply #1 on: May 20, 2015, 10:30:39 pm »
All 2D Toolkit sprites have materials attached to them... I'm not sure what you're describing here - screenshots might help?

moofly

  • Guest
Re: Sprite has material?
« Reply #2 on: May 21, 2015, 11:05:02 am »
See attached. 

These are two different backgrounds that are part of my front end.  I created them in the same way (Game Object | 2D Object | tk2d | sprite), but about a month apart.  Has there been an update in versions of 2dtoolkit that I've forgotten about?

The first background, as seen in nomat.png, I created 3 months ago. It does not have a material attached in the inspector.  It renders nice and quick on mobile.

The second background, as seen in mat.png, I created about 6 weeks ago.  It has a material attached in the inspector as you can see.  It renders like a dog on mobile.

I've tried dicing them, not dicing them, removing the material (it just doesn't render then, even though not having a material on the first background does still render - so odd).

Any ideas?
« Last Edit: May 21, 2015, 11:36:52 am by moofly »

moofly

  • Guest
Re: Sprite has material?
« Reply #3 on: May 21, 2015, 02:51:51 pm »
Further to the above reply, I've also done some testing and it doesn't seem to run slowly on my iphone6, just the iPad mini (same specs as an iPad 2), though I don't have many test devices to check it on.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite has material?
« Reply #4 on: May 23, 2015, 12:26:47 pm »
The first one can't possibly draw properly. It has no material and mesh = it will not draw. Are you sure you're not overlapping multiple layers of this somehow?

moofly

  • Guest
Re: Sprite has material?
« Reply #5 on: May 26, 2015, 10:33:53 am »
Ok, you're absolutely right - so sorry to waste your time - I was assuming it didn't have a material, but actually the material doesn't show up if the object (or in my case one of its parents) is deactivated.  So they all have materials.

There's no overlap, but I've realised I have a large hole in that background texture, and a similar shaped ring that goes on top of the first hole, so it might just be plain overdraw causing the problem.  Do you use a different shader if a texture is not fully opaque? (i.e. if you need to alpha test)?  Is it best for me to keep my textures that have alpha in them in one sprite collection, and the fully opaque textures in another?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite has material?
« Reply #6 on: May 26, 2015, 03:53:56 pm »
Look into dicing, that could help loads if you have a large sprite with an almost empty center