Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - jmcguirk

Pages: [1]
1
Support / Texture Atlas - Split Alpha Channel
« on: September 05, 2013, 12:44:40 am »
Howdy!

First off - a big fan of the tk2d framework. Absolutely could not build our game without it.

Wanted to check about the feasibility of getting something like this in Tk2D

http://www.tasharen.com/forum/index.php?topic=4018.msg19784#msg19784

We're basically struggling with textures that have a ton of alpha, but look like garbage with compression turned on. We've tried a few techniques to improve it, but can't quite get the quality we're looking for - lots of artifacts/bleeding in 0 alpha

It seems like uploading the alpha channel as uncompressed (or maybe even compressed separately) might do the trick - even if its a bit larger on disk and winds up costing us another draw call (or maybe more draw calls since it might break batching?)

2
Support / Unload Textures
« on: July 12, 2013, 11:16:52 pm »
Howdy!

Just upgraded our code base to 2.0 and wanted to get a bit of clarity on best practices around using UnloadTextures

From what I'm seeing, UnloadTextures for a sprite collection loops over the Texture2Ds associated with the collection and calls unload on them. Which is awesome, and I've confirmed in the memory profiler that the memory associated with that atlas is returned.

However, when I later attempt to create a new Tk2DSprite (one from a prefab) that references a sprite in the atlas, I'm seeing the sprite rendered as corrupted.

I think this is because Unity will not Automatically reload the Texture2D for you, and requires you to do another RSC.Load() call to fetch the texture again. I've made some slight tweaks to the SpriteCollection export, process - wondered if you'd agree they're necessary to support Reuse of texture atlases that have been unloaded.

  • Each sprite collection data now has a new field, string textureGuids[]
  • As part of the atlas creation building in the editor, the textureGuids[] are populated with Guids that reference their asset path and a pointer is added to the tk2d index via MakeLoadableAsset.
  • When a Texture atlas has its textures Unloaded, the spriteCollection is marked as being needing to have its atlases reloaded via a static collection that lives in tk2dSpriteCollectionData, indexed by spriteCollectionGuid
  • When a tk2dSprite is awake()'ned, the sprite tells the spriteCollectionData to rebuild itself if its dirty
  • A spriteCollectionData rebuilds itself by looking up all its textures by guid, and populating them into the index-appropriate material main textures

Does this make sense? is there another way to reuse a texture atlas that has been unloaded in this way?

Second question - more broadly, do you think it makes sense to invest in a ref counter autounload with tk2dsprite? E.g. (based on configuration) Automagically eject the texture atlas when the last tk2dsprite referencing that atlas is destroyed()? Then I think we'd wind up with a more intuitive system where the atlas would load/unload only when being used.

3
Support / Tk2D Bundling - Duplicate Memory?
« on: June 18, 2013, 09:33:51 pm »
Hey Folks,

Was wondering if I could get a little help on our TK2D asset bundles.

We're building a mobile trading card game and are using the Spine framework to animate our characters. Skins are created by our artists at 4x resolution and cut up into a series of PNGs. We resize those PNGs into 1x and 2x sizes and create dedicated TK2D sprite collections for each atlas. We then create a dedicated asset bundle for each character that contains the tk2dSpriteCollectionData and some configuration data about the skeleton. We then serve up the appropriate platform bundle to the client at runtime. What we're seeing is Unity is including the original PNGs in the IPA/APK - I think this is because TK2D maintains a reference under Resources/Tk2D to each Atlas thats been created for use by Tk2DSystem. Having the duplicated copy of the texture atlases shipped with the client sorta defeats the purpose of bundling :)

Here's a deep dive of our workflow

http://i.imgur.com/RARAFtj.png

1.) Each skin is imported as a collection of PNGs and propped up into a platform specific tk2d sprite collection.
2.) A prefab is created that joins the rig data, the texture data and some game configuration about the skeleton. This prefab does not live under a resources directory
3.) Platform specific bundles are created that reference the prefab created in #2.
4.) Inspecting the Resources/TK2D shows that there are references maintained that point back at the atlas - this appears to be because Tk2dSpriteCollectionBuilder.cs makes an unnamed loadable object.
5.) Build output confirms that the atlas is indeed bundled with the final build. Even though the only "usage" under a resources directory is the Tk2D index reference.

