/// <summary> /// Add all the hlsl files here /// </summary> public void AddEffects() { Renderer = new GPUImageGame(this.Dispatcher); FirstFilter = new InitialFilter(@"HLSL\RenderToScreen.fxo"); FirstFilter.AddInput("cat.dds"); temp = new InitialFilter(@"HLSL\FirstFilter.fxo"); second = new ImageFilter(@"HLSL\SpotLight.fxo", new Parameter("ImageSize", new Vector2(1, 1)), new Parameter("LightPos", new Vector2(400, 400))); second.AddInput(FirstFilter); Renderer.TerminalFilter = second; Renderer.Run(DisplayGrid); Task t = Task.Factory.StartNew(new Action(() => { Vector2 pos = new Vector2(0, 0); int add = 1; while (true) { pos.X = (pos.X + 1 * add); if (pos.X == 800 || pos.X == 0) { pos.Y = (pos.Y + 40) % 1200; add *= -1; } second.UpdateParameter("LightPos", pos); Thread.Sleep(1); } })); }
/// <summary> /// When a new image is loaded (camera capture or photo chooser tasks), add it as input to the selected filter /// </summary> /// <param name="filter"></param> /// <param name="inputImage"></param> /// <param name="list"></param> public void LoadNewImage(InitialFilter filter, WriteableBitmap inputImage, params int[] list) { //if there we no params, clear all inputs, and we want to add the input at spot -1 (= string.Empty) if (list.Length == 0) { filter.Inputs.Clear(); filter.OverwriteWith.Add(-1);//add a -1 to the list } else { //otherwise for each current input, remove it if it's position is in the int[] list for (int i = 0; i < filter.Inputs.Keys.Count; i++) { foreach (int n in list) { if (filter.Inputs.ElementAt(i).Value == n) { filter.Inputs.Remove(filter.Inputs.ElementAt(i)); filter.OverwriteWith.Add(n); } } } } //we do not want to load an image from the content filter.NewImg = inputImage; NeedsRender = true; }