Hey guys,
I have a 3d model which comes with vertex color. No textures.
The model in another 3d viewer (babylon.js sandbox)
The vertex color shows correctly.
And the same model in my Ogre 2.1 application. All vertex colors are gone.
I am pretty sure the .mesh file contains vertex colors.
This is the link to the tree mesh if someone want to check.
https://www.dropbox.com/s/zqdccw41bvvcb ... .mesh?dl=0
So my question is, is Hlms supposed to ignore vertex colors?
[2.1] Hlms ignores vertex colors?
- TaaTT4
- OGRE Contributor
- Posts: 267
- Joined: Wed Apr 23, 2014 3:49 pm
- Location: Bologna, Italy
- x 75
- Contact:
Re: [2.1] Hlms ignores vertex colors?
I believe that vertex colors probably works just in Unlit materials. To let them work in PBS too, you have to at least change its shaders (and/or customize its HLMS implementation).
Senior programmer at 505 Games; former senior engine programmer at Sandbox Games
Worked on: Racecraft Esport — Racecraft Coin-Op, Victory: The Age of Racing
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: [2.1] Hlms ignores vertex colors?
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:
create a file named CustomVS_piece_vs.glsl with this content:
create a file named CustomPS_piece_ps.glsl with this content:
put those files in a folder, and when registering the HlmsPbs add the folder as library:
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!
create a file named CustomPassBuffer_piece_vs_piece_ps.glsl with this content:
Code: Select all
@piece( custom_VStoPS )
vec4 colour;
@end
Code: Select all
@piece( custom_vs_attributes )
in vec4 colour;
@end
@piece( custom_vs_preExecution )
outVs.colour = colour;
@end
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
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 );
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!