Search Unity

SpriteTile, a fast dynamic tile system (RELEASED)

Discussion in 'Assets and Asset Store' started by Eric5h5, Dec 11, 2013.

  1. mcwool

    mcwool

    Joined:
    Jan 8, 2014
    Posts:
    14
    That would be great, thank you. I can live with it in those few scripts, the annoying part was just when I updated other assets and had to search and replace a lot. And that will reappear every time I update those assets.

    Thanks again.

    //Mcwool
     
  2. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    What I don't get about that though is there shouldn't be any transparent geometry, I've got the non-transparent setting ticked for those tiles, and it's scrolling a solid area of those tiles no gaps.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Take "Queue"="Transparent" out of the non-transparent shaders; that seems to make Unity classify it as a transparent shader even though it's using RenderType = Opaque.

    --Eric
     
  4. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    How do I do that? I clicked on "Show code" for the sprites diffuse non-transparent shader, and then I removed "Queue"="Transparent" from the tags list and saved it but when I clicked on "Show code" "Queue"="Transparent" had reappeared.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Edit the shaders in the project. Note that this won't make any difference in rendering, just what the profiler reports it under.

    --Eric
     
  6. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    How do I edit the shaders for the project?
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    They're just text files, so edit them in a text editor.

    --Eric
     
  8. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    How do I change the actual source of the shader though? all it seems I can change is the compiled text, and when I remove the "Queue"="Transparent" and save the file, it just appears again when I reload the compiled code.
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Edit the shader file with a text editor. Don't click on any buttons in Unity, just edit the shader like you edit a script.

    --Eric
     
  10. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    Did that, and I got about 15-20 fps back, but when I went into my game, where I'm displaying some tiles as a test, they have all gone completely transparent even though their collision is still there, as you can see in the image (the wizard is standing on top of invisible tiles, which were visible before). I've also attached an image of the SpriteTile editor so you can see the settings for the tiles that should be (and were) visible.


     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Well, by putting the non-transparent shader in a different rendering queue, then it won't be sorted with the transparent queue. Either put it back the way it was, or make a custom shader for the default material that's also not in the transparent queue (though that may have other side effects with other objects...and this is why things are the way they are by default).

    --Eric
     
  12. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    Thanks for the info, I was hoping SpriteTile would allow me to run a full screen tileset at around 60 fps with at least one light out of the box, because I don't have time right now to get into coding shaders. Thanks anyway.
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's not "coding shaders", just a matter of opening a shader file and taking out "Queue"="Transparent". In any case, it would depend on your hardware, but with a pixel light and diffuse transparent shaders, I get ~500fps here (a little over 1ms for CPU and GPU). That's in the editor; I assume a build is faster.

    --Eric
     
  14. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    "just a matter of opening a shader file and taking out "Queue"="Transparent"" that's what I did, and it gave me another 15-20 fps, but like I said (and you can see in the screenshots) all my foreground tiles disappeared! :) Have you got a demo project of the build you just described? I could then run it and see the difference in fps performance. I'm on a 2011 Mac Mini.
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, I'm referring to "make a custom shader for the default material that's also not in the transparent queue". "Make a custom shader" means "taking out queue = transparent", since that's what we were talking about, not creating one from scratch or something. The project was the gem hunt demo, where I put in a spotlight and changed all the tiles to use pixel lighting.

    --Eric
     
  16. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    Think I may have found a bug.
    When attempting to use GrabSprite while specifying a layer, the console keeps throwing "Invalid layer id" errors... but the grab works and returns a GameObject nonetheless. (And I know the layer id I'm specifying is valid, and I use the same id successfully with other functions).

    Code (csharp):
    1.  
    2. // I get an Int2 into variable thisTilePosition, then...
    3.  
    4. TileInfo thisTileInfo = Tile.GetTile(thisTilePosition, 5) // This works fine even though the same layer is specified as below
    5. if (thisTileInfo.tile != -1) // tile == -1 is supposed to indicate the tile is empty...so only proceed if it is not empty
    6. {
    7.     GameObject temporaryObject = Tile.GrabSprite(thisTilePosition, 5, false); // This throws the invalid layer error
    8.     // etc etc I do stuff with the temporaryObject here...
    9. }
    10.  
     
    Last edited: Jan 29, 2016
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, there's a fix for that in the next version; it has to do with changes in the way Unity handles layers in more recent versions. PM me (with your invoice ID) if you want the current scripts.

    --Eric
     
  18. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    I've been working on a problem of how to rotate an Int2 which represents a direction in the SpriteTile world, and haven't found a good solution yet.
    I want to rotate an input direction in a particular direction around its origin (0,0) based on a rotation Int2 that assumes (1,0) is "forward". So, if I input any Int2 direction (say 4,0) and apply the rotation (1,0) to it, the Int2 doesn't change (4,0).
    But if I were input the same Int2 (4,0) and apply the rotation (1,1) this should effectively rotate the input by 45 degrees counter-clockwise, outputting (4,4).
    At first I was only dealing with inputs of a fixed length (like 1,1 or 0,-1), so I just created a long series of if-statements to do this rotation. But now I want to input arbitrarily longer directions (like 4,0) so the hundreds of if-statements necessary are no longer feasible.
    Thought about converting to a Vector2 and simply rotating the Vector2 around the origin by degrees. But, of course, a vector retains its original magnitude through a rotation, and in a 2D grid world, (1,1) should be considered "effectively" the same magnitude as (1,0) - impossible with rotated vectors, where (1,1) has a greater magnitude than (1,0).
    After some research, I suspect I need some kind of bitwise rotation matrix, but that's out of my league mathematically. This might be a long shot, but would anyone here know what might be a good starting place for this problem?
     
    Last edited: Jan 31, 2016
  19. Kaven-Co-Games

    Kaven-Co-Games

    Joined:
    Jun 3, 2014
    Posts:
    19
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's just using the standard file browser; SpriteTile can't do anything special in this area even if it wanted to. I would guess you're looking in a different project.

    --Eric
     
  21. Kaven-Co-Games

    Kaven-Co-Games

    Joined:
    Jun 3, 2014
    Posts:
    19
    Im not though, very much the same directory. Ugh. I've tried reloading it and such. I dont get it >_<
     
  22. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah, me neither...unfortunately I'm not sure what else to say. If the standard OS file browser isn't showing correct files, there's not much I can do. I have to assume that's a Windows bug. Maybe restart the computer, and it might clear out some sort of file cache or something?

    --Eric
     
  23. bml

    bml

    Joined:
    Jun 5, 2013
    Posts:
    15
    @Eric5h5

    Looks like there's a namespace conflict with UnityEngine.SceneManagement.SceneManager and SpriteTile's SceneManager starting with 5.3. Tested with a new project.

    Assets/Test.cs(8,40): error CS0117: `SceneManager' does not contain a definition for `GetActiveScene'

    using UnityEngine;
    using System.Collections;
    using UnityEngine.SceneManagement;

    public class Test : MonoBehaviour {

    void Start(){
    Debug.Log(SceneManager.GetActiveScene().name);
    }
    }

    Work around:

    Explicitly use UnityEngine.SceneManagement.SceneManager.

    Thanks!
    bml
     
    Nixaan likes this.
  24. Lordinarius

    Lordinarius

    Joined:
    Sep 3, 2012
    Posts:
    94
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    1. Neither; it creates enough sprites to fill the camera view, and recycles them as the camera moves.
    2. You can use the SetColor function.
    3. It has terrain groups, which looks similar.

    --Eric
     
  26. Kaven-Co-Games

    Kaven-Co-Games

    Joined:
    Jun 3, 2014
    Posts:
    19
    You were completely right Eric(in reference to my previous posts) Idk why I had a copy of the same directory I was looking into, such a blunder on my end :c!)

    I was wondering if there was a way to change the actual layers of the gameobjects of the tiles; I am not referring to the render layer.
    https://gyazo.com/076fb77a1ba36bf4c75c2e09d48ad9fb

    On a side note, thanks to SpriteTile I've been getting a lot of work done, and now I am able to visualize these excellent structures for my game. Thank you for your amazing asset!
    https://gyazo.com/b87b912f55d0abc59e3081da23f8eeb8
     
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use SetTileRenderLayer for "actual" layers. Glad to hear you got it sorted!

    --Eric
     
  28. guitarman1209

    guitarman1209

    Joined:
    Aug 17, 2014
    Posts:
    2
    Hello there,

    When attempting to use this with a 2D NGUI Camera my map is really big... Huge. Is there something I must do to scale it to be pixel perfect?

    I'm using a rather large tileset with each tile at 32x32. I have my pixels per unit set at 32... Is this correct?
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's what I'd do; that way each tile will be 1 unit. I'm not familiar with a 2D NGUI camera so I'm afraid I don't really know what to advise.

    --Eric
     
  30. Kaven-Co-Games

    Kaven-Co-Games

    Joined:
    Jun 3, 2014
    Posts:
    19
    So I have a question, say I am procedural generating a level, how do I store the information of the level in an object so I can re-access the same level later? (I cant just regen with the same seed because tiles change as gameplay develops.
     
  31. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Use GetLevelBytes and then save the byte array using WriteAllBytes or similar.

    --Eric
     
  32. bitbiome_llc

    bitbiome_llc

    Joined:
    Aug 3, 2015
    Posts:
    58
    Hello Eric,

    Is there a way to deal with diagonal stripes of light sources on tiles? I have the same result with/without a normals material and with various light sources and property settings. Or is this a general light issue unrelated to SpriteTile?

    http://imgur.com/LTY4x0x
     
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Hi, I'm not really sure what you mean by diagonal stripes. Since the tiles in SpriteTile are just sprites, whatever lighting you might do is the same as it would be with any other sprite.

    --Eric
     
  34. bitbiome_llc

    bitbiome_llc

    Joined:
    Aug 3, 2015
    Posts:
    58
    Here is a better example of what I'm trying to prevent. Sounds like I should move the question to the lighting area, thanks.

    This happens with the material settings
    • Pixel Lighting
    • Pixel Lighting + Non-Transparent
    As mentioned before it does the same thing with custom materials.

    I am running Unity 5.3.2p3.

    http://imgur.com/j0jXnKS

     
    Last edited: Feb 19, 2016
  35. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Looks like you're using vertex lighting rather than pixel lighting.

    --Eric
     
  36. bitbiome_llc

    bitbiome_llc

    Joined:
    Aug 3, 2015
    Posts:
    58
    Yeah, I can't seem to change it at all. I created a new project and lighting works like it should. Not excited to move everything into a new project but I can't seem to get my current project to do any different type of lighting.

    OMG. I found it. A few days ago I had a lag spike and something changed in the Unity settings that I didn't catch. Apparently when I was making some changes to the Player > PC > Other Settings > Rendering Path. This was set to Legacy Vertex Lit. Changed it to forward and things work again! Whew.... well, that happened.
     
    Last edited: Feb 19, 2016
  37. guitarman1209

    guitarman1209

    Joined:
    Aug 17, 2014
    Posts:
    2
    This is what I'm seeing... Would you possibly know what might be causing this?
     
  38. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Increase the orthographic size of the camera.

    --Eric
     
  39. binary_biscuit

    binary_biscuit

    Joined:
    Dec 27, 2013
    Posts:
    1
    Hey there, this is a general problem that I'm having (that could possibly be answered by anyone)

    When moving the camera, the level can look blurry/jittery - particularly when the camera movement is gradual over time. Is this a problem with SpriteTile or how the Unity engine handles 2D pixel art sprites. Does anyone have any solution to this issue?
     
  40. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    SpriteTile doesn't do anything with rendering; it uses standard Unity sprites. I haven't seen any blurry/jittery movement myself.

    --Eric
     
  41. Nixaan

    Nixaan

    Joined:
    May 30, 2013
    Posts:
    118
    It seems that the scene preview option is not setting the sorting layer of the sprites, so they are drawn in wrong order.
     
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You're right, sorry about that. I've fixed it for the next version, but in the meantime you can fix it right now by using the source, and in the TileEditor script, in the ShowEditorPreview function, where it's setting the sprite and sortingOrder (near the end of the function), add this line:

    Code (csharp):
    1.                         tileObj.GetComponent (SpriteRenderer).sortingLayerName = sortingLayerNames[sortingLayerIndices[i]];
    --Eric
     
  43. Nixaan

    Nixaan

    Joined:
    May 30, 2013
    Posts:
    118
    Thanks, that fixed it.
     
  44. Supergeek

    Supergeek

    Joined:
    Aug 13, 2010
    Posts:
    103
    Does SpriteTile handle RPG Maker-style auto-tiles?
     
  45. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes.

    --Eric
     
  46. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    333
    Eric,

    I'm trying to zoom the camera to show the whole SpriteTile map. I only have a single layer of tiles.

    How would I move the layer and/or camera, to show everything? Is it possible to use the camera to "stretch" the map to fill the entire space available?

    (Apologies if this is answered elsewhere - I couldn't seem to find it.)
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It depends on how many tiles there are, what size they are, and whether you're using a perspective camera or not. If there are a lot of tiles in total, though, it's not really advisable, since you'd have a huge number of sprites, which could be slow.

    --Eric
     
  48. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    333
    I'm looking at a map of 32 x 18 or maybe 32 x 20 to give me a 16:9 or 16:10 aspect ratio. Each tile is 32px x 32px.

    It's probably outside the normal SpriteTile use case, but I'm using SpriteTile to draw very simple mazes with various obstacles for a top-down tank game.

    Would this be too resource-intensive?

    I'm not sure which camera type to use - it's a simple 2d game so I was thinking orthogonal, but whatever were easiest would be fine.
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, that's fine. If you had 10s of thousands of sprites, that would likely be an issue, but just some hundreds isn't.

    Eric
     
  50. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    333
    Cool - how would I zoom the camera to show full extents? It's probably basic, but I'm having a job figuring it out.