|
参考Ogre+3d+1.7+beginner+Guide+中文版学习,创建第一个着色器时候失败,一直找不出原因,附上代码:
mian.cpp中的场景函数,调用的是材质 MyMaterial14
void createScene()
{
Ogre::ManualObject* manual = mSceneMgr->createManualObject("Quad");
manual->begin("MyMaterial14", RenderOperation::OT_TRIANGLE_LIST);
manual->position(5.0, 0.0, 0.0);
manual->textureCoord(0,1);
manual->position(-5.0, 10.0, 0.0);
manual->textureCoord(1,0);
manual->position(-5.0, 0.0, 0.0);
manual->textureCoord(1,1);
manual->position(5.0, 10.0, 0.0);
manual->textureCoord(0,0);
manual->index(0);
manual->index(1);
manual->index(2);
manual->index(0);
manual->index(3);
manual->index(1);
manual->end();
manual->convertToMesh("Quad");
Ogre::Entity * ent = mSceneMgr->createEntity("Quad");
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node1");
node->attachObject(ent);
}
Ogre3DBeginnersGuide.material材质文件中定义了
fragment_program MyFragmentShader1 cg
{
source Ogre3DBeginnersGuideShaders.cg
entry_point MyFragmentShader1
profiles ps_1_1 arbfp1
}
vertex_program MyVertexShader1 cg
{
source Ogre3DBeginnerGuideShaders.cg
entry_point MyVertexShader1
profiles vs_1_1 arbvp1
default_params
{
param_named_auto worldViewMatrix worldviewproj_matrix
}
}
material MyMaterial13
{
technique
{
pass
{
vertex_program_ref MyVertexShader1
{
}
fragment_program_ref MyFragmentShader1
{
}
}
}
}
在Ogre3DBeginnersGuideShaders.cg着色器中定义:
void MyFragmentShader1(out float4 color:COLOR)
{
color = float4(0,0,1,0);
}
void MyVertexShader1(
float4 position : POSITION,
out float4 oPosition : POSITION,
uniform float4x4 worldViewMatrix)
{
oPosition = mul(worldViewMatrix, position);
}
书上结果是个蓝色四边形,我的怎么是白色,求解啊 |
|