Search Unity

what can replace RGFloat format rendertexture on mobile

Discussion in 'Shaders' started by dreamerflyer, Apr 27, 2016.

  1. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    Hi all,because i want to use render texture store vector2 float,but some mobile not support RGFloat Rendertexture,What can i do ?
     
  2. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    any help?
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    It's possible to use an ARGB32 and store a 16 bit float across two 8 bit channels. I think there's some similar example code for this in UnityCG.cginc, but it's for storing a single 32 float in all 4 channels. Otherwise you can find it here on Aras's blog:
    http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/

    You do loose some precision, and you can only do a positive value between 0 and 1 so you have to adjust whatever numbers you want to store to fit in that range, but you will get something float-like.