[Ogre 2] Porting Particle Universe

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


Lax
Hobgoblin
Posts: 583
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Re: [Ogre 2] Porting Particle Universe

Post by Lax »

Hi all,

what is the latest state of particle universe?

I try to use it with Ogre2.1, but nearly no particle effect does work correctly. The most particle effects will not crash, but I see nothing happening in the scene. Only the Tornardo and advancedLodSystem do work, because there are meshes involved. I saw, that in the 'pu_example.material', there are some tests with hlms unlit materials. But when I use e.g. the hlms unlit the 'mp_fire_02' I get a crash.

Is it worth to investigate time to particle universe, or should I use the native particle system of ogre?
I think particle universe is a great lib with lots of particle effects, so I'm not really willing to abandon it.

What do you think?

Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

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 »

I have not had a need for it so have not checked everything works with the latest version of Ogre. I am sure the issues you are seeing require simple fixes but sadly I dont have time at the moment to check and fix them. If you do get it working please make sure you create a pull request :), I am happy to try and offer advice on any issues I can.
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, just wanted to give some input on getting pu files to work, we are auto converting our old PU material files into unlit materials and they are working each time with some work though....
one thing you need to take note of in the .pu files is that if a technique is unnamed, then it does not work as expected. You might also find that it conflicts with a master / slave particle or displays the wrong texture.

the only thing we haven't got working yet is the mesh particles funny enough :P Even the chain billboards are working..
The code we are using is the same as previously posted...

however, i have noticed that particle universe files can slow the renderer down quite a lot, so to save some performance if you are using SSAO, is render them outside the render queue that is affected by SSAO. Even after doing this though, they can be quite slow.. same as particles in general... could be the v1 system though...
The most particle effects will not crash, but I see nothing happening in the scene
Some of the particles are really big and need scaled down. We are using a 1 unit = 1 meter system...
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 »

Good to know you are moving forward. As for performance, dont expect any miracles. PU is single threaded and was designed from an Objected Orientated point of view not really a Data Orientated way. Furthermore it mostly uses V1 billboards and so it is not very fast and sadly would take a lot of effort to improve, which is a little frustrating as PU has a lot of great features. Particle control and manipulation really needs to move on to the GPU like the following (post by dark_sylinc on his twitter feed)
https://turanszkij.wordpress.com/2017/1 ... imulation/
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 »

that is really cool :P
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
123iamking
Gremlin
Posts: 152
Joined: Sat Aug 12, 2017 4:16 pm
x 4

Re: [Ogre 2] Porting Particle Universe

Post by 123iamking »

I wanna ask a question, PU script (.pu) somehow similar to particle script (.particle). So Is it possible to convert pu script to particle script?
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 »

Its not something i have ever tried personally as Particle universe has a lot more features and custom script additions and tokens which are used through there script syntax. I would say no, but someone else might have a different opinion :P
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
Lax
Hobgoblin
Posts: 583
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Re: [Ogre 2] Porting Particle Universe

Post by Lax »

Thanks for the updates on this topic.
we are auto converting our old PU material files into unlit materials
Do you have somewhere the source and or the unlit-materials available for sharing?

Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

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 »

unfortunately, i cant share the source of our engine and the code we have done is very specific to our engine.
but i can tell you the processes we used.
  • We first load the PU as a text string
  • Parse through the PU file string looking for "material" and grab the material name
  • We then removed all the slashes and changed them into underscores and rewrote the PU file with the new material names.
  • Using the old material names, we look through our resource system(not ogre) and find the old material file containing the old material names.
  • We then parse the old .material file and grab all the materials and all the settings like depth_write and store this information
  • Then create a new unlit material based on each material and its specific settings and then save to a separate unlit "material.json" with the new material name that we changed within the PU file. So if old material was "catergory/material", then the new material is "category_material"
  • Once all this is done, we went through by hand and placed a name on each technique within the PU file: e.g. "technique" to "technique 01" and this fixed many of the visible problem or overlapping master/slave techniques.
what i can share though is the Unlit material creation code used after grabbing all the data:
Please note: we use a cutsom hlms and custom classes, so it will need adapted to your own code :)

Code: Select all

SkyHlmsUnlit *hlmsUnlit = static_cast<SkyHlmsUnlit*>(hlmsMgr->getHlms(Ogre::HLMS_UNLIT));

SkyResourceMemoryManager::MaterialInfo matInfo;
matInfo.name = materialName;
matInfo.type = SkyResourceMemoryManager::HLMS_UNLIT;

if (!data.useDepthWrite){ macro.mDepthWrite = false; }
if (data.useBlendType){
	if (data.mBlendType == "alpha_blend"){
		blend.setBlendType(Ogre::SceneBlendType::SBT_TRANSPARENT_ALPHA);
	}else if (data.mBlendType == "colour_blend"){
		blend.setBlendType(Ogre::SceneBlendType::SBT_TRANSPARENT_COLOUR);
	}else if (data.mBlendType == "add"){
		blend.setBlendType(Ogre::SceneBlendType::SBT_ADD);
	}else if (data.mBlendType == "modulate"){
		blend.setBlendType(Ogre::SceneBlendType::SBT_MODULATE);
	}else if (data.mBlendType == "replace"){
		blend.setBlendType(Ogre::SceneBlendType::SBT_REPLACE);
	}
}

// Depending on the scene blend type, choose a fitting blending for the texture.

