Thu, 05/19/2022 - 18:31
Forums:
Hello all,
in this document (page 4) https://dev.opencascade.org/sites/default/files/documents/release_notes_7.5.0.pdf
it says there is now Normal map texture support.
Could please somebody be so kind and lead me to an example? All I was able to find was in opencascade-7.6.0\src\BinMXCAFDoc\BinMXCAFDoc_VisMaterialDriver.cxx.
I would like to set a normal map texture to a AIS_Shape
Thanks!!
Thu, 05/19/2022 - 20:49
Take a look onto XCAFDoc_VisMaterial::FillAspect(). What you need is to define Graphic3d_TextureSet instead of a single texture and assign texture to Graphic3d_TextureUnit_Normal unit (and Graphic3d_TextureUnit_BaseColor for a normal color texture).
Sat, 05/21/2022 - 01:53
Thanks Kirill, I got it going so far:
Using is as follow
I tried to assign ONLY Graphic3d_TextureUnit_BaseColor and Graphic3d_TextureUnit_Normal but this is crashing. I have to assign something for Graphic3d_TextureUnit_Emissive and Graphic3d_TextureUnit_Occlusion as well.
I have to admit that I do not fully understand all the different textures yet and not sure what to do.
As attachment the result I get.
The textures are too big to upload here.But this is the link:
Textures
Sat, 05/21/2022 - 14:11
That's not how texture units are supposed to be set in OCCT. Graphic3d_TextureSet::SetValue() just assigns value to an array index - it should be incremented in the loop. Graphic3d_TextureUnit values should be set to to Graphic3d_TextureParams::TextureUnit() property:
m_textureBaseColor->GetParams()->SetTextureUnit (Graphic3d_TextureUnit_BaseColor);
You might want also to specify normal map and occlusion textures as stored in linear, not gamma-corrected color space to avoid their distortion:
Handle(Graphic3d_Texture2D) aTexture = ...;
aTexture->GetParams()->SetTextureUnit (...);
aTexture->SetColorMap (aTexture->GetParams()->TextureUnit() == Graphic3d_TextureUnit_BaseColor || aTexture->GetParams()->TextureUnit() == Graphic3d_TextureUnit_Emissive)
Sun, 05/22/2022 - 22:00
Works great - looks so much better.
Thank you!