Hello Guest

Author Topic: Sprite + Normal Map  (Read 17696 times)

willrmiller

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Sprite + Normal Map
« 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

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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite + Normal Map
« Reply #1 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
« Last Edit: March 02, 2016, 09:44:16 am by unikronsoftware »

willrmiller

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Sprite + Normal Map
« Reply #2 on: March 12, 2013, 06:42:37 pm »
Awesome!  Thanks.

Der_Kevin

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Sprite + Normal Map
« Reply #3 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?

profanicus

  • 2D Toolkit
  • Full Member
  • *
  • Posts: 167
    • View Profile
Re: Sprite + Normal Map
« Reply #4 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.

Dukuo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Sprite + Normal Map
« Reply #5 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite + Normal Map
« Reply #6 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.

Dukuo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Sprite + Normal Map
« Reply #7 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.


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite + Normal Map
« Reply #8 on: October 22, 2013, 10:49:07 am »
Do you have tangents enabled on the sprite collection?

Dukuo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Sprite + Normal Map
« Reply #9 on: October 22, 2013, 11:13:40 am »
Should I put Normals and Tangets in the SpriteCollection's settings over Normal Generation ?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite + Normal Map
« Reply #10 on: October 22, 2013, 11:15:00 am »
Yes, you need tangents for this to work.

Dukuo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Sprite + Normal Map
« Reply #11 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




unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite + Normal Map
« Reply #12 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.


Dukuo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Sprite + Normal Map
« Reply #13 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):


Is that the right way?

Also, which version is the oldest I can use to make it work (leaving 2.22 aside of course)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite + Normal Map
« Reply #14 on: October 22, 2013, 12:17:46 pm »
Create from grayscale shouldn't be ticked, unless your source image has normal map ticked?