Use Ogre shader, but mesh displays all white color problem

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
wyy123
Gnoblar
Posts: 3
Joined: Tue May 15, 2012 3:55 pm

Use Ogre shader, but mesh displays all white color problem

Post by wyy123 » Thu Aug 21, 2014 3:35 pm

Hello,Im new here and Im using ogre to study shaders,but i have some problem with using ogre shader. My English is not well. If I not explain my problem easy to understand,I feel very sorry. Ok,I will to explain my problem.
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
			}
		}
	}
}
This is cg file:

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);
}
This is Ogre app code snippet to use shader in a mesh:

Code: Select all

Entity *ent1 = mSceneMgr->createEntity("ogreheadEnt", "ogrehead.mesh");
ent1->setMaterialName("Custom/TexTestCg");
SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("orgeHeadNode");
node2->attachObject(ent1);
I will feel very thanks to have some solution with this problem.
0 x

User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
Contact:

Re: Use Ogre shader, but mesh displays all white color probl

Post by tod » Fri Aug 22, 2014 9:00 am

Look into Ogre.log, or post it here.
0 x

wyy123
Gnoblar
Posts: 3
Joined: Tue May 15, 2012 3:55 pm

Re: Use Ogre shader, but mesh displays all white color probl

Post by wyy123 » Fri Aug 22, 2014 3:10 pm

This is part of my ogre.log content
Attachments
Ogre.log
ogre.log text
(2.63 KiB) Downloaded 44 times
0 x

User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
Contact:

Re: Use Ogre shader, but mesh displays all white color probl

Post by tod » Mon Aug 25, 2014 2:54 pm

Cannot locate resource texColor1.cg in resource group Popular or any other group.
Variant 1: Your cg file is not called texColor1.cg
Variant 2: The file is in a path not found in resource.cfg. Solution 1: Put file in a good path, Solution 2: Edit resources.cfg to add the correct path.
0 x

wyy123
Gnoblar
Posts: 3
Joined: Tue May 15, 2012 3:55 pm

Re: Use Ogre shader, but mesh displays all white color probl

Post by wyy123 » Mon Aug 25, 2014 3:43 pm

tod wrote:
Cannot locate resource texColor1.cg in resource group Popular or any other group.
Variant 1: Your cg file is not called texColor1.cg
Variant 2: The file is in a path not found in resource.cfg. Solution 1: Put file in a good path, Solution 2: Edit resources.cfg to add the correct path.

I try the solution that edit resources.cfg and add the cg file path in it.Then, I run the App, it worked.Im so happy! Thanks a lot! :D
0 x

Post Reply