コード例 #1
0
ファイル: ShaderLayer.cs プロジェクト: Thaon/IRNBRU
public Float4 clamp(Float4 asd,float mi,float ma){
	asd.x = Mathf.Clamp(asd.x,mi,ma);
	asd.y = Mathf.Clamp(asd.y,mi,ma);
	asd.z = Mathf.Clamp(asd.z,mi,ma);
	asd.w = Mathf.Clamp(asd.w,mi,ma);
	return asd;
}
コード例 #2
0
ファイル: ShaderLayer.cs プロジェクト: Thaon/IRNBRU
public Float dot(Float4 asd,Float4 asd2){
	return asd.x*asd2.x+asd.y*asd2.y+asd.z*asd2.z+asd.w*asd2.w;
}
コード例 #3
0
ファイル: ShaderLayer.cs プロジェクト: Thaon/IRNBRU
//Float2 Interpolation_C2( Float2 x ) { return (x*x).Square().Mul((x * ((x * 6.0f) - 15.0f)).Add(10.0f)); }
void FastHash2D(Float2 Pos,out Float4 hash_0, out Float4 hash_1, out Float4 hash_2){
	Float2 Offset = new Float2(26,161);
	Float Domain = 71f;
	Float3 SomeLargeFloats = new Float3(951.135664f,642.9478304f,803.202459f);
	Float4 P = new Float4(Pos,Pos+1);
	P = P.Sub(floor(P.Mul((1.0f/Domain)),true).Mul(Domain));
	P.Add(Offset.xyxy);
	P.Square();
	P = P.xzxz*P.yyww;
	hash_0 = frac(P*(1f/SomeLargeFloats.x),true);
	hash_1 = frac(P*(1f/SomeLargeFloats.y),true);
	hash_2 = frac(P*(1f/SomeLargeFloats.z),true);
}
コード例 #4
0
ファイル: ShaderLayer.cs プロジェクト: Thaon/IRNBRU
public Float4 rsqrt(Float4 asd){
	asd.x = Mathf.Pow(asd.x,-1f/2f);
	asd.y = Mathf.Pow(asd.y,-1f/2f);
	asd.z = Mathf.Pow(asd.z,-1f/2f);
	asd.w = Mathf.Pow(asd.w,-1f/2f);
	return asd;
}
コード例 #5
0
ファイル: ShaderLayer.cs プロジェクト: Thaon/IRNBRU
public void FastHash2D(Float2 Pos,out Float4 hash_0, out Float4 hash_1){
	//Float2 Offset = new Float2(26,161);
	float Domain = 71;
	Float2 SomeLargeFloats = new Float2(951.135664f,642.9478304f);
	Float4 P = new Float4(Pos.x,Pos.y,Pos.x+1,Pos.y+1);
	P = P-floor(P*(1.0f/Domain),false)*Domain;
	P.x += 26;
	P.y += 161;
	P.z += 26;
	P.w += 161;
	P.Mul(P);
	P = P.xzxz.Mul(P.yyww);
	hash_0 = frac(P*(1/SomeLargeFloats.x),false);
	hash_1 = frac(P*(1/SomeLargeFloats.y),false);
}
コード例 #6
0
ファイル: ShaderLayer.cs プロジェクト: Thaon/IRNBRU
public Float4 frac(Float4 s,bool SpawnNew){
	if (SpawnNew)
	return s-floor(s,true);
	else
	return s.Sub(floor(s,true));
}
コード例 #7
0
ファイル: ShaderLayer.cs プロジェクト: Thaon/IRNBRU
public Float4 floor(Float4 s,bool SpawnNew){
	if (SpawnNew)
		s = new Float4(s.x,s.y,s.z,s.w);
	s.x = Mathf.Floor(s.x);
	s.y = Mathf.Floor(s.y);
	s.z = Mathf.Floor(s.z);
	s.w = Mathf.Floor(s.w);
	return s;
}
コード例 #8
0
ファイル: ShaderLayer.cs プロジェクト: Thaon/IRNBRU
Float CubistNoise(float X,float Y,float Val1,float Val2)
{
	Float2 P = new Float2(X,Y);
	Float2 Pi = floor(P,true);
	Float4 Pf_Pfmin1 = P.xyxy.Sub(new Float4(Pi,Pi+1));
	Float4 HashX, HashY, HashValue;
	FastHash2D(Pi,out HashX,out HashY,out HashValue);
	Float4 GradX = HashX.Sub(0.499999f);
	Float4 GradY = HashY.Sub(0.499999f);
	Float4 GradRes = rsqrt(GradX*GradX+GradY*GradY)*(GradX*Pf_Pfmin1.xzxz+GradY*Pf_Pfmin1.yyww);
	GradRes = ( HashValue - 0.5f ).Mul( 1.0f / GradRes );
	
	GradRes.Mul(1.4142135623730950488016887242097f);
	Float2 blend = Interpolation_C2(Pf_Pfmin1.xy);
	Float4 blend2 = new Float4(blend,new Float2(1.0f-blend));
	Float final = (dot(GradRes,blend2.zxzx*blend2.wwyy));
	//return Interpolation_C2(new Float2(0.6f));
	return clamp((final.Add(Val1)).Mul(Val2),0.0f,1.0f);
}
コード例 #9
0
 public static Float4 Step(float edge, Float4 x)
 {
     return(new Float4(Math.Step(edge, x.X), Math.Step(edge, x.Y), Math.Step(edge, x.Z), Math.Step(edge, x.W)));
 }
