From: Stuart Buchanan Date: Thu, 13 Nov 2014 20:38:28 +0000 (+0000) Subject: Support alpha for cloud definitions Thorsten RENK X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=07e09bb88c41a9ebd119efac214326efb974a457;p=simgear.git Support alpha for cloud definitions Thorsten RENK --- diff --git a/simgear/scene/sky/CloudShaderGeometry.cxx b/simgear/scene/sky/CloudShaderGeometry.cxx index 3a41ceb6..8b4ea16e 100644 --- a/simgear/scene/sky/CloudShaderGeometry.cxx +++ b/simgear/scene/sky/CloudShaderGeometry.cxx @@ -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, diff --git a/simgear/scene/sky/CloudShaderGeometry.hxx b/simgear/scene/sky/CloudShaderGeometry.hxx index b8e44fa0..82eb99c8 100644 --- a/simgear/scene/sky/CloudShaderGeometry.hxx +++ b/simgear/scene/sky/CloudShaderGeometry.hxx @@ -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; diff --git a/simgear/scene/sky/newcloud.cxx b/simgear/scene/sky/newcloud.cxx index 18b7710c..e18f6f6e 100644 --- a/simgear/scene/sky/newcloud.cxx +++ b/simgear/scene/sky/newcloud.cxx @@ -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 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. diff --git a/simgear/scene/sky/newcloud.hxx b/simgear/scene/sky/newcloud.hxx index 88edf19c..94fd6a99 100644 --- a/simgear/scene/sky/newcloud.hxx +++ b/simgear/scene/sky/newcloud.hxx @@ -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;