Skip to content

andrew-raphael-lukasik/RawTextureDataProcessingExamples

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

RawTextureData Processing Examples

Documentation gives little helpful information on this topic so I created this repo to document how to create matching data structure + how to read & process it in a IJobParallelFor.

This repository contains these kinds of processing examples:

  • Invert color
  • Edge detection
  • Box Blur
  • Gaussian Blur
  • Grayscale

Tester window available under MenuItem "Test/Raw Texture Data/Processing Example"

Tester window

Note GetRawTextureData<T> will return all the raw texture data including data from the mipmaps should they be enabled. In such case the length of the array will be longer than width * height. GetPixelData<T> does not suffer from this issue as you can pass in the desired mip level (usually 0).


Quick lookup table

Valid <T> for GetRawTextureData<T> & GetPixelData<T> or depending on texture.format property:

  • TextureFormat.Alpha8 - <byte>
  • TextureFormat.R8 - <byte>
  • TextureFormat.R16 - <ushort>,<byte2>
  • TextureFormat.RG32 - <ushort2>
  • TextureFormat.RGB48 - <ushort3>
  • TextureFormat.RGBA64 - <ushort4>
  • TextureFormat.RHalf - <half>,<byte2>
  • TextureFormat.RFloat - <float>,<byte4>
  • TextureFormat.RGB24 - <byte3>
  • TextureFormat.RGBA32 - <Color32>,<byte4>
  • TextureFormat.RGBAHalf - <half4>,<byte2x4>
  • TextureFormat.RGBAFloat - <Color>,<Vector4>,<float4>,<byte4x4>

Bestiary:

  • public struct byte2 { public byte x, y; }
  • public struct byte3 { public byte x, y, z; }
  • public struct byte4 { public byte x, y, z, w; }
  • public struct byte2x4 { public byte2 c0, c1, c2, c3; }
  • public struct byte4x4 { public byte4 c0, c1, c2, c3; }
  • public struct ushort2 { public ushort x, y; }
  • public struct ushort3 { public ushort x, y, z; }
  • public struct ushort4 { public ushort x, y, z, w; }

About

Tutorial by example. Processing RawTextureData native array formats was not documented anywhere deep enough.

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages