This project is read-only.

Issues with DrawTarget2DGroup

May 18, 2009 at 11: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?

 

May 18, 2009 at 11: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 11: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 :)

May 19, 2009 at 12:03 AM

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 19, 2009 at 12:14 AM

That was it, thanks!