I try to write a simple cg shader and use ogre app to run this.But It does't work as I expect.The mesh I use this cg shader is display all white color.The function of this shader is to let mesh display a specify texture on it.Following, is my cg shader content.
This is material file:
Code: Select all
vertex_program texTestCg_vs cg
{
source texColor1.cg
entry_point texTestCg_vs
profiles vs_1_1
default_params
{
param_named_auto worldViewProj worldviewproj_matrix
}
}
fragment_program texTestCg_ps cg
{
source texColor1.cg
entry_point texTestCg_ps
profiles ps_1_1
}
material Custom/TexTestCg
{
technique
{
pass
{
vertex_program_ref texTestCg_vs
{
}
fragment_program_ref texTestCg_ps
{
}
texture_unit
{
texture GreenSkin.jpg
}
}
}
}
Code: Select all
void texTestCg_vs(float4 pos : POSITION, float2 texcoord : TEXCOORD0,
out float4 oPos : POSITION, out float2 uv : TEXCOORD0,
uniform float4x4 worldViewProj)
{
oPos = mul(worldViewProj, pos);
uv = texcoord;
}
void texTestCg_ps(float2 uv : TEXCOORD0, out float4 color : COLOR,
uniform sampler2D texture)
{
color = tex2D(texture, uv);
}
Code: Select all
Entity *ent1 = mSceneMgr->createEntity("ogreheadEnt", "ogrehead.mesh");
ent1->setMaterialName("Custom/TexTestCg");
SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("orgeHeadNode");
node2->attachObject(ent1);