[Ogre 2] Porting Particle Universe

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


User avatar
Kohedlo
Orc
Posts: 435
Joined: Fri Nov 27, 2009 3:34 pm
Location: Ukraine, Sumy
x 32
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by Kohedlo »

make sure you set the render queue to the correct mode, (ie V1_FAST).

this in heart of problem. After:

Code: Select all

mSceneManager->getRenderQueue()->setRenderQueueMode( 5, Ogre::RenderQueue::Modes::V1_FAST );

particle->setRenderQueueGroup( 5 );
particles starts works without crash.

Only some materials looks as "white pixeled smoke". I see what cause this last.
c++ game developer.
current project: Imperial Game Engine 2.5
Image
User avatar
Kohedlo
Orc
Posts: 435
Joined: Fri Nov 27, 2009 3:34 pm
Location: Ukraine, Sumy
x 32
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by Kohedlo »

"white pixeled smoke"
looks on next screen:

Image
c++ game developer.
current project: Imperial Game Engine 2.5
Image
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: [Ogre 2] Porting Particle Universe

Post by al2950 »

Have you managed to solve your issue?

White particles means that is using the default datablock. Ensure your materials is correct. If you are still having issues post your material for me to look at.
User avatar
Kohedlo
Orc
Posts: 435
Joined: Fri Nov 27, 2009 3:34 pm
Location: Ukraine, Sumy
x 32
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by Kohedlo »

on screen used standard demo examples of PU Editor. Most in ported version is maked as material but not datablock. according this i set Qery mask for materials or datablock. Last give no result.


This white bug- also with OGRE bilboardsets. (on screen is small white rectangle under red cross)
c++ game developer.
current project: Imperial Game Engine 2.5
Image
User avatar
Kohedlo
Orc
Posts: 435
Joined: Fri Nov 27, 2009 3:34 pm
Location: Ukraine, Sumy
x 32
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by Kohedlo »

And second with white bilboards wideo memory run out very quickly!
c++ game developer.
current project: Imperial Game Engine 2.5
Image
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 51
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by SolarPortal »

Hi, I am experiencing a couple of issues when using the upgraded Particle Universe for Ogre3D 2.1 found on "scrawl/ParticleUniverse/Ogre2.1" on the previous page.

Bug 1) A Memory leak: ok, so the first bug is caused whenever a particle is ran in the scene.
Here is some information to replicate: I am using a single particle "mp_torch.pu" in the scene and have created a hlms unlit with the correct texture.

Code: Select all

hlms mp_fire_02 unlit
{
	depth_write off
	scene_blend add
	diffuse_map mp_fire_02_2x2.dds
	
	diffuse 1 1 1
}
I use this code to run the particle and the system then plays the particle indefinately, and using the task manager, you can watch the memory jump.

Code: Select all

	psys = ParticleUniverse::ParticleSystemManager::getSingletonPtr()->createParticleSystem("ParticleUni"+scene.getUniqueName(), "mp_torch", scene.sceneManager);
	
	Ogre::SceneNode* node = sceneManager->getRootSceneNode()->createChildSceneNode(); 
	node->attachObject(psys);
	node->setPosition(Ogre::Vector3(0,0,0));
	
	psys->prepare();
	psys->start();
	psys->setRenderQueueGroup(55); // | This is set to "V1_FAST" Render queue mode
Everything looks ok in the scene, but the memory cost is like 2-3mb addition a second per particle and none of it cleans up.
When i added a lot of the same particles to the scene, i went over 12gb of ram very quickly lol :P

Here is a quick image of the particle for proof that Particle Universe works on 2.1

Image

Q) Does anyone else experience this with the same setup?

Bug 2) If you call particle system prepare() without calling start() in the same frame, it causes a crash when calling renderOneFrame().
However, when start() is called directly after the prepare() it works fine. This is not good if you want to load the assets before hand.
...(for those who can't handle unperfect code... look away now... :lol: )...But a quick hack to get around this is to call is:

Code: Select all

psys->prepare();
psys->start();
psys->stop();
and this makes the particle be prepared and work as normal to be played later on.

I am continuing to look into this, but if someone has already solved it or knows where it is, then it would be a great head start :)
Thanks and looking forward to your responses.
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: [Ogre 2] Porting Particle Universe

Post by al2950 »

Hmmmm, grumble. I ported PU originally just so my system would compile, and display 'something', however it uses a lot of 1.x concepts that are not very compatible with 2.1. I was hoping the work Bryan Yan has done with this pull request would have been reviewed and merged by now.

