public void ProcessFrameGPU(ProcessVideoFrameContext context) { var inputSurface = context.InputFrame.Direct3DSurface; var outputSurface = context.OutputFrame.Direct3DSurface; using (var inputBitmap = CanvasBitmap.CreateFromDirect3D11Surface(m_canvasDevice, inputSurface)) using (var renderTarget = CanvasRenderTarget.CreateFromDirect3D11Surface(m_canvasDevice, outputSurface)) using (var drawingSession = renderTarget.CreateDrawingSession()) { var normalize = new Matrix5x4() { M11 = 1f, M22 = 1f, M33 = 1f, M44 = 1f, M51 = -m_mean.X, M52 = -m_mean.Y, M53 = -m_mean.Z }; var normalize2 = new Matrix5x4() { M11 = 1 / m_std.X, M22 = 1 / m_std.Y, M33 = 1 / m_std.Z, M44 = 1.0f }; // https://microsoft.github.io/Win2D/html/T_Microsoft_Graphics_Canvas_Effects_ColorMatrixEffect.htm var PreprocessTransfrom = new ColorMatrixEffect() { ColorMatrix = normalize2, Source = new ColorMatrixEffect() { ColorMatrix = normalize, Source = inputBitmap } }; drawingSession.DrawImage(PreprocessTransfrom); } }
private ICanvasImage CreateColorMatrix() { var colorMatrixEffect = new ColorMatrixEffect { Source = bitmapTiger }; // Animation cycles through different color settings. animationFunction = elapsedTime => { var matrix = new Matrix5x4(); matrix.M11 = (float)Math.Sin(elapsedTime * 1.5); matrix.M21 = (float)Math.Sin(elapsedTime * 1.4); matrix.M31 = (float)Math.Sin(elapsedTime * 1.3); matrix.M51 = (1 - matrix.M11 - matrix.M21 - matrix.M31) / 2; matrix.M12 = (float)Math.Sin(elapsedTime * 1.2); matrix.M22 = (float)Math.Sin(elapsedTime * 1.1); matrix.M32 = (float)Math.Sin(elapsedTime * 1.0); matrix.M52 = (1 - matrix.M12 - matrix.M22 - matrix.M32) / 2; matrix.M13 = (float)Math.Sin(elapsedTime * 0.9); matrix.M23 = (float)Math.Sin(elapsedTime * 0.8); matrix.M33 = (float)Math.Sin(elapsedTime * 0.7); matrix.M53 = (1 - matrix.M13 - matrix.M23 - matrix.M33) / 2; matrix.M44 = 1; colorMatrixEffect.ColorMatrix = matrix; }; return(colorMatrixEffect); }
private static ICanvasImage CreateColorMatrixEffect(ICanvasImage canvasImage, float coeff) { var ef = new ColorMatrixEffect { Source = canvasImage }; var matrix = new Matrix5x4(); matrix.M11 = (float)Math.Sin(coeff * 1.5); matrix.M21 = (float)Math.Sin(coeff * 1.4); matrix.M31 = (float)Math.Sin(coeff * 1.3); matrix.M51 = (1 - matrix.M11 - matrix.M21 - matrix.M31) / 2; matrix.M12 = (float)Math.Sin(coeff * 1.2); matrix.M22 = (float)Math.Sin(coeff * 1.1); matrix.M32 = (float)Math.Sin(coeff * 1.0); matrix.M52 = (1 - matrix.M12 - matrix.M22 - matrix.M32) / 2; matrix.M13 = (float)Math.Sin(coeff * 0.9); matrix.M23 = (float)Math.Sin(coeff * 0.8); matrix.M33 = (float)Math.Sin(coeff * 0.7); matrix.M53 = (1 - matrix.M13 - matrix.M23 - matrix.M33) / 2; matrix.M44 = 1; ef.ColorMatrix = matrix; return(ef); }
private static Matrix5x4 Matrix5x4FromString(string matrix) { string[] parts = matrix.Split(','); Matrix5x4 mat = new Matrix5x4(); mat.M11 = float.Parse(parts[0]); mat.M12 = float.Parse(parts[1]); mat.M13 = float.Parse(parts[2]); mat.M14 = float.Parse(parts[3]); mat.M21 = float.Parse(parts[4]); mat.M22 = float.Parse(parts[5]); mat.M23 = float.Parse(parts[6]); mat.M24 = float.Parse(parts[7]); mat.M31 = float.Parse(parts[8]); mat.M32 = float.Parse(parts[9]); mat.M33 = float.Parse(parts[10]); mat.M34 = float.Parse(parts[11]); mat.M41 = float.Parse(parts[12]); mat.M42 = float.Parse(parts[13]); mat.M43 = float.Parse(parts[14]); mat.M44 = float.Parse(parts[15]); mat.M51 = float.Parse(parts[16]); mat.M52 = float.Parse(parts[17]); mat.M53 = float.Parse(parts[18]); mat.M54 = float.Parse(parts[19]); return(mat); }
public static Matrix5x4 ToMatrix5X4(this Color color) { var colorMatrix = new Matrix5x4 { M11 = color.R * (1.0f / 255.0f), M12 = 0f, M13 = 0f, M14 = 0, M21 = 0f, M22 = color.G * (1.0f / 255.0f), M23 = 0f, M24 = 0, M31 = 0f, M32 = 0f, M33 = color.B * (1.0f / 255.0f), M34 = 0, M41 = 0f, M42 = 0f, M43 = 0f, M44 = color.A * (1.0f / 255.0f), M51 = 0, M52 = 0, M53 = 0, M54 = 0 }; return(colorMatrix); }
private static string Matrix5x4ToString(Matrix5x4 matrix) { return(String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},", matrix.M11, matrix.M12, matrix.M13, matrix.M14, matrix.M21, matrix.M22, matrix.M23, matrix.M24, matrix.M31, matrix.M32, matrix.M33, matrix.M34, matrix.M41, matrix.M42, matrix.M43, matrix.M44, matrix.M51, matrix.M52, matrix.M53, matrix.M54)); }
public void Serialize(ref Matrix5x4 value) { // Write optimized version without using Serialize methods if (Mode == SerializerMode.Write) { Writer.Write(value.M11); Writer.Write(value.M12); Writer.Write(value.M13); Writer.Write(value.M14); Writer.Write(value.M21); Writer.Write(value.M22); Writer.Write(value.M23); Writer.Write(value.M24); Writer.Write(value.M31); Writer.Write(value.M32); Writer.Write(value.M33); Writer.Write(value.M34); Writer.Write(value.M41); Writer.Write(value.M42); Writer.Write(value.M43); Writer.Write(value.M44); Writer.Write(value.M51); Writer.Write(value.M52); Writer.Write(value.M53); Writer.Write(value.M54); } else { value.M11 = Reader.ReadSingle(); value.M12 = Reader.ReadSingle(); value.M13 = Reader.ReadSingle(); value.M14 = Reader.ReadSingle(); value.M21 = Reader.ReadSingle(); value.M22 = Reader.ReadSingle(); value.M23 = Reader.ReadSingle(); value.M24 = Reader.ReadSingle(); value.M31 = Reader.ReadSingle(); value.M32 = Reader.ReadSingle(); value.M33 = Reader.ReadSingle(); value.M34 = Reader.ReadSingle(); value.M41 = Reader.ReadSingle(); value.M42 = Reader.ReadSingle(); value.M43 = Reader.ReadSingle(); value.M44 = Reader.ReadSingle(); value.M51 = Reader.ReadSingle(); value.M52 = Reader.ReadSingle(); value.M53 = Reader.ReadSingle(); value.M54 = Reader.ReadSingle(); } }
private static Matrix5x4 CreateGrayscaleMatrix() { // Microsoft's Grayscale Matrix from Win2D Documentation var matrix = new Matrix5x4 { M11 = 0.333f, M12 = 0.333f, M13 = 0.333f, M14 = 0, M21 = 0.333f, M22 = 0.333f, M23 = 0.333f, M24 = 0, M31 = 0.333f, M32 = 0.333f, M33 = 0.333f, M34 = 0, M41 = 0, M42 = 0, M43 = 0, M44 = 1, M51 = 0, M52 = 0, M53 = 0, M54 = 0 }; return(matrix); }
private static CompositionBrush CreateGrayscaleBrush() { Matrix5x4 grayscaleMatrix = CreateGrayscaleMatrix(); ColorMatrixEffect grayscaleMatrixEffect = new ColorMatrixEffect { ColorMatrix = grayscaleMatrix, Source = new CompositionEffectSourceParameter("source") }; CompositionEffectFactory grayscaleEffectFactory = _compositor.CreateEffectFactory(grayscaleMatrixEffect); var backdropBrush = grayscaleEffectFactory.CreateBrush(); backdropBrush.SetSourceParameter("source", _compositor.CreateBackdropBrush()); return(backdropBrush); }
private void BlurAmountSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) { if (effectPropertySet == null) { return; } effectPropertySet["ColorMatrix"] = new Matrix5x4() { M11 = (float)e.NewValue, M12 = 0, M13 = 0, M14 = 0, M21 = 0, M22 = (float)e.NewValue, M23 = 0, M24 = 0, M31 = 0, M32 = 0, M33 = (float)e.NewValue, M34 = 0, M41 = 0, M42 = 0, M43 = 0, M44 = 1, M51 = 0, M52 = 0, M53 = 0, M54 = 0 } ; }
private async Task SetEffectWorker(string effect) { await ResetEffectsAsync(); blurAmountSlider.Visibility = Visibility.Collapsed; effectPropertySet = new PropertySet(); string typeName = null; switch (effect) { case displacementEffect: typeName = typeof(DisplacementEffect).FullName; break; case rotatingTilesEffect: typeName = typeof(RotatedTilesEffect).FullName; break; case gaussianBlurEffect: typeName = typeof(DynamicBlurVideoEffect).FullName; Debug.WriteLine("SliderValue: " + (float)blurAmountSlider.Value); effectPropertySet["ColorMatrix"] = new Matrix5x4() { M11 = (float)blurAmountSlider.Value, M12 = 0, M13 = 0, M14 = 0, M21 = 0, M22 = (float)blurAmountSlider.Value, M23 = 0, M24 = 0, M31 = 0, M32 = 0, M33 = (float)blurAmountSlider.Value, M34 = 0, M41 = 0, M42 = 0, M43 = 0, M44 = 1, M51 = 0, M52 = 0, M53 = 0, M54 = 0 } ; blurAmountSlider.Visibility = Visibility.Visible; break; } if (typeName == null) { return; } await mediaCapture.AddVideoEffectAsync(new VideoEffectDefinition(typeName, effectPropertySet), MediaStreamType.VideoPreview); }
private void buttonSharpDX_Click(object sender, EventArgs e) { Array arr1 = Enumerator.Generate <long>(1, 1, 360).Shuffle().ToArray(3, 3, 4, 5); Array arr2 = Enumerator.Generate(15, (X) => new TestType() { a = X, b = X - 5 }).Shuffle().ToArray(5, 3); Array arrJ1 = GetJaggedArray2(); Array arrJ2 = GetJaggedArray3(); var v1 = new Vector2(1, 2); var v2 = new Vector3(1, 2, 3); var v3 = new Vector4(1, 2, 3, 4); Matrix m1 = Matrix.Identity; Matrix3x2 m2 = Matrix3x2.Identity; Matrix5x4 m3 = Matrix5x4.Identity; var o = new VectorOther { w = new Vector3(1, 2, 3) }; Debugger.Break(); }
private void UpdateEffect() { ComboBoxItem item = EffectSelection.SelectedValue as ComboBoxItem; switch ((EffectTypes)item.Tag) { case EffectTypes.ColorSwap: { Matrix5x4 mat = new Matrix5x4() { M11 = 0, M12 = 0f, M13 = 1f, M14 = 0, M21 = 0f, M22 = 1f, M23 = 0f, M24 = 0, M31 = 1f, M32 = 0f, M33 = 0f, M34 = 0, M41 = 0f, M42 = 0f, M43 = 0f, M44 = 1, M51 = 0, M52 = 0, M53 = 0, M54 = 0 }; IGraphicsEffect graphicsEffect = new ColorMatrixEffect() { ColorMatrix = mat, Source = new CompositionEffectSourceParameter("ImageSource") }; // Create the effect factory and instantiate a brush CompositionEffectFactory _effectFactory = _compositor.CreateEffectFactory(graphicsEffect, null); CompositionEffectBrush brush = _effectFactory.CreateBrush(); // Set the destination brush as the source of the image content brush.SetSourceParameter("ImageSource", _compositor.CreateHostBackdropBrush()); _hostSprite.Brush = brush; } break; case EffectTypes.ColorMask: { Matrix5x4 mat = new Matrix5x4() { M11 = 1, M12 = 0f, M13 = 0f, M14 = 2, M21 = 0f, M22 = 1f, M23 = 0f, M24 = -1, M31 = 0f, M32 = 0f, M33 = 1f, M34 = -1, M41 = 0f, M42 = 0f, M43 = 0f, M44 = 0, M51 = 0, M52 = 0, M53 = 0, M54 = 0 }; IGraphicsEffect graphicsEffect = new ColorMatrixEffect() { ColorMatrix = mat, Source = new CompositionEffectSourceParameter("ImageSource") }; // Create the effect factory and instantiate a brush CompositionEffectFactory _effectFactory = _compositor.CreateEffectFactory(graphicsEffect, null); CompositionEffectBrush brush = _effectFactory.CreateBrush(); // Set the destination brush as the source of the image content brush.SetSourceParameter("ImageSource", _compositor.CreateHostBackdropBrush()); _hostSprite.Brush = brush; } break; case EffectTypes.RedFilter: { Matrix5x4 mat = new Matrix5x4() { M11 = 1, M12 = 0f, M13 = 0f, M14 = 0, M21 = 0f, M22 = 0f, M23 = 0f, M24 = 0, M31 = 0f, M32 = 0f, M33 = 0f, M34 = 0, M41 = 0f, M42 = 0f, M43 = 0f, M44 = 1, M51 = 0, M52 = 0, M53 = 0, M54 = 0 }; IGraphicsEffect graphicsEffect = new ColorMatrixEffect() { ColorMatrix = mat, Source = new CompositionEffectSourceParameter("ImageSource") }; // Create the effect factory and instantiate a brush CompositionEffectFactory _effectFactory = _compositor.CreateEffectFactory(graphicsEffect, null); CompositionEffectBrush brush = _effectFactory.CreateBrush(); // Set the destination brush as the source of the image content brush.SetSourceParameter("ImageSource", _compositor.CreateHostBackdropBrush()); _hostSprite.Brush = brush; } break; case EffectTypes.ColorHighlight: { IGraphicsEffect graphicsEffect = new ArithmeticCompositeEffect() { MultiplyAmount = 0, Source1Amount = 1, Source2Amount = 1, Source1 = new GammaTransferEffect() { RedExponent = 7, BlueExponent = 7, GreenExponent = 7, RedAmplitude = 3, GreenAmplitude = 3, BlueAmplitude = 3, Source = new CompositionEffectSourceParameter("ImageSource") }, Source2 = new SaturationEffect() { Saturation = 0, Source = new CompositionEffectSourceParameter("ImageSource") } }; // Create the effect factory and instantiate a brush CompositionEffectFactory _effectFactory = _compositor.CreateEffectFactory(graphicsEffect, null); CompositionEffectBrush brush = _effectFactory.CreateBrush(); // Set the destination brush as the source of the image content brush.SetSourceParameter("ImageSource", _compositor.CreateHostBackdropBrush()); _hostSprite.Brush = brush; } break; case EffectTypes.Bloom: { var bloomEffectDesc = new ArithmeticCompositeEffect { Name = "Bloom", Source1Amount = 1, Source2Amount = 2, MultiplyAmount = 0, Source1 = new CompositionEffectSourceParameter("source"), Source2 = new GaussianBlurEffect { Name = "Blur", BorderMode = EffectBorderMode.Hard, BlurAmount = 40, Source = new BlendEffect { Mode = BlendEffectMode.Multiply, Background = new CompositionEffectSourceParameter("source2"), Foreground = new CompositionEffectSourceParameter("source2"), }, }, }; var bloomEffectFactory = _compositor.CreateEffectFactory(bloomEffectDesc, new[] { "Bloom.Source2Amount", "Blur.BlurAmount" }); var brush = bloomEffectFactory.CreateBrush(); var backdropBrush = _compositor.CreateHostBackdropBrush(); brush.SetSourceParameter("source", backdropBrush); brush.SetSourceParameter("source2", backdropBrush); // Setup some animations for the bloom effect ScalarKeyFrameAnimation blurAnimation = _compositor.CreateScalarKeyFrameAnimation(); blurAnimation.InsertKeyFrame(0, 0); blurAnimation.InsertKeyFrame(.5f, 2); blurAnimation.InsertKeyFrame(1, 0); blurAnimation.Duration = TimeSpan.FromMilliseconds(5000); blurAnimation.IterationBehavior = AnimationIterationBehavior.Forever; ScalarKeyFrameAnimation bloomAnimation = _compositor.CreateScalarKeyFrameAnimation(); bloomAnimation.InsertKeyFrame(0, 0); bloomAnimation.InsertKeyFrame(.5f, 40); bloomAnimation.InsertKeyFrame(1, 0); bloomAnimation.Duration = TimeSpan.FromMilliseconds(5000); bloomAnimation.IterationBehavior = AnimationIterationBehavior.Forever; brush.StartAnimation("Bloom.Source2Amount", blurAnimation); brush.StartAnimation("Blur.BlurAmount", bloomAnimation); _hostSprite.Brush = brush; } break; case EffectTypes.None: default: _hostSprite.Brush = _compositor.CreateHostBackdropBrush(); break; } }
/// <summary> /// Sets the named property to the given value. /// </summary> /// <param name="index">Index of the property</param> /// <param name="value">Value of the property</param> /// <unmanaged>HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize)</unmanaged> public unsafe void SetValue(int index, Matrix5x4 value) { SetValue(index, PropertyType.Matrix5x4, new IntPtr(&value), sizeof(Matrix5x4)); }
protected override void OnConnected() { Compositor compositor = Window.Current.Compositor; // CompositionCapabilities: Are Effects supported? bool usingFallback = !CompositionCapabilities.GetForCurrentView().AreEffectsSupported(); FallbackColor = Color.FromArgb(100, 100, 100, 100); if (usingFallback) { // If Effects are not supported, use Fallback Solid Color CompositionBrush = compositor.CreateColorBrush(FallbackColor); return; } // Define Effect graph // COLOR SWAP Matrix5x4 mat = new Matrix5x4() { M11 = 0, M12 = 0f, M13 = 1f, M14 = 0, M21 = 0f, M22 = 1f, M23 = 0f, M24 = 0, M31 = 1f, M32 = 0f, M33 = 0f, M34 = 0, M41 = 0f, M42 = 0f, M43 = 0f, M44 = 1, M51 = 0, M52 = 0, M53 = 0, M54 = 0 }; //// COLOR MASK (DOESNT WORK ???) // Matrix5x4 mat = new Matrix5x4() // { // M11 = 1, M12 = 0f, M13 = 0f, M14 = 2, // M21 = 0f, M22 = 1f, M23 = 0f, M24 = -1, // M31 = 0f, M32 = 0f, M33 = 1f, M34 = -1, // M41 = 0f, M42 = 0f, M43 = 0f, M44 = 0, // M51 = 0, M52 = 0, M53 = 0, M54 = 0 // }; //// REDFILTER //Matrix5x4 mat = new Matrix5x4() // { // M11 = 1, M12 = 0f, M13 = 0f, M14 = 0, // M21 = 0f, M22 = 0f, M23 = 0f, M24 = 0, // M31 = 0f, M32 = 0f, M33 = 0f, M34 = 0, // M41 = 0f, M42 = 0f, M43 = 0f, M44 = 1, // M51 = 0, M52 = 0, M53 = 0, M54 = 0 // }; IGraphicsEffect graphicsEffect = new ColorMatrixEffect() { ColorMatrix = mat, Source = new CompositionEffectSourceParameter("ImageSource") }; //// COLORHIGHLIGHT //IGraphicsEffect graphicsEffect = new ArithmeticCompositeEffect() //{ // MultiplyAmount = 0, // Source1Amount = 1, // Source2Amount = 1, // Source1 = new GammaTransferEffect() // { // RedExponent = 7, // BlueExponent = 7, // GreenExponent = 7, // RedAmplitude = 3, // GreenAmplitude = 3, // BlueAmplitude = 3, // Source = new CompositionEffectSourceParameter("ImageSource") // }, // Source2 = new SaturationEffect() // { // Saturation = 0, // Source = new CompositionEffectSourceParameter("ImageSource") // } //}; // Create the effect factory and instantiate a brush CompositionEffectFactory _effectFactory = compositor.CreateEffectFactory(graphicsEffect, null); CompositionEffectBrush effectBrush = _effectFactory.CreateBrush(); // Create BackdropBrush CompositionBackdropBrush backdrop = compositor.CreateHostBackdropBrush(); effectBrush.SetSourceParameter("ImageSource", backdrop); // Set EffectBrush as the brush that XamlCompBrushBase paints onto Xaml UIElement CompositionBrush = effectBrush; }
/// <summary> /// Sets the named property to the given value. /// </summary> /// <param name="name">Name of the property</param> /// <param name="value">Value of the property</param> /// <unmanaged>HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize)</unmanaged> public unsafe void SetValueByName(string name, Matrix5x4 value) { SetValueByName(name, PropertyType.Matrix4x4, new IntPtr(&value), sizeof(Matrix5x4)); }
/// <summary> /// Gets destination color. /// </summary> /// <param name="colorMatrix"> The color mtrix. </param> /// <returns> The product color. </returns> public static Color GetDestinationColor(this Matrix5x4 colorMatrix) => AdjustmentExtensions.ToColor(AdjustmentExtensions.GetDestinationColorHdr(colorMatrix));
/// <summary> /// Gets source color hdr. /// </summary> /// <param name="colorMatrix"> The color mtrix. </param> /// <returns> The product color hdr. </returns> public static Vector4 GetSourceColorHdr(this Matrix5x4 colorMatrix) => new Vector4(colorMatrix.M11, colorMatrix.M22, colorMatrix.M33, colorMatrix.M44);
/// <summary> /// Transforms a 4D vector by the given <see cref="SharpDX.Matrix5x4"/>. /// </summary> /// <param name="vector">The source vector.</param> /// <param name="transform">The transformation <see cref="SharpDX.Matrix5x4"/>.</param> /// <returns>The transformed <see cref="SharpDX.Vector4D"/>.</returns> public static Vector4D Transform(Vector4D vector, Matrix5x4 transform) { Vector4D result; Transform(ref vector, ref transform, out result); return result; }
public void CacheColorMatrix() => this.StartingColorMatrix = this.ColorMatrix;
/// <summary> /// Gets destination color hdr. /// </summary> /// <param name="colorMatrix"> The color mtrix. </param> /// <returns> The product color hdr. </returns> public static Vector4 GetDestinationColorHdr(this Matrix5x4 colorMatrix) => new Vector4(colorMatrix.M51, colorMatrix.M52, colorMatrix.M53, colorMatrix.M54);
private ICanvasImage CreateColorMatrix() { var colorMatrixEffect = new ColorMatrixEffect { Source = bitmapTiger }; // Animation cycles through different color settings. animationFunction = elapsedTime => { var matrix = new Matrix5x4(); matrix.M11 = (float)Math.Sin(elapsedTime * 1.5); matrix.M21 = (float)Math.Sin(elapsedTime * 1.4); matrix.M31 = (float)Math.Sin(elapsedTime * 1.3); matrix.M51 = (1 - matrix.M11 - matrix.M21 - matrix.M31) / 2; matrix.M12 = (float)Math.Sin(elapsedTime * 1.2); matrix.M22 = (float)Math.Sin(elapsedTime * 1.1); matrix.M32 = (float)Math.Sin(elapsedTime * 1.0); matrix.M52 = (1 - matrix.M12 - matrix.M22 - matrix.M32) / 2; matrix.M13 = (float)Math.Sin(elapsedTime * 0.9); matrix.M23 = (float)Math.Sin(elapsedTime * 0.8); matrix.M33 = (float)Math.Sin(elapsedTime * 0.7); matrix.M53 = (1 - matrix.M13 - matrix.M23 - matrix.M33) / 2; matrix.M44 = 1; colorMatrixEffect.ColorMatrix = matrix; }; return colorMatrixEffect; }
/// <summary> /// Transforms a 4D vector by the given <see cref="SharpDX.Matrix5x4"/>. /// </summary> /// <param name="vector">The source vector.</param> /// <param name="transform">The transformation <see cref="SharpDX.Matrix5x4"/>.</param> /// <param name="result">When the method completes, contains the transformed <see cref="SharpDX.Vector4D"/>.</param> public static void Transform(ref Vector4D vector, ref Matrix5x4 transform, out Vector4D result) { result = new Vector4D( (vector.X * transform.M11) + (vector.Y * transform.M21) + (vector.Z * transform.M31) + (vector.W * transform.M41) + transform.M51, (vector.X * transform.M12) + (vector.Y * transform.M22) + (vector.Z * transform.M32) + (vector.W * transform.M42) + transform.M52, (vector.X * transform.M13) + (vector.Y * transform.M23) + (vector.Z * transform.M33) + (vector.W * transform.M43) + transform.M53, (vector.X * transform.M14) + (vector.Y * transform.M24) + (vector.Z * transform.M34) + (vector.W * transform.M44) + transform.M54); }