Thanks for your response.
Quote:Original post by gharen2
First, don't use mdx. It's deprecated, obsolete, and just plain sucks. Use Xna or SlimDX instead.
How much load does i expect to have in case of switch to XNA or SlimDX ?
Quote:Original post by gharen2
- Why are you clearing with each pass?
It is of course unecessary. However, theses lines of code are taken from old code of mine that worked. After a refactor, i've got this problem, and i've tried to have the same behaviour as before, as a testing point of view.
Quote:Original post by gharen2
- Make sure the quad you're rendering the post processing to has it's texture coordinates defined. Better yet, render it to a sprite. There's information on the internet about how to use a custom pixel shader with sprites.
- Make sure the vertices' FVF is defined correctly.[/qu
OK, i'll check that.
All seems to be good:
public struct PPVERT{ public Vector4 Position; public float tu, tv; public float tu2, tv2; public static readonly VertexFormats FVF = VertexFormats.PositionW | VertexFormats.Texture2; public static VertexElement[] Decl = { new VertexElement(0,0,DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.PositionTransformed, 0), new VertexElement(0,16,DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0), new VertexElement(0,24,DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 1), VertexElement.VertexDeclarationEnd };}private static void applyPostProcesses(){ SurfaceDescription backBufferDesc = backbufferColor.Description; VertexBuffer vertexBuffer = new VertexBuffer( typeof(PPVERT), 4, device, Usage.WriteOnly, PPVERT.FVF, Pool.Default); PPVERT[] quad = (PPVERT[])vertexBuffer.Lock(0, 0); { quad[0] = new PPVERT(); quad[0].Position = new Vector4(0.0f, 0.0f, 1.0f, 1.0f); quad[0].tu = 0.0f; quad[0].tv = 0.0f; quad[0].tu2 = 0.0f; quad[0].tv2 = 0.0f; quad[1] = new PPVERT(); quad[1].Position = new Vector4(0.0f, backBufferDesc.Height, 1.0f, 1.0f); quad[1].tu = 0.0f; quad[1].tv = 1.0f; quad[1].tu2 = 0.0f; quad[1].tv2 = 1.0f; quad[2] = new PPVERT(); quad[2].Position = new Vector4(backBufferDesc.Width, 0.0f, 1.0f, 1.0f); quad[2].tu = 1.0f; quad[2].tv = 0.0f; quad[2].tu2 = 1.0f; quad[2].tv2 = 0.0f; quad[3] = new PPVERT(); quad[3].Position = new Vector4(backBufferDesc.Width, backBufferDesc.Height, 1.0f, 1.0f); quad[3].tu = 1.0f; quad[3].tv = 1.0f; quad[3].tu2 = 1.0f; quad[3].tv2 = 1.0f; } vertexBuffer.Unlock(); PerformSinglePostProcess(vertexBuffer);//, quad); vertexBuffer.Dispose();}private static void PerformSinglePostProcess(VertexBuffer iVertexBuffer)//, PPVERT[] quad){ device.VertexDeclaration = new VertexDeclaration(device, PPVERT.Decl); postProcesses.SetValue("g_txSrcColor", intermediateRenderTexture); TextureLoader.Save("d:\\tmp\\intermediateRenderTexture.png", ImageFileFormat.Png, intermediateRenderTexture); SurfaceLoader.Save("d:\\tmp\\intermediateRenderTarget.png", ImageFileFormat.Png, intermediateRenderTarget); // Validated techniques: // * PostProcessInvert // * PostProcessGreenExtraction // * PostProcessMoreColor // * PostProcessMultiSampleBlur // * PostProcessMultiSampleSharp // * PostProcessEmboss // * PostProcessdoNothing // * PostProcessBloomH // * PostProcessBloomV // * PostProcessTVization postProcesses.Technique = "PostProcessdoNothing"; device.SetRenderTarget(0, backbufferColor); //device.SetRenderTarget(0, intermediateRenderTarget); device.Clear(ClearFlags.Target, System.Drawing.Color.BlueViolet, 1.0f, 0); int numPasses = postProcesses.Begin(0); for (int passe = 0; passe < numPasses; passe++) { postProcesses.BeginPass(passe); device.SetStreamSource(0, iVertexBuffer, 0); device.VertexFormat = PPVERT.FVF; device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); postProcesses.EndPass(); } postProcesses.End(); SurfaceLoader.Save("d:\\tmp\\backbufferColor.png", ImageFileFormat.Png, backbufferColor);}
[Edited by - alt3 on April 18, 2009 9:23:51 AM]