Prasoon Pankaj

Member
  • Content count

    12
  • Joined

  • Last visited

Community Reputation

104 Neutral

About Prasoon Pankaj

  • Rank
    Member
  1. We are trying to get DirectShow work with USB video capture devices like this. The code simply adds the capture source's filter (capFilter) in the capture graph and then connects it to VMR9 renderer already added to the graph. [CODE]captureGraph.RenderStream(null, MediaType.Video, capFilter, null, vmr9);[/CODE] At present, everything runs without throwing any exception, but the output is just black. I checked the capture source's output in GraphStudio, but it also resulted in the same black output.
  2. Just need to figure out a way, using Pixel Shader, to project a texture to an arbitary user-defined rectangle. Will be accepting coordinates of the four sides of a quadrilateral: [color="#808080"][code] /// <defaultValue>0,0</defaultValue> float2 TopLeft : register(c0); /// <defaultValue>1,0</defaultValue> float2 TopRight : register(c1); /// <defaultValue>0,1</defaultValue> float2 BottomLeft : register(c2); /// <defaultValue>1,1</defaultValue> float2 BottomRight : register(c3); [/code][/color] Tried couple of interpolation algorithm, but couldn't manage to get it right. Is there any sample you guys think which I might be able to modify to get the desired result?
  3. I tried to load the data using CopyPixels(), but it throws D3DXERR_INVALIDDATA exception. [code] RenderTargetBitmap bmp = GetBitmap();// copy into a byte array int stride = bmp.PixelWidth * 4; byte[] data = new byte[bmp.PixelHeight * stride]; bmp.CopyPixels(data, stride, 0); // create texture using (MemoryStream ms = new MemoryStream(data)) { ms.Seek(0, SeekOrigin.Begin); if (dxDevice != null) { // next line throws D3DXERR_INVALIDDATA exception texture = TextureLoader.FromStream(dxDevice, ms); } } [/code]
  4. Well, the problem is simple, I have something rendered on a WPF Visual. I want to get it to on a DirectX Texture. At present, I using the following code to get the job done. [code] var bmp = new System.Windows.Media.Imaging.RenderTargetBitmap(bound.Width, bound.Height, 96, 96, System.Windows.Media.PixelFormats.Pbgra32); bmp.Render(drawingVisual); var encoder = new System.Windows.Media.Imaging.PngBitmapEncoder(); encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(bmp)); Texture texture = new Texture(dxDevice, bound.Width, bound.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); using (MemoryStream ms = new MemoryStream()) { encoder.Save(ms); ms.Seek(0, SeekOrigin.Begin); Surface privateSurface = texture.GetSurfaceLevel(0); SurfaceLoader.FromStream(privateSurface, ms, Filter.None, Color.MediumAquamarine.ToArgb()); ms.Close(); } return texture; // our prepared texture [/code] But it's somewhat slow, in an obvious manner. Can you guys suggest something which could possibly make it quicker?
  5. It was giving me some hit. So, I changed the logic to use CustomVertex.Transformed[] and used the following logic in my render loop: [code] var blendedFillColor = /* color remains the same, just changing the alpha value */; device.TextureState[0].ConstantColor = blendedFillColor; device.TextureState[0].ColorOperation = TextureOperation.SelectArg1; device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1; device.TextureState[0].ColorArgument1 = TextureArgument.Constant; device.TextureState[0].AlphaArgument1 = TextureArgument.Constant; device.SetStreamSource(0, this._vertexBuffer, 0); device.VertexFormat = CustomVertex.Transformed.Format; device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); [/code] Anything you guys wanna suggest?
  6. [quote name='smasherprog' timestamp='1303078436' post='4799630'] Instead of changing the information per vertex, why not set an alpha value per object? There isnt a need to change it per vertex when it can be set in the shader. [/quote] Can you please share few links to the stuff you are talking about? Or may be a sample code to illustrate.
  7. In my render loop I'm trying to change alpha value overtime to make objects to fade-in/out: [code] var blendedFillColor = /* color remains the same, just changing the alpha value */; var vertices = (CustomVertex.TransformedColored[])_vertexBuffer.Lock(0, 0); for (int vertexIndex = 0; vertexIndex < 4; vertexIndex++) { vertices[vertexIndex].Color = blendedFillColor.ToArgb(); } _vertexBuffer.Unlock(); dxDevice.SetStreamSource(0, _vertexBuffer, 0); dxDevice.VertexFormat = CustomVertex.TransformedColored.Format; dxDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); [/code] Is Lock() and Unlock() operation on the vertex buffer a performance hit? And also can I avoid it in my case?
  8. Well, I tried many forums* before but I guess GameDev forums might have the right people to address my problem. So, here it goes: I tried to google it out, but is there any sample Shader effect which I could use to produce an outlined FormattedText. I was able to get the outline by using BuildGeometry(), but the performance is very poor! PS: Since I'm new to this and still learning, it would be helpful if anyone can suggest whether it would be even possible or not. * http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/f8a62177-622a-4844-a18c-274c438223a0
  9. [MDX] Not able to get stencil to work

    So, I finally figured it out. It's all related to Sprites and its Begin() method. Sprite.Begin() will modify the RenderState and disable stencil. We can prevent it by setting SpriteFlags.DoNotModifyRenderState flag, but then the alpha blending is not supported when sprites are drawn. What I did now was simply call Sprite.Begin() without SpriteFlags.DoNotModifyRenderState flag set. And before the call to Sprite.Draw(), enabled stencil on the device.
  10. [MDX] Not able to get stencil to work

    OK.. So I figured out how to get it done. Referred to this post - http://www.gamedev.net/community/forums/viewreply.asp?ID=1999276 But now the sprite is ignoring alpha values and rendering sprites opaque. Similar to the effect we get when alpha blending is set to false.
  11. Was trying to get Stencil to work in my app. I use Sprites to render content on to the Device. Content could be movies, pictures or text. Can I set the stencil buffer using these Sprites, which can be used in later passes to stencil out other Sprites being rendered? I'm even not able to stencil out any of the Sprites by setting StencilFunction = Compare.Never! Anything wrong that I might be doing? I've already spent almost an entire day checking out posts related to Stencils in MDX, but just couldn't get it to work. Bit more searching got me to a technique wherein we draw silhouette of the shapes to be added to the stencil buffer. Is this really required in my case? I just want to use the Sprites, and add them to stencil buffer to stencil out other Sprites. Anybody? [Edited by - Prasoon Pankaj on September 16, 2010 2:49:44 PM]