Outside of creating a dedicated project to build my bundles (which I'm a bit loathe to do since its a logistical pain) - is there any way to get Tk2D to NOT reference these atlases as I'm explicitly managing loading them?

4
Support / Perf Issue W/ tk2dPixelPerfectHelper
« on: April 04, 2013, 04:38:07 pm »
So this started showing up in my scene creation profile as a big CPU hit,

   /// <summary>
   /// Global singleton instance.
   /// </summary>
   public static tk2dPixelPerfectHelper inst
   {
      get
      {
         if (_inst == null)
         {
            _inst = GameObject.FindObjectOfType(typeof(tk2dPixelPerfectHelper)) as tk2dPixelPerfectHelper;
            if (_inst == null)
            {
               return null;
            }
            inst.Setup();
         }
         return _inst;
      }
   }


Since essentially every tk2dsprite or textmesh that gets created or rescaled invokes an ObjectSearch that will never return successfully.

Seems to be safe to kill entirely (obviously you may need to continue to support backwards compat w/ those using tk2dPPH). Might be good to have that search governed by a killswitch

5
Support / Help with Pixel Perfect Coordinates + Multi Resolution
« on: April 02, 2013, 07:28:39 pm »
Hey Folks,

Loving 2dToolkit so far - the platforms lean and the tools are really powerful.

Wanted a bit of guidance on how to setup our scenes appropriately to scale.

- We're trying to build a 2D landscape only game targeting all Major iOS (Post Iphone 3) and Android Phones and Tablets.
- We're looking to crop the scene using the jetpack joyride style of scene composition. Essentially hud is anchored to appropriate parts of the screen and the gameboard is cropped, with some gameplay elements anchored or centered.

http://ma.ne.ro/2012/09/05/dealing-with-multiple-resolutions-in-mobile-games/

- Right now our scenes are being constructed (both art and code) in native resolution 1280x768. This allows us to hit Ipad 1, 2, Iphone 4-5 and galaxy phones. For retina, we're doing a 2x scale up of our assets by detecting and dropping the screen resolution on app initialization. Attached is a bit of a guide on what we're doing. Retina is a 2x forced scale up of the orange square. We do this by dropping the resolution (which means 2D Toolkit views it like an Ipad 1/2 effectively).
- We're using a Tk2dCamera with native resolution 1280x768 and a single wildcard override with Autoscale None, Fitmode Center and a few sprite collections (some with Mips enabled)
- Gameplay elements laid out by code are placed using a mixture of absolute pixel coordinates and absolute pixel coordinates offset by screen size.
- HUD is laid out using the Tk2DUIAnchoring system and is appropriately anchoring the hud based on screen size

The issue we're trying to solve now is the 2x scale up on retina isn't high quality enough. The graphics are pretty blurry, and we're not too happy with it. We'd like to support textures in this resolution natively, and it seems like tk2d can support this with the sprite collection and camera overrides - but I can't quite figure out the right combination of settings.

Ideally what I'd be looking for is

- Gameplay scenes continue to be constructed using 1280x768.
- App init tells tk2dSystem which "platform" to use (1x or 2x)
- Higher resolution sprites are swapped with 1:1 scale when they're available, and use a 2x scale when an appropriate sprite isn't available.

However - what I'm seeing is

- Unity coordinates are 1:1 with screen coordinates (i.e. pixel perfect) in the retina display. This is not shocking I think given that we're attempting to use the Jetpack style of scene composition to enable multiple ARs. Do I need to setup a camera override to enable coordinate scaling? If so - how can I scale the appropriate 3:2 part of the scene? In the attached example, I'd want to scale JUST the 3:2 range.
- Tk2DSystem won't take an existing 1x scale asset and scale it when the platform is set to 2x and no 2x asset is available. Though I suspect this might just be an artifact of how I've got my camera configured.

Pages: [1]