[2.1] BillboardChain and RibbonTrail

Design / architecture / roadmap discussions related to future of Ogre3D (version 2.0 and above)
Post Reply
zxz
Greenskin
Posts: 139
Joined: Sat Apr 16, 2016 9:25 pm
x 5

[2.1] BillboardChain and RibbonTrail

Post by zxz » Thu Nov 03, 2016 7:46 pm

I am trying to get Ogre::v1::BillboardChain and Ogre::v1::RibbonTrail to show up in Ogre 2.1, for now without success. Our usage was working in 1.8, but nothing shows up in 2.1, now with Unlit materials assigned instead of old school materials.

Is anybody else successfully using these classes in 2.1? Any ideas what is needed to get them showing?

I found this post from 2015, with al2950 having the same issue: http://www.ogre3d.org/forums/viewtopic. ... 12#p515902 but no solution is mentioned in the thread.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3747
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 130
Contact:

Re: [2.1] BillboardChain and RibbonTrail

Post by dark_sylinc » Thu Nov 03, 2016 8:25 pm

I wasn't aware it was broken, thanks. Added to my (long :cry: ) TODO list. BillboardSets definitely do work.

What's the code you're using to create and display those BillboardChain or RibbonTrails?
0 x

zxz
Greenskin
Posts: 139
Joined: Sat Apr 16, 2016 9:25 pm
x 5

Re: [2.1] BillboardChain and RibbonTrail

Post by zxz » Thu Nov 03, 2016 8:45 pm

I'm not yet sure if it's really broken, or just a usage error. However, our code worked fine in older versions, and is essentially the same now, just with a HlmsUnlitDatablock assigned instead of a material. This change has been successful when porting many other things so far. That, together with the mention in the other thread, led me to ask here before I dig too deeply myself.

Thanks for adding it to your TODO. I might need to look into it myself to get it working sooner though, since you really have a lot on your list.

I might clean up our code and post it later, but I do not suspect the issue is there at the moment (I hope I will not end up eating these words, simpler things have gone wrong before ;)), since it basically just creates the ribbon trail and assigns the datablock, and sets it up to track another scene node.

Since you have a lot of experience debugging these things, do you have any pointers regarding what might go wrong?
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3747
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 130
Contact:

Re: [2.1] BillboardChain and RibbonTrail

Post by dark_sylinc » Thu Nov 03, 2016 8:49 pm

I was asking a for a small snippet so I could copy paste and try :)

The first thing that comes to mind is that Billboards are a special snowflake that work best when you set the hlms datablock by name and not by pointer. If you search on our forums the explanation of why is this will be there (hint: it's technical debt)
0 x

zxz
Greenskin
Posts: 139
Joined: Sat Apr 16, 2016 9:25 pm
x 5

Re: [2.1] BillboardChain and RibbonTrail

Post by zxz » Sat Nov 05, 2016 4:04 am

Yes, I have read about that in other threads, and done that for other things such as overlays. I have tried setting the material both by datablock and by name. No change in behaviour in this case.
0 x

zxz
Greenskin
Posts: 139
Joined: Sat Apr 16, 2016 9:25 pm
x 5

Re: [2.1] BillboardChain and RibbonTrail

Post by zxz » Sat Nov 05, 2016 5:25 pm

Today I started debugging the issue, and found that a couple things were missing to get the BillboardChains to work.

1. They are never added to mRenderables
2. BillboardChain::preRender is never called, so its vertex buffers are never updated.

The patch below fixes (1):

Code: Select all

diff -r 04f7437fcbb8 OgreMain/src/OgreBillboardChain.cpp
--- a/OgreMain/src/OgreBillboardChain.cpp	Mon Oct 17 19:32:28 2016 -0300
+++ b/OgreMain/src/OgreBillboardChain.cpp	Sat Nov 05 17:21:12 2016 +0100
@@ -718,9 +718,13 @@
 
         if (mIndexData->indexCount > 0)
         {
+          if (mRenderables.empty())
+            mRenderables.push_back(this);
             //TODO: RENDER QUEUE
             //queue->addRenderable(this, mRenderQueueID, mRenderQueuePriority);
         }
+        else
+          mRenderables.clear();
 	}
 	//-----------------------------------------------------------------------
     void BillboardChain::getRenderOperation(RenderOperation& op, bool casterPass)
This patch fixes (2). However, I haven't looked into where it's actually proper to add this call.

