Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get metalness to work #2982

Closed
snowPu opened this issue Dec 5, 2023 · 7 comments
Closed

Can't get metalness to work #2982

snowPu opened this issue Dec 5, 2023 · 7 comments
Labels
invalid (question) usage questions should go to https://forums.ogre3d.org/

Comments

@snowPu
Copy link

snowPu commented Dec 5, 2023

I have the following material

material Material2
{
    technique
    {
        pass
        {
        specular 1.0 1.0 1.0 1.0 200.0
        rtshader_system
        {
           lighting_stage metal_roughness
        }
        diffuse 0.2 0.2 0.2 1.0
        }
    }
}
auto baseMaterial = Ogre::MaterialManager::getSingleton().getByName("Material2", nameOfResourceGroup);
entity->setMaterial(baseMaterial);

I know that the material gets loaded properly as the diffuse property works. However I can't see any change in appearance with the metal roughness properties.

I have a directional light in the scene created by the following code:

Ogre::Light* light = sceneManager->createLight("MainLight");
    light->setCastShadows(true);
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDiffuseColour(Ogre::ColourValue::White);
    Ogre::SceneNode* lightNode = this->cameraNode_->createChildSceneNode();
    lightNode->attachObject(light);
@paroj
Copy link
Member

paroj commented Dec 5, 2023

did you see the parameter mapping of specular here: https://ogrecave.github.io/ogre/api/latest/rtss.html#autotoc_md255 ?

as you set roughness=1.0, your material should be just slightly darker compared to blinn phong.

Also verify that the RTSS is active for your viewport (in case you are on D3D9 or GL1)

@paroj paroj added the invalid (question) usage questions should go to https://forums.ogre3d.org/ label Dec 5, 2023
@snowPu
Copy link
Author

snowPu commented Dec 5, 2023

  1. What should I check for in parameter mapping exactly? This is what it says:
    By default, roughness is read from specular[0] and metalness from specular[1].

  2. Also verify that the RTSS is active for your viewport (in case you are on D3D9 or GL1) --
    how do I check this?

  3. I wanted to post this ogre forum but my gmail id isn't being accepted for registration. I keep getting this:

verification mail delivery to gmail currently broken
The solution you provided was incorrect

@paroj
Copy link
Member

paroj commented Dec 5, 2023

What should I check for in parameter mapping exactly?

your specular[0] and specular[1] values, which are both 1.0 as you posted above

how do I check this?

you should a snippet like this in your code:

// Make this viewport work with shader generator
mViewport->setMaterialScheme(MSN_SHADERGEN);

I wanted to post this ogre forum but my gmail id isn't being accepted for registration. I keep getting this:

gmail just does not work. we are aware of this #2924

@snowPu
Copy link
Author

snowPu commented Dec 7, 2023

Unfotunately it still doesn't work :( Should I be looking out for something else?

@paroj
Copy link
Member

paroj commented Dec 8, 2023

does it work if you modify one of the materials used in the PBR sample that is referenced above?

@snowPu
Copy link
Author

snowPu commented Dec 11, 2023

So it works for me now.
What I was doing earlier:

material Electrode
{
    technique
    {
        pass
        {
        specular 0.5 0.5 0.2 64
        rtshader_system
        {
           lighting_stage metal_roughness
        }
        diffuse 0.7 0.7 0.7 1.0
        }
    }
}
auto mat = Ogre::MaterialManager::getSingleton().getByName("Electrode", ogreResources::RESOURCE_GROUP)->clone(newMatName);
mat->setDiffuse(this->definition_.display.color);
entity->setMaterial(mat)

I was doing this so that I can set the metallic properties for all electrodes in my scene, but set the diffuse properties per electrode type. So I create a clone and set diffuse properties for the cloned material.

Somehow this doesn't work to set metal properties of the material.

If I do this, however,

auto mat = Ogre::MaterialManager::getSingleton().getByName("Electrode", ogreResources::RESOURCE_GROUP);
entity->setMaterial(mat)

so not use a clone, but the original material, it works.

Do you know why?

@paroj
Copy link
Member

paroj commented Dec 11, 2023

you must explicitly clone the RTSS parts, see:

auto mat =
baseMat->clone(StringUtil::format("Examples/PBR_Sphere%d", idx), String(TRANSIENT_RESOURCE_GROUP));
#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM
RTShader::ShaderGenerator::getSingleton().cloneShaderBasedTechniques(*baseMat, *mat);
#endif

@paroj paroj closed this as completed Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid (question) usage questions should go to https://forums.ogre3d.org/
Projects
None yet
Development

No branches or pull requests

2 participants