コード例 #1
0
 /// <summary>
 /// Init Virtual Texture
 /// </summary>
 /// <param name="perTextureSize">Virtual texture's basic size</param>
 /// <param name="maximumSize">Virtual texture's array size</param>
 /// <param name="indexSize">Index Texture's size</param>
 /// <param name="formats">Each VT's format</param>
 public VirtualTexture(int maximumSize, int indexSize, NativeArray <VirtualTextureFormat> formats)
 {
     allFormats = new NativeArray <VirtualTextureFormat>(formats.Length, Allocator.Persistent);
     UnsafeUtility.MemCpy(allFormats.GetUnsafePtr(), formats.GetUnsafePtr(), sizeof(VirtualTextureFormat) * formats.Length);
     shader            = Resources.Load <ComputeShader>("VirtualTexture");
     commandListBuffer = new ComputeBuffer(64, sizeof(SetIndexCommand));
     indexBuffers      = new Native2DArray <float4>(indexSize, Allocator.Persistent);
     pool     = new TexturePool(maximumSize);
     indexTex = new RenderTexture(new RenderTextureDescriptor
     {
         colorFormat       = RenderTextureFormat.ARGBHalf,
         depthBufferBits   = 0,
         dimension         = TextureDimension.Tex2D,
         enableRandomWrite = true,
         width             = indexSize,
         height            = indexSize,
         volumeDepth       = 1,
         msaaSamples       = 1
     });
     indexTex.filterMode = FilterMode.Point;
     indexTex.Create();
     textures = new RenderTexture[formats.Length];
     for (int i = 0; i < formats.Length; ++i)
     {
         VirtualTextureFormat format = formats[i];
         textures[i] = new RenderTexture(new RenderTextureDescriptor
         {
             colorFormat       = format.format,
             depthBufferBits   = 0,
             dimension         = TextureDimension.Tex2DArray,
             enableRandomWrite = true,
             width             = (int)format.perElementSize,
             height            = (int)format.perElementSize,
             volumeDepth       = maximumSize,
             msaaSamples       = 1
         });
         textures[i].Create();
     }
     loadNewTexFrameCount = -1;
     indexBuffers.SetAll(float4(0, 0, 0, -1));
 }
コード例 #2
0
 public void Init(int2 perTextureSize, int maximumSize, int2 indexSize, NativeArray <RenderTextureFormat> formats)
 {
     commandListBuffer = new ComputeBuffer(64, sizeof(SetIndexCommand));
     indexBuffers      = new Native2DArray <float4>(indexSize, Allocator.Persistent);
     pool     = new TexturePool(maximumSize);
     indexTex = new RenderTexture(new RenderTextureDescriptor
     {
         colorFormat       = RenderTextureFormat.ARGBHalf,
         depthBufferBits   = 0,
         dimension         = TextureDimension.Tex2D,
         enableRandomWrite = true,
         width             = indexSize.x,
         height            = indexSize.y,
         volumeDepth       = 1,
         msaaSamples       = 1
     });
     indexTex.Create();
     textures = new RenderTexture[formats.Length];
     for (int i = 0; i < formats.Length; ++i)
     {
         textures[i] = new RenderTexture(new RenderTextureDescriptor
         {
             colorFormat       = formats[i],
             depthBufferBits   = 0,
             dimension         = TextureDimension.Tex2DArray,
             enableRandomWrite = true,
             width             = perTextureSize.x,
             height            = perTextureSize.y,
             volumeDepth       = maximumSize,
             msaaSamples       = 1
         });
         textures[i].Create();
     }
     loadNewTexFrameCount = -1;
     indexBuffers.SetAll(float4(0, 0, 0, -1));
 }