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: http://www.pastebin.ca/1426930

here is the hlsl TestMaterial: http://www.pastebin.ca/1426933

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

 

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


VS_OUTPUT TestMaterialVS(VS_INPUT IN)
{
    VS_OUTPUT OUT = (VS_OUTPUT)0;
    
    OUT.Position = mul(IN.Position, WorldViewProjection);
OUT.TexCoord = IN.TexCoord;
    return OUT;
}

then

            Matrix transform = Matrix.Identity;

            state.PushWorldMatrix(ref transform);

            material.Bind(state);
            element.Draw(state);

            state.PopWorldMatrix();

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

Coordinator
May 18, 2009 at 11:03 PM

Ah.

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!