Code: Select all

diff -r 04f7437fcbb8 OgreMain/src/OgreSceneManager.cpp
--- a/OgreMain/src/OgreSceneManager.cpp	Mon Oct 17 19:32:28 2016 -0300
+++ b/OgreMain/src/OgreSceneManager.cpp	Sat Nov 05 17:21:12 2016 +0100
@@ -1272,6 +1272,7 @@
 
                         while( itRend != enRend )
                         {
+                            (*itRend)->preRender(this, mDestRenderSystem);
                             mRenderQueue->addRenderableV1( i, casterPass, *itRend, *itor );
                             ++itRend;
                         }
Below is a patch for testing the fixes. It just modifies the existing AnimationTagPoint sample, adding a red BillboardChain.

Code: Select all

diff -r 04f7437fcbb8 Samples/2.0/ApiUsage/AnimationTagPoint/AnimationTagPointGameState.cpp
--- a/Samples/2.0/ApiUsage/AnimationTagPoint/AnimationTagPointGameState.cpp	Mon Oct 17 19:32:28 2016 -0300
+++ b/Samples/2.0/ApiUsage/AnimationTagPoint/AnimationTagPointGameState.cpp	Sat Nov 05 17:17:03 2016 +0100
@@ -9,6 +9,7 @@
 #include "OgreMeshManager.h"
 #include "OgreMesh2.h"
 #include "OgreMeshManager2.h"
+#include "OgreBillboardChain.h"
 
 #include "Animation/OgreSkeletonInstance.h"
 #include "Animation/OgreTagPoint.h"
@@ -129,6 +130,24 @@
         camera->setPosition( Ogre::Vector3( 0, 2.5, 4 ) );
 
         TutorialGameState::createScene01();
+
+      Ogre::SceneNode* chainNode = sceneManager->getRootSceneNode()->createChildSceneNode();
+      chainNode->setPosition(Ogre::Vector3(0, 0, 0));
+      chainNode->setOrientation(Ogre::Quaternion(1, 0, 0, 0));
+
+      Ogre::v1::BillboardChain * chain = sceneManager->createBillboardChain();
+
+      chain->setDynamic(true);
+      chain->setNumberOfChains(1);
+      chain->setUseVertexColours(true);
+      chain->setMaxChainElements(5);
+
+      for (int i = 0; i < 5; ++i)
+        chain->addChainElement(0, Ogre::v1::BillboardChain::Element(Ogre::Vector3(0.5 * i, 0, 0), 0.1, 0.2 * i, Ogre::ColourValue(1,0,0,1), Ogre::Quaternion()));
+
+      chainNode->attachObject(chain);
+      chain->setVisible(true);
+
     }
     //-----------------------------------------------------------------------------------
     void AnimationTagPointGameState::update( float timeSinceLast )
With the above patches, and the test given above. I get a red BillboardChain next to the freaky Stickman in the AnimationTagPoint sample.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3747
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 130
Contact:

Re: [2.1] BillboardChain and RibbonTrail

Post by dark_sylinc » Sat Nov 05, 2016 8:35 pm

