oFusion and Ogre shaders problems

bogas

21-02-2008 14:59:18

Hello everyone :)

I just started using Ogre and oFusion for my project which is supposed to be nice exterior visualisation (similar to what can be seen in game levels these days). I got Ogre and oFusion scene importer working, however I am having problems with shader materials. I tried to use my old normal mapping shader. It works fine in Max, however it is completely flat in Ogre :/ So i decided to rewrite it from scratch and hopefully find the reason it is not working properly.



So i started with ambient lighting first. Again this works in Max+oFusion, giving the object plain red colour, however the object is gray in Ogre. Below is just a simple shader for ambient lighting:


//Vertex shader
float4x4 matWorldViewProj;

struct VS_OUTPUT
{
float4 Pos : POSITION;
};

VS_OUTPUT main(float4 Pos : POSITION)
{
VS_OUTPUT vsout = (VS_OUTPUT)0;
vsout.Pos = mul(Pos, matWorldViewProj);
return vsout;
}



//Pixel shader
float4 main() : COLOR0
{
float Aintensity = 0.8f;
float4 Acolor = float4(1.0, 0.075, 0.075, 1.0);

//return Aintensity * Acolor;
return float4(1, 0, 1, 1);
}


I just noticed now that Ogre log throws some errors:


14:30:37: Parsing script sceneAmbLight.material
14:30:37: Error in material AmbientMaterial at line 12 of sceneAmbLight.material: Invalid vertex_program_ref entry - vertex program AmbientLightingShader_VS has not been defined.
14:30:37: Error in material AmbientMaterial at line 17 of sceneAmbLight.material: Invalid fragment_program_ref entry - fragment program AmbientLightingShader_PS has not been defined.


What could be the problem?


EDIT


Ok I got it fixed. I copied the shader source code and .program files to materials folder of my project and it works :oops:

Below is the screenshot.

Lioric

22-02-2008 15:08:32

good job :)

If you need more samples of normal mapping there are some excellent shaders posted in a few threads below