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:
Stuart Buchanan 2011-08-07 12:56:10 +01:00
parent 410c5ae919
commit 2805a2d0cc
4 changed files with 9 additions and 6 deletions

View File

@ -116,7 +116,7 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const
(GLfloat) t.cloud_height };
extensions->glVertexAttrib3fv(USR_ATTR_1, ua1 );
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);
}
}

View File

@ -52,8 +52,8 @@ class CloudShaderGeometry : public osg::Drawable
setUseDisplayList(false);
}
CloudShaderGeometry(int vx, int vy, float width, float height) :
varieties_x(vx), varieties_y(vy)
CloudShaderGeometry(int vx, int vy, float width, float height, float zsc) :
varieties_x(vx), varieties_y(vy), zscale(zsc)
{
setUseDisplayList(false);
float x = width/2.0f;
@ -107,13 +107,14 @@ class CloudShaderGeometry : public osg::Drawable
_geometry = geometry;
}
void addSprite(const SGVec3f& p, int tx, int ty, float w, float h,
float s, float cull, float cloud_height);
void addSprite(const SGVec3f& p, int tx, int ty, float w, float h,
float s, float cull, float cloud_height);
osg::ref_ptr<osg::Drawable> _geometry;
int varieties_x;
int varieties_y;
float zscale;
// Bounding box extents.
osg::BoundingBox _bbox;

View File

@ -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_y = cld_def->getIntValue("num-textures-y", 4);
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");
// 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;
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
// the sprite size because the width/height is used to define the limits of

View File

@ -70,6 +70,7 @@ private:
double min_sprite_height;
double max_sprite_height;
double bottom_shade;
double zscale;
int num_sprites;
int num_textures_x;
int num_textures_y;