Add clamping to 0..1 bounds for each of the r,g,b,a components in
the CubeMapGenerator::set_pixel() method.
This commit is contained in:
@@ -43,13 +43,13 @@ CubeMapGenerator::CubeMapGenerator(const CubeMapGenerator ©, const osg::Copy
|
||||
|
||||
void CubeMapGenerator::generateMap(bool use_osg_system)
|
||||
{
|
||||
osg::Matrix M;
|
||||
|
||||
if (use_osg_system) {
|
||||
M = osg::Matrix::rotate(osg::PI_2, osg::Vec3(1, 0, 0));
|
||||
} else {
|
||||
M = osg::Matrix::identity();
|
||||
}
|
||||
osg::Matrix M;
|
||||
|
||||
if (use_osg_system) {
|
||||
M = osg::Matrix::rotate(osg::PI_2, osg::Vec3(1, 0, 0));
|
||||
} else {
|
||||
M = osg::Matrix::identity();
|
||||
}
|
||||
|
||||
const float dst = 2.0f/(texture_size_-1);
|
||||
|
||||
@@ -57,7 +57,7 @@ void CubeMapGenerator::generateMap(bool use_osg_system)
|
||||
for (int i=0; i<texture_size_; ++i) {
|
||||
float s = -1;
|
||||
for (int j=0; j<texture_size_; ++j) {
|
||||
set_pixel(0, j, i, compute_color(osg::Vec3(1, -t, -s) * M));
|
||||
set_pixel(0, j, i, compute_color(osg::Vec3(1, -t, -s) * M));
|
||||
set_pixel(1, j, i, compute_color(osg::Vec3(-1, -t, s) * M));
|
||||
set_pixel(2, j, i, compute_color(osg::Vec3(s, 1, t) * M));
|
||||
set_pixel(3, j, i, compute_color(osg::Vec3(s, -1, -t) * M));
|
||||
|
||||
@@ -15,21 +15,21 @@
|
||||
using namespace osgUtil;
|
||||
|
||||
HighlightMapGenerator::HighlightMapGenerator(const osg::Vec3 &light_direction,
|
||||
const osg::Vec4 &light_color,
|
||||
float specular_exponent,
|
||||
int texture_size)
|
||||
: CubeMapGenerator(texture_size),
|
||||
ldir_(light_direction),
|
||||
lcol_(light_color),
|
||||
sexp_(specular_exponent)
|
||||
const osg::Vec4 &light_color,
|
||||
float specular_exponent,
|
||||
int texture_size)
|
||||
: CubeMapGenerator(texture_size),
|
||||
ldir_(light_direction),
|
||||
lcol_(light_color),
|
||||
sexp_(specular_exponent)
|
||||
{
|
||||
ldir_.normalize();
|
||||
ldir_.normalize();
|
||||
}
|
||||
|
||||
HighlightMapGenerator::HighlightMapGenerator(const HighlightMapGenerator ©, const osg::CopyOp ©op)
|
||||
: CubeMapGenerator(copy, copyop),
|
||||
ldir_(copy.ldir_),
|
||||
lcol_(copy.lcol_),
|
||||
sexp_(copy.sexp_)
|
||||
: CubeMapGenerator(copy, copyop),
|
||||
ldir_(copy.ldir_),
|
||||
lcol_(copy.lcol_),
|
||||
sexp_(copy.sexp_)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user