Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreChildPSystemRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreChildPSystemRenderingRun.h	(revision 1055)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreChildPSystemRenderingRun.h	(revision 1330)
@@ -51,6 +51,9 @@
 		return false;
 	}
-	
+	void setNode(SceneNode* n){psysNode = n;}
+	Real getSmallSysRadius(){return sysRad;}
+
 protected:	
+	SceneNode* psysNode;
 	bool perspectiveRendering;
 	bool useOwnMaterial;
@@ -58,4 +61,5 @@
 	String childParticleSystemName;
 	String particleScriptName;
+	Real sysRad;
 	/**
 		@brief the created photon hit map texture
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h	(revision 1062)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h	(revision 1330)
@@ -28,4 +28,8 @@
 							bool useOwnMaterial,
 							String impostorMaterialName,
+							bool useVParam,
+							String VParamRadius,
+							bool useFParam,
+							String FParamRadius,
 							Pass* pass,
 							OgreRenderable* parentRenderable,
@@ -35,5 +39,8 @@
 		@brief Destructor.
 	*/
-	~OgreHierarchicalParticleSystemTechnique();	
+	~OgreHierarchicalParticleSystemTechnique();
+
+	//inherited
+	void update(unsigned long frameNum);
 	
 protected:
@@ -44,4 +51,8 @@
 	unsigned char impostorTexID;
 	bool useOwnMaterial;
+	String VParamRadius;
+	String FParamRadius;
+	bool useVParam;
+	bool useFParam;
 	
 	//inherited
@@ -71,4 +82,8 @@
 	String childPSysScriptName;
 	bool useOwnMaterial;
+	String VParamRadius;
+	String FParamRadius;
+	bool useVParam;
+	bool useFParam;
 
 };
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj	(revision 1125)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj	(revision 1330)
@@ -309,4 +309,7 @@
 					RelativePath="..\..\..\..\..\App\Demos\Illum\Ogre\Media\materials\scripts\kupola.material">
 				</File>
+				<File
+					RelativePath="..\..\..\..\..\App\Demos\Illum\Ogre\Media\materials\scripts\Particles.material">
+				</File>
 			</Filter>
 			<Filter
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreChildParticlesystemRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreChildParticlesystemRenderingRun.cpp	(revision 1062)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreChildParticlesystemRenderingRun.cpp	(revision 1330)
@@ -47,5 +47,6 @@
 	 RenderTarget* rt = hpb->getRenderTarget();
 	 Viewport* v = rt->addViewport(impostorCamera);
-	 v->setBackgroundColour(ColourValue(0,1,0,0));
+	 //Viewport* v = rt->addViewport(OgreIlluminationManager::getSingleton().getMainCamera());
+	 v->setBackgroundColour(ColourValue(0,0,0,0));
 	 v->setOverlaysEnabled(false);
 	 rt->setAutoUpdated(false);
@@ -62,13 +63,31 @@
 
 	sharedRuns->getRoot()->updateBounds();
-	Sphere boundSphere = ((OgreSharedRuns*)sharedRuns->getRoot(ILLUMRUN_HPP_IMPOSTOR))->getBoundingSphere();
+	Vector3 center = sharedRuns->getRootPosition(ILLUMRUN_HPP_IMPOSTOR);
 	Camera* mainCam = OgreIlluminationManager::getSingleton().getMainCamera();
 	impostorCamera->setPosition(mainCam->getPosition());
-	Vector3 dir = boundSphere.getCenter() - mainCam->getPosition();
-	float r = boundSphere.getRadius();
-	r = 200;
+	
+	psysNode->setPosition(center);
+	ParticleSystem* psys = Root::getSingleton()._getCurrentSceneManager()->getParticleSystem(childParticleSystemName);
+	psys->_notifyCurrentCamera(impostorCamera);
+	
+	psysNode->_updateBounds();
+	AxisAlignedBox bb = psysNode->_getWorldAABB();	
+	
+	float r = (bb.getMaximum() - bb.getMinimum()).length() / 2.0;
+	sysRad = r;
+	center = bb.getCenter();
+	Vector3 dir = center - mainCam->getPosition();
 	float d = dir.normalise();
-	impostorCamera->setDirection(dir);
+	
+	if (d <= r * 1.2)//too close
+	{
+		d = r * 1.2;
+		impostorCamera->setPosition(center - dir * d);
+	}
 
