1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
13//osgFX - Copyright (C) 2003 Marco Jez
18#include <osgFX/Export>
19#include <osgFX/Effect>
21#include <osg/Material>
22#include <osg/LineWidth>
28 This effect implements a technique called 'Cel-Shading' to produce a
29 cartoon-style (non photorealistic) rendering. Two passes are required:
30 the first one draws solid surfaces, the second one draws the outlines.
31 A vertex program is used to setup texture coordinates for a sharp lighting
32 texture on unit 0 which is generated on-the-fly.
33 This effect requires the ARB_vertex_program extension.
35 class OSGFX_EXPORT Cartoon: public Effect {
38 Cartoon(const Cartoon& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
40 // effect class information
47 "This effect implements a technique called 'Cel-Shading' to produce a "
48 "cartoon-style (non photorealistic) rendering. Two passes are required: "
49 "the first one draws solid surfaces, the second one draws the outlines. "
50 "A vertex program is used to setup texture coordinates for a sharp lighting "
51 "texture on unit 0 which is generated on-the-fly.\n"
52 "This effect requires the ARB_vertex_program extension "
53 "or OpenGL Shading Language.",
55 "Marco Jez; OGLSL port by Mike Weiblen");
57 /** get the outline color */
58 inline const osg::Vec4& getOutlineColor() const;
60 /** set the outline color */
61 inline void setOutlineColor(const osg::Vec4& color);
63 /** get the outline line width */
64 inline float getOutlineLineWidth() const;
66 /** set the outline line width */
67 inline void setOutlineLineWidth(float w);
69 /** get the OpenGL light number */
70 inline int getLightNumber() const;
72 /** set the OpenGL light number that will be used in lighting computations */
73 inline void setLightNumber(int n);
77 Cartoon& operator=(const Cartoon&) { return *this; }
79 bool define_techniques();
82 osg::ref_ptr<osg::Material> _wf_mat;
83 osg::ref_ptr<osg::LineWidth> _wf_lw;
89 inline const osg::Vec4& Cartoon::getOutlineColor() const
91 return _wf_mat->getEmission(osg::Material::FRONT_AND_BACK);
94 inline void Cartoon::setOutlineColor(const osg::Vec4& color)
96 _wf_mat->setEmission(osg::Material::FRONT_AND_BACK, color);
99 inline float Cartoon::getOutlineLineWidth() const
101 return _wf_lw->getWidth();
104 inline void Cartoon::setOutlineLineWidth(float w)
109 inline int Cartoon::getLightNumber() const
114 inline void Cartoon::setLightNumber(int n)