Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Editing texture at runtime in WebGL, any advice/help?

Discussion in 'General Discussion' started by JovanD, Nov 17, 2015.

  1. JovanD

    JovanD

    Joined:
    Jan 5, 2014
    Posts:
    206
    Im doing a product visualization project on WebGL platform. What i need is to have many different colors of wood, my idea was to have a grayscale wood texture and colorize it in what ever color user/player chooses.
    Substance designer seemed like a no-brainer, but than i found out that it doesn't work in webGL, next i tried to write my own script that loops trough all the pixels in the texture and multiples them by user defined color, but that was just too slow pretty much crashing the whole thing.
    So only thing that comes to mind is doing it with shader, but the problem is i never written or know how to write a shader and since im already behind schedule i don't have time to learn.
    Im just wondering is there an asset or available source that can help me?
    Thanks in advance guys.
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,734
    I've had no problem with iterating through all of the pixels in a texture and manually setting them. I've used it in several games. Make sure you use GetPixels and SetPixels, it's much faster the GetPixel and SetPixel.

    Shaders are also pretty easy. There is no need to write your own. There are plenty of existing shaders that take a colour argument that can be used as a tint.
     
unityunity