+    impostorCamera->setDirection(dir);
+
+	//r = 200;
+	
 	if(perspectiveRendering)
 	{
@@ -76,22 +95,20 @@
 		impostorCamera->setAspectRatio(1.0);
 		Radian a = Math::ASin(r / d) * 2.0;
-		impostorCamera->setFOVy(/*a*/ Radian(Degree(90)));
-		impostorCamera->setNearClipDistance(/*std::max(0.01f, d - r)*/0.1);
-		impostorCamera->setFarClipDistance(/*r + d*/1000);		
+		impostorCamera->setFOVy( a );
+		impostorCamera->setNearClipDistance(d - r);
+		impostorCamera->setFarClipDistance(d + r);		
 	}
 	else
 	{
-		impostorCamera->setPosition(boundSphere.getCenter());
+		impostorCamera->setPosition(center);
 		impostorCamera->setProjectionType(PT_ORTHOGRAPHIC);
 		Matrix4 m;
 		m = Matrix4::IDENTITY;
-		float scale = 1.0 / boundSphere.getRadius();
+		float scale = 1.0 / r;
 		m.setScale(Vector3(scale, scale, scale));
 		impostorCamera->setCustomProjectionMatrix(true, m);
 	}	
 
-	ParticleSystem* psys = Root::getSingleton()._getCurrentSceneManager()->getParticleSystem(childParticleSystemName);
-	psys->getParentSceneNode()->setPosition(boundSphere.getCenter());
-	psys->_notifyCurrentCamera(impostorCamera);
+	//
 	psys->_updateRenderQueue(rq);
 	
@@ -100,6 +117,7 @@
 	
 	RenderTarget* rt = impostorTexture->getBuffer().getPointer()->getRenderTarget();
-	 
+	sm->setFindVisibleObjects(false);
 	rt->update();	
+	sm->setFindVisibleObjects(true);
 	
 	
@@ -109,5 +127,5 @@
 	//filename.append(StringConverter::toString(framecount));
 	filename.append(".dds");
-	rt->writeContentsToFile(filename);
+	//rt->writeContentsToFile(filename);
 	framecount++;	
 	
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp	(revision 1062)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp	(revision 1330)
@@ -14,4 +14,8 @@
 														bool useOwnMaterial,
 														String impostorMaterialName,
+														bool useVParam,
+														String VParamRadius,
+														bool useFParam,
+														String FParamRadius,
 														Pass* pass,
 														OgreRenderable* parentRenderable,
@@ -25,4 +29,8 @@
 	this->impostorMaterialName = impostorMaterialName;
 	this->useOwnMaterial = useOwnMaterial;
+	this->VParamRadius = VParamRadius;
+	this->FParamRadius = FParamRadius;
+	this->useVParam = useVParam;
+	this->useFParam = useFParam;
 	
 	//create the Particle system
@@ -36,4 +44,5 @@
 		sharedRuns->addRun(ILLUMRUN_HPP_IMPOSTOR, createChildPSysRenderingRun());	
 
+	((OgreChildPSystemRenderingRun*) sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR)->asOgreRenderingRun())->setNode(node);
 	impostorChanged(sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR));
 }
@@ -65,4 +74,17 @@
 }
 
+void OgreHierarchicalParticleSystemTechnique::update(unsigned long frameNum)
+{
+	HierarchicalParticleSystemTechnique::update(frameNum);
+
+	OgreChildPSystemRenderingRun* r = (OgreChildPSystemRenderingRun*) 
+											sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR)->asOgreRenderingRun();
+	float radius = r->getSmallSysRadius();
+	if(useVParam)
+		pass->getVertexProgramParameters()->setNamedConstant(VParamRadius, radius);
+	if(useFParam)
+		pass->getFragmentProgramParameters()->setNamedConstant(FParamRadius, radius);
+}
+
 ///Technique Parsers
 namespace HPSParsers
@@ -129,4 +151,14 @@
 		f->childPSysScriptName = params;
 	}
+	void parseVparamRadius(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
+		f->VParamRadius = params;
+	}
+	void parseFparamRadius(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
+		f->FParamRadius = params;
+	}
 
 	
@@ -148,4 +180,6 @@
 	this->attributeParsers.insert(AttribParserList::value_type("particle_script", (ILLUM_ATTRIBUTE_PARSER) parseScriptName));
 	this->attributeParsers.insert(AttribParserList::value_type("material", (ILLUM_ATTRIBUTE_PARSER) parseMaterialName));
+	this->attributeParsers.insert(AttribParserList::value_type("vparam_radius", (ILLUM_ATTRIBUTE_PARSER) parseFparamRadius));
+	this->attributeParsers.insert(AttribParserList::value_type("fparam_radius", (ILLUM_ATTRIBUTE_PARSER) parseVparamRadius));
 	
 }
@@ -165,5 +199,9 @@
 	impostorMaterialName = "";
 	childPSysScriptName = "";
-	bool useOwnMaterial = true;
+	useOwnMaterial = true;
+	VParamRadius = "";
+	FParamRadius = "";
+	useVParam = false;
+	useFParam = false;
 
 	parseParams(params);
@@ -179,4 +217,8 @@
 												useOwnMaterial,
 												impostorMaterialName,
+												useVParam,
+												VParamRadius,
+												useFParam,
+												FParamRadius,
 												pass,
 												parentRenderable,
