I'm trying to do a cartoon look to the characters of my game so i used the celshading material that come's with Ogre, but all i get is an all black material, as shown here:
So i modified the Celshading example of Ogre to load my mesh (cause i thought it was the mesh), and it renderer just as i wanted:
The code i used in my project, it's almost a 'copy and paste' of the celshading example, so i don't know why it doesn't give the same results.
Code: Select all
/* Prueba de Celshading*/
#define CUSTOM_SHININESS 1
#define CUSTOM_DIFFUSE 2
#define CUSTOM_SPECULAR 3
// Create a point light
SceneManager* mSceneMgr = mMnjPrincipal->getSceneManager();
SceneNode* rotNode;
Light* l = mSceneMgr->createLight("MainLight");
// Accept default settings: point light, white diffuse, just set position
// Add light to the scene node
rotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
rotNode->createChildSceneNode(Vector3(20,40,50))->attachObject(l);
Entity *ent = mSceneMgr->createEntity("head", "Skuul.mesh");
// Set common material, but define custom parameters to change colours
// See Example-Advanced.material for how these are finally bound to GPU parameters
SubEntity* sub;
// eyes
sub = ent->getSubEntity(0);
sub->setMaterialName("Examples/CelShading");
sub->setCustomParameter(CUSTOM_SHININESS, Vector4(35.0f, 0.0f, 0.0f, 0.0f));
sub->setCustomParameter(CUSTOM_DIFFUSE, Vector4(1.0f, 0.3f, 0.3f, 1.0f));
sub->setCustomParameter(CUSTOM_SPECULAR, Vector4(1.0f, 0.6f, 0.6f, 1.0f));
// skin
sub = ent->getSubEntity(1);
sub->setMaterialName("Examples/CelShading");
sub->setCustomParameter(CUSTOM_SHININESS, Vector4(10.0f, 0.0f, 0.0f, 0.0f));
sub->setCustomParameter(CUSTOM_DIFFUSE, Vector4(0.0f, 0.5f, 0.0f, 1.0f));
sub->setCustomParameter(CUSTOM_SPECULAR, Vector4(0.3f, 0.5f, 0.3f, 1.0f));
// Add entity to the root scene node
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);