예제 #1
0
 public override void Draw()
 {
     // Set values for horizontal pass
     Effect.Parameters["Offsets"].SetValue(offsetsH);
     Effect.Parameters["Weights"].SetValue(weightsH);
     // Render this pass into the RenderCapture
     capture.Begin();
     base.Draw();
     capture.End();
     // Get the results of the first pass
     Input = capture.GetTexture();
     if (ResultCapture != null)
     {
         ResultCapture.Begin();
     }
     // Set values for the vertical pass
     Effect.Parameters["Offsets"].SetValue(offsetsV);
     Effect.Parameters["Weights"].SetValue(weightsV);
     // Render the final pass
     base.Draw();
     if (ResultCapture != null)
     {
         ResultCapture.End();
     }
 }
예제 #2
0
        protected override void Draw(GameTime gameTime)
        {
            // Najpierw rysuję mapę głębi
            depthCapture.Begin();
            GraphicsDevice.Clear(Color.White);
            RysujMapeGlebi(gameTime);
            depthCapture.End();

            // Potem rysuję scenę w normalny sposób
            renderCapture.Begin();
            GraphicsDevice.Clear(Color.DarkBlue);
            PrzygotujShadery();
            RysujMoimShaderem(gameTime);
            renderCapture.End();

            // Tworzę też rozmytą wersję normalnego renderu
            gaussianPP.Input = renderCapture.GetTexture();
            ((GaussianBlur)gaussianPP).ResultCapture = blurCapture;
            gaussianPP.Draw();

            dof.DepthMap  = blurCapture.GetTexture();
            dof.Input     = depthCapture.GetTexture();
            dof.Unblurred = renderCapture.GetTexture();

            // Pobieram kolor mapy głębi pod kursorem i wysyłam do filtra DoF
            var depthMap = depthCapture.GetTexture();

            Color[] colorArray = new Color[depthMap.Height * depthMap.Width];
            depthMap.GetData <Color>(colorArray);
            var kolorKursor = colorArray[pozKursor.Y * depthMap.Width + pozKursor.X];

            dof.Focus = kolorKursor.R;

            Debug.WriteLine("X: " + pozKursor.X.ToString() + " Y: " + pozKursor.Y.ToString() + " D: " + kolorKursor.R.ToString());

            noPP.Input = depthMap;
            if (rysujGlebie)
            {
                dof.Draw();
            }
            else
            {
                noPP.Draw();
            }

            base.Draw(gameTime);
        }