Announcement

Collapse
No announcement yet.

Maths question. Is it possible to store multiple greyscale textures inside one greyscale texture.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Maths question. Is it possible to store multiple greyscale textures inside one greyscale texture.

    I understand it is possible to combine multiple black/white mask textures into one grey scale texture, and de-combine them into separate masks in a shader.

    My question: How would you combine/encode grey scale textures that contain a larger range of values than black and white and how would I de-combine/de-encode them in the shader?
    Is this even possible?

    Any Ideas/thoughts are welcome and very much appreciated

    #2
    why dont you just use packed textures?
    Store each greyscale texture in the single RGB channels

    Comment


      #3
      RGBA channel packing would allow me to store 4 greyscale textures inn one texture. However I am looking for a way to store ALOT more than 4 textutures in one texture.

      Comment


        #4
        Search for bit-packing.

        Comment


          #5
          What is your actual use case?

          Comment


            #6

            Originally posted by somawheels View Post
            RGBA channel packing would allow me to store 4 greyscale textures inn one texture. However I am looking for a way to store ALOT more than 4 textutures in one texture.

            Thankyou Deathrey
            Unfortunately this seems too much for my small brain; I am not a programmer. All the same, you have helped me realize the complexity of what I was asking for.




            My use case is rather alot to explain, but my simple brain thought "Hey, I dont need all the bit depth of an 8-bit greyscale texture. Maybe I can can store 30 low bit-depth textures inside one high-bit deth texture. Think of all the GPU memory and texture lookups I could save"

            But ofcourse it is not that simple :L

            Edit: After playing around with packing alpha masks, this is what I came up with. This shader encodes a binary black/white mask into a greyscale texture, and then decodes it.
            Click image for larger version  Name:	ScreenshotASE.jpg Views:	1 Size:	454.2 KB ID:	1639540

            It works fine and I can technically pack more than 1 mask. However I want to pack grey scale images, not binary black/white masks. Can someone confirm for me whether this is actually possible?
            Last edited by somawheels; 07-07-2019, 06:26 PM.

            Comment


              #7
              You could, via material shaders, do a lot of freaky things, like what you did above. Do the "encoding" when making the texture in Photoshop, then "decode" it using a material setup. You can also use the If node to only search for specific values, theoretically storing up to 256 different 1-bit "overlays" into a single uncompressed grayscale texture (though each pixel can only be used for one layer, and you'd need more than 1 bits for properly anti-aliasing round edges).

              I actually did something similar to this for The Perfect Tile System: I have a dual coloring option that shifts from black to white at a user-defined midpoint, then black to white again, each side overlaid with different colors. It's a really cool effect, and allowed me to get multiple surfaces from a single grayscale channel.
              Last edited by mariomguy; 07-08-2019, 12:35 AM.

              Comment


                #8
                Is it possible to store multiple greyscale textures inside one greyscale texture.

                Sounds like a texture atlas to me.
                Clarke's third law: Any sufficiently advanced technology is indistinguishable from magic.
                Custom Map Maker Discord
                https://discord.gg/t48GHkA
                Urban Terror https://www.urbanterror.info/home/

                Comment


                  #9
                  Originally posted by somawheels View Post

                  "Hey, I dont need all the bit depth of an 8-bit greyscale texture. Maybe I can can store 30 low bit-depth textures inside one high-bit deth texture. Think of all the GPU memory and texture lookups I could save"
                  But in 8 bits you can only store as much as 8 black/white masks, not more. Or two 4-bit masks. Or 1 7 bit grayscale image and 1 black and white mask. Or anything really, as long as it fits.

                  Originally posted by somawheels View Post
                  It works fine and I can technically pack more than 1 mask. However I want to pack grey scale images, not binary black/white masks. Can someone confirm for me whether this is actually possible?
                  Yes. You can use bitpacking in any way you can imagine, for example storing 16 8 bit greyscale masks in a single 32 bit RGBA texture.

                  Question is.. should you ?

                  Comment


                    #10
                    Keep in mind that any non linear encoding/decoding scheme will not work with bilinear filtering, mipmaps or compression. These all are quite important for quality and performance. So you save small amount of memory but pay extra cost of manual bilinear filtering, loss of mipmaps and bit packing decoding. I would not do this because of these severe limitations.
                    Instead I would store each mask as separate texture using alpha compression(BC4) and use as low texture size as possible can. This way you get compression(4bit per texel), filtering and mipmaps support. Remember that mipmapping enabled efficient streaming which is very much needed if memory is issue. Also if mask does not need all to be same size you can will save great amount of memory with just by lowering texture size for non important masks.

                    Comment


                      #11
                      Thankyou so much for that useful information Deathrey. Im sure It will help me work things out. Indeed, Question is.. should I? I dont know XD

                      Kalle_H Thanks very much for that information. You asked me earlier what my use case is; I am experimenting with creating volumetric lightingmaps and effects.

                      Currently, my method involves interpolating between a vertical stack of about 80 2k greyscale textures (which are all rendered in a post-process shader). Sampling so many textures is inefficient, and the GPU memory consumption of so many textures is also too high.

                      I would love to hear peoples thoughts on the matter.
                      Last edited by somawheels; 07-08-2019, 03:45 PM.

                      Comment


                        #12
                        Originally posted by somawheels View Post
                        T

                        Currently, my method involves interpolating between a vertical stack of about 80 2k greyscale textures (which are all rendered in a post-process shader). Sampling so many textures is inefficient, and the GPU memory consumption of so many textures is also too high.

                        I would love to hear peoples thoughts on the matter.
                        If you are doing something like that, likely you have selected completely wrong approach to a task you are facing.

                        Comment


                          #13
                          Originally posted by Deathrey View Post

                          If you are doing something like that, likely you have selected completely wrong approach to a task you are facing.
                          That post would be much more helpful if you'd actually mention the right approach as well.

                          Comment


                            #14
                            When you say vertical what do you actually mean? Are you trying to do something similar that this? https://www.ea.com/frostbite/news/ph...g-in-frostbite

                            Comment


                              #15
                              texture atlas + RGBA channels .

                              Comment

                              Working...
                              X