2D Toolkit Forum

2D Toolkit => Support => Topic started by: willrmiller on March 11, 2013, 05:10:06 pm

Title: Sprite + Normal Map
Post by: willrmiller on March 11, 2013, 05:10:06 pm
I'm interested in extending 2D Toolkit (or perhaps suggest a new feature for it) to support sprites composed of multiple images (more than one image in the sprite's shader).  A cool example of this at work is the normal mapped pixel art seen in Robot Loves Kitty's Legend of Dungeon.  Here's a link to their dev diary on the subject: http://robotloveskitty.tumblr.com/post/33164532086/legend-of-dungeon-dynamic-lighting-on-sprites (http://robotloveskitty.tumblr.com/post/33164532086/legend-of-dungeon-dynamic-lighting-on-sprites)

This could be useful for other things too - player color comes to mind.  Do you have any thoughts or suggestions for how this might be implemented?
Title: Re: Sprite + Normal Map
Post by: unikronsoftware on March 12, 2013, 09:22:37 am
Its actually possible to do it now, though its a bit of a pain to do it manually. Here's a thread that was discussing this:
http://www.2dtoolkit.com/forum/index.php/topic,1143.0.html
Title: Re: Sprite + Normal Map
Post by: willrmiller on March 12, 2013, 06:42:37 pm
Awesome!  Thanks.
Title: Re: Sprite + Normal Map
Post by: Der_Kevin on September 16, 2013, 11:14:09 pm
Its actually possible to do it now, though its a bit of a pain to do it manually. Here's a thread that was discussing this:
http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1143.0.html

hey, I was just looking for some solutions for the 2d toolkit+normalmap thing and discovered this thread.
sadly the link doesent work. is the thread now somewhere else?
or are there any news regarding the 2d toolkit working together with some normal maps?
Title: Re: Sprite + Normal Map
Post by: profanicus on September 16, 2013, 11:26:16 pm
The link still works for me. I think there are a few threads about this, try searching.

In general you just manually maintain a second Collection that is your normal map. Disable trimming on both and add the sprites in each Collection in the same order. Each time you update the normal map collection you need to manually set compression method on the resulting atlas texture to 'normal map'. But you can modify tk2d code to add this as a choice in the compression drop-down quite easily.

Sprites meshes need normals and tangents, currently I think this only works for standard sprites (and not tiled/diced/tilemaps) so you need to put your own generation code in if you want those to work.
Title: Re: Sprite + Normal Map
Post by: Dukuo on October 22, 2013, 03:51:29 am
I'm sorry I revived this thread, but i'm the same place as Der_Kevin ... Should I need any kind of permission or something to view the thread? Also, using the Search feature from this forum I couldn't find any similar thread.
Title: Re: Sprite + Normal Map
Post by: unikronsoftware on October 22, 2013, 10:00:35 am
You will need to register 2d Toolkit (instructions here: http://unikronsoftware.com/2dtoolkit/forum/index.php?index.php/topic,34.0.html).
That link is in the private support forum.
Title: Re: Sprite + Normal Map
Post by: Dukuo on October 22, 2013, 10:46:46 am
Oh, didn't knew that! I'll do it right away, but since i'm experimenting, is this the expected behaviour of what you were saying? I created a second SpriteCollection and added the bump map into it, then added to the sprite as a Transparent/Cutout/Bump Diffuse material with the normal sprite from the first atlas, and in the normal  map the atlas generated by the second sprite (which I manually changed to Normal Map)

It just doesn't feel it's shading correctly.

(http://puu.sh/4WoNZ.png)
Title: Re: Sprite + Normal Map
Post by: unikronsoftware on October 22, 2013, 10:49:07 am
Do you have tangents enabled on the sprite collection?
Title: Re: Sprite + Normal Map
Post by: Dukuo on October 22, 2013, 11:13:40 am
Should I put Normals and Tangets in the SpriteCollection's settings over Normal Generation ?
Title: Re: Sprite + Normal Map
Post by: unikronsoftware on October 22, 2013, 11:15:00 am
Yes, you need tangents for this to work.
Title: Re: Sprite + Normal Map
Post by: Dukuo on October 22, 2013, 11:21:05 am
Well, I tried with Normal Generation set to Normal and tangents (in my second spritecollection with the height map, which is shown below) but I had to use a really intense directional light to get some of the shading, and it still looks bit weird (or maybe i'm just looking the wrong way?) Here are some pictures of my SpriteCollection settings, along with the scene with the illuminated sprite and with the height map used in the second SpriteCollection and then set the generated atlas0 to normal map
(http://puu.sh/4WptB.png)
(http://puu.sh/4WppU.png)
(http://puu.sh/4WpuA.png)
Title: Re: Sprite + Normal Map
Post by: unikronsoftware on October 22, 2013, 12:03:44 pm
1. You still seem to be getting that error for some reason. (Shader wants normals).
2. Is the atlas texture set to normal map?

Also make sure you're on a recent version of tk2d, the older ones had a bug where the tangents were possibly incorrect.

Title: Re: Sprite + Normal Map
Post by: Dukuo on October 22, 2013, 12:16:18 pm
1. Yes, I'm getting the error still... don't know exactly why
2. Here's a picture of the second atlas (with the height map):
(http://puu.sh/4WqGd.png)

Is that the right way?

Also, which version is the oldest I can use to make it work (leaving 2.22 aside of course)
Title: Re: Sprite + Normal Map
Post by: unikronsoftware on October 22, 2013, 12:17:46 pm
Create from grayscale shouldn't be ticked, unless your source image has normal map ticked?
Title: Re: Sprite + Normal Map
Post by: Dukuo on October 22, 2013, 12:26:56 pm
Okay so I had the png file with normal map ticked, so I unchecked it and leave it as a height map, then I re commit the SpriteCollection with the same options as the screen I uploaded, and then set the atlas texture to normal map, this was the result:

(http://puu.sh/4WqUY.png)

Is this the expected behaviour? Could you make an example image of a sprite with normal map applied? It still doesn't look like the normal map is being applied correctly.
Title: Re: Sprite + Normal Map
Post by: yo_milo on March 01, 2016, 02:16:19 pm
Sorry for necroposting...
But the link with the way to do it is broken... I was wondering if this was implemented in tk2d, or is there a way to implement it to a game.

Thank you.
Title: Re: Sprite + Normal Map
Post by: unikronsoftware on March 02, 2016, 09:44:46 am
Fixed link...
http://www.2dtoolkit.com/forum/index.php/topic,1143.0.html