mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0030700: Visualization, TKOpenGl - support PBR Metallic-Roughness shading model
Metallic-Roughness shading model Graphic3d_TOSM_PBR has been implemented. New materials descriptors Graphic3d_PBRMaterial have been added to Graphic3d_MaterialAspect. PBR shading model requires OpenGL 3.0+ or OpenGL ES 3.0+ hardware. Environment cubemap is expected to be provided for realistic look of metallic materials. occLight_IsHeadlight() now returns bool instead of int. Avoid using lowp for enumerations to workaround occLight_IsHeadlight() ignorance on Adreno 308 caused by some GLSL optimizator bugs. OpenGl_Texture::EstimatedDataSize() - fixed estimation for Cubemap textures. OpenGl_Sampler::applySamplerParams() - fixed uninitialized GL_TEXTURE_WRAP_R in case of GL_TEXTURE_CUBE_MAP target.
This commit is contained in:
@@ -517,6 +517,14 @@ Standard_Boolean ViewerTest::ParseShadingModel (Standard_CString th
|
||||
{
|
||||
theModel = Graphic3d_TOSM_FRAGMENT;
|
||||
}
|
||||
else if (aTypeStr == "pbr")
|
||||
{
|
||||
theModel = Graphic3d_TOSM_PBR;
|
||||
}
|
||||
else if (aTypeStr == "pbr_facet")
|
||||
{
|
||||
theModel = Graphic3d_TOSM_PBR_FACET;
|
||||
}
|
||||
else if (aTypeStr == "default"
|
||||
|| aTypeStr == "def")
|
||||
{
|
||||
@@ -1982,7 +1990,7 @@ struct ViewerTest_AspectsChangeSet
|
||||
isOk = Standard_False;
|
||||
}
|
||||
if (ToSetShadingModel == 1
|
||||
&& (ShadingModel < Graphic3d_TOSM_DEFAULT || ShadingModel > Graphic3d_TOSM_FRAGMENT))
|
||||
&& (ShadingModel < Graphic3d_TOSM_DEFAULT || ShadingModel > Graphic3d_TOSM_PBR_FACET))
|
||||
{
|
||||
std::cout << "Error: unknown shading model " << ShadingModelName << ".\n";
|
||||
isOk = Standard_False;
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <OSD_OpenFile.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
@@ -1037,17 +1038,24 @@ static Standard_Integer VListMaterials (Draw_Interpretor& theDI,
|
||||
"ASPECT material does not define final colors, it is taken from Internal Color instead.\n"
|
||||
"See also Graphic3d_TypeOfMaterial enumeration'>"
|
||||
"Type</div></th>\n"
|
||||
"<th colspan='5'><div title='Common material definition for Phong shading model'>"
|
||||
"Common</div></th>\n"
|
||||
"<th rowspan='2'>Transparency</th>\n"
|
||||
"<th rowspan='2'>Refraction Index</th>\n"
|
||||
"<th colspan='9'><div title='BSDF (Bidirectional Scattering Distribution Function).\n"
|
||||
"<th colspan='5'><div title='PBR Metallic-Roughness'>"
|
||||
"PBR Metallic-Roughness</div></th>\n"
|
||||
"<th colspan='5'><div title='Common material definition for Phong shading model'>"
|
||||
"Common (Blinn-Phong)</div></th>\n"
|
||||
"<th colspan='10'><div title='BSDF (Bidirectional Scattering Distribution Function).\n"
|
||||
"Used for physically-based rendering (in path tracing engine).\n"
|
||||
"BSDF is represented as weighted mixture of basic BRDFs/BTDFs (Bidirectional Reflectance (Transmittance) Distribution Functions).\n"
|
||||
"See also Graphic3d_BSDF structure.'>"
|
||||
"BSDF</div></th>\n"
|
||||
"BSDF (Bidirectional Scattering Distribution Function)</div></th>\n"
|
||||
"</tr>\n"
|
||||
"<tr>\n"
|
||||
"<th>Color</th>\n"
|
||||
"<th>Metallic</th>\n"
|
||||
"<th>Roughness</th>\n"
|
||||
"<th>Emission</th>\n"
|
||||
"<th><div title='Index of refraction'>"
|
||||
"IOR</div></th>\n"
|
||||
"<th>Ambient</th>\n"
|
||||
"<th>Diffuse</th>\n"
|
||||
"<th>Specular</th>\n"
|
||||
@@ -1069,6 +1077,7 @@ static Standard_Integer VListMaterials (Draw_Interpretor& theDI,
|
||||
"FresnelCoat</div></th>\n"
|
||||
"<th><div title='Parameters of Fresnel reflectance of base layer'>"
|
||||
"FresnelBase</div></th>\n"
|
||||
"<th>Refraction Index</th>\n"
|
||||
"</tr>\n";
|
||||
}
|
||||
else if (!aDumpFile.IsEmpty())
|
||||
@@ -1105,13 +1114,17 @@ static Standard_Integer VListMaterials (Draw_Interpretor& theDI,
|
||||
anHtmlFile << "<tr>\n";
|
||||
anHtmlFile << "<td>" << aMat.StringName() << "</td>\n";
|
||||
anHtmlFile << "<td>" << (aMat.MaterialType() == Graphic3d_MATERIAL_PHYSIC ? "PHYSIC" : "ASPECT") << "</td>\n";
|
||||
anHtmlFile << "<td>" << aMat.Transparency() << "</td>\n";
|
||||
anHtmlFile << "<td>" << formatSvgColoredRect (aMat.PBRMaterial().Color().GetRGB()) << (Graphic3d_Vec3 )aMat.PBRMaterial().Color().GetRGB() << "</td>\n";
|
||||
anHtmlFile << "<td>" << aMat.PBRMaterial().Metallic() << "</td>\n";
|
||||
anHtmlFile << "<td>" << aMat.PBRMaterial().NormalizedRoughness() << "</td>\n";
|
||||
anHtmlFile << "<td>" << formatSvgColoredRect (Quantity_Color (aMat.PBRMaterial().Emission())) << aMat.PBRMaterial().Emission() << "</td>\n";
|
||||
anHtmlFile << "<td>" << aMat.PBRMaterial().IOR() << "</td>\n";
|
||||
anHtmlFile << "<td>" << formatSvgColoredRect (Quantity_Color (anAmbient)) << anAmbient << "</td>\n";
|
||||
anHtmlFile << "<td>" << formatSvgColoredRect (Quantity_Color (aDiffuse)) << aDiffuse << "</td>\n";
|
||||
anHtmlFile << "<td>" << formatSvgColoredRect (Quantity_Color (aSpecular)) << aSpecular << "</td>\n";
|
||||
anHtmlFile << "<td>" << formatSvgColoredRect (Quantity_Color (anEmission)) << anEmission << "</td>\n";
|
||||
anHtmlFile << "<td>" << aMat.Shininess() << "</td>\n";
|
||||
anHtmlFile << "<td>" << aMat.Transparency() << "</td>\n";
|
||||
anHtmlFile << "<td>" << aMat.RefractionIndex() << "</td>\n";
|
||||
anHtmlFile << "<td>" << aMat.BSDF().Kc << "</td>\n";
|
||||
anHtmlFile << "<td>" << aMat.BSDF().Kd << "</td>\n";
|
||||
anHtmlFile << "<td>" << aMat.BSDF().Ks << "</td>\n";
|
||||
@@ -1120,18 +1133,23 @@ static Standard_Integer VListMaterials (Draw_Interpretor& theDI,
|
||||
anHtmlFile << "<td>" << aMat.BSDF().Absorption << "</td>\n";
|
||||
anHtmlFile << "<td>" << fresnelModelString (aMat.BSDF().FresnelCoat.FresnelType()) << "</td>\n";
|
||||
anHtmlFile << "<td>" << fresnelModelString (aMat.BSDF().FresnelBase.FresnelType()) << "</td>\n";
|
||||
anHtmlFile << "<td>" << aMat.RefractionIndex() << "</td>\n";
|
||||
anHtmlFile << "</tr>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
theDI << aMat.StringName() << "\n";
|
||||
theDI << " Transparency: " << aMat.Transparency() << "\n";
|
||||
theDI << " PBR.BaseColor: " << (Graphic3d_Vec3 )aMat.PBRMaterial().Color().GetRGB() << "\n";
|
||||
theDI << " PBR.Metallic: " << aMat.PBRMaterial().Metallic() << "\n";
|
||||
theDI << " PBR.Roughness: " << aMat.PBRMaterial().NormalizedRoughness() << "\n";
|
||||
theDI << " PBR.Emission: " << aMat.PBRMaterial().Emission() << "\n";
|
||||
theDI << " PBR.IOR: " << aMat.PBRMaterial().IOR() << "\n";
|
||||
theDI << " Common.Ambient: " << anAmbient << "\n";
|
||||
theDI << " Common.Diffuse: " << aDiffuse << "\n";
|
||||
theDI << " Common.Specular: " << aSpecular << "\n";
|
||||
theDI << " Common.Emissive: " << anEmission << "\n";
|
||||
theDI << " Common.Shiness: " << aMat.Shininess() << "\n";
|
||||
theDI << " Common.Transparency: " << aMat.Transparency() << "\n";
|
||||
theDI << " RefractionIndex: " << aMat.RefractionIndex() << "\n";
|
||||
theDI << " BSDF.Kc: " << aMat.BSDF().Kc << "\n";
|
||||
theDI << " BSDF.Kd: " << aMat.BSDF().Kd << "\n";
|
||||
theDI << " BSDF.Ks: " << aMat.BSDF().Ks << "\n";
|
||||
@@ -1140,6 +1158,7 @@ static Standard_Integer VListMaterials (Draw_Interpretor& theDI,
|
||||
theDI << " BSDF.Absorption: " << aMat.BSDF().Absorption << "\n";
|
||||
theDI << " BSDF.FresnelCoat: " << fresnelModelString (aMat.BSDF().FresnelCoat.FresnelType()) << "\n";
|
||||
theDI << " BSDF.FresnelBase: " << fresnelModelString (aMat.BSDF().FresnelBase.FresnelType()) << "\n";
|
||||
theDI << " RefractionIndex: " << aMat.RefractionIndex() << "\n";
|
||||
}
|
||||
|
||||
if (anObjFile.is_open())
|
||||
@@ -1335,6 +1354,159 @@ static Standard_Integer VListColors (Draw_Interpretor& theDI,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//function : envlutWriteToFile
|
||||
//purpose :
|
||||
//==============================================================================
|
||||
static std::string envLutWriteToFile (Standard_ShortReal theValue)
|
||||
{
|
||||
std::stringstream aStream;
|
||||
aStream << theValue;
|
||||
if (aStream.str().length() == 1)
|
||||
{
|
||||
aStream << '.';
|
||||
}
|
||||
aStream << 'f';
|
||||
return aStream.str();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//function : VGenEnvLUT
|
||||
//purpose :
|
||||
//==============================================================================
|
||||
static Standard_Integer VGenEnvLUT (Draw_Interpretor&,
|
||||
Standard_Integer theArgNb,
|
||||
const char** theArgVec)
|
||||
{
|
||||
Standard_Integer aTableSize = -1;
|
||||
Standard_Integer aNbSamples = -1;
|
||||
TCollection_AsciiString aFilePath = Graphic3d_TextureRoot::TexturesFolder() + "/Textures_EnvLUT.pxx";
|
||||
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
|
||||
{
|
||||
TCollection_AsciiString anArg(theArgVec[anArgIter]);
|
||||
anArg.LowerCase();
|
||||
|
||||
if (anArg == "-size"
|
||||
|| anArg == "-s")
|
||||
{
|
||||
if (anArgIter + 1 >= theArgNb)
|
||||
{
|
||||
std::cerr << "Syntax error: size of PBR environment look up table is undefined" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
aTableSize = Draw::Atoi(theArgVec[++anArgIter]);
|
||||
|
||||
if (aTableSize < 16)
|
||||
{
|
||||
std::cerr << "Error: size of PBR environment look up table must be greater or equal 16\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (anArg == "-nbsamples"
|
||||
|| anArg == "-samples")
|
||||
{
|
||||
if (anArgIter + 1 >= theArgNb)
|
||||
{
|
||||
std::cerr << "Syntax error: number of samples to generate PBR environment look up table is undefined" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
aNbSamples = Draw::Atoi(theArgVec[++anArgIter]);
|
||||
|
||||
if (aNbSamples < 1)
|
||||
{
|
||||
std::cerr << "Syntax error: number of samples to generate PBR environment look up table must be greater than 1\n" << "\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Syntax error: unknown argument " << anArg << ";\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (aTableSize < 0)
|
||||
{
|
||||
aTableSize = 128;
|
||||
}
|
||||
|
||||
if (aNbSamples < 0)
|
||||
{
|
||||
aNbSamples = 1024;
|
||||
}
|
||||
|
||||
std::ofstream aFile;
|
||||
|
||||
OSD_OpenStream (aFile, aFilePath, std::ios::out | std::ios::binary);
|
||||
|
||||
if (!aFile.good())
|
||||
{
|
||||
std::cerr << "Error: unable to write to " << aFilePath << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
aFile << "//this file has been generated by vgenenvlut draw command\n";
|
||||
aFile << "static unsigned int Textures_EnvLUTSize = " << aTableSize << ";\n\n";
|
||||
aFile << "static float Textures_EnvLUT[] =\n";
|
||||
aFile << "{\n";
|
||||
|
||||
Handle(Image_PixMap) aPixMap = new Image_PixMap();
|
||||
aPixMap->InitZero (Image_Format_RGF, aTableSize, aTableSize);
|
||||
Graphic3d_PBRMaterial::GenerateEnvLUT (aPixMap, aNbSamples);
|
||||
|
||||
const Standard_Integer aNumbersInRow = 5;
|
||||
Standard_Integer aCounter = 0;
|
||||
|
||||
for (int y = 0; y < aTableSize - 1; ++y)
|
||||
{
|
||||
aCounter = 0;
|
||||
for (int x = 0; x < aTableSize; ++x)
|
||||
{
|
||||
aFile << envLutWriteToFile (aPixMap->Value<Graphic3d_Vec3>(aTableSize - 1 - y, x).x()) << ",";
|
||||
aFile << envLutWriteToFile (aPixMap->Value<Graphic3d_Vec3>(aTableSize - 1 - y, x).y()) << ",";
|
||||
if (++aCounter % aNumbersInRow == 0)
|
||||
{
|
||||
aFile << "\n";
|
||||
}
|
||||
else if (x != aTableSize - 1)
|
||||
{
|
||||
aFile << " ";
|
||||
}
|
||||
}
|
||||
aFile << "\n";
|
||||
if (aTableSize % aNumbersInRow != 0)
|
||||
{
|
||||
aFile << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
aCounter = 0;
|
||||
for (int x = 0; x < aTableSize - 1; ++x)
|
||||
{
|
||||
aFile << envLutWriteToFile (aPixMap->Value<Graphic3d_Vec3>(0, x).x()) << ",";
|
||||
aFile << envLutWriteToFile (aPixMap->Value<Graphic3d_Vec3>(0, x).y()) << ",";
|
||||
if (++aCounter % aNumbersInRow == 0)
|
||||
{
|
||||
aFile << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
aFile << " ";
|
||||
}
|
||||
}
|
||||
|
||||
aFile << envLutWriteToFile (aPixMap->Value<Graphic3d_Vec3>(0, aTableSize - 1).x()) << ",";
|
||||
aFile << envLutWriteToFile (aPixMap->Value<Graphic3d_Vec3>(0, aTableSize - 1).y()) << "\n";
|
||||
|
||||
aFile << "};";
|
||||
aFile.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenGlCommands
|
||||
//purpose :
|
||||
@@ -1386,4 +1558,12 @@ void ViewerTest::OpenGlCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: or dumped into specified file."
|
||||
"\n\t\t: * can be used to refer to complete list of standard colors.",
|
||||
__FILE__, VListColors, aGroup);
|
||||
theCommands.Add("vgenenvlut",
|
||||
"vgenenvlut [-size size = 128] [-nbsamples nbsamples = 1024]"
|
||||
"\n\t\t: Generates PBR environment look up table."
|
||||
"\n\t\t: Saves it as C++ source file which is expected to be included in code."
|
||||
"\n\t\t: The path where result will be located is 'Graphic3d_TextureRoot::TexturesFolder()'."
|
||||
"\n\t\t: -size size of one side of resulted square table"
|
||||
"\n\t\t: -nbsamples number of samples used in Monte-Carlo integration",
|
||||
__FILE__, VGenEnvLUT, aGroup);
|
||||
}
|
||||
|
@@ -416,6 +416,9 @@ namespace
|
||||
//! the option key for the command that sets inversion of Z axis for background cubemap
|
||||
ViewerTest_CommandOptionKey myCubeMapInvertedZOptionKey;
|
||||
|
||||
//! the option key for the command that allows skip IBL map generation
|
||||
ViewerTest_CommandOptionKey myCubeMapDoNotGenPBREnvOptionKey;
|
||||
|
||||
//! the variable set of options that are allowed for the old scenario (without any option passed)
|
||||
CommandOptionKeyVariableSet myUnnamedOptionVariableSet;
|
||||
|
||||
@@ -466,6 +469,7 @@ namespace
|
||||
myCubeMapOrderOptionKey = myCommandParser.AddOption ("order|o", "order of sides in one image packed cubemap");
|
||||
myCubeMapInvertedZOptionKey = myCommandParser.AddOption (
|
||||
"invertedz|invz|iz", "whether Z axis is inverted or not during background cubemap rendering");
|
||||
myCubeMapDoNotGenPBREnvOptionKey = myCommandParser.AddOption ("nopbrenv", "whether IBL map generation should be skipped");
|
||||
}
|
||||
|
||||
//! Creates option sets used to determine if a passed option set is valid or not
|
||||
@@ -479,6 +483,7 @@ namespace
|
||||
aCubeMapOptionSet.insert (myCubeMapOptionKey);
|
||||
ViewerTest_CommandOptionKeySet aCubeMapAdditionalOptionKeySet;
|
||||
aCubeMapAdditionalOptionKeySet.insert (myCubeMapInvertedZOptionKey);
|
||||
aCubeMapAdditionalOptionKeySet.insert (myCubeMapDoNotGenPBREnvOptionKey);
|
||||
aCubeMapAdditionalOptionKeySet.insert (myCubeMapOrderOptionKey);
|
||||
myCubeMapOptionVariableSet = CommandOptionKeyVariableSet (aCubeMapOptionSet, aCubeMapAdditionalOptionKeySet);
|
||||
|
||||
@@ -852,7 +857,17 @@ namespace
|
||||
aZIsInverted = true;
|
||||
}
|
||||
|
||||
setCubeMap (aFilePaths, anOrder.Validated(), aZIsInverted);
|
||||
bool aToGenPBREnv = true;
|
||||
if (myCommandParser.HasOption (myCubeMapDoNotGenPBREnvOptionKey))
|
||||
{
|
||||
if (!processCubeMapDoNotGenPBREnvOptionSet())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
aToGenPBREnv = false;
|
||||
}
|
||||
|
||||
setCubeMap (aFilePaths, anOrder.Validated(), aZIsInverted, aToGenPBREnv);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1017,8 +1032,7 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Processes the cubemap option
|
||||
//! @param theIsNeededToRedraw defines need of redraw after option's processing
|
||||
//! Processes the inverted z cubemap option
|
||||
//! @return true if processing was successful, or false otherwise
|
||||
bool processCubeMapInvertedZOptionSet () const
|
||||
{
|
||||
@@ -1033,6 +1047,21 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Processes the option allowing to skip IBM maps generation
|
||||
//! @return true if processing was successful, or false otherwise
|
||||
bool processCubeMapDoNotGenPBREnvOptionSet() const
|
||||
{
|
||||
const Standard_Integer aNumberOfCubeMapDoNotGenPBREnvOptionArguments =
|
||||
myCommandParser.GetNumberOfOptionArguments(myCubeMapDoNotGenPBREnvOptionKey);
|
||||
|
||||
if (aNumberOfCubeMapDoNotGenPBREnvOptionArguments != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Processes the tiles order option
|
||||
//! @param theOrder the array of indexes if cubemap sides in tile grid
|
||||
//! @return true if processing was successful, or false otherwise
|
||||
@@ -1221,7 +1250,8 @@ namespace
|
||||
//! @param theOrder array of cubemap sides indexes mapping them from tiles in packed cubemap
|
||||
static void setCubeMap (const NCollection_Array1<TCollection_AsciiString>& theFileNames,
|
||||
const Graphic3d_ValidatedCubeMapOrder theOrder = Graphic3d_CubeMapOrder::Default(),
|
||||
bool theZIsInverted = false)
|
||||
bool theZIsInverted = false,
|
||||
bool theToGenPBREnv = true)
|
||||
{
|
||||
const Handle(V3d_View)& aCurrentView = ViewerTest::CurrentView();
|
||||
Handle(Graphic3d_CubeMap) aCubeMap;
|
||||
@@ -1237,7 +1267,7 @@ namespace
|
||||
aCubeMap->GetParams()->SetRepeat(Standard_False);
|
||||
aCubeMap->GetParams()->SetTextureUnit(Graphic3d_TextureUnit_EnvMap);
|
||||
|
||||
aCurrentView->SetBackgroundCubeMap (aCubeMap, Standard_True);
|
||||
aCurrentView->SetBackgroundCubeMap (aCubeMap, theToGenPBREnv, Standard_True);
|
||||
}
|
||||
|
||||
//! Sets the image as a background
|
||||
@@ -11185,6 +11215,48 @@ static int VLight (Draw_Interpretor& theDi,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===============================================================================================
|
||||
//function : VPBREnvironment
|
||||
//purpose :
|
||||
//===============================================================================================
|
||||
static int VPBREnvironment (Draw_Interpretor&,
|
||||
Standard_Integer theArgsNb,
|
||||
const char** theArgVec)
|
||||
{
|
||||
if (theArgsNb > 2)
|
||||
{
|
||||
std::cerr << "Error: 'vpbrenv' command has only one argument\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(V3d_View) aView = ViewerTest::CurrentView();
|
||||
if (aView.IsNull())
|
||||
{
|
||||
std::cerr << "Error: no active viewer!\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString anArg = TCollection_AsciiString (theArgVec[1]);
|
||||
anArg.LowerCase();
|
||||
|
||||
if (anArg == "-generate"
|
||||
|| anArg == "-gen")
|
||||
{
|
||||
aView->GeneratePBREnvironment (Standard_True);
|
||||
}
|
||||
else if (anArg == "-clear")
|
||||
{
|
||||
aView->ClearPBREnvironment (Standard_True);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Error: unknown argument [" << theArgVec[1] << "] for 'vpbrenv' command\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! Read Graphic3d_RenderingParams::PerfCounters flag.
|
||||
static Standard_Boolean parsePerfStatsFlag (const TCollection_AsciiString& theValue,
|
||||
Standard_Boolean& theToReset,
|
||||
@@ -11391,11 +11463,13 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
|
||||
theDI << "shadingModel: ";
|
||||
switch (aView->ShadingModel())
|
||||
{
|
||||
case Graphic3d_TOSM_DEFAULT: theDI << "default"; break;
|
||||
case Graphic3d_TOSM_UNLIT: theDI << "unlit"; break;
|
||||
case Graphic3d_TOSM_FACET: theDI << "flat"; break;
|
||||
case Graphic3d_TOSM_VERTEX: theDI << "gouraud"; break;
|
||||
case Graphic3d_TOSM_FRAGMENT: theDI << "phong"; break;
|
||||
case Graphic3d_TOSM_DEFAULT: theDI << "default"; break;
|
||||
case Graphic3d_TOSM_UNLIT: theDI << "unlit"; break;
|
||||
case Graphic3d_TOSM_FACET: theDI << "flat"; break;
|
||||
case Graphic3d_TOSM_VERTEX: theDI << "gouraud"; break;
|
||||
case Graphic3d_TOSM_FRAGMENT: theDI << "phong"; break;
|
||||
case Graphic3d_TOSM_PBR: theDI << "pbr"; break;
|
||||
case Graphic3d_TOSM_PBR_FACET: theDI << "pbr_facet"; break;
|
||||
}
|
||||
{
|
||||
theDI << "perfCounters:";
|
||||
@@ -11957,11 +12031,13 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
|
||||
{
|
||||
switch (aView->ShadingModel())
|
||||
{
|
||||
case Graphic3d_TOSM_DEFAULT: theDI << "default"; break;
|
||||
case Graphic3d_TOSM_UNLIT: theDI << "unlit "; break;
|
||||
case Graphic3d_TOSM_FACET: theDI << "flat "; break;
|
||||
case Graphic3d_TOSM_VERTEX: theDI << "gouraud "; break;
|
||||
case Graphic3d_TOSM_FRAGMENT: theDI << "phong "; break;
|
||||
case Graphic3d_TOSM_DEFAULT: theDI << "default"; break;
|
||||
case Graphic3d_TOSM_UNLIT: theDI << "unlit "; break;
|
||||
case Graphic3d_TOSM_FACET: theDI << "flat "; break;
|
||||
case Graphic3d_TOSM_VERTEX: theDI << "gouraud "; break;
|
||||
case Graphic3d_TOSM_FRAGMENT: theDI << "phong "; break;
|
||||
case Graphic3d_TOSM_PBR: theDI << "pbr"; break;
|
||||
case Graphic3d_TOSM_PBR_FACET: theDI << "pbr_facet"; break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -11983,6 +12059,97 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (aFlag == "-pbrenvpow2size"
|
||||
|| aFlag == "-pbrenvp2s"
|
||||
|| aFlag == "-pep2s")
|
||||
{
|
||||
if (++anArgIter >= theArgNb)
|
||||
{
|
||||
std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
const Standard_Integer aPbrEnvPow2Size = Draw::Atoi (theArgVec[anArgIter]);
|
||||
if (aPbrEnvPow2Size < 1)
|
||||
{
|
||||
std::cout << "Error: 'Pow2Size' of PBR Environment has to be greater or equal 1\n";
|
||||
return 1;
|
||||
}
|
||||
aParams.PbrEnvPow2Size = aPbrEnvPow2Size;
|
||||
}
|
||||
else if (aFlag == "-pbrenvspecmaplevelsnumber"
|
||||
|| aFlag == "-pbrenvspecmapnblevels"
|
||||
|| aFlag == "-pbrenvspecmaplevels"
|
||||
|| aFlag == "-pbrenvsmln"
|
||||
|| aFlag == "-pesmln")
|
||||
{
|
||||
if (++anArgIter >= theArgNb)
|
||||
{
|
||||
std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
const Standard_Integer aPbrEnvSpecMapNbLevels = Draw::Atoi (theArgVec[anArgIter]);
|
||||
if (aPbrEnvSpecMapNbLevels < 2)
|
||||
{
|
||||
std::cout << "Error: 'SpecMapLevelsNumber' of PBR Environment has to be greater or equal 2\n";
|
||||
return 1;
|
||||
}
|
||||
aParams.PbrEnvSpecMapNbLevels = aPbrEnvSpecMapNbLevels;
|
||||
}
|
||||
else if (aFlag == "-pbrenvbakngdiffsamplesnumber"
|
||||
|| aFlag == "-pbrenvbakingdiffsamples"
|
||||
|| aFlag == "-pbrenvbdsn")
|
||||
{
|
||||
if (++anArgIter >= theArgNb)
|
||||
{
|
||||
std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
const Standard_Integer aPbrEnvBakingDiffNbSamples = Draw::Atoi (theArgVec[anArgIter]);
|
||||
if (aPbrEnvBakingDiffNbSamples < 1)
|
||||
{
|
||||
std::cout << "Error: 'BakingDiffSamplesNumber' of PBR Environtment has to be greater or equal 1\n";
|
||||
return 1;
|
||||
}
|
||||
aParams.PbrEnvBakingDiffNbSamples = aPbrEnvBakingDiffNbSamples;
|
||||
}
|
||||
else if (aFlag == "-pbrenvbakngspecsamplesnumber"
|
||||
|| aFlag == "-pbrenvbakingspecsamples"
|
||||
|| aFlag == "-pbrenvbssn")
|
||||
{
|
||||
if (++anArgIter >= theArgNb)
|
||||
{
|
||||
std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
const Standard_Integer aPbrEnvBakingSpecNbSamples = Draw::Atoi(theArgVec[anArgIter]);
|
||||
if (aPbrEnvBakingSpecNbSamples < 1)
|
||||
{
|
||||
std::cout << "Error: 'BakingSpecSamplesNumber' of PBR Environtment has to be greater or equal 1\n";
|
||||
return 1;
|
||||
}
|
||||
aParams.PbrEnvBakingSpecNbSamples = aPbrEnvBakingSpecNbSamples;
|
||||
}
|
||||
else if (aFlag == "-pbrenvbakingprobability"
|
||||
|| aFlag == "-pbrenvbp")
|
||||
{
|
||||
if (++anArgIter >= theArgNb)
|
||||
{
|
||||
std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
const Standard_ShortReal aPbrEnvBakingProbability = static_cast<Standard_ShortReal>(Draw::Atof (theArgVec[anArgIter]));
|
||||
if (aPbrEnvBakingProbability < 0.f
|
||||
|| aPbrEnvBakingProbability > 1.f)
|
||||
{
|
||||
std::cout << "Error: 'BakingProbability' of PBR Environtment has to be in range of [0, 1]\n";
|
||||
return 1;
|
||||
}
|
||||
aParams.PbrEnvBakingProbability = aPbrEnvBakingProbability;
|
||||
}
|
||||
else if (aFlag == "-resolution")
|
||||
{
|
||||
if (++anArgIter >= theArgNb)
|
||||
@@ -14205,6 +14372,12 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\n example: vlight -add positional -head 1 -pos 0 1 1 -color red"
|
||||
"\n example: vlight -change 0 -direction 0 -1 0 -linearAttenuation 0.2",
|
||||
__FILE__, VLight, group);
|
||||
theCommands.Add("vpbrenv",
|
||||
"vpbrenv -clear|-generate"
|
||||
"\n\t\t: Clears or generates PBR environment map of active view."
|
||||
"\n\t\t: -clear clears PBR environment (fills by white color)"
|
||||
"\n\t\t: -generate generates PBR environment from current background cubemap",
|
||||
__FILE__, VPBREnvironment, group);
|
||||
theCommands.Add("vraytrace",
|
||||
"vraytrace [0|1]"
|
||||
"\n\t\t: Turns on/off ray-tracing renderer."
|
||||
@@ -14238,6 +14411,11 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n '-rebuildGlsl on|off' Rebuild Ray-Tracing GLSL programs (for debugging)"
|
||||
"\n '-shadingModel model' Controls shading model from enumeration"
|
||||
"\n unlit, flat, gouraud, phong"
|
||||
"\n '-pbrEnvPow2size > 0' Controls size of IBL maps (real size can be calculates as 2^pbrenvpow2size)"
|
||||
"\n '-pbrEnvSMLN > 1' Controls number of mipmap levels used in specular IBL map"
|
||||
"\n '-pbrEnvBDSN > 0' Controls number of samples in Monte-Carlo integration during diffuse IBL map's sherical harmonics calculation"
|
||||
"\n '-pbrEnvBSSN > 0' Controls maximum number of samples per mipmap level in Monte-Carlo integration during specular IBL maps generation"
|
||||
"\n '-pbrEnvBP [0, 1]' Controls strength of samples number reducing during specular IBL maps generation (1 disables reducing)"
|
||||
"\n '-resolution value' Sets a new pixels density (PPI), defines scaling factor for parameters like text size"
|
||||
"\n '-aperture >= 0.0' Aperture size of perspective camera for depth-of-field effect (0 disables DOF)"
|
||||
"\n '-focal >= 0.0' Focal distance of perspective camera for depth-of-field effect"
|
||||
|
Reference in New Issue
Block a user