[SOLVED] Celshading not working correctly

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
jomunoz
Goblin
Posts: 228
Joined: Wed Apr 13, 2005 5:07 pm
Location: Medellin - Colombia

[SOLVED] Celshading not working correctly

Post by jomunoz »

Hi everyone,

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:
Image


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:
Image


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);
Last edited by jomunoz on Mon Aug 27, 2007 2:45 am, edited 1 time in total.
User avatar
jomunoz
Goblin
Posts: 228
Joined: Wed Apr 13, 2005 5:07 pm
Location: Medellin - Colombia

Post by jomunoz »

After bugging me for hours, i just discover what make it go wrong. This line:

Code: Select all

sceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
Yep, Stencil Additive shadows affects the shaders (at least in my computer). So i will be using texture shadows for the game.
Post Reply