Thanks for looking into this! I've pushed your changes (not the change to the demo). I've modified it a little so that it's _updateRenderQueue's responsability to update everything they need. "preRender" no longer makes sense in 2.1 (unless you're running V1_LEGACY render queue mode) and only adds virtual call overhead to every v1 object.

I tried to create a ribbon trail for the Stickman's hand, but it appears there are more bugs in RibbonTrail. They all seem like they could be silly like this one though, haven't looked very further into it. One of them was a mCachedTransformOutOfDate assert. While calling _getDerivedPositionUpdated would fix it, I would have to check if doing that would cause slowdowns if many ribbon trails are used. Very likely _getDerivedPosition is just being called too early and needs to be moved.

Thanks for the fix!
0 x

zxz
Greenskin
Posts: 139
Joined: Sat Apr 16, 2016 9:25 pm
x 5

Re: [2.1] BillboardChain and RibbonTrail

Post by zxz » Sat Nov 05, 2016 8:45 pm

Thanks for applying the fixes!

Hmm. RibbonTrail worked for me after my BillboardChain fixes.

EDIT: Shadows don't seem to work with BillboardChain, only a couple loose triangles appear to get drawn into the shadow buffer. I seem to remember that they used to be reoriented towards the shadow camera when rendered from that vantage point. Is that functionality still intact?
0 x

Lax
Gnome
Posts: 306
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 4

Re: [2.1] BillboardChain and RibbonTrail

Post by Lax » Fri Jan 26, 2018 11:27 pm

Hi,

I'm also trying to get RibbonTrail working, but no matter what unlit material I use, i get the exception:

Code: Select all

OGRE EXCEPTION(1:InvalidStateException): Renderable must have at least 2 coordinates in UV set #0. Either change the mesh, or change the UV source settings
I use the following unlit material for ribbon trail:

Code: Select all

hlms LightRibbonTrail unlit
{
	diffuse_map ribbonband.png #2
	scene_blend add
	depth_write off
	cull_mode none
}
I set the unlit material by name:

Code: Select all

this->ribbonTrail->setDatablockOrMaterialName("LightRibbonTrail", "Unlit");
this->ribbonTrail->setUseVertexColours(true);
I tried different things like setting setTextureUvSource by source code etc., but nothing works...

Did someone manage to get ribbon trail working?
Regards
Lax
0 x

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

Re: [2.1] BillboardChain and RibbonTrail

Post by Kohedlo » Sun Jan 28, 2018 7:58 pm



this is ribbon trail on 2.1 and code.






Code: Select all


  p->ribbon = Ogre::Root::getSingletonPtr()->getSceneManager(CfgManager::getSingleton().main_scene_manager_name)->createRibbonTrail();

   Ogre::Root::getSingletonPtr()->getSceneManager(CfgManager::getSingleton().main_scene_manager_name)
	   ->getRootSceneNode()->attachObject(p->ribbon);
  // sN->attachObject(p->ribbon);
p->ribbon->setTrailLength(p->setTrailLength);
//p->ribbon->setMaxChainElements(p->maxElements);
p->ribbon->setInitialColour(0, p->col.r, p->col.g, p->col.b);
p->ribbon->setColourChange(0, p->colourChange.r, p->colourChange.g, p->colourChange.b, p->colourChange.a);
p->ribbon->setInitialWidth(0, p->width);
p->ribbon->setDatablock(p->material);
p->ribbon->setWidthChange(0,p->widthDeltaPerSecond);
p->ribbon->addNode(sN);





void I_SCENE::UpdateRibbonTrail(std::string Name) // and update that currently need
{
IParticle* p = GetParticle(Name);

if(p->partycleType == 4)
p->ribbon->_timeUpdate(IEngine::getSingleton().timeSinceLastFrame);
}
1 x
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 11
Contact:

Re: [2.1] BillboardChain and RibbonTrail

Post by Kohedlo » Sun Jan 28, 2018 8:01 pm

and material script

Code: Select all

hlms RibbonTrail unlit
{
            lighting off
            scene_blend add
            depth_write off

            
                diffuse_map ribbonband.png
}
2 x
c++ game developer.
current project: Imperial Game Engine 2.5
Image

Lax
Gnome
Posts: 306
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 4

Re: [2.1] BillboardChain and RibbonTrail

Post by Lax » Mon Jan 29, 2018 11:09 pm

Cool, thanks for the show case and the example code!
I will take a look at it.

Regards
Lax
0 x

Lax
Gnome
Posts: 306
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 4

Re: [2.1] BillboardChain and RibbonTrail

Post by Lax » Wed Jan 31, 2018 6:16 pm

Hi kohedlo,

I checked you code with mine, and its similiar. But as soon as I set the datablock for the ribbon trail, I get the error:

Code: Select all

OGRE EXCEPTION(1:InvalidStateException): Renderable must have at least 2 coordinates in UV set #0. Either change the mesh, or change the UV source settings in HlmsUnlit::calculateHashForPreCreate
Do you have an idea how to fix this?

Regards
Lax
0 x

przemir
Kobold
Posts: 27
Joined: Sun May 11, 2014 7:55 pm
Location: Poland
x 2

Re: [2.1] BillboardChain and RibbonTrail

Post by przemir » Wed Jul 25, 2018 10:31 pm

Lax wrote:
Wed Jan 31, 2018 6:16 pm

Code: Select all

OGRE EXCEPTION(1:InvalidStateException): Renderable must have at least 2 coordinates in UV set #0. Either change the mesh, or change the UV source settings in HlmsUnlit::calculateHashForPreCreate
Do you have an idea how to fix this?
I had the same problem. I solved this by setting datablock later - at least frame later after creating and initializing ribbon trail.
0 x

Lax
Gnome
Posts: 306
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 4

Re: [2.1] BillboardChain and RibbonTrail

Post by Lax » Thu Jul 26, 2018 9:23 pm

Hi,

I tried that out, but that did not work.
Can you post your unlit material code, maybe something is wrong with my ribbon trail definition?

Regards
Lax
0 x

przemir
Kobold
Posts: 27
Joined: Sun May 11, 2014 7:55 pm
Location: Poland
x 2

Re: [2.1] BillboardChain and RibbonTrail

Post by przemir » Thu Jul 26, 2018 11:35 pm

Lax wrote:
Thu Jul 26, 2018 9:23 pm
Hi,

I tried that out, but that did not work.
Can you post your unlit material code, maybe something is wrong with my ribbon trail definition?

Regards
Lax
Material code was already mentioned. I didn't add anything new:

Code: Select all

hlms LightRibbonTrail unlit
{
    lighting off
    depth_write off
    scene_blend add
//  diffuse 1.0 0.0 0.0 1.0
    diffuse_map ribbonband.png
}
Initialization code (note that you can't have mSwordTrail->setDatablock here as it will cause OGRE EXCEPTION immediately - perhaps because renderable don't have vertices yet - that is just my guess):

Code: Select all

Ogre::SceneNode* chainNode = BModule::m->sceneManager->getRootSceneNode()->createChildSceneNode();
chainNode->setPosition(Ogre::Vector3(0, 0, 0));
chainNode->setOrientation(Ogre::Quaternion(1, 0, 0, 0));

mSwordTrail = BModule::m->sceneManager->createRibbonTrail();
mSwordTrail->setName("RibbonTrail");
mSwordTrail->setDynamic(true);
mSwordTrail->setNumberOfChains(1);
mSwordTrail->setUseVertexColours(true);
mSwordTrail->setMaxChainElements(80);
mSwordTrail->setUseTextureCoords(true);
mSwordTrail->setFaceCamera(false, Ogre::Vector3::UNIT_Y);
mSwordTrail->setTrailLength(20);

// mSwordTrail->setDatablock("LightRibbonTrail"); 
// mSwordTrail->setTextureCoordDirection(Ogre::v1::BillboardChain::TCD_V);

for (int i = 0; i < 1; ++i) {
    mSwordTrail->setInitialColour(i, 1.0, 1.0, 1.0, 1.0);
    mSwordTrail->setColourChange(i, 1.25, 1.25, 1.25, 1.25);
    mSwordTrail->setWidthChange(i, 0.0);
    mSwordTrail->setInitialWidth(i, 1.0);
}

chainNode->attachObject(mSwordTrail);

And later (next frame in ::frameRenderingQueued method)

Code: Select all

mSwordTrail->addNode(node);
mSwordTrail->setVisible(true);
mSwordTrail->setDatablock("LightRibbonTrail");
And my ribbonband texture:
Image
1 x

Lax
Gnome
Posts: 306
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 4

Re: [2.1] BillboardChain and RibbonTrail

Post by Lax » Tue Jul 31, 2018 8:28 pm

nd later (next frame in ::frameRenderingQueued method)
Ok thanks for the tip. Now the error message is gone.

But I still see no ribbon trail. I added the same values for the ribbontrail as you have.
I have still no clue why that ribbon trail will not work :(

Best Regards
Lax
0 x

przemir
Kobold
Posts: 27
Joined: Sun May 11, 2014 7:55 pm
Location: Poland
x 2

Re: [2.1] BillboardChain and RibbonTrail

Post by przemir » Thu Aug 02, 2018 12:13 pm

Lax wrote:
Tue Jul 31, 2018 8:28 pm
But I still see no ribbon trail. I added the same values for the ribbontrail as you have.
I have still no clue why that ribbon trail will not work :(
Can you see ribbontrail without texture? Set white colour in material (black material will be fully transparent) like below:

Code: Select all

hlms LightRibbonTrail unlit
{
    lighting off
    depth_write off
    scene_blend add
    diffuse 1.0 1.0 1.0 1.0
}
Remove 'setFaceCamera' to make ribbontrail always face camera - it should be easier to spot.

Code: Select all

// mSwordTrail->setFaceCamera(false, Ogre::Vector3::UNIT_Y);
0 x

Post Reply