コード例 #10
0
 public static Float4 Mod(Float4 x, float y)
 {
     return(x - (y * Math.Floor(x / y)));
 }
コード例 #11
0
 public static Float4 DegreesToRadians(Float4 degrees)
 {
     return(degrees * 0.0174532924f);
 }
コード例 #12
0
 public static Float4 InverseSqrt(Float4 x)
 {
     return(new Float4(Math.InverseSqrt(x.X), Math.InverseSqrt(x.Y), Math.InverseSqrt(x.Z), Math.InverseSqrt(x.W)));
 }
コード例 #13
0
 public static Float4 Atan(Float4 radians)
 {
     return(new Float4(Math.Atan(radians.X), Math.Atan(radians.Y), Math.Atan(radians.Z), Math.Atan(radians.W)));
 }
コード例 #14
0
 public static Float4 Pow(Float4 x, Float4 y)
 {
     return(new Float4(Math.Pow(x.X, y.X), Math.Pow(x.Y, y.Y), Math.Pow(x.Z, y.Z), Math.Pow(x.W, y.W)));
 }
コード例 #15
0
 public static Float4 Round(Float4 x, int decimals)
 {
     return(new Float4(Math.Round(x.X, decimals), Math.Round(x.Y, decimals), Math.Round(x.Z, decimals), Math.Round(x.W, decimals)));
 }
コード例 #16
0
 public static float ComponentMin(Float4 x)
 {
     return(Math.Min(Math.Min(Math.Min(x.X, x.Y), x.Z), x.W));
 }
コード例 #17
0
		public void GetQuaternion(ref float x, ref float y, ref float z, ref float w) {} // 0x00A1D240-0x00A1D250
		public void GetQuaternion(ref Float4 quaternion) {} // 0x00A1D250-0x00A1D270
コード例 #18
0
 public static Float4 Fract(Float4 x)
 {
     return(x - Math.Floor(x));
 }
コード例 #19
0
 public void FillFromNetworkBuffer(ref Byte[] buffer, int i)
 {
     int offset = 104 + i * 176;
         pos = NetworkReaderHelper.ReadFloat4(ref buffer, offset);
         vel = NetworkReaderHelper.ReadFloat4(ref buffer, offset + 16);
         accel = NetworkReaderHelper.ReadFloat4(ref buffer, offset + 32);
         quat = NetworkReaderHelper.ReadFloat4(ref buffer, offset + 48);
         angvel = NetworkReaderHelper.ReadFloat4(ref buffer, offset + 64);
         angaccel = NetworkReaderHelper.ReadFloat4(ref buffer, offset + 80);
         handle_pos = NetworkReaderHelper.ReadFloat4(ref buffer, offset + 96);
         handle_vel = NetworkReaderHelper.ReadFloat4(ref buffer, offset + 112);
         handle_accel = NetworkReaderHelper.ReadFloat4(ref buffer, offset + 128);
         pad.FillFromNetworkBuffer(ref buffer, i);
         timestamp = NetworkReaderHelper.ReadInt64(ref buffer, offset + 152);
         temperature = NetworkReaderHelper.ReadFloat(ref buffer, offset + 160);
         camera_pitch_angle = NetworkReaderHelper.ReadFloat(ref buffer, offset + 164);
         tracking_flags = NetworkReaderHelper.ReadUint32(ref buffer, offset + 168);
 }