SkyHlmsUnlitDatablock* unlitDatablock = static_cast<SkyHlmsUnlitDatablock*>(hlmsUnlit->createDatablock(materialName, materialName, macro, blend, Ogre::HlmsParamVec(), true, Ogre::BLANKSTRING, resourceGroup));
unlitDatablock->setColour(Ogre::ColourValue(data.diffuseTintColor.r, data.diffuseTintColor.g, data.diffuseTintColor.b));

if (loadingPUEffect){
	unlitDatablock->setIntensity(7.0f);
}else{
	unlitDatablock->setIntensity(3.0f);
}

Ogre::HlmsTextureManager::TextureLocation texLocation;
Ogre::HlmsSamplerblock samplerblock;
if (data.diffuseTetxureName.first != "" && data.diffuseTetxureName.first != "white.bmp"){
	try{
		SkyResourcePair texRes = makeResPair(data.diffuseTetxureName.first, diffuseResourceGroup);
		texLocation = hlmsMgr->getTextureManager()->createOrRetrieveTexture(data.diffuseTetxureName.first, Ogre::HlmsTextureManager::TEXTURE_TYPE_DIFFUSE, texRes.second);
		if (!texLocation.texture.isNull()){
			samplerblock = Ogre::HlmsSamplerblock();

			// Set the texture repeat modes for unlit.
			if (data.textureRepeatMode == SkyMaterial2::TR_WRAP){
				samplerblock.mU = Ogre::TAM_WRAP; samplerblock.mV = Ogre::TAM_WRAP; samplerblock.mW = Ogre::TAM_WRAP;
			}else if (data.textureRepeatMode == SkyMaterial2::TR_CLAMP){
				samplerblock.mU = Ogre::TAM_CLAMP; samplerblock.mV = Ogre::TAM_CLAMP; samplerblock.mW = Ogre::TAM_CLAMP;
			}else if (data.textureRepeatMode == SkyMaterial2::TR_BORDER){
				samplerblock.mU = Ogre::TAM_BORDER; samplerblock.mV = Ogre::TAM_BORDER; samplerblock.mW = Ogre::TAM_BORDER;
			}
		
			//lprint("Applying Diffuse tex..");
			unlitDatablock->setTexture(SkyPBRTextureTypes::PBSM_DIFFUSE, texLocation.xIdx, texLocation.texture, &samplerblock);
			matInfo.textures.push_back(texRes);  matInfo.textureSlots.push_back(SkyPBRTextureTypes::PBSM_DIFFUSE);

		//	lprint("Applying Diffuse tex.. Complete!");
		}
		else{
		//	lprint("Error: failed to apply DIFFUSE texture.");
		}
	}catch (Ogre::Exception &e){
		//SkyMessage.SkyException(e, "Diffuse Texture Failure", "SkyResources.cpp", "createHlmsFromMaterial", "UNlIT: createOrRetrieveTexture or datablock->setTexture()");
		lprint("Error: Failed to apply diffuse map: " + data.diffuseTetxureName.first);
	}
}

if (data.alphaEnable){
	if (data.alphaRejectEnable){
		unlitDatablock->setAlphaTest(Ogre::CMPF_GREATER_EQUAL);
		unlitDatablock->setAlphaTestThreshold(data.alphaRejectAmt / 255.0f);
	}
}

std::string filepath = matFile.substr(0, matFile.find_last_of("/\\")+1);
hlmsMgr->saveMaterial(unlitDatablock, filepath + materialName + ".skymat");
What we havent done yet, is port the mesh side of particle to v2, so it does crash on us when load say the tornado which chucks out rock meshes :)
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
Lax
Hobgoblin
Posts: 583
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Re: [Ogre 2] Porting Particle Universe

Post by Lax »

Hi all,

thanks for the code snippets. But before I start to convert. There are some new issues, so that particle universe will not work with Ogre2.1
As soon as I start e.g. the particle effect 'mp_torch', I get the following crash:

Code: Select all

18:21:31: OGRE EXCEPTION(-2147467259:RenderingAPIException): Cannot compile D3D11 high-level shader 1610907779VertexShader_vs Errors:
(107,64-81): error X3018: invalid subscript 'depthRange'
 in D3D11HLSLProgram::compileMicrocode
The error occurs, when a particle effect is rendered and the unlit script investigated:

Code: Select all

hlms mp_fire_02 unlit
{
	// depth_write off
	scene_blend alpha_blend
	diffuse_map mp_fire_02_2x2.dds
}
I first thought, it has something todo with shadows, so I set:

Code: Select all

this->particle->setCastShadows(false);
Then I get the error:

Code: Select all

invalid subscript 'viewProj'
Transforming the unlit material to json, does also not work. It seems, that unlit is somehow buggy...

Has somebody an idea, how to solve this issue?

Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

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 »

Which version of ogre are you using? are you running one of the samples that comes with PU repo, or are you creating the particle system in your own engine.

Actually which ever your answer is, update the HLMS shader files from the version of Ogre you are building with and let me know if it makes an difference!
Lax
Hobgoblin
Posts: 583
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Re: [Ogre 2] Porting Particle Universe

Post by Lax »

Hi,

It was totally my mistake. I forgot for a long time to register the "Hlms/Unlit/Any" archive.
Thus the whole time the unlit datablocks did only work partially :(

Now the particle effects do work.

Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

Post Reply