I cant look at any of these issues next week, but ill try to have a look at them the week after if you have had no luck.

**EDIT** I think I might know why the crash might happen....
User avatar
Kohedlo
Orc
Posts: 435
Joined: Fri Nov 27, 2009 3:34 pm
Location: Ukraine, Sumy
x 32
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by Kohedlo »

Ok./ Unlit material is ok./


Image

Large
c++ game developer.
current project: Imperial Game Engine 2.5
Image
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 51
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by SolarPortal »

I have been testing and after some time trying to render externalData into a BillboardSet outside of Particle Universe in a testbed,
i can now say that it is not at fault and there is something else inside PU that is at fault. Still hunting.... :)

@Kohedlo, cool that yours is working too now :)
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: [Ogre 2] Porting Particle Universe

Post by al2950 »

FYI I have just started using PU in anger in my engine, and as a result I have pushed some changes. The latest push fixes random crashes that may occur in RenderQueue::addRenderable which was caused by PU adding BillboardSets to render when it had not initialised them properly, effectively meaning Renderable::mHlmsDatablock was null.

Also dark_sylinc pushed a fix for a memory leak in billboardSet, which I have assumed would fix the mentioned memory leak, but I have not checked yet :oops:
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 51
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by SolarPortal »

thanks. I have not tested the memory leak fix yet but it is on my list to test again :)
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 51
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by SolarPortal »

I have now tested PU again and the memory leak seems to have been fixed with the latest version of 2.1 :) Good job ogre team!
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
dermont
Bugbear
Posts: 812
Joined: Thu Dec 09, 2004 2:51 am
x 42

Re: [Ogre 2] Porting Particle Universe

Post by dermont »

Nice, there are a couple of minor issues on Linux with header paths and Ogre will only load plugins with the same so name versions.

Code: Select all

diff --git a/Samples/ParticleUniverseDemo/src/BaseApplication.cpp b/Samples/ParticleUniverseDemo/src/BaseApplication.cpp
index 9e579c2..f1dcaae 100644
--- a/Samples/ParticleUniverseDemo/src/BaseApplication.cpp
+++ b/Samples/ParticleUniverseDemo/src/BaseApplication.cpp
@@ -6,7 +6,7 @@
 #include <OIS.h>
 #include <OgreArchiveManager.h>
 #include <OgreHlmsManager.h>
-#include <Hlms\Unlit\OgreHlmsUnlit.h>
+#include <Hlms/Unlit/OgreHlmsUnlit.h>

--- a/Plugins/ParticleUniverse/CMakeLists.txt
+++ b/Plugins/ParticleUniverse/CMakeLists.txt
@@ -16,4 +16,4 @@ add_definitions(-DPARTICLE_UNIVERSE_EXPORTS)
 
 add_library(${PARTICLEUNIVERSE_PLUGIN_NAME} SHARED ${PROJECT_SOURCES})
 target_link_libraries(${PARTICLEUNIVERSE_PLUGIN_NAME} ${LIBS})
-set_target_properties(${PARTICLEUNIVERSE_PLUGIN_NAME} PROPERTIES VERSION "1.9.0" SOVERSION "1.9.0" PREFIX "")
+set_target_properties(${PARTICLEUNIVERSE_PLUGIN_NAME} PROPERTIES VERSION "2.1.0" SOVERSION "2.1.0" PREFIX "")

diff --git a/Samples/ParticleUniverseDemo/include/ParticleUniverseDemo.h b/Samples/ParticleUniverseDemo/include/ParticleUniverseDemo.h
index 30a27f5..6e1295b 100644
--- a/Samples/ParticleUniverseDemo/include/ParticleUniverseDemo.h
+++ b/Samples/ParticleUniverseDemo/include/ParticleUniverseDemo.h
@@ -10,7 +10,7 @@
 #include <OgreRenderWindow.h>
 #include <OgreRoot.h>
 #include <OgreSceneNode.h>
-#include <Compositor\OgreCompositorManager2.h>
+#include <Compositor/OgreCompositorManager2.h>
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 51
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by SolarPortal »

Thanks for the latest patch, i am now up and running with PU except i did run into a problem creating particle systems using Templates.
Since the Creation order of the billboardset has changed and we use variables now that are applied in the _prepare() phase of the renderable.

When a template is created, the file is parsed and the properties are stored correctly for the template. Although, when "creating a particle system" based on a template, the properties like "billboard_type, billboard_origin, billboard_rotation_type" are set to the default. So i have added this little block into the "ParticleUniverseBillboardRenderer.cpp" and it seems to work quite nicely so far.

