Home Coding, Scripting, Shaders

Grayscale to color in real time with small one row of pixels lut texture?

gnoop
sublime tool
Online / Send Message
gnoop sublime tool
I wonder would it be calculative or memory expensive  to turn grayscale image to RGB  same way Gradient node in Substance designer works ?  or just by using  LUt image  like 8x1 pixels texture?

Why we use 2k  RGB  textures for base color   instead of just one channel packed together with roughness and AO   + some tiny LUT image  if we do base color/albedo  exactly  same   "gradient node" way in SubsDesigner?

Replies

  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    its a cheap operation in your shader and can save a shit load of memory

    if it's a runtime changeable thing there will be a cost associated with passing data around - that can be prohibitive but will depend on your engine/use case.  it'll be equivalent to something like changing a light colour based on input from the game and if there is a problem it will most likely be related to how many things have the functionality enabled or how many datapoints are involved.

    you need to be a bit clever with texture formats on the luts and the textures that drive them - what you choose will be peculiar to your engine/use case but we have been known to use very small (32x4) uncompressed luts rather than larger compressed ones and we tend to use higher quality grayscale inputs than you normally would.  this is mainly to reduce banding and is arguably only a good idea because we generally have a very clean and simple art style. 
    The result of that is that you may only be 1/2 the memory footprint rather than 1/4 vs using color maps. 

    it's worth mentioning that you can apply the same logic to generating roughness/metallic etc - we did that to great success in a recent game

  • gnoop
    Online / Send Message
    gnoop sublime tool
    poopipe  Thanks a lot for the comment .   The idea crossed my mind long ago  since I do all my textures from heigh /depth basically  and base color ones looks like something from  256 colors pallet era.   As well as roughness too.  

     Am I right when think it would be basically same as regular texture filtering when gpu calculate color in between pixels?    And it could  theoretically  workaround  bottlenecks between  VRAM  and GPU  data flow ? 
        
     Need to find words to persuade our  shader programmer  :)   since we never did it before   and I think it's not a typical  way.   
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    the lut texture can be filtered or not - it's just  a texture. 

    with the most basic implementation you're sampling one extra texture so that's a thing someone might choose to argue over.  If you dont' have any need for dynamic changes or haven't planned to mix and match luts with the grayscale source textures then you're really only gaining in terms of memory footprint.

    This sort of thing is extremely common in vfx and the shader world so I imagine it's not going to be a strange idea to the shader programmer. 

    in terms of what happens on the GPU I would expect it's very specific to your implementation so i can't possibly comment


    I'm a big fan of the technique independent of any efficiency gains  - its a hell of a step up visually from multiplying your basecolor over a grayscale map and it opens up all sorts of options if you have customisation systems or want to re-use assets 



  • gnoop
    Online / Send Message
    gnoop sublime tool
    Thanks again  poopipe.    You are always a source of helpful  info.
  • Eric Chadwick
    I also did a bunch of this, in two different games, it was actually a ton of fun doing all the color grading, possibilities are limitless


  • gnoop
    Online / Send Message
    gnoop sublime tool
    Thanks for the links Eric  
Sign In or Register to comment.