Flat shading with addShadowVolumeSceneNode()

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Andreas
Posts: 166
Joined: Sun Oct 31, 2004 7:15 am
Location: Münster / Germany
Contact:

Flat shading with addShadowVolumeSceneNode()

Post by Andreas »

Hi all,

i once more have a question i hope you guys can help me with. :)

Please have a look at the following Screenshots of a simple AnimatedMeshSceneNode in a scene with one light source:

Image

After adding an IShadowVolumeSceneNode the SceneNode looks like this:

Image

Please note the hard transition from bright to dark parts of the SceneNode. Additionally, the shadow doesn't seem to be correct (it should be a UV Sphere, but looks more like an
Icosphere in Blender terms) The system is Windows 7 with mingw and OpenGL, i exported the mesh from Blender 2.6 with Gandalfs B3D exporter (exporting normals enabled).

Here is the code i used to create the scene:

Code: Select all

 
    camera = sceneManager->addCameraSceneNode(0, vector3df(30, 20, 0), vector3df(0, 10, -10), 0);
 
    sceneManager->setAmbientLight(SColor(200, 120, 120, 120));
    sceneManager->addLightSceneNode(0, vector3df(0, 20, -10), SColor(0, 120, 120, 120), 40, 0);
 
    scene::IAnimatedMesh* mesh = sceneManager->getMesh("models/sphere.b3d");
    IAnimatedMeshSceneNode *node = 0;
 
    if (mesh) {
        node = sceneManager->addAnimatedMeshSceneNode(mesh);
        node->setScale(vector3df(4, 4, 4));
        node->setPosition(vector3df(0, 10, 0));
        node->setMaterialFlag(EMF_LIGHTING, true);
        node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
        // This line is the only difference between the two screenshots.
        node->addShadowVolumeSceneNode();
    }
 
Is there any way to avoid the flat shaded parts and get a more smooth transition from the bright to the dark parts of the SceneNode?

Thanks
Andreas
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Flat shading with addShadowVolumeSceneNode()

Post by Mel »

There isn't much that can be really done. That is how the shadow volumes are calculated.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Andreas
Posts: 166
Joined: Sun Oct 31, 2004 7:15 am
Location: Münster / Germany
Contact:

Re: Flat shading with addShadowVolumeSceneNode()

Post by Andreas »

Hi Mel,

thanks for the response. I had hoped there were some flags to disable shadows on the node that is causing the shadow,
but ok, i guess i'll have to live without dynamic shadows then... :(

Best regards
Andreas
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: Flat shading with addShadowVolumeSceneNode()

Post by sudi »

You can always use shaders.
There are alot of extensions on this forum that allow dynamic soft shadows
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Andreas
Posts: 166
Joined: Sun Oct 31, 2004 7:15 am
Location: Münster / Germany
Contact:

Re: Flat shading with addShadowVolumeSceneNode()

Post by Andreas »

Yes you are right, i will search for a shader.
But since i don't know anything about shader programming or integrating them in irrlicht this could get a bit hard. :wink:
Post Reply