Search Unity

Normalmap from Grayscale changes Sizes

Discussion in 'Shaders' started by Chisokuni, Jul 23, 2014.

  1. Chisokuni

    Chisokuni

    Joined:
    Apr 30, 2014
    Posts:
    28
    Hi,

    I'm working on a 2D game and i made a Shader that uses Normalmaps on Sprites. now when i draw a heightmap for my sprite and und mark it as a Normalmap and check the box for "Create from grayscale" it generates the right normalmap, but in the wrong size.

    for example:
    i have a Sprite 10x10 Pixel,
    i have a heightmap 10x10 Pixel,
    if i now generate a Normalmap from that the normalmap is 8x8 pixel.

    okay when thinking about normalmaps and what they realy are its right, i have 10 pixel so there are 8 gradients between.

    but now comes my problem:
    when i make a heigtmap of 12x12 pixels to get the 10 gradients inbetween unity produces a normalmap with 16x16 pixel from that.

    is there anyone who can explane to me why this is happening and/or can tell me how to change that?
     
  2. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    It happens because your textures are NPOT. (Not Power Of Two.)

    Older desktop GPU's and current mobile GPU's only support textures with a width and height that equals 2, 4, 8, 16, 32, etc. I'd say that would pretty much be on the first page in a book on computer graphics.