Code: Select all

		// New: Copy the settings from the template if it exists
		ParticleSystem* pTemplate = ParticleSystemManager::getSingletonPtr()->getParticleSystemTemplate(technique->getParentSystem()->getTemplateName());
		if (pTemplate){
			for (int i = 0; i < pTemplate->getNumTechniques(); i++){
				if (technique->getName() == pTemplate->getTechnique(i)->getName()){
					ParticleUniverse::String rendererType = pTemplate->getTechnique(i)->getRenderer()->getRendererType();
					if (rendererType == getRendererType()){
						pTemplate->getTechnique(i)->getRenderer()->copyAttributesTo(this);
					}
				}
			}
		}
Here is the full code for the function:

Code: Select all

	void BillboardRenderer::_prepare(ParticleTechnique* technique)
	{
		Ogre::LogManager::getSingleton().stream() << "\n[Particle Universe] Preparing Particle Technique: "+technique->getName();
		// Use the given technique, although it should be the same as mParentTechnique (must be set already)
		if (!technique || mRendererInitialised)
			return;


		mBillboardSet = PU_NEW Ogre::v1::BillboardSet(Ogre::Id::generateNewId<ParticleRenderer>(),
											technique->getParentSystem()->getDummyObjectMemMgr(),
											technique->getParentSystem()->_getManager(),
											0, true);
		mBillboardSet->setBillboardsInWorldSpace(true);

		// New: Copy the settings from the template if it exists
		ParticleSystem* pTemplate = ParticleSystemManager::getSingletonPtr()->getParticleSystemTemplate(technique->getParentSystem()->getTemplateName());
		if (pTemplate){
			for (int i = 0; i < pTemplate->getNumTechniques(); i++){
				if (technique->getName() == pTemplate->getTechnique(i)->getName()){
					ParticleUniverse::String rendererType = pTemplate->getTechnique(i)->getRenderer()->getRendererType();
					if (rendererType == getRendererType()){
						pTemplate->getTechnique(i)->getRenderer()->copyAttributesTo(this);
					}
				}
			}
		}
		
		//Now set the properties which may have been restored from the template.
		setBillboardType(mBillboardType);
		setUseAccurateFacing(mUseAccurateFacing);
		setBillboardOrigin(mBillboardOrigin);
		setBillboardRotationType(mBillboardRotationType);
		setCommonDirection(mBillboardDirection);
		setCommonUpVector(mBillboardUpVector);
		setPointRenderingEnabled(mPointRenderingEnabled);

		_notifyParticleQuota(technique->getVisualParticleQuota());

		// Notify attached, but only if the parentnode exists
		if (technique->getParentSystem()->getParentNode())
		{		
			_notifyAttached(technique->getParentSystem()->getParentNode());
		}
		_notifyDefaultDimensions(_mRendererScale.x * technique->getDefaultWidth(),
								_mRendererScale.y * technique->getDefaultHeight(),
								_mRendererScale.z * technique->getDefaultDepth());
		_setMaterialName(technique->getMaterialName());
		mBillboardSet->setRenderQueueGroup(mQueueId);
		
		// Set the texture coordinates (if used)
		if (mTextureCoordsSet)
		{
			mBillboardSet->setTextureCoords(*mUVList.begin(), static_cast<uint16>(mUVList.size()));
		}
		else if (mTextureCoordsRowsAndColumnsSet)
		{
			mBillboardSet->setTextureStacksAndSlices(mTextureCoordsRows, mTextureCoordsColumns);
		}
		
		mRendererInitialised = true;
	}

The chunk of code must happen after the billboardset creation and same with other renderer types, otherwise i would have put it in the "void ParticleTechnique::_prepareRenderer(void)" before" _prepare();"
Note: It also means al techniques need a unique name in the particle universe file :)

Someone may know a better way of doing this or the correct way. But it allows the oriented_self particles to work again with no apparent side effects :)

Edit: ok, the only issue i have is relating to the base renderer settings where it resets scale back to 1,1,1. Found in:

Code: Select all

ParticleRenderer::copyAttributesTo(renderer);

Code: Select all

renderer->_mRendererScale = _mRendererScale;
I simply commented this out, since it is defaulted at the top of the file and seems ok to me :)
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by AshMcConnell »

I got a bit confused during the thread, can I just check what would be the recommended repo / branch to start with Particle Universe for 2.1?

Thanks guys, can't wait to get some 80s-F1 style sparks! :)

Image
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 51
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by SolarPortal »

