Add support for "squashing" the billboarding of individual 3D cloud sprites, to allow thin layers of stratus to be generated by large textures.
This commit is contained in:
@@ -116,7 +116,7 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
(GLfloat) t.cloud_height };
|
(GLfloat) t.cloud_height };
|
||||||
extensions->glVertexAttrib3fv(USR_ATTR_1, ua1 );
|
extensions->glVertexAttrib3fv(USR_ATTR_1, ua1 );
|
||||||
extensions->glVertexAttrib3fv(USR_ATTR_2, ua2 );
|
extensions->glVertexAttrib3fv(USR_ATTR_2, ua2 );
|
||||||
glColor4f(t.position.x(), t.position.y(), t.position.z(), 1.0);
|
glColor4f(t.position.x(), t.position.y(), t.position.z(), zscale);
|
||||||
_geometry->draw(renderInfo);
|
_geometry->draw(renderInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ class CloudShaderGeometry : public osg::Drawable
|
|||||||
setUseDisplayList(false);
|
setUseDisplayList(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
CloudShaderGeometry(int vx, int vy, float width, float height) :
|
CloudShaderGeometry(int vx, int vy, float width, float height, float zsc) :
|
||||||
varieties_x(vx), varieties_y(vy)
|
varieties_x(vx), varieties_y(vy), zscale(zsc)
|
||||||
{
|
{
|
||||||
setUseDisplayList(false);
|
setUseDisplayList(false);
|
||||||
float x = width/2.0f;
|
float x = width/2.0f;
|
||||||
@@ -107,13 +107,14 @@ class CloudShaderGeometry : public osg::Drawable
|
|||||||
_geometry = geometry;
|
_geometry = geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addSprite(const SGVec3f& p, int tx, int ty, float w, float h,
|
void addSprite(const SGVec3f& p, int tx, int ty, float w, float h,
|
||||||
float s, float cull, float cloud_height);
|
float s, float cull, float cloud_height);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Drawable> _geometry;
|
osg::ref_ptr<osg::Drawable> _geometry;
|
||||||
|
|
||||||
int varieties_x;
|
int varieties_x;
|
||||||
int varieties_y;
|
int varieties_y;
|
||||||
|
float zscale;
|
||||||
|
|
||||||
// Bounding box extents.
|
// Bounding box extents.
|
||||||
osg::BoundingBox _bbox;
|
osg::BoundingBox _bbox;
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ SGNewCloud::SGNewCloud(const SGPath &texture_root, const SGPropertyNode *cld_def
|
|||||||
num_textures_x = cld_def->getIntValue("num-textures-x", 4);
|
num_textures_x = cld_def->getIntValue("num-textures-x", 4);
|
||||||
num_textures_y = cld_def->getIntValue("num-textures-y", 4);
|
num_textures_y = cld_def->getIntValue("num-textures-y", 4);
|
||||||
bottom_shade = cld_def->getDoubleValue("bottom-shade", 1.0);
|
bottom_shade = cld_def->getDoubleValue("bottom-shade", 1.0);
|
||||||
|
zscale = cld_def->getDoubleValue("z-scale", 1.0);
|
||||||
texture = cld_def->getStringValue("texture", "cl_cumulus.png");
|
texture = cld_def->getStringValue("texture", "cl_cumulus.png");
|
||||||
|
|
||||||
// Create a new Effect for the texture, if required.
|
// Create a new Effect for the texture, if required.
|
||||||
@@ -165,7 +166,7 @@ osg::ref_ptr<EffectGeode> SGNewCloud::genCloud() {
|
|||||||
|
|
||||||
osg::ref_ptr<EffectGeode> geode = new EffectGeode;
|
osg::ref_ptr<EffectGeode> geode = new EffectGeode;
|
||||||
|
|
||||||
CloudShaderGeometry* sg = new CloudShaderGeometry(num_textures_x, num_textures_y, max_width, max_height);
|
CloudShaderGeometry* sg = new CloudShaderGeometry(num_textures_x, num_textures_y, max_width, max_height, zscale);
|
||||||
|
|
||||||
// Determine how big this specific cloud instance is. Note that we subtract
|
// Determine how big this specific cloud instance is. Note that we subtract
|
||||||
// the sprite size because the width/height is used to define the limits of
|
// the sprite size because the width/height is used to define the limits of
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ private:
|
|||||||
double min_sprite_height;
|
double min_sprite_height;
|
||||||
double max_sprite_height;
|
double max_sprite_height;
|
||||||
double bottom_shade;
|
double bottom_shade;
|
||||||
|
double zscale;
|
||||||
int num_sprites;
|
int num_sprites;
|
||||||
int num_textures_x;
|
int num_textures_x;
|
||||||
int num_textures_y;
|
int num_textures_y;
|
||||||
|
|||||||
Reference in New Issue
Block a user