Discussion:
Flat Shading
Robert Kern
2011-06-29 18:42:38 UTC
Permalink
Hi,

I've been trying to figure out how to switch to flat shading but I can't quite figure out how. Could someone help me out?

Thank you!

Cheers,
Robert

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41043#41043
Farshid Lashkari
2011-06-29 18:47:13 UTC
Permalink
Hi Robert,

I've been trying to figure out how to switch to flat shading but I can't
Post by Robert Kern
quite figure out how. Could someone help me out?
You can use the osg::ShadeModel state attribute to enable flat shading.

Cheers,
Farshid
Robert Kern
2011-06-29 18:58:36 UTC
Permalink
Hi,

Yes, but how do I use osg::ShadeModel? Do I get it from a viewer or camra? Do I make it my self and then pass it off to something?

Thank you!

Cheers,
Robert

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41046#41046
Farshid Lashkari
2011-06-29 19:07:49 UTC
Permalink
Hi Robert,

Yes, but how do I use osg::ShadeModel? Do I get it from a viewer or camra?
Post by Robert Kern
Do I make it my self and then pass it off to something?
You will need to create an instance of the osg::ShadeModel class and apply
it to the stateset of the subgraph you want to enable flat shading on. For
example:

osg::ref_ptr<osg::ShadeModel> shadeModel = new
osg::ShadeModel(osg::ShadeModel::FLAT);
root->getOrCreateStateSet()->setAttributeAndModes(shadeModel.get(),osg::StateAttribute::ON);

where "root" is the root node of the subgraph. Once you've applied the shade
model attribute, you can switch back and forth between smooth and flat
shading by using the "shadeModel->setMode(..)" method.

Cheers,
Farshid

Continue reading on narkive:
Loading...