コード例 #20
0
ファイル: PSMoveWrapper.cs プロジェクト: jasonlu00/LeafSOURCE
    public Float4 quatToEuler(Float4 q)
    {
        Float4 euler;

        euler.y = Convert.ToSingle(Math.Asin(2.0 * ((q.x * q.z) - (q.w * q.y))));

        if (euler.y == 90.0)
        {
            euler.x = Convert.ToSingle(2.0 * Math.Atan2(q.x, q.w));
            euler.z = 0;
        }
        else if (euler.y == -90.0)
        {
            euler.x = Convert.ToSingle(-2.0 * Math.Atan2(q.x, q.w));
            euler.z = 0;
        }
        else
        {
            euler.x = Convert.ToSingle(Math.Atan2(2.0 * ((q.x * q.y) + (q.z * q.w)), 1.0 - (2.0 * ((q.y * q.y) + (q.z * q.z)))));
            euler.z = Convert.ToSingle(Math.Atan2(2.0 * ((q.x * q.w) + (q.y * q.z)), 1.0 - (2.0 * ((q.z * q.z) + (q.w * q.w)))));
        }

        euler.w = 0;

        return euler;
    }
コード例 #21
0
ファイル: ShaderFloats.cs プロジェクト: Thaon/IRNBRU
	public Float4 Sub(Float4 xx){
		x-=xx.x;
		y-=xx.y;
		z-=xx.z;
		w-=xx.w;
		return this;
	}
コード例 #22
0
ファイル: ShaderFloats.cs プロジェクト: Thaon/IRNBRU
	public Float4 Div(Float4 xx){
		x/=xx.x;
		y/=xx.y;
		z/=xx.z;
		w/=xx.w;
		return this;
	}
コード例 #23
0
ファイル: ShaderFloats.cs プロジェクト: Thaon/IRNBRU
	public Float4 Add(Float4 xx){
		x+=xx.x;
		y+=xx.y;
		z+=xx.z;
		w+=xx.w;
		return this;
	}
コード例 #24
0
 public static Float4 Sign(Float4 a)
 {
     return(new Float4(Math.Sign(a.X), Math.Sign(a.Y), Math.Sign(a.Z), Math.Sign(a.W)));
 }
