Search Unity

I Need a Shader With Separate Specular Texture

Discussion in 'Shaders' started by w1nterl0ng, Jul 28, 2010.

  1. w1nterl0ng

    w1nterl0ng

    Joined:
    Jan 19, 2010
    Posts:
    32
    Hi All, I need a material that I can upload a graphic into at run time, usign WWW and uploading a .JPG or .PNG, yet still retain the original Specular Layer.

    Any suggestions?

    Thanks, Fred
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    The basic specular shader uses the image's alpha channel as the specularity map. JPG doesn't allow for an alpha channel, but you could use PNG for this.
     
  3. w1nterl0ng

    w1nterl0ng

    Joined:
    Jan 19, 2010
    Posts:
    32
    @andeeee I have tried this with no real success. When I save a png from Photoshop, with a specular layer in the alpha channel, on import it makes the material have a funny hue, like all yellow or all red. I will attempt to post an example tonight (central time).

    Also, is there a way to store a specular map in the game, and when someone uploads a png without alpha, someone merge the two files and assign that new texture to the material?

    Thanks, Fred
     
  4. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
  5. w1nterl0ng

    w1nterl0ng

    Joined:
    Jan 19, 2010
    Posts:
    32
    @Daniel, I will give that try tonight, if I am understanding you correctly, I can have my static specular map loaded as a 2D array of colors, then load the graphic uploaded by the the user into it's own 2D array, then, loop over the spec map, evaluate the grayscale and apply it to the alpha of the appropriate pixel in the user created 2D array.

    I hope that made sense, and I hope it is correct. I will post the code if it works :)

    See you all tonight.
    Fred