private void CreateTexture2() { if (m_Texture2 != null) { return; } const int width = 40; const int height = 40; m_Texture2 = CreateTexture(width, height).GetManaged(); }
private void Create3DTexture() { if (m_Texture3D != null && m_Texture3D.Valid) { return; } const int cubeSize = 256; const int width = cubeSize; const int height = cubeSize; const int depth = cubeSize; var texture = Renderer.CreateTexture3D(width, height, depth, TextureFormat.Unorm16); Renderer.UpdateTexture3D(texture, Create3DLut(width, height, depth)); m_Texture3D = texture.GetManaged(); }
private unsafe void Upload3DLut(Lut3DHeader header, byte[] lutBuffer) { int inputBitsR = header.InputBitDepth[2]; int inputBitsG = header.InputBitDepth[1]; int inputBitsB = header.InputBitDepth[0]; int rSize = 1 << inputBitsR; int gSize = 1 << inputBitsG; int bSize = 1 << inputBitsB; const int channelCount = 4; var data = new ushort[bSize, gSize, rSize *channelCount]; fixed(void *lutByte = lutBuffer) { var lut = (ushort *)lutByte; for (int b = 0; b < bSize; b++) { for (int g = 0; g < gSize; g++) { for (int r = 0; r < rSize; r++) { var lutOffset = ((r << (inputBitsG + inputBitsB)) + (g << inputBitsB) + b) * 3; var max = (1 << header.OutputBitDepth) - 1; var n = ushort.MaxValue / max; data[b, g, r *channelCount + 0] = (ushort)(lut[lutOffset + 2] * n); data[b, g, r *channelCount + 1] = (ushort)(lut[lutOffset + 1] * n); data[b, g, r *channelCount + 2] = (ushort)(lut[lutOffset + 0] * n); data[b, g, r *channelCount + 3] = ushort.MaxValue; } } } } var texture = Renderer.CreateTexture3D(bSize, gSize, rSize, TextureFormat.Unorm16); Renderer.UpdateTexture3D(texture, data); m_Texture3D = texture.GetManaged(); m_CurrentFileName = FileName; }
public static TextureSourceFilter <TTexture> ToFilter <TTexture>(this IManagedTexture <TTexture> texture) where TTexture : class, IBaseTexture { return(new TextureSourceFilter <TTexture>(texture.GetLease())); }
public static ITextureFilter <TTexture> ToFilter <TTexture>(this IManagedTexture <TTexture> texture) where TTexture : IBaseTexture { return(new ManagedTextureFilter <TTexture>(texture)); }
public ManagedTextureFilter(IManagedTexture <TTexture> texture) : this(texture.GetLease()) { }