Support alpha for cloud definitions Thorsten RENK

This commit is contained in:
Stuart Buchanan
2014-11-13 20:38:28 +00:00
parent 1b7f310ea6
commit 07e09bb88c
4 changed files with 11 additions and 4 deletions

View File

@@ -129,7 +129,7 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const
}
const Extensions* extensions = getExtensions(state.getContextID(),true);
GLfloat ua1[3] = { (GLfloat) 1.0f,
GLfloat ua1[3] = { (GLfloat) alpha_factor,
(GLfloat) shade_factor,
(GLfloat) cloud_height };
GLfloat ua2[3] = { (GLfloat) bottom_factor,

View File

@@ -54,8 +54,10 @@ class CloudShaderGeometry : public osg::Drawable
setUseDisplayList(false);
}
CloudShaderGeometry(int vx, int vy, float width, float height, float ts, float ms, float bs, float shade, float ch, float zsc) :
varieties_x(vx), varieties_y(vy), top_factor(ts), middle_factor(ms), bottom_factor(bs), shade_factor(shade), cloud_height(ch), zscale(zsc)
CloudShaderGeometry(int vx, int vy, float width, float height, float ts, float ms, float bs, float shade, float ch, float zsc, float af) :
varieties_x(vx), varieties_y(vy), top_factor(ts), middle_factor(ms),
bottom_factor(bs), shade_factor(shade), cloud_height(ch), zscale(zsc),
alpha_factor(af)
{
setUseDisplayList(false);
float x = width/2.0f;
@@ -121,6 +123,7 @@ class CloudShaderGeometry : public osg::Drawable
float shade_factor;
float cloud_height;
float zscale;
float alpha_factor;
// Bounding box extents.
osg::BoundingBox _bbox;

View File

@@ -102,6 +102,7 @@ SGNewCloud::SGNewCloud(const SGPath &texture_root, const SGPropertyNode *cld_def
max_shade_lighting_factor = cld_def->getFloatValue("max-shade-lighting-factor", min(min_shade_lighting_factor + 0.1, 1.0));
zscale = cld_def->getFloatValue("z-scale", 1.0);
alpha_factor = cld_def->getFloatValue("alpha-factor",1.0);
texture = cld_def->getStringValue("texture", "cl_cumulus.png");
// Create a new Effect for the texture, if required.
@@ -169,7 +170,8 @@ osg::ref_ptr<EffectGeode> SGNewCloud::genCloud() {
bottom_factor,
shade_factor,
height,
zscale);
zscale,
alpha_factor);
// Determine the cull distance. This is used to remove sprites that are too close together.
// The value is squared as we use vector calculations.

View File

@@ -93,6 +93,8 @@ private:
// zscale indicates how sprites should be scaled vertically
// after billboarding.
float zscale;
// alpha_factor is the transparency adjustment of the clouds
float alpha_factor;
bool height_map_texture;
int num_sprites;
int num_textures_x;