[Ogre 2] Porting Particle Universe
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [Ogre 2] Porting Particle Universe
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
-
- OGRE Expert User
- Posts: 1227
- Joined: Thu Dec 11, 2008 7:56 pm
- Location: Bristol, UK
- x 157
Re: [Ogre 2] Porting Particle Universe
- SolarPortal
- OGRE Contributor
- Posts: 203
- Joined: Sat Jul 16, 2011 8:29 pm
- Location: UK
- x 51
- Contact:
Re: [Ogre 2] Porting Particle Universe
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 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...
Some of the particles are really big and need scaled down. We are using a 1 unit = 1 meter system...The most particle effects will not crash, but I see nothing happening in the scene
-
- OGRE Expert User
- Posts: 1227
- Joined: Thu Dec 11, 2008 7:56 pm
- Location: Bristol, UK
- x 157
Re: [Ogre 2] Porting Particle Universe
https://turanszkij.wordpress.com/2017/1 ... imulation/
- SolarPortal
- OGRE Contributor
- Posts: 203
- Joined: Sat Jul 16, 2011 8:29 pm
- Location: UK
- x 51
- Contact:
Re: [Ogre 2] Porting Particle Universe
-
- Gremlin
- Posts: 152
- Joined: Sat Aug 12, 2017 4:16 pm
- x 4
Re: [Ogre 2] Porting Particle Universe
- SolarPortal
- OGRE Contributor
- Posts: 203
- Joined: Sat Jul 16, 2011 8:29 pm
- Location: UK
- x 51
- Contact:
Re: [Ogre 2] Porting Particle Universe
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [Ogre 2] Porting Particle Universe
Do you have somewhere the source and or the unlit-materials available for sharing?we are auto converting our old PU material files into unlit materials
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
- SolarPortal
- OGRE Contributor
- Posts: 203
- Joined: Sat Jul 16, 2011 8:29 pm
- Location: UK
- x 51
- Contact:
Re: [Ogre 2] Porting Particle Universe
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.
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");
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [Ogre 2] Porting Particle Universe
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
Code: Select all
hlms mp_fire_02 unlit
{
// depth_write off
scene_blend alpha_blend
diffuse_map mp_fire_02_2x2.dds
}
Code: Select all
this->particle->setCastShadows(false);
Code: Select all
invalid subscript 'viewProj'
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
-
- OGRE Expert User
- Posts: 1227
- Joined: Thu Dec 11, 2008 7:56 pm
- Location: Bristol, UK
- x 157
Re: [Ogre 2] Porting Particle Universe
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!
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [Ogre 2] Porting Particle Universe
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