Problem: I would like to work with vertex colors delivered by Maya in my cgfx shader. It should be a trivial problem but I have no luck so far.
Attempt: Below I have written up a super simple shader which should just display the raw vertex colors. Result is pure white though.
Details: Internally the shader works fine, if I set the vert color to red in the vs it comes through just fine. So the issue is getting the value from Maya. Also tried with both COLOR and COLOR0.
Any help or guidance appreciated.
// string Category = "Effects\\Cg\\BRDF";
// string keywords = "texture";
string description = "Pure vertex color";
//////////////////////////////////////////////////////////
// untweakables //////////////////////////////////////////
//////////////////////////////////////////////////////////
float4x4 WorldViewProjXf : WorldViewProjection < string UIWidget="none";>;
/****************************************************/
/********** SAMPLERS ********************************/
/****************************************************/
texture ColorTex : Diffuse
<
string ResourceName = "default_color.dds";
string ResourceType = "2D";
>;
sampler2D ColorSampler = sampler_state
{
Texture = <ColorTex>;
MagFilter = Linear;
MinFilter = LinearMipmapLinear;
};
/****************************************************/
/********** CG SHADER FUNCTIONS *********************/
/****************************************************/
/**************************************/
/***** SHARED STRUCT ******************/
/**** Data from app vertex buffer *****/
/**** for all passes *****/
/**************************************/
struct appData {
float3 Position : POSITION;
float4 VertColor: COLOR;
};
/****************************************/
/****************************************/
// vertex->fragment registers used for this pass only
struct outVertexData {
float4 HPosition : POSITION;
float4 vertColor : TEXCOORD1;
};
/****************************************/
/****************************************/
outVertexData textureVS(appData IN)
{
outVertexData OUT;
OUT.vertColor = IN.VertColor;
//OUT.vertColor = float4(1.0f,0.0f,0.0f,0.0f);
float4 Po = float4(IN.Position.xyz,1.0);
OUT.HPosition = mul(WorldViewProjXf, Po);
return OUT;
}
float4 texturePS(outVertexData IN) : COLOR
{
return IN.vertColor;
}
/****************************************************/
/********** TECHNIQUES ******************************/
/****************************************************/
technique main {
pass p0 {
VertexProgram = compile arbvp1 textureVS();
DepthTestEnable = true;
DepthMask = true;
CullFaceEnable = false;
FragmentProgram = compile arbfp1 texturePS();
}
}
/***************************** eof ***/