Пример #1
0
 public half4x4(bool4x4 v)
 {
     this.c0 = (half4)math.select(new float4(0.0f), new float4(1.0f), v.c0);
     this.c1 = (half4)math.select(new float4(0.0f), new float4(1.0f), v.c1);
     this.c2 = (half4)math.select(new float4(0.0f), new float4(1.0f), v.c2);
     this.c3 = (half4)math.select(new float4(0.0f), new float4(1.0f), v.c3);
 }
Пример #2
0
 public half4x4(int4x4 v)
 {
     this.c0 = new half4(v.c0);
     this.c1 = new half4(v.c1);
     this.c2 = new half4(v.c2);
     this.c3 = new half4(v.c3);
 }
Пример #3
0
 public half4x4(uint v)
 {
     this.c0 = (half4)v;
     this.c1 = (half4)v;
     this.c2 = (half4)v;
     this.c3 = (half4)v;
 }
        public void Execute()
        {
            float gridToWorldPosition = (1f / GameSurface.Resolution) * GameSurface.Size;

            for (int x = 0; x < Resolution; x++)
            {
                for (int y = 0; y < Resolution; y++)
                {
                    float2 positionWS = new float2(x, y) * gridToWorldPosition;

                    float height = math.sin((Time + (x * SinScale)) * HeightScale);

                    for (int i = 0; i < Weights.Length; i++)
                    {
                        float2 weightPosition = Weights[i].xy;
                        float  distance       = math.length(positionWS - weightPosition);
                        float  heightOffset   = math.smoothstep(0, 1, (Weights[i].z - distance) * 0.2f) * WeightStrength;
                        height += heightOffset;
                    }

                    float4 oldValue = PositionTexture[x + (y * Resolution)];
                    float4 newValue = new half4((half)(x * gridToWorldPosition), (half)(y * gridToWorldPosition), (half)height, (half)1);



                    PositionTexture[x + (y * Resolution)] = (half4)math.lerp(oldValue, newValue, DeltaTime);
                }
            }
        }
Пример #5
0
 public half4x4(float v)
 {
     this.c0 = (half4)v;
     this.c1 = (half4)v;
     this.c2 = (half4)v;
     this.c3 = (half4)v;
 }
Пример #6
0
 public void Combine(ref half4 curr, ref half4 value)
 {
     curr.x += value.x;
     curr.y += value.y;
     curr.z += value.z;
     curr.w += value.w;
 }
Пример #7
0
 public void Combine(ref half4 curr, ref half4 value)
 {
     curr.x *= value.x;
     curr.y *= value.y;
     curr.z *= value.z;
     curr.w *= value.w;
 }
