TaaTT4 is right, you need to customize the hlmsPbs implementation. Try this:
create a file named CustomPassBuffer_piece_vs_piece_ps.glsl with this content:
Code: Select all
@piece( custom_VStoPS )
vec4 colour;
@end
create a file named CustomVS_piece_vs.glsl with this content:
Code: Select all
@piece( custom_vs_attributes )
in vec4 colour;
@end
@piece( custom_vs_preExecution )
outVs.colour = colour;
@end
create a file named CustomPS_piece_ps.glsl with this content:
Code: Select all
@piece( custom_ps_posExecution )
outColour.xyz *= inPs.colour.xyz; //you could also use this data in previous parts of the shader to multiply just the diffuser part for example
@end
put those files in a folder, and when registering the HlmsPbs add the folder as library:
Code: Select all
//Create & Register HlmsPbs
//Do the same for HlmsPbs:
Ogre::HlmsPbs::getDefaultPaths( mainFolderPath, libraryFoldersPaths );
Ogre::Archive *archivePbs = archiveManager.load( rootHlmsFolder + mainFolderPath,
"FileSystem", true );
//Get the library archive(s)
Ogre::ArchiveVec archivePbsLibraryFolders;
libraryFolderPathIt = libraryFoldersPaths.begin();
libraryFolderPathEn = libraryFoldersPaths.end();
while( libraryFolderPathIt != libraryFolderPathEn )
{
Ogre::Archive *archiveLibrary =
archiveManager.load( rootHlmsFolder + *libraryFolderPathIt, "FileSystem", true );
archivePbsLibraryFolders.push_back( archiveLibrary );
++libraryFolderPathIt;
}
//ADD CUSTOM FOLDER
Ogre::Archive *archiveLibraryCustom = archiveManager.load( rootHlmsFolder+"Hlms/Pbs/MySuperDuperCustomFolder", "FileSystem", true );
archivePbsLibraryFolders.push_back( archiveLibraryCustom );
//Create and register
mHlmsPbs = OGRE_NEW Ogre::HlmsPbs( archivePbs, &archivePbsLibraryFolders );
Ogre::Root::getSingleton().getHlmsManager()->registerHlms( mHlmsPbs );
note: this is for glsl, I guess if you change vec4 for float4 and .glsl for .any should work for d3d and metal too
The next problem would be to identify which meshes have vertex color and which doesn't, so you don't do the outColour multiplication when inPs.colour is probably black. but tell me if this works first.
cheers!