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
+1 -1
View File
@@ -129,7 +129,7 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const
} }
const Extensions* extensions = getExtensions(state.getContextID(),true); const Extensions* extensions = getExtensions(state.getContextID(),true);
GLfloat ua1[3] = { (GLfloat) 1.0f, GLfloat ua1[3] = { (GLfloat) alpha_factor,
(GLfloat) shade_factor, (GLfloat) shade_factor,
(GLfloat) cloud_height }; (GLfloat) cloud_height };
GLfloat ua2[3] = { (GLfloat) bottom_factor, GLfloat ua2[3] = { (GLfloat) bottom_factor,
+5 -2
View File
@@ -54,8 +54,10 @@ class CloudShaderGeometry : public osg::Drawable
setUseDisplayList(false); setUseDisplayList(false);
} }
CloudShaderGeometry(int vx, int vy, float width, float height, float ts, float ms, float bs, float shade, float ch, float 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) 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); setUseDisplayList(false);
float x = width/2.0f; float x = width/2.0f;
@@ -121,6 +123,7 @@ class CloudShaderGeometry : public osg::Drawable
float shade_factor; float shade_factor;
float cloud_height; float cloud_height;
float zscale; float zscale;
float alpha_factor;
// Bounding box extents. // Bounding box extents.
osg::BoundingBox _bbox; osg::BoundingBox _bbox;
+3 -1
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)); 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); 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"); 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.
@@ -169,7 +170,8 @@ osg::ref_ptr<EffectGeode> SGNewCloud::genCloud() {
bottom_factor, bottom_factor,
shade_factor, shade_factor,
height, height,
zscale); zscale,
alpha_factor);
// Determine the cull distance. This is used to remove sprites that are too close together. // Determine the cull distance. This is used to remove sprites that are too close together.
// The value is squared as we use vector calculations. // The value is squared as we use vector calculations.
+2
View File
@@ -93,6 +93,8 @@ private:
// zscale indicates how sprites should be scaled vertically // zscale indicates how sprites should be scaled vertically
// after billboarding. // after billboarding.
float zscale; float zscale;
// alpha_factor is the transparency adjustment of the clouds
float alpha_factor;
bool height_map_texture; bool height_map_texture;
int num_sprites; int num_sprites;
int num_textures_x; int num_textures_x;