Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Flipbook animation with normal maps

Discussion in '2D' started by R_ociN, Apr 27, 2023.

  1. R_ociN

    R_ociN

    Joined:
    Mar 7, 2022
    Posts:
    3
    Hi there, it seems like it is not possible but I'll ask nevertheless.

    Can flipbook animations be used with normal maps?
    I have two sprite sheets, one with a 3x3 sprite of a moving character and the corresponding 3x3 normal map.
    However, when I try to use it for my animation, the sprite is not illuminated with the normal map.

    If anyone knows how to do it please let me know
     
  2. venediklee

    venediklee

    Joined:
    Jul 24, 2017
    Posts:
    200
    I use massive textures for flipbook animations with normal maps. Never encountered an issue with 2d lights not working with them even when the texture type of the normal map is set to sprite.

    Go to the main(diffuse/albedo) sprite, open sprite editor and check if the secondary texture "_NormalMap" is set like this example
    upload_2023-4-27_21-54-30.png

    If not, you can always go to (from the top toolbar) Window>Analysis>Frame Debugger and check the normals drawn in the scene there

    upload_2023-4-27_21-56-1.png

    PS: this is for demonstration purposes only, your normal colors might be different
     
    R_ociN likes this.
  3. R_ociN

    R_ociN

    Joined:
    Mar 7, 2022
    Posts:
    3
    It looks like there is something that is not working properly
    I tried to set the "Texture Type" to "Normal Map" or to "Sprite" with sprite mode as multiple, in neither case it works
    Here is info I am getting from the Frame Debugger:
    missingNormals.png

    Is there a way to set the secondary texture to be used as a normal map? Or is it done by default?
    I set the name of the secondary to _NormalMap as you did, but the texture is not being called "normal.normalMapFileName" as in your case, but just "normalMapFileName"

    Thank you for your help
     
  4. venediklee

    venediklee

    Joined:
    Jul 24, 2017
    Posts:
    200
    File name is not important. The name of the secondary texture field is important(_NormalMap etc., they can be selected from the dropdown menu). The _NormalMap is the default way of storing the normal map of a texture, because the sprite-lit-default material uses the _NormalMap reference. You can literally use any reference if you are doing a custom material, you just have to make sure the secondary texture field's name is set accordingly.

    That being said, are you sure you are using sprite-lit-default material? It looks like the "Draw 2D Lights" section of your frame debugger doesn't even bother with normals. Either you don't have a material that uses normal maps or you don't have normal maps assigned

    To make absolutely sure you have normals assigned, go to the step that draws your character and look inside the Textures tab(under the Output/Mesh thingy). All the textures of the material of your character should be there
     
    R_ociN likes this.
  5. R_ociN

    R_ociN

    Joined:
    Mar 7, 2022
    Posts:
    3
    After spending too much time on this problem I saw that I was using "Point Light" instead of "Spot Light 2D".

    Seing "Draw 2D Lights" in the debugger confused me a bit in the beginning but then I realized that the global light is a 2D light and the rest was being ignored.

    Thank you again for taking the time!
     
    venediklee likes this.