WS20: Object mask bug fix for random lights

The random lights placement algorithm was using the incorrect channel
from the object mask image, (red instead of blue as mentioned in
Docs/README.materials). This commit rectifies the mismatch.
This commit is contained in:
Fahim Imaduddin Dalvi 2022-01-17 22:13:38 +03:00
parent 4ed559d5a9
commit 1afbda9833
2 changed files with 4 additions and 4 deletions

View File

@ -267,12 +267,12 @@ public:
SGVec2f texCoord = a*t0 + b*t1 + c*t2;
// Check this random point against the object mask
// red channel.
// blue channel.
osg::Image* img = object_mask->getImage();
unsigned int x = (int) (img->s() * texCoord.x()) % img->s();
unsigned int y = (int) (img->t() * texCoord.y()) % img->t();
if (mt_rand(&seed) < img->getColor(x, y).r()) {
if (mt_rand(&seed) < img->getColor(x, y).b()) {
points.push_back(randomPoint);
}
} else {

View File

@ -196,12 +196,12 @@ public:
SGVec2f texCoord = a*t0 + b*t1 + c*t2;
// Check this random point against the object mask
// red channel.
// blue channel.
osg::Image* img = object_mask->getImage();
unsigned int x = (int) (img->s() * texCoord.x()) % img->s();
unsigned int y = (int) (img->t() * texCoord.y()) % img->t();
if (mt_rand(&seed) < img->getColor(x, y).r()) {
if (mt_rand(&seed) < img->getColor(x, y).b()) {
points.push_back(randomPoint);
}
} else {