Weird Issue With CG Runtime

Started by
-1 comments, last by akaitora 10 years, 3 months ago

Hey guys! I am integrating the CG Runtime into my game engine but I am running into a strange issue.

My engine only supports loading cgfx. I wrote the following shader as a test


struct VS_INPUT
{
      float4 position  : POSITION;
      float4 normal    : NORMAL;
};
 
struct VS_OUTPUT
{
      float4 color   : COLOR0;
      float4 position  : POSITION;
};
 
VS_OUTPUT myvs( uniform float4x4 ModelViewProj, const VS_INPUT vin)
{
        VS_OUTPUT vout;
        float4 position = mul(ModelViewProj, vin.position) * 5.0;
        vout.position = position;
        vout.color = float4(1,0,0,1);
 
        return vout;
}
 
float4x4 mvp    :       WorldViewProjection;
 
technique main
{
        pass p0
        {
                Zenable = false;
                ZWriteEnable = false;
 
                VertexProgram = compile vs_1_1 myvs( mvp );
        }
}

When running, I can visually see that the ZEnable state is disabled but my 3d model is not showing up as red. The vertex program that I wrote should have shaded my model red. I am doing the following to render my model

cgSetPassState( this->pass );
 
// Send Verts and normals to directx
mpDev->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1);
mpDev->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 1, t, sizeof(CUSTOMVERT));
 
cgResetPassState( this->pass );
 

Will the cgSetPassState also invoke the VertexProgram or is there something else I need to do to invoke it? Thanks!

xdpixel.com - Practical Computer Graphics

This topic is closed to new replies.

Advertisement