i believe we originally ported on 2.1, however, we have been running the 2-1 pso branch for sometime now :)
Both should work with PU. :)
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by AshMcConnell »

Good stuff. It's scrawl's 2.1 branch I take it?

I would like to go to 2-1 pso, but I don't think MyGUI works with it yet :)

I bought the PU editor, but all the links seem to be dead these days unfortunately, I dropped spookyboo an email, but no response as yet.
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 51
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by SolarPortal »

the 2.1 / 2.1-pso branch we use is from sinbad's bitbucket: https://bitbucket.org/sinbad/ogre/branch/v2-1
We only use librocket and Gorilla, so don't really know about myGUI :)

Yes, we cant seem to access the fxexpression site either these days.
I do believe PU went MIT though as you can see in this github file: https://github.com/scrawl/particleunive ... icense.txt

Hope this helps :D
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by AshMcConnell »

Thanks Solar :)

I think that repo is for the plugin (i.e. a way to use particle universe in ogre) rather than the editor unless I'm mistaken though?
User avatar
spookyboo
Silver Sponsor
Silver Sponsor
Posts: 1141
Joined: Tue Jul 06, 2004 5:57 am
x 151
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by spookyboo »

All original code (including the code of the editor) is still available on https://github.com/spookyboo/particle-universe-editor, however this was still compiled with Ogre 1.8
nB. I'm still alive (but not so active atm). Work on the HLMS Editor slowed down, but that's only temporary :P
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by AshMcConnell »

Aha - there it is :)

Thanks Spookyboo, much appreciated. I am also trying to sneak in some dev time in between "real life" stuff :)
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: [Ogre 2] Porting Particle Universe

Post by al2950 »

Given that everything (PSO etc) has just been merged into 2.1, it will force me to update the libraries that I still have to support in my engine, ie Particle Universe MyGUI. If you can wait I will have to do this as one of the first things in the new year, unless someone else does it before me!
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by AshMcConnell »

al2950 wrote:Given that everything (PSO etc) has just been merged into 2.1, it will force me to update the libraries that I still have to support in my engine, ie Particle Universe MyGUI. If you can wait I will have to do this as one of the first things in the new year, unless someone else does it before me!
Thanks al2950. Given my current free time allocation at the moment (i.e approaching 0 hours), I'll probably only get a chance to try and make some decent sparks in the editor with a vague hope of integration at some point :)
User avatar
Kohedlo
Orc
Posts: 435
Joined: Fri Nov 27, 2009 3:34 pm
Location: Ukraine, Sumy
x 32
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by Kohedlo »

there are unable port all particles.


after adding to pu directory,

Code: Select all

system example_016
{
    category                                    Examples_11_20
    technique 
    {
        visual_particle_quota                   3000
        material                                ParticleUniverse/Dirt
        default_particle_width                  0.03
        default_particle_height                 0.18
        renderer                                Billboard
        {
            billboard_type                      oriented_self
            billboard_origin                    bottom_center
        }
        emitter                                 Point 
        {
            angle                               60
            time_to_live                        4
            velocity                            dyn_random
            {
                min                             0.3
                max                             0.9
            }
            force_emission                      true
        }
        affector                                Scale 
        {
            x_scale                             dyn_curved_linear
            {
                control_point                   0 12
                control_point                   0.05 6
                control_point                   0.1 3
                control_point                   0.15 1.5
                control_point                   1 0
            }
            y_scale                             dyn_curved_linear
            {
                control_point                   0 30
                control_point                   0.05 15
                control_point                   0.1 6
                control_point                   0.15 3
                control_point                   1 0
            }
        }
        affector                                Colour 
        {
            time_colour                         0    1 1 1 1
            time_colour                         0.4  1 1 1 1
            time_colour                         0.5  1 1 1 0
        }
    }
}
and

Code: Select all

hlms ParticleUniverse/Dirt unlit
{
            lighting off
            scene_blend alpha_blend
            depth_write off

            
                diffuse_map pu_dirt_256x512.png
}
and texture pu_dirt_256x512.png

particle cant be loaded in 2.1 ver. renderer.
c++ game developer.
current project: Imperial Game Engine 2.5
Image
User avatar
Kohedlo
Orc
Posts: 435
Joined: Fri Nov 27, 2009 3:34 pm
Location: Ukraine, Sumy
x 32
Contact:

Re: [Ogre 2] Porting Particle Universe

Post by Kohedlo »

is in 2/1 port new script syntaxis?
c++ game developer.
current project: Imperial Game Engine 2.5
Image
Post Reply