]> git.mxchange.org Git - simgear.git/commitdiff
Support alpha for cloud definitions Thorsten RENK
authorStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Thu, 13 Nov 2014 20:38:28 +0000 (20:38 +0000)
committerStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Thu, 13 Nov 2014 20:38:28 +0000 (20:38 +0000)
simgear/scene/sky/CloudShaderGeometry.cxx
simgear/scene/sky/CloudShaderGeometry.hxx
simgear/scene/sky/newcloud.cxx
simgear/scene/sky/newcloud.hxx

index 3a41ceb69acc34838b0fe499bcb7e4563543283f..8b4ea16e4e8b140f5e92e63cc5aa4f724988da9a 100644 (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,
index b8e44fa06b1254da1e8421a457482cd5437c4eff..82eb99c879772f78bbe7fddf36298f7011966745 100644 (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;
index 18b7710c20115ca4f07f42584fdce8f678066997..e18f6f6e8c4b7e747ce7572bd388878bfc8bcc09 100644 (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.
index 88edf19c4bba181683b57d8f16cf449733db3494..94fd6a9982d8df223a553ab40a56701bbaa1004a 100644 (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;