For the usage of ogre shader, refer to the two instructions:
Http://www.ogre3d.org/forums/viewtopic.php? F = 1 & t = 76580 # p483996
Http://www.ogre3d.org/tikiwiki/tiki-index.php? Page = RT + shader + System
I tried it myself.
// Create scenemanager and camera
Ogre: scenemanager * Sm = RT-> createscenemanager (Ogre: st_generic, "testscence ");
// Shader
If (Ogre: rtshader: shadergenerator: Initialize ()){
Ogre: rtshader: shadergenerator * mshadergenerator = ogre: rtshader: shadergenerator: getsingletonptr ();
Mshadergenerator-> setshadercachepath ("C: \ Download \ OgreSDK_vc10_v1-8-1 \ media \ rtshaderlib \ cache ");
Mshadergenerator-> addscenemanager (SM );
}
Set the shader material.
Ogre: entity * ET = Sm-> createentity ("robot. mesh ");
// Ogre: resourcegroupmanager: getsingleton (). Create
Et-> setmaterial (Ogre: materialmanager: getsingleton (). getbyname ("RTSs/layeredblending"); // This is defined in the material script. The file is in the shaderlib folder under ogre media.
Ogre: scenenode * node = Sm-> getrootscenenode ()-> createchildscenenode (Ogre: vector3 (0, 0 ));
Node-> attachobject (ET );
Node-> Roll (Ogre: radian (0.9 ));
Node-> Scale (1, 1, 3 );
An error occurred while running. The resource was not added.
Ogre: resourcegroupmanager: getsingleton (). addresourcelocation (
"C: \ Download \ OgreSDK_vc10_v1-8-1 \ media \ rtshaderlib"
, "Filesystem"
, "Rtshaderlib ");
Ogre: resourcegroupmanager: getsingleton (). addresourcelocation (
"C: \ Download \ OgreSDK_vc10_v1-8-1 \ media \ rtshaderlib \ materials"
, "Filesystem"
, "Rtshaderlib ");
After joining the program, the program runs successfully. The robot was previously completely yellow and now it is striped.
Script Definition
// This material demonstrates the texture blending extension.
Material RTSs/layeredblending
{
Technique
{
Pass
{
Lighting off
Texture_unit
{
Scale 0.1 0.1
Texture Rockwall. TGA
}
Texture_unit
{
// RT shader System Section-required by the layered blend extension.
Rtshader_system
{
Layered_blend luminosity
Source_modifier src1_inverse_modulate custom 2
}
Texture ogrelogo.png
}
}
}
}