PBS Metallic workflow rendering result not expected

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
chengzhigao
Gnoblar
Posts: 5
Joined: Tue Nov 26, 2019 6:53 am

PBS Metallic workflow rendering result not expected

Post by chengzhigao »

Hi,

I am playing around the PBS in Ogre3D V2.2. I tried to modify the Smaple_PbsMaterials file to test one data which contains a mesh + normal texture + base color + metallic texture + roughness texture. The workflow is set as MetallicWorkflow. I created a datablock + 4 textures as shown below:

Code: Select all

                std::string textureNames[8] = { "marble_Color.png",   "marble_Normal.png",
                                                   "marble_Metalic.png", "marble_Roughness.png",
                                                   "silver_Color.png",   "silver_Normal.png",
                                                   "silver_Metallic.png", "silver_Roughness.png" };
                 int tIndex = 1;
                datablock->setWorkflow( Ogre::HlmsPbsDatablock::Workflows::MetallicWorkflow );
                Ogre::TextureGpu *baseColor = textureMgr->createOrRetrieveTexture(
                    textureNames[tIndex * 4 + 0], Ogre::GpuPageOutStrategy::Discard,   Ogre::CommonTextureTypes::Diffuse,
                    Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, Ogre::TextureFilter::TypeGenerateDefaultMipmaps );
                datablock->setTexture( Ogre::PBSM_DIFFUSE, baseColor );

                Ogre::TextureGpu *normal = textureMgr->createOrRetrieveTexture(
                    textureNames[tIndex * 4 + 1], Ogre::GpuPageOutStrategy::Discard,  Ogre::CommonTextureTypes::NormalMap,
           Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,   Ogre::TextureFilter::TypeGenerateDefaultMipmaps );
                datablock->setTexture( Ogre::PBSM_NORMAL, normal );

                Ogre::TextureGpu *metalic = textureMgr->createOrRetrieveTexture(
                    textureNames[tIndex * 4 + 2], Ogre::GpuPageOutStrategy::Discard,   Ogre::TextureFlags::PrefersLoadingFromFileAsSRGB, 
                    Ogre::TextureTypes::Type2D,   Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
                    Ogre::TextureFilter::TypeGenerateDefaultMipmaps );
                datablock->setTexture( Ogre::PBSM_METALLIC, metalic );

                Ogre::TextureGpu *roughness = textureMgr->createOrRetrieveTexture(
                    textureNames[tIndex * 4 + 3], Ogre::GpuPageOutStrategy::Discard,    Ogre::TextureFlags::PrefersLoadingFromFileAsSRGB, 
                    Ogre::TextureTypes::Type2D,  Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
                    Ogre::TextureFilter::TypeGenerateDefaultMipmaps );
                datablock->setTexture( Ogre::PBSM_ROUGHNESS, roughness );

                // add the Reflection map:
                Ogre::TextureGpu *texture = textureMgr->createOrRetrieveTexture(
                    "SaintPetersBasilica.dds", Ogre::GpuPageOutStrategy::Discard,
                    Ogre::TextureFlags::PrefersLoadingFromFileAsSRGB, Ogre::TextureTypes::TypeCube,
                    Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
                    Ogre::TextureFilter::TypeGenerateDefaultMipmaps );
However, the render result is quite different from the one seem in Substance Painter, can somebody to answer some questions?
1) Are the parameters specified for the texture or the data block right?
2) Are there are some missing parameters not set there?
3) How could i specify a metallic texture in the script file?
4) In the PbsMaterials.material "hlms Rocks pbs" section, why there is a roughness parameter there given there is a roughness_map below?
5) Is it possible to use a HDR file as the reflection map?

Thanks & Regards,
Spencer
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: PBS Metallic workflow rendering result not expected

Post by xrgo »

Hello!!
you should post comparison screenshots to see whats going on,
but everything is going to look bad until you use a good cubemap, so answering
5) same as you do with other textures but with PBSM_REFLECTION
this alone should fix most of the differences... but!! it still not going to match, since ogre by default do stuffs a little different, this is being fixed, see: viewtopic.php?f=25&t=95523
1) yes your code looks good at first glance (screenshots please!)
2) depends on what you're trying to achieve...
4) ...parameters specified by numeric value are multiplied by the texture, for example you can make the base color texture redish if you set the diffuse as (1.0, 0.0, 0.0), I am not sure which are the defaults (you can look at them in the source) but in my code I usually set everything to white or 1 if a texture is setted.
3) I think there's is no "metallic" keyword, try "specular"? sorry I have 0 experience with material scrips, I do everything by code

Saludos!
chengzhigao
Gnoblar
Posts: 5
Joined: Tue Nov 26, 2019 6:53 am

Re: PBS Metallic workflow rendering result not expected

Post by chengzhigao »

Hi,

Thanks very much for your reply. Below is the hdr file i would like to use as reflection map, it looks like this:
Image

However, i could not get it rendered as Reflection map in the sample, I tried many different combination of attribute when i call textureMgr->createOrRetrieveTexture(...) like Type2D, TypeCube, CommonTextureTypes::EnvMap etc, for example:

Code: Select all

Ogre::TextureGpu *texture = textureMgr->createOrRetrieveTexture(
                        //"SaintPetersBasilica.dds", Ogre::GpuPageOutStrategy::Discard,
                        "panorama_map.hdr", Ogre::GpuPageOutStrategy::Discard,
                        //Ogre::TextureFlags::PrefersLoadingFromFileAsSRGB, Ogre::TextureTypes::TypeCube,
                        Ogre::CommonTextureTypes::EnvMap, Ogre::TextureTypes::Type2D,
                        Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
                        Ogre::TextureFilter::TypeGenerateDefaultMipmaps );
                        
	                datablock->setTexture( Ogre::PBSM_REFLECTION, texture );
	                
The overall Ogre pbs rendering for this is shown as:
Image

The Expected result from substance is like:
Image

Obviously Something is not right, the reflection map seems not rendered at all. Not sure where it went wrong.

Thanks & regards,
Spencer
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: PBS Metallic workflow rendering result not expected

Post by al2950 »

Please check the ogre.log file, as I am pretty sure .hdr files are not supported.. If not there should be an obvious error in the log file.
Post Reply