[2.3] Dealing with multi pass rendering in ogre next

Problems building or running the engine, queries about how to use features etc.
Post Reply
psysu
Halfling
Posts: 72
Joined: Tue Jun 01, 2021 7:47 am
x 6

[2.3] Dealing with multi pass rendering in ogre next

Post by psysu »

Hi,

is there way to do multiple pass rendering using HLMS like old Ogre::Material ?

For Example, i have a piece of old material code here that on first pass it renders a renderable as PM_SOLID polygon mode and the second pass it renders it as PM_WIREFRAME polygon mode. I'm out of ideas here on how to do this in ogre-next.

I would be really helpful if someone can help me out here.

Thanks

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

Re: [2.3] Dealing with multi pass rendering in ogre next

Post by dark_sylinc »

The short version is no.

However you can simply do:

Code: Select all

item = sceneMgr->createItem( params );
itemClone = sceneMgr->createItem( params );

item->setMaterialOrDatablockName( "Material A" );
itemClone->setMaterialOrDatablockName( "Material B" );

sceneNode->attachObject( item );
sceneNode->attachObject( itemClone );

That is, create two near-identical items that are clone of each other but with the different materials and attach them to the same SceneNode.

If only a submesh needs to be affected, you can use itemClone->getSubItem( i )->mRenderable Visible = false to hide the submeshes you don't want.

Cheers

psysu
Halfling
Posts: 72
Joined: Tue Jun 01, 2021 7:47 am
x 6

Re: [2.3] Dealing with multi pass rendering in ogre next

Post by psysu »

Alright this approach does solve my problem.

However, im just brainstorming here since this approach creates an additional Ogre::Item resource. is there a way to solve this through Compositor passes ? like 2 render_scene passes on first pass, it renders an Item in a certain rasterizer state and on second pass, it renders the same item in another rasterizer state.

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

Re: [2.3] Dealing with multi pass rendering in ogre next

Post by dark_sylinc »

That'd be quite inefficient in comparison because setDatablock is a relatively expensive operation.

If the problem itself only required different shaders then yes that is a good option because you could add a property in preparePassHash to activate a special pass-specific shader path in the during your special render_scene pass.

However because your problem requires changing blendblocks (and hence flushing the datablocks) it'd be expensive.

psysu
Halfling
Posts: 72
Joined: Tue Jun 01, 2021 7:47 am
x 6

Re: [2.3] Dealing with multi pass rendering in ogre next

Post by psysu »

Ah alright thanks for giving clarity on this

psysu
Halfling
Posts: 72
Joined: Tue Jun 01, 2021 7:47 am
x 6

Re: [2.3] Dealing with multi pass rendering in ogre next

Post by psysu »

hI, I have another doubt regarding this topic.

is there a way to disable only colour writing of a particular SubItem in a render_scene Pass ? something more analogous to Ogre::Pass::setColourWriteEnabled in Ogre 1.X.

i figured out a way to do this by splitting Each SubMesh into a Mesh, and move them into a specific RenderQueueGroup after Item creation. But can this be done at SubItem level ?

Thanks.

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

Re: [2.3] Dealing with multi pass rendering in ogre next

Post by dark_sylinc »

Materials have the colour_write property (which is a shortcut to setting channel_mask to 0):

Code: Select all

hlms my_material pbs
{
    colour_write false
    // Alternatively set the blend mask (it's the same thing)
    channel_mask 0
    // This is how you enable all channels (i.e. the opposite)
    channel_mask rgba
}

Programmatically:

Code: Select all

blendblock.mBlendChannelMask = 0u;
datablock->setBlendblock( blendblock );

And finally assign this datablock to the subitem you want to hide its colour (but not depth)

Post Reply