Exemplo n.º 1
0
 public int GetMaxSize(VTOutput output)
 {
     if (_maxSize == null)
     {
         _maxSize = _channelProperties.Values.Max(t => TextureData.GetData(t.Item1).Width);
     }
     return(_maxSize.Value);
 }
Exemplo n.º 2
0
            public void Load(Texture2DArray[] targets, Vector2 position, int size, VTOutput output)
            {
                var channels   = VT0Info.Current.Channels;
                var outSize    = output.Size;
                int srcMipBias = outSize - size;

                for (int i = 0; i < channels.Count; i++)
                {
                    var props  = _channelProperties[channels[i]];
                    var target = targets[i];
                    var data   = TextureData.GetData(props.Item1);

                    var       stagingKey = ValueTuple.Create(data.Width, data.Height, data.Format);
                    Texture2D staging;
                    _staging.TryGetValue(stagingKey, out staging);
                    if (staging == null)
                    {
                        _staging[stagingKey] =
                            (staging = new Texture2D(data.Width, data.Height, data.Format, true));
                    }
                    // TODO: Only stage the mips we need
                    staging.LoadRawTextureData(data.Data);
                    var intPos = Vector2Int.FloorToInt(
                        Vector2.Scale(position, new Vector2(target.width, target.height)));

                    var mipCount = (int)Mathf.Log(Mathf.Min(target.width, target.height), 2);
                    for (int m = 0; m < mipCount; m++)
                    {
                        Graphics.CopyTexture(
                            staging, 0, m + srcMipBias, 0, 0, data.Width, data.Height,
                            target, 0, m, intPos.x, intPos.y
                            );
                    }

                    _material.SetVector(props.Item2, new Vector4(position.x, position.y,
                                                                 (float)size / outSize,
                                                                 (float)size / outSize)); // TODO: Rectangular texture support
                }
            }