Issues with DrawTarget2DGroup

May 18, 2009 at 10:33 PM

I'm trying to use DrawTarget2DGroup to render to 2 render targets in 1 pass.  Here is a sample i through together of exactly the same thing im trying to do.

here is the C# code:

here is the hlsl TestMaterial:

Basically the textures are blank when i try to draw them after the drawTarget pass.  Any ideas?


May 18, 2009 at 10:40 PM

The most likely problem is that in the vertex shader you are not multiplying the input position by the worldviewprojection matrix.
Even though it's 2D it still requires this, because it uses the mvp to align the element.

May 18, 2009 at 10:56 PM

No dice, i added 


float4x4 WorldViewProjection : WORLDVIEWPROJECTION;

    OUT.Position = mul(IN.Position, WorldViewProjection);
OUT.TexCoord = IN.TexCoord;
    return OUT;


            Matrix transform = Matrix.Identity;

            state.PushWorldMatrix(ref transform);



in my drawer but it's still not working.  By the way, thanks for the quick response :)

May 18, 2009 at 11:03 PM


I see the problem.
You need to be using a ShaderElement if you want to use a custom shader on a 2D element :-)

Also you don't need to worry about world matrices for 2D elements, as they manage their own alignment to the screen.

May 18, 2009 at 11:14 PM

That was it, thanks!