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#ifndef OSGUTIL_HIGHLIGHTMAPGENERATOR_
14#define OSGUTIL_HIGHLIGHTMAPGENERATOR_
16#include <osgUtil/Export>
18#include <osgUtil/CubeMapGenerator>
23 /** This cube map generator produces a specular highlight map.
24 * The vector-color association is: C = (R dot (-L)) ^ n, where C is the
25 * resulting color, R is the reflection vector, L is the light direction
26 * and n is the specular exponent.
28 class OSGUTIL_EXPORT HighlightMapGenerator: public CubeMapGenerator {
30 HighlightMapGenerator(
31 const osg::Vec3 &light_direction,
32 const osg::Vec4 &light_color,
33 float specular_exponent,
34 int texture_size = 64);
36 HighlightMapGenerator(const HighlightMapGenerator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
39 virtual ~HighlightMapGenerator() {}
40 HighlightMapGenerator &operator=(const HighlightMapGenerator &) { return *this; }
42 inline virtual osg::Vec4 compute_color(const osg::Vec3 &R) const;
52 inline osg::Vec4 HighlightMapGenerator::compute_color(const osg::Vec3 &R) const
54 float v = -ldir_ * (R / R.length());
56 osg::Vec4 color(lcol_ * powf(v, sexp_));