コード例 #25
0
ファイル: VoxelImage.cs プロジェクト: evrimulgen/tsvme
        /*
         * private unsafe Mem GetCounter()
         * {
         *  fixed (ulong* dataptr = &voxelctr)
         *  {
         *      counter = manager.Context.CreateBuffer(MemFlags.READ_WRITE, 8, new IntPtr(dataptr));
         *  }
         *  return counter;
         * }*/

        private unsafe void DoRayCasting(BitmapData output)
        {
            try
            {
                int deviceIndex = 0;
                outputBuffer = manager.Context.CreateBuffer(MemFlags.USE_HOST_PTR, output.Stride * output.Height, output.Scan0);



                if (first || changeDistance)
                {
                    // модель камеры UVN
                    camPos = new Float4()
                    {
                        S0 =
                            vol.GetSize() / 2 - (float)Math.Cos(camAngle * Math.PI / 180) * camDist,
                        S1 = vol.GetSize() / 2,
                        S2 = vol.GetSize() / 2 - (float)Math.Sin(camAngle * Math.PI / 180) * camDist,
                        S3 = 0
                    };

                    first          = false;
                    changeDistance = false;
                    camPosOld      = camPos;
                }

                else
                {
                    // поворот вокруг оси куба визуализации
                    if (angleChange && leftChange)
                    {
                        camPosOld.S0 -= camLookAt.S0;
                        camPosOld.S2 -= camLookAt.S2;

                        camPos.S0 = (float)Math.Cos(camAngle * Math.PI / 180) * camPosOld.S0 + (float)Math.Sin(camAngle * Math.PI / 180) * camPosOld.S2;
                        camPos.S1 = vol.GetSize() / 2;
                        camPos.S2 = -(float)Math.Sin(camAngle * Math.PI / 180) * camPosOld.S0 + (float)Math.Cos(camAngle * Math.PI / 180) * camPosOld.S2;
                        camPos.S3 = 0;

                        camPos.S0 += camLookAt.S0;
                        camPos.S2 += camLookAt.S2;

                        camPosOld   = camPos;
                        angleChange = false;
                        leftChange  = false;
                    }
                    if (angleChange && rightChange)
                    {
                        camPosOld.S0 -= camLookAt.S0;
                        camPosOld.S2 -= camLookAt.S2;

                        camPos.S0 = (float)Math.Cos(camAngle * Math.PI / 180) * camPosOld.S0 - (float)Math.Sin(camAngle * Math.PI / 180) * camPosOld.S2;
                        camPos.S1 = vol.GetSize() / 2;
                        camPos.S2 = (float)Math.Sin(camAngle * Math.PI / 180) * camPosOld.S0 + (float)Math.Cos(camAngle * Math.PI / 180) * camPosOld.S2;
                        camPos.S3 = 0;

                        camPos.S0 += camLookAt.S0;
                        camPos.S2 += camLookAt.S2;

                        camPosOld   = camPos;
                        angleChange = false;
                        leftChange  = false;
                    }
                }

                camLookAt = new Float4()
                {
                    S0 = vol.GetSize() / camfactorX,
                    S1 = vol.GetSize() / camfactorX,
                    S2 = vol.GetSize() / camfactorZ,
                    S3 = 0
                };

                //light = camPos;

                // направление камеры, UVN модель
                camForward = camLookAt.Sub(camPos).Normalize(); // направление просмотра
                var up    = new Float4(0.0f, 1.0f, 0.0f, 0.0f);
                var right = MathClass.Cross(up, camForward).Normalize().Times(1.5f);
                up = MathClass.Cross(camForward, right).Normalize().Times(-1.5f);



                /*  обработка выходного изображения BitmapData в OpenCl устройстве */
                for (var x = 0; x < output.Width; x += blocksize)
                {
                    for (var y = 0; y < output.Height; y += blocksize)
                    {
                        var rayTracingGlobalWorkSize = new IntPtr[2]; // work_dim = 2
                        rayTracingGlobalWorkSize[0] = (IntPtr)(output.Width - x > blocksize ? blocksize : output.Width - x);
                        rayTracingGlobalWorkSize[1] = (IntPtr)(output.Height - y > blocksize ? blocksize : output.Height - y);

                        var rayTracingGlobalOffset = new IntPtr[2];
                        rayTracingGlobalOffset[0] = (IntPtr)x;
                        rayTracingGlobalOffset[1] = (IntPtr)y;

                        float ka  = (float)(Convert.ToDouble(kamb.Text));
                        float kd  = (float)(Convert.ToDouble(kdiff.Text));
                        float ks  = (float)(Convert.ToDouble(kspec.Text));
                        float exp = (float)(Convert.ToDouble(specexp.Text));

                        float kkc = (float)(Convert.ToDouble(this.kc.Text));
                        float kkl = (float)(Convert.ToDouble(this.kl.Text));
                        float kkq = (float)(Convert.ToDouble(this.kq.Text));

                        /* передали аргументы в kernel функцию */
                        kernel.SetArg(0, output.Width);
                        kernel.SetArg(1, output.Height);
                        kernel.SetArg(2, outputBuffer);  // в ядре с global, поскольку для выполнения требуется доступ к output
                        kernel.SetArg(3, output.Stride);
                        kernel.SetArg(4, camPos);
                        kernel.SetArg(5, camForward);
                        kernel.SetArg(6, right);
                        kernel.SetArg(7, up);
                        kernel.SetArg(8, vol.CreateBuffer());
                        kernel.SetArg(9, vol.GetSize());
                        kernel.SetArg(10, light);
                        kernel.SetArg(11, boxMinCon);
                        kernel.SetArg(12, boxMaxCon);
                        kernel.SetArg(13, Convert.ToInt16(colorMi.Text));
                        kernel.SetArg(14, Convert.ToInt16(colorMa.Text));
                        kernel.SetArg(15, _cutArrea.Checked ? (short)1 : (short)0);
                        kernel.SetArg(16, _trilinear.Checked ? (short)1 : (short)0);
                        kernel.SetArg(17, tf.Checked ? (short)1: (short)0);
                        kernel.SetArg(18, GetColors());
                        kernel.SetArg(19, winWidth_vox);
                        kernel.SetArg(20, winCentre_vox);
                        kernel.SetArg(21, form_this.knots_counter);
                        kernel.SetArg(22, Convert.ToInt16(colorMi2.Text));
                        kernel.SetArg(23, Convert.ToInt16(colorMa2.Text));
                        kernel.SetArg(24, GetOpacity());
                        kernel.SetArg(25, ka);
                        kernel.SetArg(26, kd);
                        kernel.SetArg(27, ks);
                        kernel.SetArg(28, exp);
                        kernel.SetArg(29, kkc);
                        kernel.SetArg(30, kkl);
                        kernel.SetArg(31, kkq);
                        //kernel.SetArg(32, GetCounter());

                        /* Ставит в очередь команду для исполнения kernel на устройстве */

                        /*
                         *  rayTracingGlobalOffset -
                         *  globalWorkOffset: может использоваться для указания массива значений
                         *  размерности work_dim unsigned который описывает смещение используемое для расчета  global ID  work-item
                         *  вместо того чтобы global IDs всегда начинался со смещение (0, 0,... 0).
                         *
                         *  rayTracingGlobalWorkSize -
                         *  globalWorkSize: общее число global work-items вычисляется как global_work_size[0] *...* global_work_size[work_dim - 1].
                         *
                         */
                        manager.CQ[deviceIndex].EnqueueNDRangeKernel(kernel, 2, rayTracingGlobalOffset, rayTracingGlobalWorkSize, null);
                    }
                }

                /* подождали пока все work-items выполнятся */
                manager.CQ[deviceIndex].EnqueueBarrier();

                /* для того чтобы получить доступ к памяти и записать в выходное изображение мы просим у OpenCL *наложить* данные в хост-устройство */
                IntPtr p = manager.CQ[deviceIndex].EnqueueMapBuffer(outputBuffer, true, MapFlags.READ, IntPtr.Zero, (IntPtr)(output.Stride * output.Height));
                //IntPtr z = manager.CQ[deviceIndex].EnqueueMapBuffer(counter, true, MapFlags.READ_WRITE, IntPtr.Zero, (IntPtr)(sizeof(ulong)));

                /* когда мы заканчиваем работать с буфером надо вызвать эту функцию */
                manager.CQ[deviceIndex].EnqueueUnmapMemObject(outputBuffer, p);
                //manager.CQ[deviceIndex].EnqueueUnmapMemObject(counter, z);
                manager.CQ[deviceIndex].Finish();
                realctr          += voxelctr;
                voxelCounter.Text = Convert.ToString(realctr);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ray casting exception:" + ex.Message, "Exception");
                //Environment.Exit(-1);
            }
            finally
            {
                if (outputBuffer != null)
                {
                    outputBuffer.Dispose();
                }
            }
        }
