diff --git a/examples/osgprecipitation/osgprecipitation.cpp b/examples/osgprecipitation/osgprecipitation.cpp index 35da4568b..e1c2b7a94 100644 --- a/examples/osgprecipitation/osgprecipitation.cpp +++ b/examples/osgprecipitation/osgprecipitation.cpp @@ -82,6 +82,71 @@ public: osg::ref_ptr _uniform; }; +void fillSpotLightImage(unsigned char* ptr, const osg::Vec4& centerColour, const osg::Vec4& backgroudColour, unsigned int size, float power) +{ + float mid = (float(size)-1.0f)*0.5f; + float div = 2.0f/float(size); + for(unsigned int r=0;rdata(0,r,0); + for(unsigned int c=0;cdata(0,0,0); + fillSpotLightImage(ptr, centerColour, backgroudColour, size, power); +#else + osg::Image::MipmapDataType mipmapData; + unsigned int s = size; + unsigned int totalSize = 0; + unsigned i; + for(i=0; s>0; s>>=1, ++i) + { + if (i>0) mipmapData.push_back(totalSize); + totalSize += s*s*4; + std::cout<<" i= "<addUniform(baseTextureSampler); - osg::Texture2D* texture = new osg::Texture2D(osgDB::readImageFile("Images/particle.rgb")); +// osg::Texture2D* texture = new osg::Texture2D(osgDB::readImageFile("Images/particle.rgb")); + osg::Texture2D* texture = new osg::Texture2D(createSpotLightImage(osg::Vec4(1.0f,1.0f,1.0f,1.0f),osg::Vec4(1.0f,1.0f,1.0f,0.0f),32,1.0)); +// texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); stateset->setTextureAttribute(0, texture); // make it render after the normal transparent bin @@ -253,7 +320,7 @@ osg::Node* createModel(osg::Node* loadedModel, bool useShaders) osg::Group* group = new osg::Group; osg::BoundingBox bb(0.0, 0.0, 0.0, 100.0, 100.0, 100.0); - osg::Vec3 velocity(0.0,0.0,-2.0); + osg::Vec3 velocity(0.0,2.0,-5.0); unsigned int numParticles = 150000; if (loadedModel) diff --git a/examples/osgprecipitation/rain.vert b/examples/osgprecipitation/rain.vert index 0ada2b113..c57a7f536 100644 --- a/examples/osgprecipitation/rain.vert +++ b/examples/osgprecipitation/rain.vert @@ -31,7 +31,7 @@ void main(void) vec2 dp = vec2( -dv_normalized.y, dv_normalized.x ) * particleSize; float area = length(dv.xy)*length(dp); - colour.a = 0.2+(particleSize2)/area; + colour.a = 0.1+(particleSize2)/area; v1.xyz += dv*texCoord.y;