Пример #8
0
 public half4x4(double v)
 {
     this.c0 = (half4)v;
     this.c1 = (half4)v;
     this.c2 = (half4)v;
     this.c3 = (half4)v;
 }
    protected override void OnUpdate()
    {
        _timeLeft -= Time.DeltaTime;
        if (_timeLeft > 0f)
        {
            return;
        }
        _timeLeft = _particleSpawnTime;

        var positionTexture = _positionsTexture;
        var positionsList   = new NativeList <half4>(resolution, Allocator.TempJob);
        var writer          = positionsList.AsParallelWriter();

        // Walking Smoke VFX
        Entities
        .WithName("FillPositionsTextureArrayJob")
        .WithAll <UnitTag>()
        .ForEach((Entity unitEntity, int entityInQueryIndex, in LocalToWorld ltw, in UnitSpeed unitSpeed) =>
        {
            // If speed meets a certain threshold, then start spawning VFX
            var pos = ltw.Position;

            if (unitSpeed.Value > 1)
            {
                var a          = (half)1; // TODO make the alpha channel ramp (speed will change how many particles spawn. Right now it's always 1)
                half4 texColor = new half4((half)pos.x, (half)pos.y, (half)pos.z, a);
                writer.AddNoResize(texColor);
            }
        }).ScheduleParallel();
Пример #10
0
 public half4x4(double4x4 v)
 {
     this.c0 = (half4)v.c0;
     this.c1 = (half4)v.c1;
     this.c2 = (half4)v.c2;
     this.c3 = (half4)v.c3;
 }
Пример #11
0
 public half4x4(float4x4 v)
 {
     this.c0 = (half4)v.c0;
     this.c1 = (half4)v.c1;
     this.c2 = (half4)v.c2;
     this.c3 = (half4)v.c3;
 }
Пример #12
0
 public half4x4(float4 c0, float4 c1, float4 c2, float4 c3)
 {
     this.c0 = (half4)c0;
     this.c1 = (half4)c1;
     this.c2 = (half4)c2;
     this.c3 = (half4)c3;
 }
Пример #13
0
        public static void half4_minvalue()
        {
            half4 min = half.MinValueAsHalf;

            TestUtils.AreEqual(0xfbff, min.x.value);
            TestUtils.AreEqual(0xfbff, min.y.value);
            TestUtils.AreEqual(0xfbff, min.z.value);
            TestUtils.AreEqual(0xfbff, min.w.value);
        }
Пример #14
0
        public static void half4_from_float4_explicit_conversion()
        {
            half4 h = (half4)float4(123.4f, 5.96046448e-08f, -65504.0f, float.PositiveInfinity);

            TestUtils.AreEqual(0x57B6, h.x.value);
            TestUtils.AreEqual(0x0001, h.y.value);
            TestUtils.AreEqual(0xFBFF, h.z.value);
            TestUtils.AreEqual(0x7C00, h.w.value);
        }
Пример #15
0
        public static void half4_maxvalue()
        {
            half4 max = half.MaxValueAsHalf;

            TestUtils.AreEqual(0x7bff, max.x.value);
            TestUtils.AreEqual(0x7bff, max.y.value);
            TestUtils.AreEqual(0x7bff, max.z.value);
            TestUtils.AreEqual(0x7bff, max.w.value);
        }
Пример #16
0
 public half4x4(float m00, float m01, float m02, float m03,
                float m10, float m11, float m12, float m13,
                float m20, float m21, float m22, float m23,
                float m30, float m31, float m32, float m33)
 {
     this.c0 = new half4(new float4(m00, m10, m20, m30));
     this.c1 = new half4(new float4(m01, m11, m21, m31));
     this.c2 = new half4(new float4(m02, m12, m22, m32));
     this.c3 = new half4(new float4(m03, m13, m23, m33));
 }
Пример #17
0
        public static void half4_from_double4_construction()
        {
            half4 h0 = half4(double4(0.0, 2.98e-08, 5.96046448e-08, 123.4));
            half4 h1 = half4(double4(65504.0, 65520.0, double.PositiveInfinity, TestUtils.SignedDoubleQNaN()));
            half4 h2 = half4(double4(-2.98e-08, -5.96046448e-08, -123.4, -65504.0));
            half4 h3 = half4(double4(-65520.0, double.NegativeInfinity, double.NegativeInfinity, 0.0));

            TestUtils.AreEqual(uint4(0x0000, 0x0000, 0x0001, 0x57B6), uint4(h0.x.value, h0.y.value, h0.z.value, h0.w.value));
            TestUtils.AreEqual(uint4(0x7BFF, 0x7C00, 0x7C00, 0xFE00), uint4(h1.x.value, h1.y.value, h1.z.value, h1.w.value));
            TestUtils.AreEqual(uint4(0x8000, 0x8001, 0xD7B6, 0xFBFF), uint4(h2.x.value, h2.y.value, h2.z.value, h2.w.value));
            TestUtils.AreEqual(uint4(0xFC00, 0xFC00, 0xFC00, 0x0000), uint4(h3.x.value, h3.y.value, h3.z.value, h3.w.value));
        }
Пример #18
0
        public static void half4_from_float4_construction()
        {
            half4 h0 = half4(float4(0.0f, 2.98e-08f, 5.96046448e-08f, 123.4f));
            half4 h1 = half4(float4(65504.0f, 65520.0f, float.PositiveInfinity, TestUtils.SignedFloatQNaN()));
            half4 h2 = half4(float4(-2.98e-08f, -5.96046448e-08f, -123.4f, -65504.0f));
            half4 h3 = half4(float4(-65520.0f, float.NegativeInfinity, float.NegativeInfinity, 0.0f));

            TestUtils.AreEqual(uint4(0x0000, 0x0000, 0x0001, 0x57B6), uint4(h0.x.value, h0.y.value, h0.z.value, h0.w.value));
            TestUtils.AreEqual(uint4(0x7BFF, 0x7C00, 0x7C00, 0xFE00), uint4(h1.x.value, h1.y.value, h1.z.value, h1.w.value));
            TestUtils.AreEqual(uint4(0x8000, 0x8001, 0xD7B6, 0xFBFF), uint4(h2.x.value, h2.y.value, h2.z.value, h2.w.value));
            TestUtils.AreEqual(uint4(0xFC00, 0xFC00, 0xFC00, 0x0000), uint4(h3.x.value, h3.y.value, h3.z.value, h3.w.value));
        }
                public void Init()
                {
                    f4 = (float4 *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <float4>() * 10000, UnsafeUtility.AlignOf <float4>(), Allocator.Persistent);
                    for (int i = 0; i < 10000; ++i)
                    {
                        f4[i] = new float4(1.0f, 2.0f, 3.0f, 4.0f);
                    }

                    h4 = (half4 *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <half4>() * 10000, UnsafeUtility.AlignOf <half4>(), Allocator.Persistent);
                    for (int i = 0; i < 10000; ++i)
                    {
                        h4[i] = new half4(new float4(-1.0f, -2.0f, -3.0f, -4.0f));
                    }
                }
    void PrintCubemap()
    {
        float3[][] forwd = new float3[6][];
        for (int i = 0; i < 6; ++i)
        {
            forwd[i] = new float3[4];
        }
        //Forward
        forwd[4][0] = normalize(float3(-1, 1, 1));
        forwd[4][1] = normalize(float3(1, 1, 1));
        forwd[4][2] = normalize(float3(-1, -1, 1));
        forwd[4][3] = normalize(float3(1, -1, 1));
        //Left
        forwd[1][0] = normalize(float3(-1, 1, -1));
        forwd[1][1] = normalize(float3(-1, 1, 1));
        forwd[1][2] = normalize(float3(-1, -1, -1));
        forwd[1][3] = normalize(float3(-1, -1, 1));
        //Back
        forwd[5][0] = normalize(float3(1, 1, -1));
        forwd[5][1] = normalize(float3(-1, 1, -1));
        forwd[5][2] = normalize(float3(1, -1, -1));
        forwd[5][3] = normalize(float3(-1, -1, -1));

        //Right
        forwd[0][0] = normalize(float3(1, 1, 1));
        forwd[0][1] = normalize(float3(1, 1, -1));
        forwd[0][2] = normalize(float3(1, -1, 1));
        forwd[0][3] = normalize(float3(1, -1, -1));

        //up
        forwd[2][0] = normalize(float3(-1, 1, -1));
        forwd[2][1] = normalize(float3(1, 1, -1));
        forwd[2][2] = normalize(float3(-1, 1, 1));
        forwd[2][3] = normalize(float3(1, 1, 1));

        //down
        forwd[3][0] = normalize(float3(-1, -1, 1));
        forwd[3][1] = normalize(float3(1, -1, 1));
        forwd[3][2] = normalize(float3(-1, -1, -1));
        forwd[3][3] = normalize(float3(1, -1, -1));
        uint2 size = uint2(max((uint)texture.width, 1024), max((uint)texture.height, 1024));

        ComputeBuffer cb       = new ComputeBuffer((int)size.x * (int)size.y, sizeof(float4), ComputeBufferType.Default);
        int           mipCount = useMipMap ? (int)(log2(size.x / 16) + 0.1) : 1;
        TextureData   data     = new TextureData
        {
            depth       = 6,
            width       = size.x,
            height      = size.y,
            mipCount    = (uint)mipCount,
            format      = TextureData.LoadFormat.LoadFormat_RGBAFloat16,
            textureType = TextureType.Cubemap
        };

        readCS.SetTexture(0, "_MainTex", texture);
        readCS.SetBuffer(0, "_ResultBuffer", cb);
        float4[]          readbackValues = new float4[size.x * size.y];
        NativeList <byte> lst            = new NativeList <byte>((int)(size.x * size.y * 1.4), Unity.Collections.Allocator.Temp);
        byte *            headerPtr      = (byte *)data.Ptr();

        for (int i = 0; i < sizeof(TextureData); ++i)
        {
            lst.Add(headerPtr[i]);
        }
        Vector4[] setterArray = new Vector4[4];
        for (int face = 0; face < 6; ++face)
        {
            size = uint2(max((uint)texture.width, 1024), max((uint)texture.height, 1024));
            for (int i = 0; i < mipCount; ++i)
            {
                readCS.SetInt("_TargetMipLevel", i);
                readCS.SetInt("_Count", (int)size.x);
                for (int j = 0; j < 4; ++j)
                {
                    setterArray[j] = (Vector3)forwd[face][j];
                }
                readCS.SetVectorArray("_Directions", setterArray);
                readCS.Dispatch(0, max(1, Mathf.CeilToInt(size.x / 8f)), max(1, Mathf.CeilToInt(size.y / 8f)), 1);
                int cum = (int)(size.x * size.y);
                cb.GetData(readbackValues, 0, 0, cum);
                int pixelSize = 0;
                if (isCubemapCompress)
                {
                    pixelSize = 1;
                    NativeArray <byte> compressedData = new NativeArray <byte>(cum, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
                    BC6UHCompressJob   job;
                    job.dest   = (uint4 *)compressedData.GetUnsafePtr();
                    job.source = readbackValues.Ptr();
                    job.width  = (int)size.x;
                    JobHandle handle = job.Schedule((cum / 16), max((cum / 16) / 20, 1));
                    handle.Complete();
                    for (int a = 0; a < compressedData.Length; ++a)
                    {
                        lst.Add(compressedData[a]);
                    }
                }
                else
                {
                    pixelSize = sizeof(half4);
                    for (int j = 0; j < cum; ++j)
                    {
                        half4 hlfResult = (half4)readbackValues[j];
                        byte *b         = (byte *)hlfResult.Ptr();
                        for (int z = 0; z < sizeof(half4); ++z)
                        {
                            lst.Add(b[z]);
                        }
                    }
                }
                for (int j = cum * pixelSize; j < 512; ++j)
                {
                    lst.Add(0);
                }
                size /= 2;
                size  = max(size, 1);
            }
        }
        byte[] finalArray = new byte[lst.Length];
        UnsafeUtility.MemCpy(finalArray.Ptr(), lst.unsafePtr, lst.Length);
        using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
        {
            fs.Write(finalArray, 0, lst.Length);
        }
    }
Пример #21
0
        public static void half4_from_double4_construction_signed_zero()
        {
            half4 h0 = half4(double4(TestUtils.SignedDoubleZero(), TestUtils.SignedDoubleZero(), TestUtils.SignedDoubleZero(), TestUtils.SignedDoubleZero()));

            TestUtils.AreEqual(uint4(0x8000, 0x8000, 0x8000, 0x8000), uint4(h0.x.value, h0.y.value, h0.z.value, h0.w.value));
        }
        public static double Double4Half4(ref double4 a)
        {
            var h = new half4(a);

            return(Vectors.ConvertToDouble((double4) new double4(h).x));
        }
    void PrintTex2D()
    {
        uint2 size     = uint2((uint)texture.width, (uint)texture.height);
        int   mipCount = useMipMap ? min((int)(log2(size.x / 32) + 0.1), (int)(log2(size.y / 32) + 0.1)) : 1;

        Debug.Log(mipCount);
        TextureData data;

        data.width       = size.x;
        data.height      = size.y;
        data.depth       = 1;
        data.textureType = TextureType.Tex2D;
        data.mipCount    = (uint)mipCount;
        data.format      = tex2DFormat;
        NativeList <byte> lst       = new NativeList <byte>((int)(size.x * size.y * 1.4 * 8), Unity.Collections.Allocator.Temp);
        byte *            headerPtr = (byte *)data.Ptr();

        for (int i = 0; i < sizeof(TextureData); ++i)
        {
            lst.Add(headerPtr[i]);
        }

        if (tex2DFormat == TextureData.LoadFormat.LoadFormat_BC6H)
        {
            uint4[]       datas    = new uint4[size.x * size.y];
            CommandBuffer cbuffer  = new CommandBuffer();
            GPUCompress   compress = new GPUCompress(bc7Compress, bc6Compress, (int)size.x, (int)size.y, 0x80000, 0);
            for (int i = 0; i < mipCount; ++i)
            {
                compress.Compress(texture as Texture2D, (int)size.x, (int)size.y, i, cbuffer, true);
                Graphics.ExecuteCommandBuffer(cbuffer);
                var len = compress.GetData((int)size.x, (int)size.y, datas);
                for (int a = 0; a < len; ++a)
                {
                    uint4 value = datas[a];
                    byte *ptr   = (byte *)value.Ptr();
                    for (int b = 0; b < sizeof(uint4); ++b)
                    {
                        lst.Add(ptr[b]);
                    }
                }
                for (int a = datas.Length * sizeof(uint4); a < 512; ++a)
                {
                    lst.Add(0);
                }
                size /= 2;
                size  = max(size, 1);
            }

            compress.Dispose();
            cbuffer.Dispose();
        }
        else if (tex2DFormat == TextureData.LoadFormat.LoadFormat_BC7)
        {
            uint4[]       datas    = new uint4[size.x * size.y];
            CommandBuffer cbuffer  = new CommandBuffer();
            GPUCompress   compress = new GPUCompress(bc7Compress, bc6Compress, (int)size.x, (int)size.y, 0x80000, 0);
            for (int i = 0; i < mipCount; ++i)
            {
                compress.Compress(texture as Texture2D, (int)size.x, (int)size.y, i, cbuffer, false);
                Graphics.ExecuteCommandBuffer(cbuffer);
                var len = compress.GetData((int)size.x, (int)size.y, datas);
                for (int a = 0; a < len; ++a)
                {
                    uint4 value = datas[a];
                    byte *ptr   = (byte *)value.Ptr();
                    for (int b = 0; b < sizeof(uint4); ++b)
                    {
                        lst.Add(ptr[b]);
                    }
                }
                for (int a = datas.Length * sizeof(uint4); a < 512; ++a)
                {
                    lst.Add(0);
                }
                size /= 2;
                size  = max(size, 1);
            }

            compress.Dispose();
            cbuffer.Dispose();
        }
        else if ((int)tex2DFormat >= 8 && (int)tex2DFormat <= 10)
        {
            //integer texture

            int    pass      = 0;
            uint[] dataArray = null;
            readCS.SetVector("_TextureSize", float4(size.x - 0.5f, size.y - 0.5f, size.x, size.y));
            readCS.SetInt("_Count", (int)size.x);
            ComputeBuffer cb = null;
            switch (tex2DFormat)
            {
            case TextureData.LoadFormat.LoadFormat_UINT:
                pass      = 2;
                dataArray = new uint[size.x * size.y];
                cb        = new ComputeBuffer(dataArray.Length, sizeof(int));
                readCS.SetTexture(pass, "_UIntTexture", texture);
                readCS.SetBuffer(pass, "_ResultInt1Buffer", cb);
                break;

            case TextureData.LoadFormat.LoadFormat_UINT2:
                pass      = 3;
                dataArray = new uint[size.x * size.y * 2];
                cb        = new ComputeBuffer(dataArray.Length, sizeof(int));
                readCS.SetTexture(pass, "_UInt2Texture", texture);
                readCS.SetBuffer(pass, "_ResultInt2Buffer", cb);
                break;

            case TextureData.LoadFormat.LoadFormat_UINT4:
                pass      = 4;
                dataArray = new uint[size.x * size.y * 4];
                cb        = new ComputeBuffer(dataArray.Length, sizeof(int));
                readCS.SetTexture(pass, "_UInt4Texture", texture);
                readCS.SetBuffer(pass, "_ResultInt4Buffer", cb);
                break;
            }
            readCS.Dispatch(pass, (int)size.x / 8, (int)size.y / 8, 1);
            cb.GetData(dataArray);
            foreach (var i in dataArray)
            {
                uint  p   = i;
                byte *ptr = (byte *)p.Ptr();
                for (uint a = 0; a < sizeof(int); ++a)
                {
                    lst.Add(ptr[a]);
                }
            }

            cb.Dispose();
        }
        else
        {
            ComputeBuffer cb = new ComputeBuffer((int)size.x * (int)size.y, sizeof(float4), ComputeBufferType.Default);
            readCS.SetTexture(1, "_MainTex2D", texture);
            readCS.SetBuffer(1, "_ResultBuffer", cb);
            float4[] readbackValues = new float4[size.x * size.y];
            float *  byteArray      = stackalloc float[4];
            for (int i = 0; i < mipCount; ++i)
            {
                readCS.SetVector("_TextureSize", float4(size.x - 0.5f, size.y - 0.5f, size.x, size.y));
                readCS.SetInt("_Count", (int)size.x);
                readCS.SetInt("_TargetMipLevel", i);
                readCS.Dispatch(1, max(1, Mathf.CeilToInt(size.x / 8f)), max(1, Mathf.CeilToInt(size.y / 8f)), 1);
                int cum = (int)(size.x * size.y);
                cb.GetData(readbackValues, 0, 0, cum);
                switch (tex2DFormat)
                {
                case TextureData.LoadFormat.LoadFormat_RGBAFloat16:
                    for (int j = 0; j < cum; ++j)
                    {
                        half4 hlfResult = (half4)readbackValues[j];
                        byte *b         = (byte *)hlfResult.Ptr();
                        for (int z = 0; z < sizeof(half4); ++z)
                        {
                            lst.Add(b[z]);
                        }
                    }
                    for (int j = cum * sizeof(half4); j < 512; ++j)
                    {
                        lst.Add(0);
                    }
                    break;

                case TextureData.LoadFormat.LoadFormat_RGFLOAT16:
                    for (int j = 0; j < cum; ++j)
                    {
                        half2 hlfResult = (half2)readbackValues[j].xy;
                        byte *b         = (byte *)hlfResult.Ptr();
                        for (int z = 0; z < sizeof(half2); ++z)
                        {
                            lst.Add(b[z]);
                        }
                    }
                    for (int j = cum * sizeof(half2); j < 512; ++j)
                    {
                        lst.Add(0);
                    }
                    break;

                case TextureData.LoadFormat.LoadFormat_RGBAFloat32:
                    for (int j = 0; j < cum; ++j)
                    {
                        float4 hlfResult = readbackValues[j];
                        byte * b         = (byte *)hlfResult.Ptr();
                        for (int z = 0; z < sizeof(float4); ++z)
                        {
                            lst.Add(b[z]);
                        }
                    }
                    for (int j = cum * sizeof(float4); j < 512; ++j)
                    {
                        lst.Add(0);
                    }
                    break;

                case TextureData.LoadFormat.LoadFormat_RGBA16:
                    for (int j = 0; j < cum; ++j)
                    {
                        ushort *shorts = (ushort *)byteArray;
                        float * flt    = (float *)readbackValues[j].Ptr();
                        for (int bb = 0; bb < 4; ++bb)
                        {
                            shorts[bb] = (ushort)(flt[bb] * 65535);
                        }
                        byte *b = (byte *)shorts;
                        for (int z = 0; z < sizeof(ushort) * 4; ++z)
                        {
                            lst.Add(b[z]);
                        }
                    }
                    for (int j = cum * sizeof(ushort) * 4; j < 512; ++j)
                    {
                        lst.Add(0);
                    }
                    break;

                case TextureData.LoadFormat.LoadFormat_RG16:
                    for (int j = 0; j < cum; ++j)
                    {
                        ushort *shorts = (ushort *)byteArray;
                        float * flt    = (float *)readbackValues[j].Ptr();
                        for (int bb = 0; bb < 2; ++bb)
                        {
                            shorts[bb] = (ushort)(flt[bb] * 65535);
                        }
                        byte *b = (byte *)shorts;
                        for (int z = 0; z < sizeof(ushort) * 2; ++z)
                        {
                            lst.Add(b[z]);
                        }
                    }
                    for (int j = cum * sizeof(ushort) * 2; j < 512; ++j)
                    {
                        lst.Add(0);
                    }
                    break;

                case TextureData.LoadFormat.LoadFormat_RGBA8:
                    for (int j = 0; j < cum; ++j)
                    {
                        byte * shorts = (byte *)byteArray;
                        float *flt    = (float *)readbackValues[j].Ptr();
                        for (int bb = 0; bb < 4; ++bb)
                        {
                            shorts[bb] = (byte)(flt[bb] * 255);
                        }
                        for (int z = 0; z < sizeof(byte) * 4; ++z)
                        {
                            lst.Add(shorts[z]);
                        }
                    }
                    for (int j = cum * sizeof(byte) * 4; j < 512; ++j)
                    {
                        lst.Add(0);
                    }
                    break;

                    /*  case TextureData.LoadFormat.LoadFormat_BC7:
                     *    {
                     *
                     *
                     *        NativeArray<byte> compressedData = new NativeArray<byte>(cum, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
                     *        BC7CompressJob job;
                     *        job.dest = (uint4*)compressedData.GetUnsafePtr();
                     *        job.source = readbackValues.Ptr();
                     *        job.width = (int)size.x;
                     *        JobHandle handle = job.Schedule((cum / 16), max((cum / 16) / 20, 1));
                     *        handle.Complete();
                     *        for (int a = 0; a < compressedData.Length; ++a)
                     *        {
                     *            lst.Add(compressedData[a]);
                     *        }
                     *        for (int j = cum * sizeof(byte); j < 512; ++j)
                     *        {
                     *            lst.Add(0);
                     *        }
                     * }
                     * break;
                     * case TextureData.LoadFormat.LoadFormat_BC6H:
                     * {
                     *  NativeArray<byte> compressedData = new NativeArray<byte>(cum, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
                     *  BC6UHCompressJob job;
                     *  job.dest = (uint4*)compressedData.GetUnsafePtr();
                     *  job.source = readbackValues.Ptr();
                     *  job.width = (int)size.x;
                     *  JobHandle handle = job.Schedule((cum / 16), max((cum / 16) / 20, 1));
                     *  handle.Complete();
                     *  for (int a = 0; a < compressedData.Length; ++a)
                     *  {
                     *      lst.Add(compressedData[a]);
                     *  }
                     *  for (int j = cum * sizeof(byte); j < 512; ++j)
                     *  {
                     *      lst.Add(0);
                     *  }
                     * }
                     * break;*/
                }

                size /= 2;
                size  = max(size, 1);
            }
            cb.Dispose();
        }
        byte[] finalArray = new byte[lst.Length];
        UnsafeUtility.MemCpy(finalArray.Ptr(), lst.unsafePtr, lst.Length);
        using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
        {
            fs.Write(finalArray, 0, lst.Length);
        }
    }
Пример #24
0
 public static Color ToColor(this half4 f)
 {
     return(new Color(f.x, f.y, f.z, f.w));
 }
        public static float Float4Half4(ref float4 a)
        {
            var h = new half4(a);

            return(Vectors.ConvertToFloat((float4) new float4(h).x));
        }
Пример #26
0
        public static void half4_from_float4_construction_signed_zero()
        {
            half4 h0 = half4(float4(-0.0f, -0.0f, -0.0f, -0.0f));

            TestUtils.AreEqual(uint4(0x8000, 0x8000, 0x8000, 0x8000), uint4(h0.x.value, h0.y.value, h0.z.value, h0.w.value));
        }
Пример #27
0
 public void GetIdentity(out half4 identity)
 {
     identity = new half4(0);
 }
Пример #28
0
 public half8(half2 x01, half2 x23, half4 x4567)
 {
     this = maxmath.ashalf(new ushort8(maxmath.asushort(x01), maxmath.asushort(x23), maxmath.asushort(x4567)));
 }
Пример #29
0
 public half8(half4 x0123, half2 x45, half2 x67)
 {
     this = maxmath.ashalf(new ushort8(maxmath.asushort(x0123), maxmath.asushort(x45), maxmath.asushort(x67)));
 }
Пример #30
0
 public half8(half2 x01, half4 x2345, half2 x67)
 {
     this = maxmath.ashalf(new ushort8(maxmath.asushort(x01), maxmath.asushort(x2345), maxmath.asushort(x67)));
 }