Jump to content

  • Log In with Google      Sign In   
  • Create Account

Prasoon Pankaj

Member Since 16 Sep 2010
Offline Last Active Jan 14 2012 04:04 AM

Topics I've Started

Rendering Issues with DirectShow and USB Video Sources

11 January 2012 - 09:44 PM

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.

captureGraph.RenderStream(null, MediaType.Video, capFilter, null, vmr9);

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.

Pixel shader to project a texture to an arbitary quadrilateral

23 September 2011 - 09:01 PM

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:


/// <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); 



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?

Quick code to get a WPF Visual to DirectX Texture (performance wise)

23 April 2011 - 07:56 AM

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.

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

But it's somewhat slow, in an obvious manner. Can you guys suggest something which could possibly make it quicker?

Is VertexBuffer Lock/Unlock appropriate in this case?

17 April 2011 - 01:03 PM

In my render loop I'm trying to change alpha value overtime to make objects to fade-in/out:

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);

Is Lock() and Unlock() operation on the vertex buffer a performance hit? And also can I avoid it in my case?

[WPF HLSL] Text Outlining Using WPF Shader Effects

10 December 2010 - 11:17 PM

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

PARTNERS