コード例 #26
0
 public static Float4 RadiansToDegrees(Float4 radians)
 {
     return(radians * 57.2957764f);
 }
コード例 #27
0
 public void SetLocation(Float4 newLocation)
 {
     newLocation -= Pivot;
     Position     = newLocation;
 }
コード例 #28
0
ファイル: ShaderFloats.cs プロジェクト: Thaon/IRNBRU
	public Float4 Mul(Float4 xx){
		x*=xx.x;
		y*=xx.y;
		z*=xx.z;
		w*=xx.w;
		return this;
	}
コード例 #29
0
ファイル: Program.cs プロジェクト: mantis1262/Optymalizcjie
        static void Main(string[] args)
        {
            Float3    f3    = new Float3(10, 20, 30);
            Float3    f32   = new Float3(20, 20, 30);
            Float3SSE f3sse = new Float3SSE(new float[3] {
                10, 20, 30
            });
            Float3SSE f3sse2 = new Float3SSE(new float[3] {
                20, 20, 30
            });
            Float4      float4      = new Float4(2, 2, 2, 2);
            Float4      float42     = new Float4(-1, -31.32f, -12.3f, 2);
            Float4x4    float4X4    = new Float4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6);
            Float4SSE   float4sse   = new Float4SSE(new float[] { 2, 2, 2, 2 });
            Float4SSE   float42sse  = new Float4SSE(new float[] { -1, -31.32f, -12.3f, 2 });
            Float4x4SSE float4X4sse = new Float4x4SSE(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6);

            Stopwatch stopwatch = new Stopwatch();

            //Float3
            Console.WriteLine("Float3");
            stopwatch.Start();
            Float3 a = f3 + f32;

            stopwatch.Stop();
            Console.WriteLine("sumaFPU" + a.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            Float3SSE asse = f3sse + f3sse2;

            stopwatch.Stop();
            Console.WriteLine("sumaSSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();
            ///
            stopwatch.Start();
            a = f3 - f32;
            stopwatch.Stop();
            Console.WriteLine("rożnicaFPU" + a.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            asse = f3sse - f3sse2;
            stopwatch.Stop();
            Console.WriteLine("rożnicaSSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();
            ///
            stopwatch.Start();
            a = f3 * f32;
            stopwatch.Stop();
            Console.WriteLine("ilocztnFPU" + a.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            asse = f3sse * f3sse2;
            stopwatch.Stop();
            Console.WriteLine("iloczynSSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();
            ///
            stopwatch.Start();
            a = f3 / f32;
            stopwatch.Stop();
            Console.WriteLine("iloraz FPU" + a.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            asse = f3sse / f3sse2;
            stopwatch.Stop();
            Console.WriteLine("iloraz SSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            /////
            ///
            Console.WriteLine("\n\n Skalar");
            stopwatch.Start();
            a = f3 + 1;
            stopwatch.Stop();
            Console.WriteLine("suma FPU" + a.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            asse = f3sse + 1;
            stopwatch.Stop();
            Console.WriteLine("suma SSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            ///
            stopwatch.Start();
            a = f3 - 1;
            stopwatch.Stop();
            Console.WriteLine("Rożnica FPU" + a.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            asse = f3sse - 1;
            stopwatch.Stop();
            Console.WriteLine("Ronica SSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            ///
            stopwatch.Start();
            a = f3 * 2;
            stopwatch.Stop();
            Console.WriteLine("iloczyn FPU" + a.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            asse = f3sse * 2;
            stopwatch.Stop();
            Console.WriteLine("iloczyn SSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();
            ///
            stopwatch.Start();
            a = f3 / 2.5f;
            stopwatch.Stop();
            Console.WriteLine("iloraz FPU" + a.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            asse = f3sse / 2.5f;
            stopwatch.Stop();
            Console.WriteLine("iloraz SSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();


            ///
            stopwatch.Start();
            a = f3.Normalized;
            stopwatch.Stop();
            Console.WriteLine("Normalizacjia FPU" + a.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            asse = f3sse.Normalized;
            stopwatch.Stop();
            Console.WriteLine("Normalizacjia  SSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            ///
            stopwatch.Start();
            a = f3.Reflect(f32);
            stopwatch.Stop();
            Console.WriteLine("Reflect FPU" + a.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            asse = f3sse.Reflect(f3sse2);
            stopwatch.Stop();
            Console.WriteLine("Reflect SSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            ///
            stopwatch.Start();
            a = f3.saturate();
            stopwatch.Stop();
            Console.WriteLine("Saturate FPU" + a.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            asse = f3sse.Saturat();
            stopwatch.Stop();
            Console.WriteLine("Saturate SSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            ///
            stopwatch.Start();
            float s = f3.Dot(f32);

            stopwatch.Stop();
            Console.WriteLine("dot FPU" + s.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            asse = f3sse.Dot(f3sse2);
            stopwatch.Stop();
            Console.WriteLine("dot SSE" + asse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            ////
            ///Float4

            Console.WriteLine("Float3");
            stopwatch.Start();
            Float4 a4 = float4 + float42;

            stopwatch.Stop();
            Console.WriteLine("sumaFPU" + a4.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            Float4SSE a4sse = float42sse + float4sse;

            stopwatch.Stop();
            Console.WriteLine("sumaSSE" + a4sse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();
            ///
            stopwatch.Start();
            a4 = float4 - float42;
            stopwatch.Stop();
            Console.WriteLine("rożnicaFPU" + a4.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            a4sse = float4sse - float42sse;
            stopwatch.Stop();
            Console.WriteLine("rożnicaSSE" + a4sse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();
            ///
            stopwatch.Start();
            a4 = float4 * float42;
            stopwatch.Stop();
            Console.WriteLine("ilocztnFPU" + a4.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            a4sse = float4sse * float42sse;
            stopwatch.Stop();
            Console.WriteLine("iloczynSSE" + a4sse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();
            ///
            stopwatch.Start();
            a4 = float4 / float42;
            stopwatch.Stop();
            Console.WriteLine("iloraz FPU" + a4.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            a4sse = float4sse / float42sse;
            stopwatch.Stop();
            Console.WriteLine("iloraz SSE" + a4sse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            /////
            ///
            Console.WriteLine("\n\n Skalar");
            stopwatch.Start();
            a4 = float4 + 1;
            stopwatch.Stop();
            Console.WriteLine("suma FPU" + a4.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            a4sse = float4sse + 1;
            stopwatch.Stop();
            Console.WriteLine("suma SSE" + a4sse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            ///
            stopwatch.Start();
            a4 = float4 - 1;
            stopwatch.Stop();
            Console.WriteLine("Rożnica FPU" + a4.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            a4sse = float4sse - 1;
            stopwatch.Stop();
            Console.WriteLine("Ronica SSE" + a4sse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            ///
            stopwatch.Start();
            a4 = float4 * 2;
            stopwatch.Stop();
            Console.WriteLine("iloczyn FPU" + a4.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            a4sse = float4sse * 2;
            stopwatch.Stop();
            Console.WriteLine("iloczyn SSE" + a4sse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();
            ///
            stopwatch.Start();
            a4 = float4 / 2.5f;
            stopwatch.Stop();
            Console.WriteLine("iloraz FPU" + a4.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            a4sse = float4sse / 2.5f;
            stopwatch.Stop();
            Console.WriteLine("iloraz SSE" + a4sse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            ///
            ///

            Console.WriteLine("macierz");

            stopwatch.Start();
            Float4 aas = float4X4 * float4;

            stopwatch.Stop();
            Console.WriteLine("dot FPU" + aas.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Restart();
            float4sse = float4X4sse * float4sse;
            stopwatch.Stop();
            Console.WriteLine("dot SSE" + float4sse.Vector.ToString());
            Console.WriteLine("time" + stopwatch.Elapsed.TotalMilliseconds);
            stopwatch.Restart();

            Console.ReadKey();
        }
コード例 #30
0
 public static Float4 Cos(Float4 radians)
 {
     return(new Float4(Math.Cos(radians.X), Math.Cos(radians.Y), Math.Cos(radians.Z), Math.Cos(radians.W)));
 }
コード例 #31
0
ファイル: GL.cs プロジェクト: mortend/uno
 public void Uniform4(int location, Float4 value)
 {
     TKGL.Uniform4(location, value.X, value.Y, value.Z, value.W);
 }
コード例 #32
0
 public static float ComponentSum(Float4 x)
 {
     return(((x.X + x.Y) + x.Z) + x.W);
 }
コード例 #33
0
 public static Float4 Lerp(Float4 a, Float4 b, Float4 t)
 {
     return(a + ((b - a) * t));
 }
コード例 #34
0
 public static Float4 Atan2(Float4 y, Float4 x)
 {
     return(new Float4(Math.Atan2(y.X, x.X), Math.Atan2(y.Y, x.Y), Math.Atan2(y.Z, x.Z), Math.Atan2(y.W, x.W)));
 }
コード例 #35
0
ファイル: ShaderLayer.cs プロジェクト: Thaon/IRNBRU
public Float4 CellularWeightSamples( Float4 Samples )
{
	Samples = Samples.Mul(2.0f).Sub(1);
	//return (1.0 - Samples * Samples) * sign(Samples);
	return ((Samples+0).Square().Square()).Sub(sign(Samples,false));
}
コード例 #36
0
 public static Float4 Exp(Float4 x)
 {
     return(new Float4(Math.Exp(x.X), Math.Exp(x.Y), Math.Exp(x.Z), Math.Exp(x.W)));
 }
コード例 #37
0
 public static Float4 Step(Float4 edge, Float4 x)
 {
     return(new Float4(Math.Step(edge.X, x.X), Math.Step(edge.Y, x.Y), Math.Step(edge.Z, x.Z), Math.Step(edge.W, x.W)));
 }
コード例 #38
0
 public static Float4 Log2(Float4 x)
 {
     return(new Float4(Math.Log2(x.X), Math.Log2(x.Y), Math.Log2(x.Z), Math.Log2(x.W)));
 }
コード例 #39
0
 public static Float4 SmoothStep(float edge0, float edge1, Float4 x)
 {
     return(new Float4(Math.SmoothStep(edge0, edge1, x.X), Math.SmoothStep(edge0, edge1, x.Y), Math.SmoothStep(edge0, edge1, x.Z), Math.SmoothStep(edge0, edge1, x.W)));
 }
コード例 #40
0
 public static Float4 Abs(Float4 a)
 {
     return(new Float4(Math.Abs(a.X), Math.Abs(a.Y), Math.Abs(a.Z), Math.Abs(a.W)));
 }
コード例 #41
0
 public static Float4 SmoothStep(Float4 edge0, Float4 edge1, Float4 x)
 {
     return(new Float4(Math.SmoothStep(edge0.X, edge1.X, x.X), Math.SmoothStep(edge0.Y, edge1.Y, x.Y), Math.SmoothStep(edge0.Z, edge1.Z, x.Z), Math.SmoothStep(edge0.W, edge1.W, x.W)));
 }
コード例 #42
0
 public static Float4 Floor(Float4 v)
 {
     return(new Float4(Math.Floor(v.X), Math.Floor(v.Y), Math.Floor(v.Z), Math.Floor(v.W)));
 }
コード例 #43
0
 public static Float4 Saturate(Float4 x)
 {
     return(Math.Clamp(x, 0.0f, 1.0f));
 }
コード例 #44
0
 public static Float4 Ceil(Float4 v)
 {
     return(new Float4(Math.Ceil(v.X), Math.Ceil(v.Y), Math.Ceil(v.Z), Math.Ceil(v.W)));
 }
コード例 #45
0
 public static Float4 Round(Float4 x)
 {
     return(Math.Floor(x + 0.5f));
 }
コード例 #46
0
ファイル: ShaderLayer.cs プロジェクト: Thaon/IRNBRU
Float4 sign(Float4 s,bool SpawnNew){
	if (SpawnNew)
	s = new Float4(s.x,s.y,s.z,s.w);
	if (s.x>0)s.x = 1;
	if (s.x<0)s.x = -1;
	if (s.x==0)s.x = 0;
	if (s.y>0)s.y = 1;
	if (s.y<0)s.y = -1;
	if (s.y==0)s.y = 0;
	if (s.z>0)s.z = 1;
	if (s.z<0)s.z = -1;
	if (s.z==0)s.z = 0;
	if (s.w>0)s.w = 1;
	if (s.w<0)s.w = -1;
	if (s.w==0)s.w = 0;
	return s;
}
コード例 #47
-1
ファイル: ShaderLayer.cs プロジェクト: Thaon/IRNBRU
Float4 FastHash2D(Float2 Pos){
	Float2 Offset = new Float2(26,161);
	Float Domain = 71;
	Float SomeLargeFloat = 951.135664f;
	Float4 P = new Float4(Pos.xy,Pos.xy+1);
	//P = P-floor(P*(1.0f/Domain))*Domain;
	P = P-floor((P+0).Mul(1.0f/Domain),true).Mul(Domain);
	P.Add(Offset.xyxy);
	P.Square();
	return frac(P.xzxz.Mul(P.yyww).Mul(1.0f/SomeLargeFloat),false);
}