]> OCCT Git - occt-copy.git/commitdiff
0029528: Visualization, TKOpenGl - allow defining sRGB textures
authorkgv <kgv@opencascade.com>
Thu, 29 Aug 2019 08:04:56 +0000 (11:04 +0300)
committerkgv <kgv@opencascade.com>
Fri, 20 Sep 2019 10:19:39 +0000 (13:19 +0300)
Quantity_Color definition has been modified to store RGB components
in linear color space within Quantity_TOC_RGB type.
Standard colors defined by Quantity_NameOfColor enumeration has been updated accordingly.
New Quantity_TOC_sRGB type has been introduced to handle RGB components in non-linear sRGB color space.

OpenGl_TextureFormat class definition has been moved to dedicated files.
New method OpenGl_TextureFormat::FindFormat() replaces OpenGl_Texture::GetDataFormat().
New method OpenGl_TextureFormat::FindSizedFormat() replaces OpenGl_FrameBuffer::getColorDataFormat()
and OpenGl_FrameBuffer::getDepthDataFormat().

Graphic3d_TextureRoot::IsColorMap() - introduced new property defining
if RGB(A)8 image formats should be loaded as sRGB(A) textures or as data RGB(A) textures.
OpenGl_Texture initialization methods have been extended with new theIsColorMap argument.

vreadpixel - added argument -sRGB printing color in sRGB color space.

69 files changed:
dox/dev_guides/upgrade/upgrade.md
src/D3DHost/D3DHost_FrameBuffer.cxx
src/Graphic3d/Graphic3d_MaterialAspect.cxx
src/Graphic3d/Graphic3d_TextureMap.hxx
src/Graphic3d/Graphic3d_TextureRoot.cxx
src/Graphic3d/Graphic3d_TextureRoot.hxx
src/Graphic3d/Graphic3d_TypeOfLimit.hxx
src/IGESCAFControl/IGESCAFControl_Reader.cxx
src/IGESCAFControl/IGESCAFControl_Writer.cxx
src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx
src/MeshVS/MeshVS_TwoColors.cxx
src/OpenGl/FILES
src/OpenGl/OpenGl_AspectsSprite.cxx
src/OpenGl/OpenGl_BackgroundArray.cxx
src/OpenGl/OpenGl_BackgroundArray.hxx
src/OpenGl/OpenGl_Caps.cxx
src/OpenGl/OpenGl_Caps.hxx
src/OpenGl/OpenGl_Context.cxx
src/OpenGl/OpenGl_Context.hxx
src/OpenGl/OpenGl_Font.cxx
src/OpenGl/OpenGl_FrameBuffer.cxx
src/OpenGl/OpenGl_FrameBuffer.hxx
src/OpenGl/OpenGl_GraphicDriver.cxx
src/OpenGl/OpenGl_Material.hxx
src/OpenGl/OpenGl_ShaderManager.cxx
src/OpenGl/OpenGl_ShaderManager.hxx
src/OpenGl/OpenGl_Texture.cxx
src/OpenGl/OpenGl_Texture.hxx
src/OpenGl/OpenGl_TextureFormat.cxx [new file with mode: 0644]
src/OpenGl/OpenGl_TextureFormat.hxx [new file with mode: 0644]
src/OpenGl/OpenGl_TileSampler.cxx
src/OpenGl/OpenGl_View.cxx
src/OpenGl/OpenGl_View.hxx
src/OpenGl/OpenGl_View_Raytrace.cxx
src/OpenGl/OpenGl_View_Redraw.cxx
src/OpenGl/OpenGl_Window.cxx
src/OpenGl/OpenGl_Workspace.cxx
src/QABugs/QABugs_17.cxx
src/QABugs/QABugs_19.cxx
src/Quantity/Quantity_Color.cxx
src/Quantity/Quantity_Color.hxx
src/Quantity/Quantity_ColorRGBA.cxx
src/Quantity/Quantity_ColorRGBA.hxx
src/Quantity/Quantity_ColorTable.pxx
src/Quantity/Quantity_TypeOfColor.hxx
src/RWGltf/RWGltf_GltfJsonParser.cxx
src/RWGltf/RWGltf_MaterialCommon.hxx
src/RWObj/RWObj_Material.hxx
src/RWObj/RWObj_MtlReader.cxx
src/STEPCAFControl/STEPCAFControl_Writer.cxx
src/STEPConstruct/STEPConstruct_Styles.cxx
src/Shaders/Display.fs
src/Shaders/PathtraceBase.fs
src/Shaders/Shaders_Display_fs.pxx
src/Shaders/Shaders_PathtraceBase_fs.pxx
src/StdSelect/StdSelect_ViewerSelector3d.cxx
src/ViewerTest/ViewerTest.cxx
src/ViewerTest/ViewerTest_OpenGlCommands.cxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
src/Vrml/Vrml_DirectionalLight.cxx
src/Vrml/Vrml_Material.cxx
src/Vrml/Vrml_PointLight.cxx
src/Vrml/Vrml_SpotLight.cxx
src/VrmlAPI/VrmlAPI_Writer.cxx
src/VrmlData/VrmlData_Color.hxx
src/VrmlData/VrmlData_Material.cxx
src/VrmlData/VrmlData_ShapeConvert.cxx
tests/v3d/glsl/texture_trsf
tests/v3d/glsl/texture_trsf2

index 09bc12a249a3f5a7a59d29db7c2e4ff05fd6a88a..b86be03161c594ed46e8b1dea6e92cf13551182b 100644 (file)
@@ -1833,3 +1833,26 @@ The following API changes have been made:
 @subsection upgrade_740_stdnamespace Standard_Stream.hxx no more has "using std::" statements
 *Standard_Stream.hxx* header, commonly included by other OCCT header files, does no more add entities from *std namespace* related to streams (like *std::cout*, *std::istream* and others) into global namespace.
 The application code relying on this matter should be updated to either specify std namespace explicitly (like std::cout) or add "using std::" statements locally.
+
+@section upgrade_occt750 Upgrade to OCCT 7.5.0
+
+@subsection upgrade_750_srgb_color RGB color definition
+
+OCCT 3D Viewer has been improved to properly perform lighting using in linear RGB color space and then convert result into non-linear gamma-shifted sRGB color space before displaying on display.
+This change affects texture mapping, material definition and color definition.
+
+Previously *Quantity_Color* definition was provided with unspecified RGB color space.
+In practice, mixed color spaces have been actually used, with non-linear sRGB prevailing in general.
+Since OCCT 7.5.0, *Quantity_Color* now specifies that components are defined in linear RGB color space.
+
+This change affects following parts:
+* Standard colors defined by *Quantity_NameOfColor* enumeration have been converted into linear RGB values within Quantity_Color construction.
+* Application may use new enumeration value *Quantity_TOC_sRGB* for passing/fetching colors in sRGB color space,
+  which can be useful for interoperation with color picking widgets (returning 8-bit integer values within [0..255] range)
+  or for porting colors constants within old application code without manual conversion.
+* *Graphic3d_MaterialAspect* color components are now expected in linear RGB color space,
+  and standard OCCT materials within *Graphic3d_NameOfMaterial* enumeration have been updated accordingly.
+* Texture mapping now handles new *Graphic3d_TextureRoot::IsColorMap()* for interpreting content in linear RGB or sRGB color space.
+  It is responsibility of user specifying this flag correctly. The flag value is TRUE by default.
+* Method *Image_PixMap::PixelColor()* has been extended with a new Boolean flag for performing linearization of non-linear sRGB.
+  This flag is FALSE by default; application should consider passing TRUE instead for further handling *Quantity_Color* properly as linear RGB values.
index 9592561dfcdb9670d482a771ac3e490592d6c6f6..fe691f42e97fa49c97176e73f8ba9eda7b6a75b3 100644 (file)
@@ -193,14 +193,11 @@ Standard_Boolean D3DHost_FrameBuffer::InitD3dInterop (const Handle(OpenGl_Contex
   myIsOwnDepth  = true;
   theCtx->arbFBO->glGenFramebuffers (1, &myGlFBufferId);
 
-  GLenum aPixelFormat = 0, aDataType = 0;
-  if (myDepthFormat != 0
-  &&  getDepthDataFormat (myDepthFormat, aPixelFormat, aDataType)
-  && !myDepthStencilTexture->Init (theCtx, myDepthFormat,
-                                   aPixelFormat, aDataType,
-                                   aSizeX, aSizeY, Graphic3d_TOT_2D))
+  const OpenGl_TextureFormat aDepthFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, myDepthFormat);
+  if (aDepthFormat.IsValid()
+  && !myDepthStencilTexture->Init (theCtx, aDepthFormat, Graphic3d_Vec2i (aSizeX, aSizeY), Graphic3d_TOT_2D))
   {
-    Release (theCtx.operator->());
+    Release (theCtx.get());
     theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
                          TCollection_AsciiString("D3DHost_FrameBuffer, could not initialize GL_DEPTH24_STENCIL8 texture ") + aSizeX + "x" + aSizeY);
     return Standard_False;
@@ -288,17 +285,16 @@ void D3DHost_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theCtx)
   theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                                           myColorTextures (0)->GetTarget(), myColorTextures (0)->TextureId(), 0);
 
-  GLenum aDepthPixelFormat = 0, aDepthDataType = 0;
-  getDepthDataFormat (myDepthFormat, aDepthPixelFormat, aDepthDataType);
+  const OpenGl_TextureFormat aDepthFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, myDepthFormat);
   if (myDepthStencilTexture->IsValid())
   {
   #ifdef GL_DEPTH_STENCIL_ATTACHMENT
-    theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthPixelFormat == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
+    theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
                                             myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
   #else
     theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
                                             myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
-    if (aDepthPixelFormat == GL_DEPTH_STENCIL)
+    if (aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL)
     {
       theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
                                               myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
@@ -310,12 +306,12 @@ void D3DHost_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theCtx)
     if (myDepthStencilTexture->IsValid())
     {
     #ifdef GL_DEPTH_STENCIL_ATTACHMENT
-      theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthPixelFormat == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
+      theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
                                               myDepthStencilTexture->GetTarget(), 0, 0);
     #else
       theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
                                               myDepthStencilTexture->GetTarget(), 0, 0);
-      if (aDepthPixelFormat == GL_DEPTH_STENCIL)
+      if (aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL)
       {
         theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
                                                 myDepthStencilTexture->GetTarget(), 0, 0);
index 9e9624be2d22e72c5a8d560c3a3ada10ec0f39db..f90c9e6848d2da1000ee8d78981a3b7a6334f272 100644 (file)
@@ -91,9 +91,9 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       MaterialType = Graphic3d_MATERIAL_ASPECT;
 
       Shininess = 0.0078125f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.50f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.25f));
       Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.24f));
-      Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.06f));
+      Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.004896f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
 
       BSDF.Kd = Graphic3d_Vec3 (0.2f);
@@ -104,7 +104,7 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       MaterialType = Graphic3d_MATERIAL_ASPECT;
 
       Shininess = 1.00f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.44f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.22f));
       Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.50f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (1.0f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
@@ -117,9 +117,9 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       MaterialType = Graphic3d_MATERIAL_ASPECT;
 
       Shininess = 0.09375f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.33f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.165f));
       Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.40f));
-      Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.44f));
+      Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.162647f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
 
       BSDF.Kd = Graphic3d_Vec3 (0.2f);
@@ -131,7 +131,7 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       Shininess = 0.05f;
       Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.0f));
       Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (1.0f));
-      Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.62f));
+      Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.342392f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (1.0f));
 
       BSDF.Kd = Graphic3d_Vec3 (0.0f);
@@ -145,7 +145,7 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       Shininess = 0.13f;
       Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.0f));
       Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.47f));
-      Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.45f));
+      Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.170645f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
 
       BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f),
@@ -158,8 +158,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
         Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.58f, 0.42f, 0.20f)), 0.045f);
 
       Shininess = 0.65f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.329f, 0.224f, 0.027f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.780f, 0.569f, 0.114f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.088428f, 0.041081f, 0.002090f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.570482f, 0.283555f, 0.012335f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.992f, 0.941f, 0.808f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -170,8 +170,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
         Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.65f, 0.35f, 0.15f)), 0.045f);
 
       Shininess = 0.65f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.213f, 0.128f, 0.054f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.714f, 0.428f, 0.181f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.037301f, 0.014931f, 0.004305f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.468185f, 0.153344f, 0.027491f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.590f, 0.408f, 0.250f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -182,8 +182,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
         Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.955008f, 0.637427f, 0.538163f)), 0.045f);
 
       Shininess = 0.65f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.191f, 0.074f, 0.023f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.604f, 0.270f, 0.083f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.030370f, 0.006451f, 0.001780f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.323236f, 0.059254f, 0.007584f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.950f, 0.640f, 0.540f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -194,8 +194,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
         Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (1.000000f, 0.765557f, 0.336057f)), 0.045f);
 
       Shininess = 0.80f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.300f, 0.230f, 0.095f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.752f, 0.580f, 0.100f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.073239f, 0.043234f, 0.009264f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.525643f, 0.295700f, 0.010023f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (1.000f, 0.710f, 0.290f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -206,8 +206,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
         Graphic3d_Fresnel::CreateConductor (1.8800f, 3.4900f), 0.045f);
 
       Shininess = 0.50f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.106f, 0.059f, 0.114f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.427f, 0.471f, 0.541f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.010979f, 0.004795f, 0.012335f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.152583f, 0.188174f, 0.253972f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.333f, 0.333f, 0.522f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -215,9 +215,9 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       MaterialType = Graphic3d_MATERIAL_ASPECT;
 
       Shininess = 0.01f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.26f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.13f));
       Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.75f));
-      Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.05f));
+      Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.003936f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
 
       BSDF.Kd = Graphic3d_Vec3 (0.482353f, 0.482353f, 0.482353f);
@@ -229,8 +229,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
         Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.971519f, 0.959915f, 0.915324f)), 0.045f);
 
       Shininess = 0.75f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.275f, 0.275f, 0.250f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.630f, 0.630f, 0.630f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.061465f, 0.061465f, 0.050876f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.354692f, 0.354692f, 0.354692f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.950f, 0.930f, 0.880f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -241,8 +241,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
         Graphic3d_Fresnel::CreateConductor (Graphic3d_Vec3 (2.90f, 2.80f, 2.53f), Graphic3d_Vec3 (3.08f, 2.90f, 2.74f)), 0.045f);
 
       Shininess = 0.90f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.150f, 0.150f, 0.180f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.500f, 0.510f, 0.520f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.019607f, 0.019607f, 0.027212f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.214041f, 0.223414f, 0.233022f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.560f, 0.570f, 0.580f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -254,8 +254,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       DiffuseCoef = 0.75f;
 
       Shininess = 0.17f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (1.00f, 0.8f, 0.62f) * 0.19f);
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (1.00f, 0.8f, 0.62f) * 0.75f);
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.030074f, 0.020069f, 0.013011f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.522522f, 0.318547f, 0.183064f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.98f, 1.0f, 0.60f) * 0.08f);
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
 
@@ -269,8 +269,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
         Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.549585f, 0.556114f, 0.554256f)), 0.045f);
 
       Shininess = 0.90f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.200f, 0.200f, 0.225f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.550f, 0.550f, 0.550f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.033105f, 0.033105f, 0.041436f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.263273f, 0.263273f, 0.263273f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.975f, 0.975f, 0.975f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -281,8 +281,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
         Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.913183f, 0.921494f, 0.924524f)), 0.045f);
 
       Shininess = 0.75f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.300f, 0.300f, 0.300f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.600f, 0.600f, 0.600f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.073239f, 0.073239f, 0.073239f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.318547f, 0.318547f, 0.318547f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.910f, 0.920f, 0.920f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -293,7 +293,7 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.0f));
       Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.0f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.62f));
-      Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f, 0.90f, 0.414f));
+      Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f, 0.787412f, 0.142892f));
 
       BSDF.Kd = Graphic3d_Vec3 (0.0f);
       BSDF.Ks = Graphic3d_Vec4 (0.5f, 0.5f, 0.5f, 0.f);
@@ -304,8 +304,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       MaterialType = Graphic3d_MATERIAL_PHYSIC;
 
       Shininess = 0.3f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.054f, 0.050f, 0.066f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.183f, 0.170f, 0.225f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.004305f, 0.003936f, 0.005532f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.028053f, 0.024515f, 0.041436f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.333f, 0.329f, 0.346f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
 
@@ -316,8 +316,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       MaterialType = Graphic3d_MATERIAL_PHYSIC;
 
       Shininess = 0.10f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.135f, 0.223f, 0.158f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.540f, 0.890f, 0.630f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.016338f, 0.040729f, 0.021493f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.252950f, 0.767769f, 0.354692f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.316f, 0.316f, 0.316f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
 
@@ -329,8 +329,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       MaterialType = Graphic3d_MATERIAL_PHYSIC;
 
       Shininess = 0.01f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.050f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.150f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.003936f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.019607f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
 
@@ -348,8 +348,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       TransparencyCoef = 0.80f;
 
       Shininess = 0.90f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.450f, 0.450f, 0.475f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.050f, 0.050f, 0.075f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.170645f, 0.170645f, 0.191627f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.003936f, 0.003936f, 0.006571f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.380f, 0.380f, 0.380f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -364,8 +364,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       TransparencyCoef = 0.80f;
 
       Shininess = 0.50f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.550f, 0.575f, 0.575f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.050f, 0.075f, 0.075f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.263273f, 0.290143f, 0.290143f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.003936f, 0.006571f, 0.006571f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.920f, 0.920f, 0.920f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -380,8 +380,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       TransparencyCoef = 0.80f;
 
       Shininess = 0.90f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.550f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.100f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.263273f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.010023f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.970f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
@@ -397,22 +397,22 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
       TransparencyCoef = 0.80f;
 
       Shininess = 0.90f;
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.550f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.100f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.263273f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.010023f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.970f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
     case Graphic3d_NOM_UserDefined:
       MaterialType = Graphic3d_MATERIAL_PHYSIC;
       Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.1f));
-      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.8f));
+      Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.6f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.2f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       break;
     case Graphic3d_NOM_DEFAULT:
       MaterialType = Graphic3d_MATERIAL_ASPECT;
 
-      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.30f));
+      Colors[Graphic3d_TOR_AMBIENT]  = Quantity_Color (Graphic3d_Vec3 (0.15f));
       Colors[Graphic3d_TOR_DIFFUSE]  = Quantity_Color (Graphic3d_Vec3 (0.65f));
       Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.0f));
       Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
index 10eeb403fe98520a52e00bc7cb75da0b6fc07cce..ad9a89fb63507d28ebec36fc1a3185e93a15ad0d 100644 (file)
 #ifndef _Graphic3d_TextureMap_HeaderFile
 #define _Graphic3d_TextureMap_HeaderFile
 
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
 #include <Graphic3d_TextureRoot.hxx>
 #include <Graphic3d_TypeOfTexture.hxx>
-#include <Standard_Boolean.hxx>
 #include <Graphic3d_LevelOfTextureAnisotropy.hxx>
 class TCollection_AsciiString;
 
-
-class Graphic3d_TextureMap;
-DEFINE_STANDARD_HANDLE(Graphic3d_TextureMap, Graphic3d_TextureRoot)
-
 //! This is an abstract class for managing texture applyable on polygons.
 class Graphic3d_TextureMap : public Graphic3d_TextureRoot
 {
-
+  DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureMap, Graphic3d_TextureRoot)
 public:
 
-  
-
   //! enable texture smoothing
   Standard_EXPORT void EnableSmooth();
-  
 
   //! Returns TRUE if the texture is smoothed.
   Standard_EXPORT Standard_Boolean IsSmoothed() const;
-  
 
   //! disable texture smoothing
   Standard_EXPORT void DisableSmooth();
   
-
-  //! enable texture modulate mode.
+    //! enable texture modulate mode.
   //! the image is modulate with the shading of the surface.
   Standard_EXPORT void EnableModulate();
-  
 
   //! disable texture modulate mode.
   //! the image is directly decal on the surface.
   Standard_EXPORT void DisableModulate();
-  
 
   //! Returns TRUE if the texture is modulate.
   Standard_EXPORT Standard_Boolean IsModulate() const;
-  
 
   //! use this methods if you want to enable
   //! texture repetition on your objects.
   Standard_EXPORT void EnableRepeat();
-  
 
   //! use this methods if you want to disable
   //! texture repetition on your objects.
   Standard_EXPORT void DisableRepeat();
-  
 
   //! Returns TRUE if the texture repeat is enable.
   Standard_EXPORT Standard_Boolean IsRepeat() const;
-  
-  //! @return level of anisontropy texture filter.
+
+  //! @return level of anisotropy texture filter.
   //! Default value is Graphic3d_LOTA_OFF.
   Standard_EXPORT Graphic3d_LevelOfTextureAnisotropy AnisoFilter() const;
-  
-  //! @param theLevel level of anisontropy texture filter.
-  Standard_EXPORT void SetAnisoFilter (const Graphic3d_LevelOfTextureAnisotropy theLevel);
-
-
 
-
-  DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureMap,Graphic3d_TextureRoot)
+  //! @param theLevel level of anisotropy texture filter.
+  Standard_EXPORT void SetAnisoFilter (const Graphic3d_LevelOfTextureAnisotropy theLevel);
 
 protected:
 
-  
   Standard_EXPORT Graphic3d_TextureMap(const TCollection_AsciiString& theFileName, const Graphic3d_TypeOfTexture theType);
   
   Standard_EXPORT Graphic3d_TextureMap(const Handle(Image_PixMap)& thePixMap, const Graphic3d_TypeOfTexture theType);
 
-
-
-private:
-
-
-
-
 };
 
-
-
-
-
-
+DEFINE_STANDARD_HANDLE(Graphic3d_TextureMap, Graphic3d_TextureRoot)
 
 #endif // _Graphic3d_TextureMap_HeaderFile
index 5ea41b2f4674e71a93bb162120a7e4ca52847de6..919086c5c3f440bb81988f79c589d713f01b9bc2 100644 (file)
@@ -89,7 +89,8 @@ Graphic3d_TextureRoot::Graphic3d_TextureRoot (const TCollection_AsciiString& the
 : myParams   (new Graphic3d_TextureParams()),
   myPath     (theFileName),
   myRevision (0),
-  myType     (theType)
+  myType     (theType),
+  myIsColorMap (true)
 {
   generateId();
 }
@@ -103,7 +104,8 @@ Graphic3d_TextureRoot::Graphic3d_TextureRoot (const Handle(Image_PixMap)&   theP
 : myParams   (new Graphic3d_TextureParams()),
   myPixMap   (thePixMap),
   myRevision (0),
-  myType     (theType)
+  myType     (theType),
+  myIsColorMap (true)
 {
   generateId();
 }
index 90cb639dc531c613ff42fcfd28e8816340166bdf..6240bdee5531a369b474ce4e919a853c3df1dd30 100644 (file)
@@ -91,6 +91,19 @@ public:
   //! @return low-level texture parameters
   const Handle(Graphic3d_TextureParams)& GetParams() const { return myParams; }
 
+  //! Return flag indicating color nature of values within the texture; TRUE by default.
+  //!
+  //! This flag will be used to interpret 8-bit per channel RGB(A) images as sRGB(A) textures
+  //! with implicit linearizion of color components.
+  //! Has no effect on images with floating point values (always considered linearized).
+  //!
+  //! When set to FALSE, such images will be interpreted as textures will be linear component values,
+  //! which is useful for RGB(A) textures defining non-color properties (like Normalmap/Metalness/Roughness).
+  Standard_Boolean IsColorMap() const { return myIsColorMap; }
+
+  //! Set flag indicating color nature of values within the texture.
+  void SetColorMap (Standard_Boolean theIsColor) { myIsColorMap = theIsColor; }
+
 protected:
 
   //! Creates a texture from a file
@@ -114,6 +127,7 @@ protected:
   OSD_Path                        myPath;     //!< image file path - as one of the ways for defining the texture source
   Standard_Size                   myRevision; //!< image revision - for signaling changes in the texture source (e.g. file update, pixmap update)
   Graphic3d_TypeOfTexture         myType;     //!< texture type
+  Standard_Boolean                myIsColorMap; //!< flag indicating color nature of values within the texture
 
 };
 
index 3c0b3c1f52679ced202e027879436b917277e042..097c53816aed971dcc7779f8d999012b04e61fe1 100644 (file)
@@ -29,6 +29,7 @@ enum Graphic3d_TypeOfLimit
   Graphic3d_TypeOfLimit_HasRayTracingTextures,          //!< indicates whether ray tracing textures are supported
   Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSampling,  //!< indicates whether adaptive screen sampling is supported
   Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSamplingAtomic,//!< indicates whether optimized adaptive screen sampling is supported (hardware supports atomic float operations)
+  Graphic3d_TypeOfLimit_HasSRGB,                        //!< indicates whether sRGB rendering is supported
   Graphic3d_TypeOfLimit_HasBlendedOit,                  //!< indicates whether necessary GL extensions for Weighted, Blended OIT available (without MSAA).
   Graphic3d_TypeOfLimit_HasBlendedOitMsaa,              //!< indicates whether necessary GL extensions for Weighted, Blended OIT available (with MSAA).
   Graphic3d_TypeOfLimit_HasFlatShading,                 //!< indicates whether Flat shading (Graphic3d_TOSM_FACET) is supported
index 635cea9a20db745b9fea8e4ddbb729bc6a1dd372..4d2e7964ecf3c6f4eb04bdade10cfd3dd3f65004 100644 (file)
@@ -218,7 +218,7 @@ Standard_Boolean IGESCAFControl_Reader::Transfer (Handle(TDocStd_Document) &doc)
             checkColorRange ( r );
             checkColorRange ( g );
             checkColorRange ( b );
-            col.SetValues ( 0.01*r, 0.01*g, 0.01*b, Quantity_TOC_RGB );
+            col.SetValues ( 0.01*r, 0.01*g, 0.01*b, Quantity_TOC_sRGB );
           }
         }
       }
index fff75cc4d83e0fea7181705ca31128bf558a6494..2314700a80676ca662523faab6090d811d7ddd3b 100644 (file)
@@ -308,7 +308,9 @@ void IGESCAFControl_Writer::MakeColors (const TopoDS_Shape &S,
        Handle(TCollection_HAsciiString) str = 
          new TCollection_HAsciiString ( col.StringName ( col.Name() ) );
        colent = new IGESGraph_Color;
-       colent->Init ( col.Red() * 100., col.Green() * 100., col.Blue() * 100., str );
+       NCollection_Vec3<Standard_Real> aColor_sRGB;
+       col.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
+       colent->Init ( aColor_sRGB.r() * 100., aColor_sRGB.g() * 100., aColor_sRGB.b() * 100., str );
        AddEntity ( colent );
        colors.Bind ( c, colent );
       }
index 8856854542223bf73fa28bd9a7bf6f4c592abff0..cd816e2070a92981dd5f4701e5a54ebc1b59dcea 100644 (file)
@@ -786,7 +786,7 @@ Handle(Graphic3d_Texture2D) MeshVS_NodalColorPrsBuilder::CreateTexture() const
 
   // create and fill image with colors
   Handle(Image_PixMap) anImage = new Image_PixMap();
-  if (!anImage->InitTrash (Image_Format_RGBA, Standard_Size(getNearestPow2 (aColorsNb)), 2))
+  if (!anImage->InitTrash (Image_Format_RGBA, Standard_Size(getNearestPow2 (aColorsNb)), 2)) /// TODO
   {
     return NULL;
   }
index e845d9ece02274f39176a8b4522348b19077ec38..ae37617848bd0d6fc4fbc4efbe79e2ac625641d8 100644 (file)
@@ -71,13 +71,15 @@ Standard_Boolean operator== ( const MeshVS_TwoColors& K1,
 MeshVS_TwoColors BindTwoColors ( const Quantity_Color& theCol1, const Quantity_Color& theCol2 )
 {
   MeshVS_TwoColors aRes;
-
-  aRes.r1 = unsigned ( theCol1.Red()   * 255.0 );
-  aRes.g1 = unsigned ( theCol1.Green() * 255.0 );
-  aRes.b1 = unsigned ( theCol1.Blue()  * 255.0 );
-  aRes.r2 = unsigned ( theCol2.Red()   * 255.0 );
-  aRes.g2 = unsigned ( theCol2.Green() * 255.0 );
-  aRes.b2 = unsigned ( theCol2.Blue()  * 255.0 );
+  NCollection_Vec3<Standard_Real> aColor_sRGB;
+  theCol1.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
+  aRes.r1 = unsigned ( aColor_sRGB.r() * 255.0 );
+  aRes.g1 = unsigned ( aColor_sRGB.g() * 255.0 );
+  aRes.b1 = unsigned ( aColor_sRGB.b() * 255.0 );
+  theCol2.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
+  aRes.r2 = unsigned ( aColor_sRGB.r() * 255.0 );
+  aRes.g2 = unsigned ( aColor_sRGB.g() * 255.0 );
+  aRes.b2 = unsigned ( aColor_sRGB.b() * 255.0 );
 
   return aRes;
 }
@@ -94,11 +96,11 @@ Quantity_Color ExtractColor ( MeshVS_TwoColors& theTwoColors, const Standard_Int
   if ( Index == 1 )
     aRes.SetValues ( Standard_Real (theTwoColors.r1) / max,
                      Standard_Real (theTwoColors.g1) / max,
-                     Standard_Real (theTwoColors.b1) / max, Quantity_TOC_RGB );
+                     Standard_Real (theTwoColors.b1) / max, Quantity_TOC_sRGB );
   else if (Index == 2)
     aRes.SetValues ( Standard_Real (theTwoColors.r2) / max,
                      Standard_Real (theTwoColors.g2) / max,
-                     Standard_Real (theTwoColors.b2) / max, Quantity_TOC_RGB );
+                     Standard_Real (theTwoColors.b2) / max, Quantity_TOC_sRGB );
 
   return aRes;
 }
@@ -112,8 +114,8 @@ void ExtractColors ( MeshVS_TwoColors& theTwoColors, Quantity_Color& theCol1, Qu
   Standard_Real max = 255.0;
   theCol1.SetValues ( Standard_Real (theTwoColors.r1) / max,
                       Standard_Real (theTwoColors.g1) / max,
-                      Standard_Real (theTwoColors.b1) / max, Quantity_TOC_RGB );
+                      Standard_Real (theTwoColors.b1) / max, Quantity_TOC_sRGB );
   theCol2.SetValues ( Standard_Real (theTwoColors.r2) / max,
                       Standard_Real (theTwoColors.g2) / max,
-                      Standard_Real (theTwoColors.b2) / max, Quantity_TOC_RGB );
+                      Standard_Real (theTwoColors.b2) / max, Quantity_TOC_sRGB );
 }
index b0c1962b8d9bc0a2ea84426be0699864c8c4566d..57b56c0a84d92bfce26c91f3e2749dec628c36f1 100755 (executable)
@@ -52,6 +52,8 @@ OpenGl_FrameBuffer.hxx
 OpenGl_FrameBuffer.cxx
 OpenGl_Texture.cxx
 OpenGl_Texture.hxx
+OpenGl_TextureFormat.cxx
+OpenGl_TextureFormat.hxx
 OpenGl_TextureSet.cxx
 OpenGl_TextureSet.hxx
 OpenGl_Resource.hxx
index 646f7281cb8793484b65d3d5f4c78ffa35fae585..abaa6db0118968fce4d77127d4b174d5817a38b6 100644 (file)
@@ -1767,7 +1767,7 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
 
     theMarkerSize = Max ((Standard_ShortReal )anImage->Width(),(Standard_ShortReal )anImage->Height());
 
-    aSprite->Init (theCtx, *anImage.operator->(), Graphic3d_TOT_2D);
+    aSprite->Init (theCtx, *anImage, Graphic3d_TOT_2D, true);
     if (!hadAlreadyAlpha)
     {
       if (anImageA.IsNull()
@@ -1778,7 +1778,7 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
       }
       if (!anImageA.IsNull())
       {
-        aSpriteA->Init (theCtx, *anImageA.operator->(), Graphic3d_TOT_2D);
+        aSpriteA->Init (theCtx, *anImageA, Graphic3d_TOT_2D, true);
       }
     }
   }
index cf49fe12449b2febce7f70ad5d35e1b63c7f40cd..6796992caa1d6b6cd2d4be7add795d48a181f833 100644 (file)
@@ -34,9 +34,6 @@ OpenGl_BackgroundArray::OpenGl_BackgroundArray (const Graphic3d_TypeOfBackground
   myViewHeight (0),
   myToUpdate (Standard_False)
 {
-  Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
-  myAttribs = new Graphic3d_Buffer (anAlloc);
-
   myDrawMode = GL_TRIANGLE_STRIP;
   myIsFillType = true;
 
@@ -140,11 +137,12 @@ void OpenGl_BackgroundArray::invalidateData()
 // =======================================================================
 Standard_Boolean OpenGl_BackgroundArray::init (const Handle(OpenGl_Workspace)& theWorkspace) const
 {
+  const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
   switch (myType)
   {
     case Graphic3d_TOB_GRADIENT:
     {
-      if (!createGradientArray())
+      if (!createGradientArray (aCtx))
       {
         return Standard_False;
       }
@@ -174,7 +172,6 @@ Standard_Boolean OpenGl_BackgroundArray::init (const Handle(OpenGl_Workspace)& t
   }
 
   // Init VBO
-  const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
   if (myIsVboInit)
   {
     clearMemoryGL (aCtx);
@@ -191,7 +188,7 @@ Standard_Boolean OpenGl_BackgroundArray::init (const Handle(OpenGl_Workspace)& t
 // method  : createGradientArray
 // purpose :
 // =======================================================================
-Standard_Boolean OpenGl_BackgroundArray::createGradientArray() const
+Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenGl_Context)& theCtx) const
 {
   // Initialize data for primitive array
   Graphic3d_Attribute aGragientAttribInfo[] =
@@ -200,6 +197,11 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray() const
     { Graphic3d_TOA_COLOR, Graphic3d_TOD_VEC3 }
   };
 
+  if (myAttribs.IsNull())
+  {
+    Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
+    myAttribs = new Graphic3d_Buffer (anAlloc);
+  }
   if (!myAttribs->Init (4, aGragientAttribInfo, 2))
   {
     return Standard_False;
@@ -311,7 +313,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray() const
     *aVertData = aVertices[anIt];
 
     OpenGl_Vec3* aColorData = reinterpret_cast<OpenGl_Vec3* >(myAttribs->changeValue (anIt) + myAttribs->AttributeOffset (1));
-    *aColorData = OpenGl_Vec3(aCorners[anIt][0], aCorners[anIt][1], aCorners[anIt][2]);
+    *aColorData = theCtx->Vec4FromQuantityColor (OpenGl_Vec4(aCorners[anIt][0], aCorners[anIt][1], aCorners[anIt][2], 1.0f)).rgb();
   }
 
   return Standard_True;
@@ -329,6 +331,11 @@ Standard_Boolean OpenGl_BackgroundArray::createTextureArray (const Handle(OpenGl
     { Graphic3d_TOA_UV,  Graphic3d_TOD_VEC2 }
   };
 
+  if (myAttribs.IsNull())
+  {
+    Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
+    myAttribs = new Graphic3d_Buffer (anAlloc);
+  }
   if (!myAttribs->Init (4, aTextureAttribInfo, 2))
   {
     return Standard_False;
@@ -397,6 +404,11 @@ Standard_Boolean OpenGl_BackgroundArray::createCubeMapArray() const
     { Graphic3d_TOA_POS, Graphic3d_TOD_VEC2}
   };
 
+  if (myAttribs.IsNull())
+  {
+    Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
+    myAttribs = new Graphic3d_Buffer (anAlloc);
+  }
   if (!myAttribs->Init(4, aCubeMapAttribInfo, 1))
   {
     return Standard_False;
@@ -428,7 +440,9 @@ void OpenGl_BackgroundArray::Render (const Handle(OpenGl_Workspace)& theWorkspac
   }
   if (myToUpdate
    || myViewWidth  != aViewSizeX
-   || myViewHeight != aViewSizeY)
+   || myViewHeight != aViewSizeY
+   || myAttribs.IsNull()
+   || myVboAttribs.IsNull())
   {
     myViewWidth  = aViewSizeX;
     myViewHeight = aViewSizeY;
index 65e2b4a83d1dbe7dc683ebbabcfc1611233adc39..c662ebfc9cb4086f75e005d836ecaaf75ebcced9 100644 (file)
@@ -79,7 +79,7 @@ protected:
   Standard_EXPORT Standard_Boolean init (const Handle(OpenGl_Workspace)& theWorkspace) const;
 
   //! Initializes gradient arrays.
-  Standard_EXPORT Standard_Boolean createGradientArray() const;
+  Standard_EXPORT Standard_Boolean createGradientArray (const Handle(OpenGl_Context)& theCtx) const;
 
   //! Initializes texture arrays.
   //! @param theWorkspace OpenGl workspace that stores texture in the current enabled face aspect.
index b1b5d152a257371d771af0594a711b06a55b499f..d352e9b2b8afa71a1d3a70cbec2d8716dac523e0 100755 (executable)
@@ -17,7 +17,6 @@
 
 #include <OpenGl_GlCore20.hxx>
 
-
 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Caps,Standard_Transient)
 
 // =======================================================================
@@ -25,7 +24,8 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Caps,Standard_Transient)
 // purpose  :
 // =======================================================================
 OpenGl_Caps::OpenGl_Caps()
-: vboDisable        (Standard_False),
+: sRGBDisable       (Standard_False),
+  vboDisable        (Standard_False),
   pntSpritesDisable (Standard_False),
   keepArrayData     (Standard_False),
   ffpEnable         (Standard_False),
@@ -67,6 +67,7 @@ OpenGl_Caps::OpenGl_Caps()
 // =======================================================================
 OpenGl_Caps& OpenGl_Caps::operator= (const OpenGl_Caps& theCopy)
 {
+  sRGBDisable       = theCopy.sRGBDisable;
   vboDisable        = theCopy.vboDisable;
   pntSpritesDisable = theCopy.pntSpritesDisable;
   keepArrayData     = theCopy.keepArrayData;
index d5747be4c14a35a140a2571c6696acf6752ff79e..e0b123c1df23a80e1d92eea8556b5967087d3050 100755 (executable)
@@ -27,7 +27,8 @@ class OpenGl_Caps : public Standard_Transient
 
 public: //! @name flags to disable particular functionality, should be used only for testing purposes!
 
-  Standard_Boolean vboDisable;        //!< flag permits VBO usage, will significantly affect performance (OFF by default)
+  Standard_Boolean sRGBDisable;       //!< Disables sRGB rendering (OFF by default)
+  Standard_Boolean vboDisable;        //!< disallow VBO usage for debugging purposes (OFF by default)
   Standard_Boolean pntSpritesDisable; //!< flag permits Point Sprites usage, will significantly affect performance (OFF by default)
   Standard_Boolean keepArrayData;     //!< Disables freeing CPU memory after building VBOs (OFF by default)
   Standard_Boolean ffpEnable;         //!< Enables FFP (fixed-function pipeline), do not use built-in GLSL programs (OFF by default)
index 702ed31aaf9b211860b880656ac66a613039139a..6536a7033e202dd7c77eb9734a25dc9dee709ec4 100644 (file)
@@ -116,11 +116,16 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
   hasHighp   (Standard_False),
   hasUintIndex(Standard_False),
   hasTexRGBA8(Standard_False),
-  hasFlatShading (OpenGl_FeatureNotAvailable),
 #else
   hasHighp   (Standard_True),
   hasUintIndex(Standard_True),
   hasTexRGBA8(Standard_True),
+#endif
+  hasTexSRGB (Standard_False),
+  hasFboSRGB (Standard_False),
+#if defined(GL_ES_VERSION_2_0)
+  hasFlatShading (OpenGl_FeatureNotAvailable),
+#else
   hasFlatShading (OpenGl_FeatureInCore),
 #endif
   hasGlslBitwiseOps  (OpenGl_FeatureNotAvailable),
@@ -464,6 +469,29 @@ void OpenGl_Context::SetDrawBuffers (const Standard_Integer theNb, const Standar
   myFuncs->glDrawBuffers (theNb, (const GLenum*)theDrawBuffers);
 }
 
+// =======================================================================
+// function : SetFrameBufferSRGB
+// purpose  :
+// =======================================================================
+void OpenGl_Context::SetFrameBufferSRGB()
+{
+#if !defined(GL_ES_VERSION_2_0)
+  if (!hasFboSRGB)
+  {
+    return;
+  }
+
+  if (ToRenderSRGB())
+  {
+    core11fwd->glEnable (GL_FRAMEBUFFER_SRGB);
+  }
+  else
+  {
+    core11fwd->glDisable (GL_FRAMEBUFFER_SRGB);
+  }
+#endif
+}
+
 // =======================================================================
 // function : SetCullBackFaces
 // purpose  :
@@ -1349,6 +1377,8 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
 
   hasTexRGBA8 = IsGlGreaterEqual (3, 0)
              || CheckExtension ("GL_OES_rgb8_rgba8");
+  hasTexSRGB  = IsGlGreaterEqual (3, 0);
+  hasFboSRGB  = IsGlGreaterEqual (3, 0);
   // NPOT textures has limited support within OpenGL ES 2.0
   // which are relaxed by OpenGL ES 3.0 or some extensions
   //arbNPTW     = IsGlGreaterEqual (3, 0)
@@ -1506,6 +1536,8 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
   myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP;
 
   hasTexRGBA8 = Standard_True;
+  hasTexSRGB       = IsGlGreaterEqual (2, 0);
+  hasFboSRGB       = IsGlGreaterEqual (2, 1);
   arbDrawBuffers   = CheckExtension ("GL_ARB_draw_buffers");
   arbNPTW          = CheckExtension ("GL_ARB_texture_non_power_of_two");
   arbTexFloat      = IsGlGreaterEqual (3, 0)
@@ -3400,10 +3432,10 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_Aspects* theAspect,
                                        ? anAspect->BackInteriorColor()
                                        : aFrontIntColor;
 
-  myMatFront.Init (aMatFrontSrc, aFrontIntColor);
+  myMatFront.Init (*this, aMatFrontSrc, aFrontIntColor);
   if (toDistinguish)
   {
-    myMatBack.Init (aMatBackSrc, aBackIntColor);
+    myMatBack.Init (*this, aMatBackSrc, aBackIntColor);
   }
   else
   {
@@ -3507,7 +3539,10 @@ void OpenGl_Context::SetColor4fv (const OpenGl_Vec4& theColor)
 {
   if (!myActiveProgram.IsNull())
   {
-    myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_COLOR), theColor);
+    if (const OpenGl_ShaderUniformLocation& aLoc = myActiveProgram->GetStateLocation (OpenGl_OCCT_COLOR))
+    {
+      myActiveProgram->SetUniform (this, aLoc, Vec4FromQuantityColor (theColor));
+    }
   }
 #if !defined(GL_ES_VERSION_2_0)
   else if (core11 != NULL)
index 6c7f256a11e3a03fdc1eb3079a2644448715a5e1..e64378250d29f8f81254cf432f772caf81544e43 100644 (file)
@@ -538,6 +538,43 @@ public:
   //! @return TRUE if atomic adaptive screen sampling in ray tracing mode is supported
   Standard_Boolean HasRayTracingAdaptiveSamplingAtomic() const { return myHasRayTracingAdaptiveSamplingAtomic; }
 
+  //! Returns TRUE if sRGB rendering is supported.
+  bool HasSRGB() const
+  {
+    return hasTexSRGB
+       &&  hasFboSRGB;
+  }
+
+  //! Returns TRUE if sRGB rendering is supported and permitted.
+  bool ToRenderSRGB() const
+  {
+    return HasSRGB()
+       && !caps->sRGBDisable
+       && !caps->ffpEnable;
+  }
+
+  //! Convert Quantity_ColorRGBA into vec4.
+  OpenGl_Vec4 Vec4FromQuantityColor (const OpenGl_Vec4& theColor) const
+  {
+    return ToRenderSRGB()
+         ? Vec4LinearFromQuantityColor(theColor)
+         : Vec4sRGBFromQuantityColor  (theColor);
+  }
+
+  //! Convert Quantity_ColorRGBA into vec4.
+  const OpenGl_Vec4& Vec4LinearFromQuantityColor (const OpenGl_Vec4& theColor) const
+  {
+    // interpret Quantity_Color as linear RGB, hence conversion is NOT required
+    return theColor;
+  }
+
+  //! Convert Quantity_ColorRGBA into vec4.
+  OpenGl_Vec4 Vec4sRGBFromQuantityColor (const OpenGl_Vec4& theColor) const
+  {
+    // interpret Quantity_Color as linear RGB, hence conversion is required
+    return Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB (theColor);
+  }
+
   //! Returns true if VBO is supported and permitted.
   inline bool ToUseVbo() const
   {
@@ -688,6 +725,9 @@ public: //! @name methods to alter or retrieve current state
     SetDrawBuffer (theBuffer);
   }
 
+  //! Enables/disables GL_FRAMEBUFFER_SRGB flag.
+  Standard_EXPORT void SetFrameBufferSRGB();
+
   //! Return cached flag indicating writing into color buffer is enabled or disabled (glColorMask).
   bool ColorMask() const { return myColorMask; }
 
@@ -893,6 +933,8 @@ public: //! @name extensions
   Standard_Boolean       hasHighp;           //!< highp in GLSL ES fragment shader is supported
   Standard_Boolean       hasUintIndex;       //!< GLuint for index buffer is supported (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_element_index_uint)
   Standard_Boolean       hasTexRGBA8;        //!< always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8
+  Standard_Boolean       hasTexSRGB;         //!< sRGB texture    formats (desktop OpenGL 2.0, OpenGL ES 3.0 or GL_EXT_texture_sRGB)
+  Standard_Boolean       hasFboSRGB;         //!< sRGB FBO render targets (desktop OpenGL 2.1, OpenGL ES 3.0)
   OpenGl_FeatureFlag     hasFlatShading;     //!< Complex flag indicating support of Flat shading (Graphic3d_TOSM_FACET) (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_standard_derivatives)
   OpenGl_FeatureFlag     hasGlslBitwiseOps;  //!< GLSL supports bitwise operations; OpenGL 3.0 / OpenGL ES 3.0 (GLSL 130 / GLSL ES 300) or OpenGL 2.1 + GL_EXT_gpu_shader4
   OpenGl_FeatureFlag     hasDrawBuffers;     //!< Complex flag indicating support of multiple draw buffers (desktop OpenGL 2.0, OpenGL ES 3.0, GL_ARB_draw_buffers, GL_EXT_draw_buffers)
index 34ddf425ab03691e3d74650939769fcfd1552a5d..99471b8a11605a6e7faf1e28a7cd8cf25b7b09d9 100755 (executable)
@@ -147,15 +147,11 @@ bool OpenGl_Font::createTexture (const Handle(OpenGl_Context)& theCtx)
 
   Image_PixMap aBlackImg;
   if (!aBlackImg.InitZero (Image_Format_Alpha, Standard_Size(aTextureSizeX), Standard_Size(aTextureSizeY))
-   || !aTexture->Init (theCtx, aBlackImg, Graphic3d_TOT_2D)) // myTextureFormat
+   || !aTexture->Init (theCtx, aBlackImg, Graphic3d_TOT_2D, true)) // myTextureFormat
   {
-    TCollection_ExtendedString aMsg;
-    aMsg += "New texture initialization of size ";
-    aMsg += aTextureSizeX;
-    aMsg += "x";
-    aMsg += aTextureSizeY;
-    aMsg += " for textured font has failed.";
-    theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
+    theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+                         TCollection_AsciiString ("New texture initialization of size ")
+                       + aTextureSizeX + "x" + aTextureSizeY + " for textured font has failed.");
     return false;
   }
 
index a3fa54f032ab1216dea685dc84342e14c3cc7f8e..30bff9a79875311177cee2932985065bfd287b9c 100644 (file)
@@ -40,119 +40,6 @@ namespace
   }
 }
 
-// =======================================================================
-// function : getDepthDataFormat
-// purpose  :
-// =======================================================================
-bool OpenGl_FrameBuffer::getDepthDataFormat (GLint   theTextFormat,
-                                             GLenum& thePixelFormat,
-                                             GLenum& theDataType)
-{
-  switch (theTextFormat)
-  {
-    case GL_DEPTH24_STENCIL8:
-    {
-      thePixelFormat = GL_DEPTH_STENCIL;
-      theDataType    = GL_UNSIGNED_INT_24_8;
-      return true;
-    }
-    case GL_DEPTH32F_STENCIL8:
-    {
-      thePixelFormat = GL_DEPTH_STENCIL;
-      theDataType    = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
-      return true;
-    }
-    case GL_DEPTH_COMPONENT16:
-    {
-      thePixelFormat = GL_DEPTH_COMPONENT;
-      theDataType    = GL_UNSIGNED_SHORT;
-      return true;
-    }
-    case GL_DEPTH_COMPONENT24:
-    {
-      thePixelFormat = GL_DEPTH_COMPONENT;
-      theDataType    = GL_UNSIGNED_INT;
-      return true;
-    }
-    case GL_DEPTH_COMPONENT32F:
-    {
-      thePixelFormat = GL_DEPTH_COMPONENT;
-      theDataType    = GL_FLOAT;
-      return true;
-    }
-  }
-  return false;
-}
-
-// =======================================================================
-// function : getColorDataFormat
-// purpose  :
-// =======================================================================
-bool OpenGl_FrameBuffer::getColorDataFormat (const Handle(OpenGl_Context)& theGlContext,
-                                             GLint   theTextFormat,
-                                             GLenum& thePixelFormat,
-                                             GLenum& theDataType)
-{
-  switch (theTextFormat)
-  {
-    case GL_RGBA32F:
-    {
-      thePixelFormat = GL_RGBA;
-      theDataType    = GL_FLOAT;
-      return true;
-    }
-    case GL_R32F:
-    {
-      thePixelFormat = GL_RED;
-      theDataType    = GL_FLOAT;
-      return true;
-    }
-    case GL_RGBA16F:
-    {
-      thePixelFormat = GL_RGBA;
-      theDataType    = GL_HALF_FLOAT;
-      if (theGlContext->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
-      {
-      #if defined(GL_ES_VERSION_2_0)
-        theDataType = GL_HALF_FLOAT_OES;
-      #else
-        theDataType = GL_FLOAT;
-      #endif
-      }
-      return true;
-    }
-    case GL_R16F:
-    {
-      thePixelFormat = GL_RED;
-      theDataType    = GL_HALF_FLOAT;
-      if (theGlContext->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
-      {
-      #if defined(GL_ES_VERSION_2_0)
-        theDataType = GL_HALF_FLOAT_OES;
-      #else
-        theDataType = GL_FLOAT;
-      #endif
-      }
-      return true;
-    }
-    case GL_RGBA8:
-    case GL_RGBA:
-    {
-      thePixelFormat = GL_RGBA;
-      theDataType    = GL_UNSIGNED_BYTE;
-      return true;
-    }
-    case GL_RGB8:
-    case GL_RGB:
-    {
-      thePixelFormat = GL_RGB;
-      theDataType = GL_UNSIGNED_BYTE;
-      return true;
-    }
-  }
-  return false;
-}
-
 // =======================================================================
 // function : OpenGl_FrameBuffer
 // purpose  :
@@ -265,7 +152,7 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo
       && !aColorTexture->Init2DMultisample (theGlContext, theNbSamples,
                                             aColorFormat, aSizeX, aSizeY))
       {
-        Release (theGlContext.operator->());
+        Release (theGlContext.get());
         return Standard_False;
       }
     }
@@ -274,17 +161,13 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo
   {
     for (Standard_Integer aColorBufferIdx = 0; aColorBufferIdx < myColorTextures.Length(); ++aColorBufferIdx)
     {
-      GLenum aPixelFormat = 0;
-      GLenum aDataType    = 0;
       const Handle(OpenGl_Texture)& aColorTexture = myColorTextures (aColorBufferIdx);
       const GLint                   aColorFormat  = myColorFormats  (aColorBufferIdx);
-      if (aColorFormat != 0
-      &&  getColorDataFormat (theGlContext, aColorFormat, aPixelFormat, aDataType)
-      && !aColorTexture->Init (theGlContext, aColorFormat,
-                               aPixelFormat, aDataType,
-                               aSizeX, aSizeY, Graphic3d_TOT_2D))
+      const OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindSizedFormat (theGlContext, aColorFormat);
+      if (aFormat.IsValid()
+      && !aColorTexture->Init (theGlContext, aFormat, Graphic3d_Vec2i (aSizeX, aSizeY), Graphic3d_TOT_2D))
       {
-        Release (theGlContext.operator->());
+        Release (theGlContext.get());
         return Standard_False;
       }
     }
@@ -402,18 +285,13 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo
   }
   else
   {
-    GLenum aPixelFormat = 0;
-    GLenum aDataType    = 0;
-
     for (Standard_Integer aColorBufferIdx = 0; aColorBufferIdx < myColorTextures.Length(); ++aColorBufferIdx)
     {
       const Handle(OpenGl_Texture)& aColorTexture = myColorTextures (aColorBufferIdx);
       const GLint                   aColorFormat  = myColorFormats  (aColorBufferIdx);
-      if (aColorFormat != 0
-      &&  getColorDataFormat (theGlContext, aColorFormat, aPixelFormat, aDataType)
-      && !aColorTexture->Init (theGlContext, aColorFormat,
-                               aPixelFormat, aDataType,
-                               aSizeX, aSizeY, Graphic3d_TOT_2D))
+      const OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindSizedFormat (theGlContext, aColorFormat);
+      if (aFormat.IsValid()
+      && !aColorTexture->Init (theGlContext, aFormat, Graphic3d_Vec2i (aSizeX, aSizeY), Graphic3d_TOT_2D))
       {
         Release (theGlContext.operator->());
         return Standard_False;
@@ -422,21 +300,14 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo
 
     // extensions (GL_OES_packed_depth_stencil, GL_OES_depth_texture) + GL version might be used to determine supported formats
     // instead of just trying to create such texture
-    if (myDepthFormat != 0
-    &&  getDepthDataFormat (myDepthFormat, aPixelFormat, aDataType)
-    && !myDepthStencilTexture->Init (theGlContext, myDepthFormat,
-                                      aPixelFormat, aDataType,
-                                      aSizeX, aSizeY, Graphic3d_TOT_2D))
+    const OpenGl_TextureFormat aDepthFormat = OpenGl_TextureFormat::FindSizedFormat (theGlContext, myDepthFormat);
+    if (aDepthFormat.IsValid()
+    && !myDepthStencilTexture->Init (theGlContext, aDepthFormat, Graphic3d_Vec2i (aSizeX, aSizeY), Graphic3d_TOT_2D))
     {
-      TCollection_ExtendedString aMsg = TCollection_ExtendedString()
-        + "Warning! Depth textures are not supported by hardware!";
-      theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
-                                 GL_DEBUG_TYPE_PORTABILITY,
-                                 0,
-                                 GL_DEBUG_SEVERITY_HIGH,
-                                 aMsg);
-
-      hasStencilRB = aPixelFormat == GL_DEPTH_STENCIL
+      theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
+                                 "Warning! Depth textures are not supported by hardware!");
+
+      hasStencilRB = aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL
                   && theGlContext->extPDS;
       GLint aDepthStencilFormat = hasStencilRB
                                 ? GL_DEPTH24_STENCIL8
@@ -599,10 +470,8 @@ Standard_Boolean OpenGl_FrameBuffer::InitWithRB (const Handle(OpenGl_Context)& t
   bool hasStencilRB = false;
   if (myDepthFormat != 0)
   {
-    GLenum aPixelFormat = 0;
-    GLenum aDataType    = 0;
-    getDepthDataFormat (myDepthFormat, aPixelFormat, aDataType);
-    hasStencilRB = aPixelFormat == GL_DEPTH_STENCIL;
+    const OpenGl_TextureFormat aDepthFormat = OpenGl_TextureFormat::FindSizedFormat (theGlCtx, myDepthFormat);
+    hasStencilRB = aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL;
 
     theGlCtx->arbFBO->glGenRenderbuffers (1, &myGlDepthRBufferId);
     theGlCtx->arbFBO->glBindRenderbuffer (GL_RENDERBUFFER, myGlDepthRBufferId);
@@ -789,6 +658,7 @@ void OpenGl_FrameBuffer::ChangeViewport (const GLsizei theVPSizeX,
 void OpenGl_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theGlCtx)
 {
   theGlCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, myGlFBufferId);
+  theGlCtx->SetFrameBufferSRGB();
 }
 
 // =======================================================================
@@ -798,6 +668,7 @@ void OpenGl_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theGlCtx)
 void OpenGl_FrameBuffer::BindDrawBuffer (const Handle(OpenGl_Context)& theGlCtx)
 {
   theGlCtx->arbFBO->glBindFramebuffer (GL_DRAW_FRAMEBUFFER, myGlFBufferId);
+  theGlCtx->SetFrameBufferSRGB();
 }
 
 // =======================================================================
@@ -823,6 +694,7 @@ void OpenGl_FrameBuffer::UnbindBuffer (const Handle(OpenGl_Context)& theGlCtx)
   else
   {
     theGlCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, NO_FRAMEBUFFER);
+    theGlCtx->SetFrameBufferSRGB();
   }
 }
 
index 4b7cd222af0dc514ce6a13955740c2605555ab56..1fef00a3db75a4c1a2d678714c1547259e182c23 100644 (file)
@@ -269,19 +269,6 @@ protected:
     return myGlFBufferId != NO_FRAMEBUFFER;
   }
 
-protected:
-
-  //! Determine data type from texture sized format.
-  Standard_EXPORT static bool getDepthDataFormat (GLint   theTextFormat,
-                                                  GLenum& thePixelFormat,
-                                                  GLenum& theDataType);
-
-  //! Determine data type from texture sized format.
-  Standard_EXPORT static bool getColorDataFormat (const Handle(OpenGl_Context)& theCtx,
-                                                  GLint   theTextFormat,
-                                                  GLenum& thePixelFormat,
-                                                  GLenum& theDataType);
-
 protected:
 
   typedef NCollection_Vector<Handle(OpenGl_Texture)> OpenGl_TextureArray;
index b5afc254ee7655699505112628b4db04832b5b73..1dddb00d591a8166ad5d95df68cdd054b3985d9a 100644 (file)
@@ -408,6 +408,8 @@ Standard_Integer OpenGl_GraphicDriver::InquireLimit (const Graphic3d_TypeOfLimit
       return (!aCtx.IsNull() && aCtx->HasRayTracingAdaptiveSampling()) ? 1 : 0;
     case Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSamplingAtomic:
       return (!aCtx.IsNull() && aCtx->HasRayTracingAdaptiveSamplingAtomic()) ? 1 : 0;
+    case Graphic3d_TypeOfLimit_HasSRGB:
+      return (!aCtx.IsNull() && aCtx->HasSRGB()) ? 1 : 0;
     case Graphic3d_TypeOfLimit_HasBlendedOit:
       return (!aCtx.IsNull()
             && aCtx->hasDrawBuffers != OpenGl_FeatureNotAvailable
index 70695a707c9186075ffac7c558d273db47beed48..79ef0668d281a4d938749e27d2d4b5d06b3737d2 100644 (file)
@@ -19,6 +19,8 @@
 #include <Graphic3d_MaterialAspect.hxx>
 #include <OpenGl_Vec.hxx>
 
+class OpenGl_Context;
+
 //! OpenGL material definition
 struct OpenGl_Material
 {
@@ -52,8 +54,9 @@ struct OpenGl_Material
     Params  (1.0f, 0.0f, 0.0f, 0.0f) {}
 
   //! Initialize material
-  void Init (const Graphic3d_MaterialAspect& theProp,
-             const Quantity_Color&           theInteriorColor);
+  void Init (const OpenGl_Context& theCtx,
+             const Graphic3d_MaterialAspect& theProp,
+             const Quantity_Color& theInteriorColor);
 
   //! Returns packed (serialized) representation of material properties
   const OpenGl_Vec4* Packed() const { return reinterpret_cast<const OpenGl_Vec4*> (this); }
index 4bc3ab1a98d8e565992000da660122665e8b9aac..b9e0eb80478817983b9d44b836c08963475a5b26 100644 (file)
@@ -408,6 +408,7 @@ OpenGl_ShaderManager::OpenGl_ShaderManager (OpenGl_Context* theContext)
   myShadingModel (Graphic3d_TOSM_VERTEX),
   myUnlitPrograms (new OpenGl_SetOfPrograms()),
   myContext  (theContext),
+  mySRgbState (theContext->ToRenderSRGB()),
   myHasLocalOrigin (Standard_False),
   myLastView (NULL)
 {
@@ -562,6 +563,23 @@ void OpenGl_ShaderManager::switchLightPrograms()
   }
 }
 
+// =======================================================================
+// function : UpdateSRgbState
+// purpose  :
+// =======================================================================
+void OpenGl_ShaderManager::UpdateSRgbState()
+{
+  if (mySRgbState == myContext->ToRenderSRGB())
+  {
+    return;
+  }
+
+  mySRgbState = myContext->ToRenderSRGB();
+
+  // special cases - GLSL programs dealing with sRGB/linearRGB internally
+  myStereoPrograms[Graphic3d_StereoMode_Anaglyph].Nullify();
+}
+
 // =======================================================================
 // function : UpdateLightSourceStateTo
 // purpose  : Updates state of OCCT light sources
@@ -744,6 +762,8 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr
       continue;
     }
 
+    // ignoring OpenGl_Context::ToRenderSRGB() for light colors,
+    // as non-absolute colors for lights are rare and require tuning anyway
     aLightType.Type        = aLight.Type();
     aLightType.IsHeadlight = aLight.IsHeadlight();
     aLightParams.Color     = aLight.PackedColor();
@@ -1227,7 +1247,7 @@ void OpenGl_ShaderManager::PushInteriorState (const Handle(OpenGl_ShaderProgram)
     }
     else
     {
-      theProgram->SetUniform (myContext, aLocWireframeColor, theAspect->EdgeColorRGBA());
+      theProgram->SetUniform (myContext, aLocWireframeColor, myContext->Vec4FromQuantityColor (theAspect->EdgeColorRGBA()));
     }
   }
   if (const OpenGl_ShaderUniformLocation aLocQuadModeState = theProgram->GetStateLocation (OpenGl_OCCT_QUAD_MODE_STATE))
@@ -2432,19 +2452,21 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramStereo (Handle(OpenGl_Sh
       aName = "anaglyph";
       aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("mat4 uMultL", Graphic3d_TOS_FRAGMENT));
       aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("mat4 uMultR", Graphic3d_TOS_FRAGMENT));
-      aSrcFrag =
-          EOL"const vec4 THE_POW_UP   =       vec4 (2.2, 2.2, 2.2, 1.0);"
-          EOL"const vec4 THE_POW_DOWN = 1.0 / vec4 (2.2, 2.2, 2.2, 1.0);"
-          EOL
-          EOL"void main()"
-          EOL"{"
-          EOL"  vec4 aColorL = occTexture2D (uLeftSampler,  TexCoord);"
-          EOL"  vec4 aColorR = occTexture2D (uRightSampler, TexCoord);"
-          EOL"  aColorL = pow (aColorL, THE_POW_UP);" // normalize
-          EOL"  aColorR = pow (aColorR, THE_POW_UP);"
-          EOL"  vec4 aColor = uMultR * aColorR + uMultL * aColorL;"
-          EOL"  occSetFragColor (pow (aColor, THE_POW_DOWN));"
-          EOL"}";
+      const TCollection_AsciiString aNormalize = mySRgbState
+                                               ? EOL"#define sRgb2linear(theColor) theColor"
+                                                 EOL"#define linear2sRgb(theColor) theColor"
+                                               : EOL"#define sRgb2linear(theColor) pow(theColor, vec4(2.2, 2.2, 2.2, 1.0))"
+                                                 EOL"#define linear2sRgb(theColor) pow(theColor, 1.0 / vec4(2.2, 2.2, 2.2, 1.0))";
+      aSrcFrag = aNormalize
+      + EOL"void main()"
+        EOL"{"
+        EOL"  vec4 aColorL = occTexture2D (uLeftSampler,  TexCoord);"
+        EOL"  vec4 aColorR = occTexture2D (uRightSampler, TexCoord);"
+        EOL"  aColorL = sRgb2linear (aColorL);"
+        EOL"  aColorR = sRgb2linear (aColorR);"
+        EOL"  vec4 aColor = uMultR * aColorR + uMultL * aColorL;"
+        EOL"  occSetFragColor (linear2sRgb (aColor));"
+        EOL"}";
       break;
     }
     case Graphic3d_StereoMode_RowInterlaced:
index be560c083b66aff9f2f3168c1521422096779068..62dfaf7dfe1ccd8d5d984ffd50f6421ac22df441 100644 (file)
@@ -50,6 +50,9 @@ public:
   //! Release all resources.
   Standard_EXPORT void clear();
 
+  //! Fetch sRGB state from caps and invalidates programs, if necessary.
+  Standard_EXPORT void UpdateSRgbState();
+
   //! Return local camera transformation.
   const gp_XYZ& LocalOrigin() const { return myLocalOrigin; }
 
@@ -775,6 +778,7 @@ protected:
   Handle(OpenGl_VertexBuffer)        myBoundBoxVertBuffer; //!< bounding box vertex buffer
 
   OpenGl_Context*                    myContext;            //!< OpenGL context
+  Standard_Boolean                   mySRgbState;          //!< track sRGB state
 
 protected:
 
index 6a354d165a529860c75a83c956f65443d6c6ae31..a6553ac40505ba8d1b99716ae134b6f9d5e0275b 100644 (file)
@@ -177,240 +177,22 @@ bool OpenGl_Texture::InitSamplerObject (const Handle(OpenGl_Context)& theCtx)
       && mySampler->Init (theCtx, *this);
 }
 
-//=======================================================================
-//function : GetDataFormat
-//purpose  :
-//=======================================================================
-bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
-                                    const Image_Format            theFormat,
-                                    GLint&                        theTextFormat,
-                                    GLenum&                       thePixelFormat,
-                                    GLenum&                       theDataType)
-{
-  theTextFormat  = GL_RGBA8;
-  thePixelFormat = 0;
-  theDataType    = 0;
-  switch (theFormat)
-  {
-    case Image_Format_GrayF:
-    {
-      if (theCtx->core11 == NULL)
-      {
-        theTextFormat  = GL_R8;  // GL_R32F
-        thePixelFormat = GL_RED;
-      }
-      else
-      {
-      #if !defined(GL_ES_VERSION_2_0)
-        theTextFormat  = GL_LUMINANCE8;
-      #else
-        theTextFormat  = GL_LUMINANCE;
-      #endif
-        thePixelFormat = GL_LUMINANCE;
-      }
-      theDataType = GL_FLOAT;
-      return true;
-    }
-    case Image_Format_AlphaF:
-    {
-      if (theCtx->core11 == NULL)
-      {
-        theTextFormat  = GL_R8;  // GL_R32F
-        thePixelFormat = GL_RED;
-      }
-      else
-      {
-      #if !defined(GL_ES_VERSION_2_0)
-        theTextFormat  = GL_ALPHA8;
-      #else
-        theTextFormat  = GL_ALPHA;
-      #endif
-        thePixelFormat = GL_ALPHA;
-      }
-      theDataType = GL_FLOAT;
-      return true;
-    }
-    case Image_Format_RGBAF:
-    {
-      theTextFormat  = GL_RGBA8; // GL_RGBA32F
-      thePixelFormat = GL_RGBA;
-      theDataType    = GL_FLOAT;
-      return true;
-    }
-    case Image_Format_BGRAF:
-    {
-      if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
-      {
-        return false;
-      }
-      theTextFormat  = GL_RGBA8;    // GL_RGBA32F
-      thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA
-      theDataType    = GL_FLOAT;
-      return true;
-    }
-    case Image_Format_RGBF:
-    {
-      theTextFormat  = GL_RGB8; // GL_RGB32F
-      thePixelFormat = GL_RGB;
-      theDataType    = GL_FLOAT;
-      return true;
-    }
-    case Image_Format_BGRF:
-    {
-    #if !defined(GL_ES_VERSION_2_0)
-      theTextFormat  = GL_RGB8; // GL_RGB32F
-      thePixelFormat = GL_BGR;  // equals to GL_BGR_EXT
-      theDataType    = GL_FLOAT;
-      return true;
-    #else
-      return false;
-    #endif
-    }
-    case Image_Format_RGBA:
-    {
-      theTextFormat = GL_RGBA8;
-      thePixelFormat = GL_RGBA;
-      theDataType    = GL_UNSIGNED_BYTE;
-      return true;
-    }
-    case Image_Format_BGRA:
-    {
-    #if !defined(GL_ES_VERSION_2_0)
-      if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
-      {
-        return false;
-      }
-      theTextFormat  = GL_RGBA8;
-    #else
-      if (!theCtx->extBgra)
-      {
-        return false;
-      }
-      theTextFormat  = GL_BGRA_EXT;
-    #endif
-      thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA
-      theDataType    = GL_UNSIGNED_BYTE;
-      return true;
-    }
-    case Image_Format_RGB32:
-    {
-    #if !defined(GL_ES_VERSION_2_0)
-      // ask driver to convert data to RGB8 to save memory
-      theTextFormat  = GL_RGB8;
-    #else
-      // conversion is not supported
-      theTextFormat  = GL_RGBA8;
-    #endif
-      thePixelFormat = GL_RGBA;
-      theDataType    = GL_UNSIGNED_BYTE;
-      return true;
-    }
-    case Image_Format_BGR32:
-    {
-    #if !defined(GL_ES_VERSION_2_0)
-      if (!theCtx->IsGlGreaterEqual(1, 2) && !theCtx->extBgra)
-      {
-        return false;
-      }
-      theTextFormat  = GL_RGB8;
-    #else
-      if (!theCtx->extBgra)
-      {
-        return false;
-      }
-      theTextFormat  = GL_BGRA_EXT;
-    #endif
-      thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA
-      theDataType    = GL_UNSIGNED_BYTE;
-      return true;
-    }
-    case Image_Format_RGB:
-    {
-      theTextFormat = GL_RGB8;
-      thePixelFormat = GL_RGB;
-      theDataType    = GL_UNSIGNED_BYTE;
-      return true;
-    }
-    case Image_Format_BGR:
-    {
-    #if !defined(GL_ES_VERSION_2_0)
-      if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
-      {
-        return false;
-      }
-      theTextFormat = GL_RGB8;
-      thePixelFormat = GL_BGR; // equals to GL_BGR_EXT
-      theDataType    = GL_UNSIGNED_BYTE;
-      return true;
-    #else
-      return false;
-    #endif
-    }
-    case Image_Format_Gray:
-    {
-      if (theCtx->core11 == NULL)
-      {
-        theTextFormat  = GL_R8;
-        thePixelFormat = GL_RED;
-      }
-      else
-      {
-      #if !defined(GL_ES_VERSION_2_0)
-        theTextFormat  = GL_LUMINANCE8;
-      #else
-        theTextFormat  = GL_LUMINANCE;
-      #endif
-        thePixelFormat = GL_LUMINANCE;
-      }
-      theDataType = GL_UNSIGNED_BYTE;
-      return true;
-    }
-    case Image_Format_Alpha:
-    {
-      if (theCtx->core11 == NULL)
-      {
-        theTextFormat  = GL_R8;
-        thePixelFormat = GL_RED;
-      }
-      else
-      {
-      #if !defined(GL_ES_VERSION_2_0)
-        theTextFormat  = GL_ALPHA8;
-      #else
-        theTextFormat  = GL_ALPHA;
-      #endif
-        thePixelFormat = GL_ALPHA;
-      }
-      theDataType = GL_UNSIGNED_BYTE;
-      return true;
-    }
-    case Image_Format_UNKNOWN:
-    {
-      return false;
-    }
-  }
-  return false;
-}
-
 // =======================================================================
 // function : Init
 // purpose  :
 // =======================================================================
 bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
-                           const Standard_Integer        theTextFormat,
-                           const GLenum                  thePixelFormat,
-                           const GLenum                  theDataType,
-                           const Standard_Integer        theSizeX,
-                           const Standard_Integer        theSizeY,
+                           const OpenGl_TextureFormat&   theFormat,
+                           const Graphic3d_Vec2i&        theSizeXY,
                            const Graphic3d_TypeOfTexture theType,
                            const Image_PixMap*           theImage)
 {
-  if (theSizeX < 1
-   || theSizeY < 1)
+  if (theSizeXY.x() < 1
+   || theSizeXY.y() < 1)
   {
     theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
                          "Error: texture of 0 size cannot be created.");
-    Release (theCtx.operator->());
+    Release (theCtx.get());
     return false;
   }
 
@@ -423,14 +205,14 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
 #endif
   const Standard_Boolean toCreateMipMaps = (theType == Graphic3d_TOT_2D_MIPMAP);
   const bool toPatchExisting = IsValid()
-                            && myTextFormat == thePixelFormat
+                            && myTextFormat == theFormat.PixelFormat()
                             && myTarget == aTarget
                             && myHasMipmaps == toCreateMipMaps
-                            && mySizeX  == theSizeX
-                            && (mySizeY == theSizeY || theType == Graphic3d_TOT_1D);
+                            && mySizeX  == theSizeXY.x()
+                            && (mySizeY == theSizeXY.y() || theType == Graphic3d_TOT_1D);
   if (!Create (theCtx))
   {
-    Release (theCtx.operator->());
+    Release (theCtx.get());
     return false;
   }
 
@@ -441,37 +223,37 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
   }
   else
   {
-    myIsAlpha = thePixelFormat == GL_ALPHA;
+    myIsAlpha = theFormat.PixelFormat() == GL_ALPHA;
   }
 
   myHasMipmaps             = toCreateMipMaps;
-  myTextFormat             = thePixelFormat;
-  mySizedFormat            = theTextFormat;
+  myTextFormat             = theFormat.PixelFormat();
+  mySizedFormat            = theFormat.InternalFormat();
   myNbSamples              = 1;
 #if !defined(GL_ES_VERSION_2_0)
-  const GLint anIntFormat  = theTextFormat;
+  const GLint anIntFormat  = theFormat.InternalFormat();
 #else
   // ES 2.0 does not support sized formats and format conversions - them detected from data type
-  const GLint anIntFormat  = theCtx->IsGlGreaterEqual (3, 0) ? theTextFormat : thePixelFormat;
+  const GLint anIntFormat  = theCtx->IsGlGreaterEqual (3, 0) ? theFormat.InternalFormat() : theFormat.PixelFormat();
 #endif
 
-  if (theDataType == GL_FLOAT && !theCtx->arbTexFloat)
+  if (theFormat.DataType() == GL_FLOAT
+  && !theCtx->arbTexFloat)
   {
     theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
                          "Error: floating-point textures are not supported by hardware.");
-    Release (theCtx.operator->());
+    Release (theCtx.get());
     return false;
   }
 
   const GLsizei aMaxSize = theCtx->MaxTextureSize();
-  if (theSizeX > aMaxSize
-   || theSizeY > aMaxSize)
+  if (theSizeXY.x() > aMaxSize
+   || theSizeXY.y() > aMaxSize)
   {
-    TCollection_ExtendedString aWarnMessage = TCollection_ExtendedString ("Error: Texture dimension - ")
-      + theSizeX + "x" + theSizeY + " exceeds hardware limits (" + aMaxSize + "x" + aMaxSize + ")";
-
-    theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aWarnMessage);
-    Release (theCtx.operator->());
+    theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+                         TCollection_AsciiString ("Error: Texture dimension - ") + theSizeXY.x() + "x" + theSizeXY.y()
+                       + " exceeds hardware limits (" + aMaxSize + "x" + aMaxSize + ")");
+    Release (theCtx.get());
     return false;
   }
 #if !defined(GL_ES_VERSION_2_0)
@@ -481,18 +263,15 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
     // however some hardware (NV30 - GeForce FX, RadeOn 9xxx and Xxxx) supports GLSL but not NPOT!
     // Trying to create NPOT textures on such hardware will not fail
     // but driver will fall back into software rendering,
-    const GLsizei aWidthP2  = OpenGl_Context::GetPowerOfTwo (theSizeX, aMaxSize);
-    const GLsizei aHeightP2 = OpenGl_Context::GetPowerOfTwo (theSizeY, aMaxSize);
-
-    if (theSizeX != aWidthP2
-     || (theType != Graphic3d_TOT_1D && theSizeY != aHeightP2))
+    const GLsizei aWidthP2  = OpenGl_Context::GetPowerOfTwo (theSizeXY.x(), aMaxSize);
+    const GLsizei aHeightP2 = OpenGl_Context::GetPowerOfTwo (theSizeXY.y(), aMaxSize);
+    if (theSizeXY.x() != aWidthP2
+     || (theType != Graphic3d_TOT_1D && theSizeXY.y() != aHeightP2))
     {
-      TCollection_ExtendedString aWarnMessage =
-        TCollection_ExtendedString ("Error: NPOT Textures (") + theSizeX + "x" + theSizeY + ") are not supported by hardware.";
-
-      theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, aWarnMessage);
-
-      Release (theCtx.operator->());
+      theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
+                           TCollection_AsciiString ("Error: NPOT Textures (") + theSizeXY.x() + "x" + theSizeXY.y() + ")"
+                           " are not supported by hardware.");
+      Release (theCtx.get());
       return false;
     }
   }
@@ -500,18 +279,15 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
   else if (!theCtx->IsGlGreaterEqual (3, 0) && theType == Graphic3d_TOT_2D_MIPMAP)
   {
     // Mipmap NPOT textures are not supported by OpenGL ES 2.0.
-    const GLsizei aWidthP2  = OpenGl_Context::GetPowerOfTwo (theSizeX, aMaxSize);
-    const GLsizei aHeightP2 = OpenGl_Context::GetPowerOfTwo (theSizeY, aMaxSize);
-
-    if (theSizeX != aWidthP2
-     || theSizeY != aHeightP2)
+    const GLsizei aWidthP2  = OpenGl_Context::GetPowerOfTwo (theSizeXY.x(), aMaxSize);
+    const GLsizei aHeightP2 = OpenGl_Context::GetPowerOfTwo (theSizeXY.y(), aMaxSize);
+    if (theSizeXY.x() != aWidthP2
+     || theSizeXY.y() != aHeightP2)
     {
-      TCollection_ExtendedString aWarnMessage =
-        TCollection_ExtendedString ("Error: Mipmap NPOT Textures (") + theSizeX + "x" + theSizeY + ") are not supported by OpenGL ES 2.0";
-
-      theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, aWarnMessage);
-
-      Release (theCtx.operator->());
+      theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
+                           TCollection_AsciiString ("Error: Mipmap NPOT Textures (") + theSizeXY.x() + "x" + theSizeXY.y() + ")"
+                           " are not supported by OpenGL ES 2.0");
+      Release (theCtx.get());
       return false;
     }
   }
@@ -551,15 +327,15 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
       if (toPatchExisting)
       {
         glTexSubImage1D (GL_TEXTURE_1D, 0, 0,
-                         theSizeX, thePixelFormat, theDataType, aDataPtr);
+                         theSizeXY.x(), theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
         Unbind (theCtx);
         return true;
       }
 
       // use proxy to check texture could be created or not
       glTexImage1D (GL_PROXY_TEXTURE_1D, 0, anIntFormat,
-                    theSizeX, 0,
-                    thePixelFormat, theDataType, NULL);
+                    theSizeXY.x(), 0,
+                    theFormat.PixelFormat(), theFormat.DataType(), NULL);
       glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
       glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
       if (aTestWidth == 0)
@@ -571,16 +347,16 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
       }
 
       glTexImage1D (GL_TEXTURE_1D, 0, anIntFormat,
-                    theSizeX, 0,
-                    thePixelFormat, theDataType, aDataPtr);
+                    theSizeXY.x(), 0,
+                    theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
       if (glGetError() != GL_NO_ERROR)
       {
         Unbind (theCtx);
-        Release (theCtx.operator->());
+        Release (theCtx.get());
         return false;
       }
 
-      mySizeX = theSizeX;
+      mySizeX = theSizeXY.x();
       mySizeY = 1;
 
       Unbind (theCtx);
@@ -588,7 +364,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
     #else
       theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
                            "Error: 1D textures are not supported by hardware.");
-      Release (theCtx.operator->());
+      Release (theCtx.get());
       return false;
     #endif
     }
@@ -600,8 +376,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
       {
         glTexSubImage2D (GL_TEXTURE_2D, 0,
                          0, 0,
-                         theSizeX, theSizeY,
-                         thePixelFormat, theDataType, aDataPtr);
+                         theSizeXY.x(), theSizeXY.y(),
+                         theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
         Unbind (theCtx);
         return true;
       }
@@ -609,8 +385,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
     #if !defined(GL_ES_VERSION_2_0)
       // use proxy to check texture could be created or not
       glTexImage2D (GL_PROXY_TEXTURE_2D, 0, anIntFormat,
-                    theSizeX, theSizeY, 0,
-                    thePixelFormat, theDataType, NULL);
+                    theSizeXY.x(), theSizeXY.y(), 0,
+                    theFormat.PixelFormat(), theFormat.DataType(), NULL);
       glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH,  &aTestWidth);
       glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestHeight);
       glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
@@ -618,28 +394,29 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
       {
         // no memory or broken input parameters
         Unbind (theCtx);
-        Release (theCtx.operator->());
+        Release (theCtx.get());
         return false;
       }
     #endif
 
       glTexImage2D (GL_TEXTURE_2D, 0, anIntFormat,
-                    theSizeX, theSizeY, 0,
-                    thePixelFormat, theDataType, aDataPtr);
+                    theSizeXY.x(), theSizeXY.y(), 0,
+                    theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
       const GLenum anErr = glGetError();
       if (anErr != GL_NO_ERROR)
       {
         theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
-                             TCollection_AsciiString ("Error: 2D texture ") + theSizeX + "x" + theSizeY
-                                                   + " IF: " + int(anIntFormat) + " PF: " + int(thePixelFormat) + " DT: " + int(theDataType)
+                             TCollection_AsciiString ("Error: 2D texture ") + theSizeXY.x() + "x" + theSizeXY.y()
+                                                   + " IF: " + int(anIntFormat) + " PF: " + int(theFormat.PixelFormat())
+                                                   + " DT: " + int(theFormat.DataType())
                                                    + " can not be created with error " + int(anErr) + ".");
         Unbind (theCtx);
-        Release (theCtx.operator->());
+        Release (theCtx.get());
         return false;
       }
 
-      mySizeX = theSizeX;
-      mySizeY = theSizeY;
+      mySizeX = theSizeXY.x();
+      mySizeY = theSizeXY.y();
 
       Unbind (theCtx);
       return true;
@@ -652,8 +429,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
       {
         glTexSubImage2D (GL_TEXTURE_2D, 0,
                          0, 0,
-                         theSizeX, theSizeY,
-                         thePixelFormat, theDataType, aDataPtr);
+                         theSizeXY.x(), theSizeXY.y(),
+                         theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
         if (theCtx->arbFBO != NULL)
         {
           // generate mipmaps
@@ -661,7 +438,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
           if (glGetError() != GL_NO_ERROR)
           {
             Unbind (theCtx);
-            Release (theCtx.operator->());
+            Release (theCtx.get());
             return false;
           }
         }
@@ -673,8 +450,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
     #if !defined(GL_ES_VERSION_2_0)
       // use proxy to check texture could be created or not
       glTexImage2D (GL_PROXY_TEXTURE_2D, 0, anIntFormat,
-                    theSizeX, theSizeY, 0,
-                    thePixelFormat, theDataType, NULL);
+                    theSizeXY.x(), theSizeXY.y(), 0,
+                    theFormat.PixelFormat(), theFormat.DataType(), NULL);
       glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH,  &aTestWidth);
       glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestHeight);
       glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
@@ -682,29 +459,30 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
       {
         // no memory or broken input parameters
         Unbind (theCtx);
-        Release (theCtx.operator->());
+        Release (theCtx.get());
         return false;
       }
     #endif
 
       // upload main picture
       glTexImage2D (GL_TEXTURE_2D, 0, anIntFormat,
-                    theSizeX, theSizeY, 0,
-                    thePixelFormat, theDataType, theImage->Data());
+                    theSizeXY.x(), theSizeXY.y(), 0,
+                    theFormat.PixelFormat(), theFormat.DataType(), theImage->Data());
       const GLenum aTexImgErr = glGetError();
       if (aTexImgErr != GL_NO_ERROR)
       {
         theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
-                             TCollection_AsciiString ("Error: 2D texture ") + theSizeX + "x" + theSizeY
-                                                    + " IF: " + int(anIntFormat) + " PF: " + int(thePixelFormat) + " DT: " + int(theDataType)
+                             TCollection_AsciiString ("Error: 2D texture ") + theSizeXY.x() + "x" + theSizeXY.y()
+                                                    + " IF: " + int(anIntFormat) + " PF: " + int(theFormat.PixelFormat())
+                                                    + " DT: " + int(theFormat.DataType())
                                                     + " can not be created with error " + int(aTexImgErr) + ".");
         Unbind (theCtx);
-        Release (theCtx.operator->());
+        Release (theCtx.get());
         return false;
       }
 
-      mySizeX = theSizeX;
-      mySizeY = theSizeY;
+      mySizeX = theSizeXY.x();
+      mySizeY = theSizeXY.y();
 
       if (theCtx->arbFBO != NULL)
       {
@@ -715,18 +493,16 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
         if (glGetError() != GL_NO_ERROR)
         {
           Unbind (theCtx);
-          Release (theCtx.operator->());
+          Release (theCtx.get());
           return false;
         }
       }
       else
       {
-        const TCollection_ExtendedString aWarnMessage ("Warning: generating mipmaps requires GL_ARB_framebuffer_object extension which is missing.");
-
-        theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, aWarnMessage);
-
+        theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
+                             "Warning: generating mipmaps requires GL_ARB_framebuffer_object extension which is missing.");
         Unbind (theCtx);
-        Release (theCtx.operator->());
+        Release (theCtx.get());
         return false;
       }
 
@@ -741,7 +517,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
     }
   }
 
-  Release (theCtx.operator->());
+  Release (theCtx.get());
   return false;
 }
 
@@ -751,27 +527,23 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
 // =======================================================================
 bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
                            const Image_PixMap&           theImage,
-                           const Graphic3d_TypeOfTexture theType)
+                           const Graphic3d_TypeOfTexture theType,
+                           const Standard_Boolean        theIsColorMap)
 {
   if (theImage.IsEmpty())
   {
-    Release (theCtx.operator->());
+    Release (theCtx.get());
     return false;
   }
 
-  GLenum aPixelFormat;
-  GLenum aDataType;
-  GLint aTextFormat;
-  if (!GetDataFormat (theCtx, theImage, aTextFormat, aPixelFormat, aDataType))
+  const OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theImage.Format(), theIsColorMap);
+  if (!aFormat.IsValid())
   {
-    Release (theCtx.operator->());
+    Release (theCtx.get());
     return false;
   }
 
-  return Init (theCtx,
-               aTextFormat, aPixelFormat, aDataType,
-               (Standard_Integer)theImage.SizeX(),
-               (Standard_Integer)theImage.SizeY(),
+  return Init (theCtx, aFormat, Graphic3d_Vec2i ((Standard_Integer)theImage.SizeX(), (Standard_Integer)theImage.SizeY()),
                theType, &theImage);
 }
 
@@ -791,7 +563,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)&       theCtx,
   {
     case Graphic3d_TOT_CUBEMAP:
     {
-      return InitCubeMap (theCtx, Handle(Graphic3d_CubeMap)::DownCast(theTextureMap));
+      return initCubeMap (theCtx, Handle(Graphic3d_CubeMap)::DownCast(theTextureMap),
+                          0, Image_Format_RGB, false, theTextureMap->IsColorMap());
     }
     default:
     {
@@ -800,7 +573,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)&       theCtx,
       {
         return false;
       }
-      return Init (theCtx, *anImage, theTextureMap->Type());
+      return Init (theCtx, *anImage, theTextureMap->Type(), theTextureMap->IsColorMap());
     }
   }
 }
@@ -935,24 +708,14 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx,
 // purpose  :
 // =======================================================================
 bool OpenGl_Texture::Init3D (const Handle(OpenGl_Context)& theCtx,
-                             const GLint                   theTextFormat,
-                             const GLenum                  thePixelFormat,
-                             const GLenum                  theDataType,
-                             const Standard_Integer        theSizeX,
-                             const Standard_Integer        theSizeY,
-                             const Standard_Integer        theSizeZ,
+                             const OpenGl_TextureFormat&   theFormat,
+                             const Graphic3d_Vec3i&        theSizeXYZ,
                              const void*                   thePixels)
 {
   if (theCtx->Functions()->glTexImage3D == NULL)
   {
-    TCollection_ExtendedString aMsg ("Error: three-dimensional textures are not supported by hardware.");
-
-    theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
-                         GL_DEBUG_TYPE_ERROR,
-                         0,
-                         GL_DEBUG_SEVERITY_HIGH,
-                         aMsg);
-
+    theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+                         "Error: three-dimensional textures are not supported by hardware.");
     return false;
   }
 
@@ -965,83 +728,80 @@ bool OpenGl_Texture::Init3D (const Handle(OpenGl_Context)& theCtx,
   myNbSamples = 1;
   myHasMipmaps = false;
 
-  const GLsizei aSizeX = Min (theCtx->MaxTextureSize(), theSizeX);
-  const GLsizei aSizeY = Min (theCtx->MaxTextureSize(), theSizeY);
-  const GLsizei aSizeZ = Min (theCtx->MaxTextureSize(), theSizeZ);
-
+  const Graphic3d_Vec3i aSizeXYZ = theSizeXYZ.cwiseMin (Graphic3d_Vec3i (theCtx->MaxTextureSize()));
+  if (aSizeXYZ != theSizeXYZ)
+  {
+    theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+                         "Error: 3D texture dimensions exceed hardware limits.");
+    Release (theCtx.get());
+    Unbind (theCtx);
+    return false;
+  }
   Bind (theCtx);
 
-  if (theDataType == GL_FLOAT && !theCtx->arbTexFloat)
+  if (theFormat.DataType() == GL_FLOAT
+  && !theCtx->arbTexFloat)
   {
-    TCollection_ExtendedString aMsg ("Error: floating-point textures are not supported by hardware.");
-
-    theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
-                         GL_DEBUG_TYPE_ERROR,
-                         0,
-                         GL_DEBUG_SEVERITY_HIGH,
-                         aMsg);
-
-    Release (theCtx.operator->());
+    theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+                         "Error: floating-point textures are not supported by hardware.");
+    Release (theCtx.get());
     Unbind (theCtx);
     return false;
   }
 
-  mySizedFormat = theTextFormat;
+  mySizedFormat = theFormat.InternalFormat();
 
   // setup the alignment
   OpenGl_UnpackAlignmentSentry::Reset();
 
 #if !defined (GL_ES_VERSION_2_0)
   theCtx->core15fwd->glTexImage3D (GL_PROXY_TEXTURE_3D, 0, mySizedFormat,
-                                   aSizeX, aSizeY, aSizeZ, 0,
-                                   thePixelFormat, theDataType, NULL);
+                                   aSizeXYZ.x(), aSizeXYZ.y(), aSizeXYZ.z(), 0,
+                                   theFormat.PixelFormat(), theFormat.DataType(), NULL);
 
-  GLint aTestSizeX = 0;
-  GLint aTestSizeY = 0;
-  GLint aTestSizeZ = 0;
-
-  glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &aTestSizeX);
-  glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &aTestSizeY);
-  glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_DEPTH, &aTestSizeZ);
+  NCollection_Vec3<GLint> aTestSizeXYZ;
+  glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH,  &aTestSizeXYZ.x());
+  glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &aTestSizeXYZ.y());
+  glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_DEPTH,  &aTestSizeXYZ.z());
   glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
-
-  if (aTestSizeX == 0 || aTestSizeY == 0 || aTestSizeZ == 0)
+  if (aTestSizeXYZ.x() == 0 || aTestSizeXYZ.y() == 0 || aTestSizeXYZ.z() == 0)
   {
     Unbind (theCtx);
-    Release (theCtx.operator->());
+    Release (theCtx.get());
     return false;
   }
 #endif
 
   applyDefaultSamplerParams (theCtx);
   theCtx->Functions()->glTexImage3D (myTarget, 0, mySizedFormat,
-                                     aSizeX, aSizeY, aSizeZ, 0,
-                                     thePixelFormat, theDataType, thePixels);
+                                     aSizeXYZ.x(), aSizeXYZ.y(), aSizeXYZ.z(), 0,
+                                     theFormat.PixelFormat(), theFormat.DataType(), thePixels);
 
   if (glGetError() != GL_NO_ERROR)
   {
     Unbind (theCtx);
-    Release (theCtx.operator->());
+    Release (theCtx.get());
     return false;
   }
 
-  mySizeX = aSizeX;
-  mySizeY = aSizeY;
-  mySizeZ = aSizeZ;
+  mySizeX = aSizeXYZ.x();
+  mySizeY = aSizeXYZ.y();
+  mySizeZ = aSizeXYZ.z();
 
   Unbind (theCtx);
   return true;
 }
 
 // =======================================================================
-// function : InitCubeMap
+// function : initCubeMap
 // purpose  :
 // =======================================================================
-bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)&    theCtx,
+bool OpenGl_Texture::initCubeMap (const Handle(OpenGl_Context)&    theCtx,
                                   const Handle(Graphic3d_CubeMap)& theCubeMap,
-                                  Standard_Size                    theSize,
-                                  Image_Format                     theFormat,
-                                  Standard_Boolean                 theToGenMipmap)
+                                  Standard_Size    theSize,
+                                  Image_Format     theFormat,
+                                  Standard_Boolean theToGenMipmap,
+                                  Standard_Boolean theIsColorMap)
 {
   if (!Create (theCtx))
   {
@@ -1051,8 +811,7 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)&    theCtx,
 
   if (!theCubeMap.IsNull())
   {
-    Handle(Image_PixMap) anImage = theCubeMap->Reset().Value();
-    if (!anImage.IsNull())
+    if (Handle(Image_PixMap) anImage = theCubeMap->Reset().Value())
     {
       theSize   = anImage->SizeX();
       theFormat = anImage->Format();
@@ -1060,17 +819,14 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)&    theCtx,
     else
     {
       theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
-        "Unable to get the first side of cubemap");
+                           "Unable to get the first side of cubemap");
       Release(theCtx.get());
       return false;
     }
   }
 
-  GLenum aPixelFormat = GL_RGB;
-  GLenum aDataType = 0;
-  GLint aTextFormat = 0;
-
-  if (!GetDataFormat (theCtx, theFormat, aTextFormat, aPixelFormat, aDataType))
+  OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theFormat, theIsColorMap);
+  if (!aFormat.IsValid())
   {
     Unbind(theCtx);
     Release(theCtx.get());
@@ -1123,8 +879,8 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)&    theCtx,
       }
       else
       {
-        theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, TCollection_AsciiString() +
-          "Unable to get [" + i + "] side of cubemap");
+        theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+                             TCollection_AsciiString() + "Unable to get [" + i + "] side of cubemap");
         Unbind (theCtx);
         Release (theCtx.get());
         return false;
@@ -1133,17 +889,18 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)&    theCtx,
     }
 
     glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0,
-                  aTextFormat,
+                  aFormat.InternalFormat(),
                   GLsizei(theSize), GLsizei(theSize),
-                  0, aPixelFormat, aDataType,
+                  0, aFormat.PixelFormat(), aFormat.DataType(),
                   aData);
 
     OpenGl_UnpackAlignmentSentry::Reset();
 
-    if (glGetError() != GL_NO_ERROR)
+    const GLenum anErr = glGetError();
+    if (anErr != GL_NO_ERROR)
     {
       theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
-        "Unable to initialize side of cubemap");
+                           TCollection_AsciiString ("Unable to initialize side of cubemap. Error #") + int(anErr));
       Unbind (theCtx);
       Release (theCtx.get());
       return false;
@@ -1152,16 +909,16 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)&    theCtx,
 
   if (theToGenMipmap && theCtx->arbFBO != NULL)
   {
-      theCtx->arbFBO->glGenerateMipmap (myTarget);
-
-      if (glGetError() != GL_NO_ERROR)
-      {
-        theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
-          "Unable to generate mipmap of cubemap");
-        Unbind(theCtx);
-        Release(theCtx.get());
-        return false;
-      }
+    theCtx->arbFBO->glGenerateMipmap (myTarget);
+    const GLenum anErr = glGetError();
+    if (anErr != GL_NO_ERROR)
+    {
+      theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+                           TCollection_AsciiString ("Unable to generate mipmap of cubemap. Error #") + int(anErr));
+      Unbind (theCtx);
+      Release (theCtx.get());
+      return false;
+    }
   }
 
   Unbind (theCtx.get());
index 9b0061a55b293b32f40005c5c89cb3bffb7ac6ef..a9520d370f110167fa19bd62395fb5678ba56ebf 100644 (file)
@@ -16,7 +16,7 @@
 #define _OpenGl_Texture_H__
 
 #include <Graphic3d_CubeMap.hxx>
-#include <OpenGl_GlCore13.hxx>
+#include <OpenGl_TextureFormat.hxx>
 #include <OpenGl_NamedResource.hxx>
 #include <OpenGl_Sampler.hxx>
 #include <Graphic3d_TextureUnit.hxx>
 class Graphic3d_TextureParams;
 class Image_PixMap;
 
-//! Selects preferable texture format for specified parameters.
-template<class T>
-struct OpenGl_TextureFormatSelector
-{
-  // Not implemented
-};
-
-template<>
-struct OpenGl_TextureFormatSelector<GLubyte>
-{
-  static GLint Internal (GLuint theChannels)
-  {
-    switch (theChannels)
-    {
-      case 1:
-        return GL_R8;
-      case 2:
-        return GL_RG8;
-      case 3:
-        return GL_RGB8;
-      case 4:
-        return GL_RGBA8;
-      default:
-        return GL_NONE;
-    }
-  }
-
-  static GLint DataType()
-  {
-    return GL_UNSIGNED_BYTE;
-  }
-};
-
-template<>
-struct OpenGl_TextureFormatSelector<GLushort>
-{
-  static GLint Internal (GLuint theChannels)
-  {
-    switch (theChannels)
-    {
-      case 1:
-        return GL_R16;
-      case 2:
-        return GL_RG16;
-      case 3:
-        return GL_RGB16;
-      case 4:
-        return GL_RGBA16;
-      default:
-        return GL_NONE;
-    }
-  }
-
-  static GLint DataType()
-  {
-    return GL_UNSIGNED_SHORT;
-  }
-};
-
-template<>
-struct OpenGl_TextureFormatSelector<GLfloat>
-{
-  static GLint Internal (GLuint theChannels)
-  {
-    switch (theChannels)
-    {
-      case 1:
-        return GL_R32F;
-      case 2:
-        return GL_RG32F;
-      case 3:
-        return GL_RGB32F;
-      case 4:
-        return GL_RGBA32F;
-      default:
-        return GL_NONE;
-    }
-  }
-
-  static GLint DataType()
-  {
-    return GL_FLOAT;
-  }
-};
-
-template<>
-struct OpenGl_TextureFormatSelector<GLuint>
-{
-  static GLint Internal (GLuint theChannels)
-  {
-    switch (theChannels)
-    {
-      case 1:
-        return GL_RED;
-      case 2:
-        return GL_RG;
-      case 3:
-        return GL_RGB;
-      case 4:
-        return GL_RGBA;
-      default:
-        return GL_NONE;
-    }
-  }
-
-  static GLint DataType()
-  {
-    return GL_UNSIGNED_INT;
-  }
-};
-
-//! Only unsigned formats are available in OpenGL ES 2.0
-#if !defined(GL_ES_VERSION_2_0)
-template<>
-struct OpenGl_TextureFormatSelector<GLbyte>
-{
-  static GLint Internal (GLuint theChannels)
-  {
-    switch (theChannels)
-    {
-      case 1:
-        return GL_R8_SNORM;
-      case 2:
-        return GL_RG8_SNORM;
-      case 3:
-        return GL_RGB8_SNORM;
-      case 4:
-        return GL_RGBA8_SNORM;
-      default:
-        return GL_NONE;
-    }
-  }
-
-  static GLint DataType()
-  {
-    return GL_BYTE;
-  }
-};
-
-template<>
-struct OpenGl_TextureFormatSelector<GLshort>
-{
-  static GLint Internal (GLuint theChannels)
-  {
-    switch (theChannels)
-    {
-      case 1:
-        return GL_R16_SNORM;
-      case 2:
-        return GL_RG16_SNORM;
-      case 3:
-        return GL_RGB16_SNORM;
-      case 4:
-        return GL_RGBA16_SNORM;
-      default:
-        return GL_NONE;
-    }
-  }
-
-  static GLint DataType()
-  {
-    return GL_SHORT;
-  }
-};
-
-template<>
-struct OpenGl_TextureFormatSelector<GLint>
-{
-  static GLint Internal (GLuint theChannels)
-  {
-    switch (theChannels)
-    {
-      case 1:
-        return GL_RED_SNORM;
-      case 2:
-        return GL_RG_SNORM;
-      case 3:
-        return GL_RGB_SNORM;
-      case 4:
-        return GL_RGBA_SNORM;
-      default:
-        return GL_NONE;
-    }
-  }
-
-  static GLint DataType()
-  {
-    return GL_INT;
-  }
-};
-#endif
-
-//! Stores parameters of OpenGL texture format.
-class OpenGl_TextureFormat
-{
-  friend class OpenGl_Texture;
-
-public:
-
-  //! Returns OpenGL format of the pixel data.
-  inline GLenum Format() const
-  {
-    switch (myChannels)
-    {
-      case 1:
-        return GL_RED;
-      case 2:
-        return GL_RG;
-      case 3:
-        return GL_RGB;
-      case 4:
-        return GL_RGBA;
-      default:
-        return GL_NONE;
-    }
-  }
-
-  //! Returns OpenGL internal format of the pixel data.
-  inline GLint Internal() const
-  {
-    return myInternal;
-  }
-
-  //! Returns OpenGL data type of the pixel data.
-  inline GLint DataType() const
-  {
-    return myDataType;
-  }
-
-  //! Returns texture format for specified type and number of channels.
-  template<class T, int N>
-  static OpenGl_TextureFormat Create()
-  {
-    return OpenGl_TextureFormat (N,
-                                 OpenGl_TextureFormatSelector<T>::Internal(N),
-                                 OpenGl_TextureFormatSelector<T>::DataType());
-  }
-
-private:
-
-  //! Creates new texture format.
-  OpenGl_TextureFormat (const GLint theChannels,
-                        const GLint theInternal,
-                        const GLint theDataType)
-  : myInternal (theInternal),
-    myChannels (theChannels),
-    myDataType (theDataType) {}
-
-private:
-
-  GLint myInternal; //!< OpenGL internal format of the pixel data
-  GLint myChannels; //!< Number of channels for each pixel (from 1 to 4)
-  GLint myDataType; //!< OpenGL data type of input pixel data
-
-};
-
 //! Texture resource.
 class OpenGl_Texture : public OpenGl_NamedResource
 {
@@ -305,59 +49,32 @@ public:
   Standard_EXPORT virtual ~OpenGl_Texture();
 
   //! @return true if current object was initialized
-  inline bool IsValid() const
-  {
-    return myTextureId != NO_TEXTURE;
-  }
+  bool IsValid() const { return myTextureId != NO_TEXTURE; }
 
   //! @return target to which the texture is bound (GL_TEXTURE_1D, GL_TEXTURE_2D)
-  inline GLenum GetTarget() const
-  {
-    return myTarget;
-  }
+  GLenum GetTarget() const { return myTarget; }
 
   //! @return texture width (0 LOD)
-  inline GLsizei SizeX() const
-  {
-    return mySizeX;
-  }
+  GLsizei SizeX() const { return mySizeX; }
 
   //! @return texture height (0 LOD)
-  inline GLsizei SizeY() const
-  {
-    return mySizeY;
-  }
+  GLsizei SizeY() const { return mySizeY; }
 
   //! @return texture ID
-  inline GLuint TextureId() const
-  {
-    return myTextureId;
-  }
+  GLuint TextureId() const { return myTextureId; }
 
   //! @return texture format (not sized)
-  inline GLenum GetFormat() const
-  {
-    return myTextFormat;
-  }
+  GLenum GetFormat() const { return myTextFormat; }
   
   //! @return texture format (sized)
-  GLint SizedFormat() const
-  {
-    return mySizedFormat;
-  }
+  GLint SizedFormat() const { return mySizedFormat; }
 
   //! Return true for GL_RED and GL_ALPHA formats.
-  bool IsAlpha() const
-  {
-    return myIsAlpha;
-  }
+  bool IsAlpha() const { return myIsAlpha; }
 
   //! Setup to interprete the format as Alpha by Shader Manager
   //! (should be GL_ALPHA within compatible context or GL_RED otherwise).
-  void SetAlpha (const bool theValue)
-  {
-    myIsAlpha = theValue;
-  }
+  void SetAlpha (const bool theValue) { myIsAlpha = theValue; }
 
   //! Creates Texture id if not yet generated.
   //! Data should be initialized by another method.
@@ -409,17 +126,15 @@ public:
   //! Notice that texture will be unbound after this call.
   Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theCtx,
                              const Image_PixMap&           theImage,
-                             const Graphic3d_TypeOfTexture theType);
+                             const Graphic3d_TypeOfTexture theType,
+                             const Standard_Boolean        theIsColorMap);
 
   //! Initialize the texture with specified format, size and texture type.
   //! If theImage is empty the texture data will contain trash.
   //! Notice that texture will be unbound after this call.
   Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theCtx,
-                             const GLint                   theTextFormat,
-                             const GLenum                  thePixelFormat,
-                             const GLenum                  theDataType,
-                             const GLsizei                 theSizeX,
-                             const GLsizei                 theSizeY,
+                             const OpenGl_TextureFormat&   theFormat,
+                             const Graphic3d_Vec2i&        theSizeXY,
                              const Graphic3d_TypeOfTexture theType,
                              const Image_PixMap*           theImage = NULL);
 
@@ -445,66 +160,112 @@ public:
 
   //! Initializes 3D texture rectangle with specified format and size.
   Standard_EXPORT bool Init3D (const Handle(OpenGl_Context)& theCtx,
-                               const GLint                   theTextFormat,
-                               const GLenum                  thePixelFormat,
-                               const GLenum                  theDataType,
-                               const Standard_Integer        theSizeX,
-                               const Standard_Integer        theSizeY,
-                               const Standard_Integer        theSizeZ,
+                               const OpenGl_TextureFormat&   theFormat,
+                               const Graphic3d_Vec3i&        theSizeXYZ,
                                const void*                   thePixels);
 
-  //! Initializes 6 sides of cubemap.
-  //! If theCubeMap is not NULL then size and format will be taken from it
-  //! and corresponding arguments will be ignored.
-  //! Otherwise this parametres will be taken from arguments.
-  //! theToGenMipmap allows to generate mipmaped cubemap.
-  Standard_EXPORT bool InitCubeMap (const Handle(OpenGl_Context)&    theCtx,
-                                    const Handle(Graphic3d_CubeMap)& theCubeMap,
-                                    Standard_Size                    theSize = 0,
-                                    Image_Format                     theFormat = Image_Format_RGB,
-                                    Standard_Boolean                 theToGenMipmap = Standard_False);
-
-  //! The same InitCubeMap but there is another order of arguments.
-  bool InitCubeMap (const Handle(OpenGl_Context)&    theCtx,
-                    const Handle(Graphic3d_CubeMap)& theCubeMap,
-                    Standard_Boolean                 theToGenMipmap,
-                    Standard_Size                    theSize = 0,
-                    Image_Format                     theFormat = Image_Format_RGB)
-  {
-    return InitCubeMap (theCtx, theCubeMap, theSize, theFormat, theToGenMipmap);
-  }
-
   //! @return true if texture was generated within mipmaps
   Standard_Boolean HasMipmaps() const { return myHasMipmaps; }
 
-  //! Return texture type and format by Image_Format.
-  Standard_EXPORT static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
-                                             const Image_Format            theFromat,
-                                             GLint&                        theTextFormat,
-                                             GLenum&                       thePixelFormat,
-                                             GLenum&                       theDataType);
+  //! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
+  Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
+
+  //! Returns TRUE for point sprite texture.
+  virtual bool IsPointSprite() const { return false; }
 
-  //! Return texture type and format by Image_PixMap data format.
+public:
+
+  Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat::FindFormat() should be used instead")
+  static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
+                             const Image_Format            theFormat,
+                             GLint&                        theTextFormat,
+                             GLenum&                       thePixelFormat,
+                             GLenum&                       theDataType)
+  {
+    OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theFormat, false);
+    theTextFormat  = aFormat.InternalFormat();
+    thePixelFormat = aFormat.PixelFormat();
+    theDataType    = aFormat.DataType();
+    return aFormat.IsValid();
+  }
+
+  Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat::FindFormat() should be used instead")
   static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
                              const Image_PixMap&           theData,
                              GLint&                        theTextFormat,
                              GLenum&                       thePixelFormat,
                              GLenum&                       theDataType)
   {
-    return GetDataFormat (theCtx, theData.Format(), theTextFormat, thePixelFormat, theDataType);
+    OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theData.Format(), false);
+    theTextFormat  = aFormat.InternalFormat();
+    thePixelFormat = aFormat.PixelFormat();
+    theDataType    = aFormat.DataType();
+    return aFormat.IsValid();
   }
 
-  //! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
-  Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
+  Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat should be passed instead of separate parameters")
+  bool Init (const Handle(OpenGl_Context)& theCtx,
+             const GLint                   theTextFormat,
+             const GLenum                  thePixelFormat,
+             const GLenum                  theDataType,
+             const GLsizei                 theSizeX,
+             const GLsizei                 theSizeY,
+             const Graphic3d_TypeOfTexture theType,
+             const Image_PixMap*           theImage = NULL)
+  {
+    OpenGl_TextureFormat aFormat;
+    aFormat.SetInternalFormat (theTextFormat);
+    aFormat.SetPixelFormat (thePixelFormat);
+    aFormat.SetDataType (theDataType);
+    return Init (theCtx, aFormat, Graphic3d_Vec2i (theSizeX, theSizeY), theType, theImage);
+  }
 
-  //! Returns TRUE for point sprite texture.
-  virtual bool IsPointSprite() const { return false; }
+  Standard_DEPRECATED("Deprecated method, theIsColorMap parameter should be explicitly specified")
+  bool Init (const Handle(OpenGl_Context)& theCtx,
+             const Image_PixMap& theImage,
+             const Graphic3d_TypeOfTexture theType)
+  {
+    return Init (theCtx, theImage, theType, true);
+  }
+
+  Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat should be passed instead of separate parameters")
+  bool Init3D (const Handle(OpenGl_Context)& theCtx,
+               const GLint  theTextFormat,
+               const GLenum thePixelFormat,
+               const GLenum theDataType,
+               const Standard_Integer theSizeX,
+               const Standard_Integer theSizeY,
+               const Standard_Integer theSizeZ,
+               const void* thePixels)
+  {
+    OpenGl_TextureFormat aFormat;
+    aFormat.SetInternalFormat (theTextFormat);
+    aFormat.SetPixelFormat (thePixelFormat);
+    aFormat.SetDataType (theDataType);
+    return Init3D (theCtx, aFormat, Graphic3d_Vec3i (theSizeX, theSizeY, theSizeZ), thePixels);
+  }
 
 protected:
 
   //! Apply default sampler parameters after texture creation.
   Standard_EXPORT void applyDefaultSamplerParams (const Handle(OpenGl_Context)& theCtx);
 
+  //! Initializes 6 sides of cubemap.
+  //! If theCubeMap is not NULL then size and format will be taken from it and corresponding arguments will be ignored.
+  //! Otherwise this parametres will be taken from arguments.
+  //! @param theCtx         [in] active OpenGL context
+  //! @param theCubeMap     [in] cubemap definition, can be NULL
+  //! @param theSize        [in] cubemap dimensions
+  //! @param theFormat      [in] image format
+  //! @param theToGenMipmap [in] flag to generate mipmaped cubemap
+  //! @param theIsColorMap  [in] flag indicating cubemap storing color values
+  Standard_EXPORT bool initCubeMap (const Handle(OpenGl_Context)&    theCtx,
+                                    const Handle(Graphic3d_CubeMap)& theCubeMap,
+                                    Standard_Size    theSize,
+                                    Image_Format     theFormat,
+                                    Standard_Boolean theToGenMipmap,
+                                    Standard_Boolean theIsColorMap);
+
 protected:
 
   Handle(OpenGl_Sampler) mySampler; //!< texture sampler
diff --git a/src/OpenGl/OpenGl_TextureFormat.cxx b/src/OpenGl/OpenGl_TextureFormat.cxx
new file mode 100644 (file)
index 0000000..7490eda
--- /dev/null
@@ -0,0 +1,429 @@
+// Copyright (c) 2017-2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <OpenGl_TextureFormat.hxx>
+
+#include <OpenGl_Context.hxx>
+
+// =======================================================================
+// function : FindFormat
+// purpose  :
+// =======================================================================
+OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Context)& theCtx,
+                                                       Image_Format theFormat,
+                                                       bool theIsColorMap)
+{
+  OpenGl_TextureFormat aFormat;
+  switch (theFormat)
+  {
+    case Image_Format_GrayF:
+    {
+      aFormat.SetNbComponents (1);
+      if (theCtx->core11 == NULL)
+      {
+        aFormat.SetInternalFormat (GL_R8); // GL_R32F
+        aFormat.SetPixelFormat (GL_RED);
+      }
+      else
+      {
+      #if !defined(GL_ES_VERSION_2_0)
+        aFormat.SetInternalFormat (GL_LUMINANCE8);
+      #else
+        aFormat.SetInternalFormat (GL_LUMINANCE);
+      #endif
+        aFormat.SetPixelFormat (GL_LUMINANCE);
+      }
+      aFormat.SetDataType (GL_FLOAT);
+      return aFormat;
+    }
+    case Image_Format_AlphaF:
+    {
+      aFormat.SetNbComponents (1);
+      if (theCtx->core11 == NULL)
+      {
+        aFormat.SetInternalFormat (GL_R8);  // GL_R32F
+        aFormat.SetPixelFormat (GL_RED);
+      }
+      else
+      {
+      #if !defined(GL_ES_VERSION_2_0)
+        aFormat.SetInternalFormat (GL_ALPHA8);
+      #else
+        aFormat.SetInternalFormat (GL_ALPHA);
+      #endif
+        aFormat.SetPixelFormat (GL_ALPHA);
+      }
+      aFormat.SetDataType (GL_FLOAT);
+      return aFormat;
+    }
+    case Image_Format_RGBAF:
+    {
+      aFormat.SetNbComponents (4);
+      aFormat.SetInternalFormat (GL_RGBA8); // GL_RGBA32F
+      aFormat.SetPixelFormat (GL_RGBA);
+      aFormat.SetDataType (GL_FLOAT);
+      return aFormat;
+    }
+    case Image_Format_BGRAF:
+    {
+      if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
+      {
+        return aFormat;
+      }
+      aFormat.SetNbComponents (4);
+      aFormat.SetInternalFormat (GL_RGBA8); // GL_RGBA32F
+      aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA
+      aFormat.SetDataType (GL_FLOAT);
+      return aFormat;
+    }
+    case Image_Format_RGBF:
+    {
+      aFormat.SetNbComponents (3);
+      aFormat.SetInternalFormat (GL_RGB8); // GL_RGB32F
+      aFormat.SetPixelFormat (GL_RGB);
+      aFormat.SetDataType (GL_FLOAT);
+      return aFormat;
+    }
+    case Image_Format_BGRF:
+    {
+    #if !defined(GL_ES_VERSION_2_0)
+      aFormat.SetNbComponents (3);
+      aFormat.SetInternalFormat (GL_RGB8); // GL_RGB32F
+      aFormat.SetPixelFormat (GL_BGR);     // equals to GL_BGR_EXT
+      aFormat.SetDataType (GL_FLOAT);
+      return aFormat;
+    #else
+      return aFormat;
+    #endif
+    }
+    case Image_Format_RGBA:
+    {
+      aFormat.SetNbComponents (4);
+      aFormat.SetInternalFormat (GL_RGBA8);
+      aFormat.SetPixelFormat (GL_RGBA);
+      aFormat.SetDataType (GL_UNSIGNED_BYTE);
+      if (theIsColorMap
+       && theCtx->ToRenderSRGB())
+      {
+        aFormat.SetInternalFormat (GL_SRGB8_ALPHA8);
+      }
+      return aFormat;
+    }
+    case Image_Format_BGRA:
+    {
+    #if !defined(GL_ES_VERSION_2_0)
+      if (!theCtx->IsGlGreaterEqual (1, 2)
+       && !theCtx->extBgra)
+      {
+        return aFormat;
+      }
+      aFormat.SetNbComponents (4);
+      aFormat.SetInternalFormat (GL_RGBA8);
+      if (theIsColorMap
+       && theCtx->ToRenderSRGB())
+      {
+        aFormat.SetInternalFormat (GL_SRGB8_ALPHA8); /// TODO
+      }
+    #else
+      if (!theCtx->extBgra)
+      {
+        return aFormat;
+      }
+      aFormat.SetNbComponents (4);
+      aFormat.SetInternalFormat (GL_BGRA_EXT);
+    #endif
+      aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA
+      aFormat.SetDataType (GL_UNSIGNED_BYTE);
+      return aFormat;
+    }
+    case Image_Format_RGB32:
+    {
+    #if !defined(GL_ES_VERSION_2_0)
+      // ask driver to convert data to RGB8 to save memory
+      aFormat.SetNbComponents (3);
+      aFormat.SetInternalFormat (GL_RGB8);
+      if (theIsColorMap
+       && theCtx->ToRenderSRGB())
+      {
+        aFormat.SetInternalFormat (GL_SRGB8);
+      }
+    #else
+      // conversion is not supported
+      aFormat.SetNbComponents (4);
+      aFormat.SetInternalFormat (GL_RGBA8);
+      if (theIsColorMap
+       && theCtx->ToRenderSRGB())
+      {
+        aFormat.SetInternalFormat (GL_SRGB8_ALPHA8);
+      }
+    #endif
+      aFormat.SetPixelFormat (GL_RGBA);
+      aFormat.SetDataType (GL_UNSIGNED_BYTE);
+      return aFormat;
+    }
+    case Image_Format_BGR32:
+    {
+    #if !defined(GL_ES_VERSION_2_0)
+      if (!theCtx->IsGlGreaterEqual(1, 2) && !theCtx->extBgra)
+      {
+        return aFormat;
+      }
+      aFormat.SetNbComponents (3);
+      aFormat.SetInternalFormat (GL_RGB8);
+      if (theIsColorMap
+       && theCtx->ToRenderSRGB())
+      {
+        aFormat.SetInternalFormat (GL_SRGB8); /// TODO
+      }
+    #else
+      if (!theCtx->extBgra)
+      {
+        return false;
+      }
+      aFormat.SetNbComponents (4);
+      aFormat.SetInternalFormat (GL_BGRA_EXT);
+    #endif
+      aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA
+      aFormat.SetDataType (GL_UNSIGNED_BYTE);
+      return aFormat;
+    }
+    case Image_Format_RGB:
+    {
+      aFormat.SetNbComponents (3);
+      aFormat.SetInternalFormat (GL_RGB8);
+      aFormat.SetPixelFormat (GL_RGB);
+      aFormat.SetDataType (GL_UNSIGNED_BYTE);
+      if (theIsColorMap
+       && theCtx->ToRenderSRGB())
+      {
+        aFormat.SetInternalFormat (GL_SRGB8);
+      }
+      return aFormat;
+    }
+    case Image_Format_BGR:
+    {
+    #if !defined(GL_ES_VERSION_2_0)
+      if (!theCtx->IsGlGreaterEqual (1, 2)
+       && !theCtx->extBgra)
+      {
+        return aFormat;
+      }
+      aFormat.SetNbComponents (3);
+      aFormat.SetInternalFormat (GL_RGB8);
+      if (theIsColorMap
+       && theCtx->ToRenderSRGB())
+      {
+        aFormat.SetInternalFormat (GL_SRGB8);
+      }
+      aFormat.SetPixelFormat (GL_BGR); // equals to GL_BGR_EXT
+      aFormat.SetDataType (GL_UNSIGNED_BYTE);
+    #endif
+      return aFormat;
+    }
+    case Image_Format_Gray:
+    {
+      aFormat.SetNbComponents (1);
+      if (theCtx->core11 == NULL)
+      {
+        aFormat.SetInternalFormat (GL_R8);
+        aFormat.SetPixelFormat (GL_RED);
+      }
+      else
+      {
+      #if !defined(GL_ES_VERSION_2_0)
+        aFormat.SetInternalFormat (GL_LUMINANCE8);
+      #else
+        aFormat.SetInternalFormat (GL_LUMINANCE);
+      #endif
+        aFormat.SetPixelFormat (GL_LUMINANCE);
+      }
+      aFormat.SetDataType (GL_UNSIGNED_BYTE);
+      return aFormat;
+    }
+    case Image_Format_Alpha:
+    {
+      aFormat.SetNbComponents (1);
+      if (theCtx->core11 == NULL)
+      {
+        aFormat.SetInternalFormat (GL_R8);
+        aFormat.SetPixelFormat (GL_RED);
+      }
+      else
+      {
+      #if !defined(GL_ES_VERSION_2_0)
+        aFormat.SetInternalFormat (GL_ALPHA8);
+      #else
+        aFormat.SetInternalFormat (GL_ALPHA);
+      #endif
+        aFormat.SetPixelFormat (GL_ALPHA);
+      }
+      aFormat.SetDataType (GL_UNSIGNED_BYTE);
+      return aFormat;
+    }
+    case Image_Format_UNKNOWN:
+    {
+      return aFormat;
+    }
+  }
+  return aFormat;
+}
+
+// =======================================================================
+// function : FindSizedFormat
+// purpose  :
+// =======================================================================
+OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_Context)& theCtx,
+                                                            GLint theSizedFormat)
+{
+  OpenGl_TextureFormat aFormat;
+  switch (theSizedFormat)
+  {
+    case GL_RGBA32F:
+    {
+      aFormat.SetNbComponents (4);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_RGBA);
+      aFormat.SetDataType (GL_FLOAT);
+      return aFormat;
+    }
+    case GL_R32F:
+    {
+      aFormat.SetNbComponents (1);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_RED);
+      aFormat.SetDataType (GL_FLOAT);
+      return aFormat;
+    }
+    case GL_RGBA16F:
+    {
+      aFormat.SetNbComponents (4);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_RGBA);
+      aFormat.SetDataType (GL_HALF_FLOAT);
+      if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
+      {
+      #if defined(GL_ES_VERSION_2_0)
+        aFormat.SetDataType (GL_HALF_FLOAT_OES);
+      #else
+        aFormat.SetDataType (GL_FLOAT);
+      #endif
+      }
+      return aFormat;
+    }
+    case GL_R16F:
+    {
+      aFormat.SetNbComponents (1);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_RED);
+      aFormat.SetDataType (GL_HALF_FLOAT);
+      if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
+      {
+      #if defined(GL_ES_VERSION_2_0)
+        aFormat.SetDataType (GL_HALF_FLOAT_OES);
+      #else
+        aFormat.SetDataType (GL_FLOAT);
+      #endif
+      }
+      return aFormat;
+    }
+    case GL_SRGB8_ALPHA8:
+    case GL_RGBA8:
+    case GL_RGBA:
+    {
+      aFormat.SetNbComponents (4);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_RGBA);
+      aFormat.SetDataType (GL_UNSIGNED_BYTE);
+      if (theSizedFormat == GL_SRGB8_ALPHA8
+      && !theCtx->ToRenderSRGB())
+      {
+        aFormat.SetInternalFormat (GL_RGBA8); // fallback format
+      }
+      return aFormat;
+    }
+    case GL_SRGB8:
+    case GL_RGB8:
+    case GL_RGB:
+    {
+      aFormat.SetNbComponents (3);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_RGB);
+      aFormat.SetDataType (GL_UNSIGNED_BYTE);
+      if (theSizedFormat == GL_SRGB8
+      && !theCtx->ToRenderSRGB())
+      {
+        aFormat.SetInternalFormat (GL_RGB8); // fallback format
+      }
+      return aFormat;
+    }
+    // integer types
+    case GL_R32I:
+    {
+      aFormat.SetNbComponents (1);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_RED_INTEGER);
+      aFormat.SetDataType (GL_INT);
+      return aFormat;
+    }
+    case GL_RG32I:
+    {
+      aFormat.SetNbComponents (2);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_RG_INTEGER);
+      aFormat.SetDataType (GL_INT);
+      return aFormat;
+    }
+    // depth formats
+    case GL_DEPTH24_STENCIL8:
+    {
+      aFormat.SetNbComponents (2);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_DEPTH_STENCIL);
+      aFormat.SetDataType (GL_UNSIGNED_INT_24_8);
+      return aFormat;
+    }
+    case GL_DEPTH32F_STENCIL8:
+    {
+      aFormat.SetNbComponents (2);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_DEPTH_STENCIL);
+      aFormat.SetDataType (GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+      return aFormat;
+    }
+    case GL_DEPTH_COMPONENT16:
+    {
+      aFormat.SetNbComponents (1);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_DEPTH_COMPONENT);
+      aFormat.SetDataType (GL_UNSIGNED_SHORT);
+      return aFormat;
+    }
+    case GL_DEPTH_COMPONENT24:
+    {
+      aFormat.SetNbComponents (1);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_DEPTH_COMPONENT);
+      aFormat.SetDataType (GL_UNSIGNED_INT);
+      return aFormat;
+    }
+    case GL_DEPTH_COMPONENT32F:
+    {
+      aFormat.SetNbComponents (1);
+      aFormat.SetInternalFormat (theSizedFormat);
+      aFormat.SetPixelFormat (GL_DEPTH_COMPONENT);
+      aFormat.SetDataType (GL_FLOAT);
+      return aFormat;
+    }
+  }
+  return aFormat;
+}
diff --git a/src/OpenGl/OpenGl_TextureFormat.hxx b/src/OpenGl/OpenGl_TextureFormat.hxx
new file mode 100644 (file)
index 0000000..7bd95b6
--- /dev/null
@@ -0,0 +1,262 @@
+// Copyright (c) 2017-2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _OpenGl_TextureFormat_HeaderFile
+#define _OpenGl_TextureFormat_HeaderFile
+
+#include <Image_Format.hxx>
+#include <OpenGl_GlCore13.hxx>
+#include <Standard_Handle.hxx>
+
+class OpenGl_Context;
+
+//! Stores parameters of OpenGL texture format.
+class OpenGl_TextureFormat
+{
+public:
+
+  //! Returns texture format for specified type and number of channels.
+  //! @tparam theCompType component type
+  //! @tparam theNbComps  number of components
+  template<class theCompType, int theNbComps>
+  static OpenGl_TextureFormat Create();
+
+  //! Find texture format suitable to specified image format.
+  //! @param theCtx [in] OpenGL context defining supported texture formats
+  //! @param theFormat [in] image format
+  //! @param theIsColorMap [in] flag indicating color nature of image (to select sRGB texture)
+  //! @return found format or invalid format
+  Standard_EXPORT static OpenGl_TextureFormat FindFormat (const Handle(OpenGl_Context)& theCtx,
+                                                          Image_Format theFormat,
+                                                          bool theIsColorMap);
+
+  //! Find texture format suitable to specified internal (sized) texture format.
+  //! @param theCtx [in] OpenGL context defining supported texture formats
+  //! @param theSizedFormat [in] sized (internal) texture format (example: GL_RGBA8)
+  //! @return found format or invalid format
+  Standard_EXPORT static OpenGl_TextureFormat FindSizedFormat (const Handle(OpenGl_Context)& theCtx,
+                                                               GLint theSizedFormat);
+
+public:
+
+  //! Empty constructor (invalid texture format).
+  OpenGl_TextureFormat() : myInternalFormat (0), myPixelFormat (0), myDataType (0), myNbComponents (0) {}
+
+  //! Return TRUE if format is defined.
+  bool IsValid() const
+  {
+    return myInternalFormat != 0
+        && myPixelFormat != 0
+        && myDataType != 0;
+  }
+
+  //! Returns OpenGL internal format of the pixel data (example: GL_R32F).
+  GLint InternalFormat() const { return myInternalFormat; }
+
+  //! Sets texture internal format.
+  void SetInternalFormat (GLint theInternal) { myInternalFormat = theInternal; }
+
+  //! Returns OpenGL format of the pixel data (example: GL_RED).
+  GLenum PixelFormat() const { return myPixelFormat; }
+
+  //! Sets OpenGL format of the pixel data.
+  void SetPixelFormat (GLenum theFormat) { myPixelFormat = theFormat; }
+
+  //! Returns OpenGL data type of the pixel data (example: GL_FLOAT).
+  GLint DataType() const { return myDataType; }
+
+  //! Sets OpenGL data type of the pixel data.
+  void SetDataType (GLint theType) { myDataType = theType; }
+
+  //! Returns number of components (channels). Here for debugging purposes.
+  GLint NbComponents() const { return myNbComponents; }
+
+  //! Sets number of components (channels).
+  void SetNbComponents (GLint theNbComponents) { myNbComponents = theNbComponents; }
+
+  //! Return TRUE if internal texture format is sRGB(A).
+  bool IsSRGB() const
+  {
+    return myInternalFormat == GL_SRGB8
+        || myInternalFormat == GL_SRGB8_ALPHA8;
+  }
+
+public:
+
+  //! Returns OpenGL internal format of the pixel data (example: GL_R32F).
+  GLint Internal() const { return myInternalFormat; }
+
+  //! Returns OpenGL format of the pixel data (example: GL_RED).
+  GLenum Format() const { return myPixelFormat; }
+
+private:
+
+  GLint  myInternalFormat; //!< OpenGL internal format of the pixel data
+  GLenum myPixelFormat;    //!< OpenGL pixel format
+  GLint  myDataType;       //!< OpenGL data type of input pixel data
+  GLint  myNbComponents;   //!< number of channels for each pixel (from 1 to 4)
+
+};
+
+//! Selects preferable texture format for specified parameters.
+template<class T> struct OpenGl_TextureFormatSelector
+{
+  // Not implemented
+};
+
+//! Specialization for unsigned byte.
+template<> struct OpenGl_TextureFormatSelector<GLubyte>
+{
+  static GLint DataType() { return GL_UNSIGNED_BYTE; }
+  static GLint Internal (GLuint theChannels)
+  {
+    switch (theChannels)
+    {
+      case 1:  return GL_R8;
+      case 2:  return GL_RG8;
+      case 3:  return GL_RGB8;
+      case 4:  return GL_RGBA8;
+      default: return GL_NONE;
+    }
+  }
+};
+
+//! Specialization for unsigned short.
+template<> struct OpenGl_TextureFormatSelector<GLushort>
+{
+  static GLint DataType() { return GL_UNSIGNED_SHORT; }
+  static GLint Internal (GLuint theChannels)
+  {
+    switch (theChannels)
+    {
+      case 1:  return GL_R16;
+      case 2:  return GL_RG16;
+      case 3:  return GL_RGB16;
+      case 4:  return GL_RGBA16;
+      default: return GL_NONE;
+    }
+  }
+};
+
+//! Specialization for float.
+template<> struct OpenGl_TextureFormatSelector<GLfloat>
+{
+  static GLint DataType() { return GL_FLOAT; }
+  static GLint Internal (GLuint theChannels)
+  {
+    switch (theChannels)
+    {
+      case 1:  return GL_R32F;
+      case 2:  return GL_RG32F;
+      case 3:  return GL_RGB32F;
+      case 4:  return GL_RGBA32F;
+      default: return GL_NONE;
+    }
+  }
+};
+
+//! Specialization for unsigned int.
+template<> struct OpenGl_TextureFormatSelector<GLuint>
+{
+  static GLint DataType() { return GL_UNSIGNED_INT; }
+  static GLint Internal (GLuint theChannels)
+  {
+    switch (theChannels)
+    {
+      case 1:  return GL_RED;
+      case 2:  return GL_RG;
+      case 3:  return GL_RGB;
+      case 4:  return GL_RGBA;
+      default: return GL_NONE;
+    }
+  }
+};
+
+//! Only unsigned formats are available in OpenGL ES 2.0
+#if !defined(GL_ES_VERSION_2_0)
+//! Specialization for signed byte.
+template<> struct OpenGl_TextureFormatSelector<GLbyte>
+{
+  static GLint DataType() { return GL_BYTE; }
+  static GLint Internal (GLuint theChannels)
+  {
+    switch (theChannels)
+    {
+      case 1:  return GL_R8_SNORM;
+      case 2:  return GL_RG8_SNORM;
+      case 3:  return GL_RGB8_SNORM;
+      case 4:  return GL_RGBA8_SNORM;
+      default: return GL_NONE;
+    }
+  }
+};
+
+//! Specialization for signed short.
+template<> struct OpenGl_TextureFormatSelector<GLshort>
+{
+  static GLint DataType() { return GL_SHORT; }
+  static GLint Internal (GLuint theChannels)
+  {
+    switch (theChannels)
+    {
+      case 1:  return GL_R16_SNORM;
+      case 2:  return GL_RG16_SNORM;
+      case 3:  return GL_RGB16_SNORM;
+      case 4:  return GL_RGBA16_SNORM;
+      default: return GL_NONE;
+    }
+  }
+};
+
+//! Specialization for signed int.
+template<> struct OpenGl_TextureFormatSelector<GLint>
+{
+  static GLint DataType() { return GL_INT; }
+  static GLint Internal (GLuint theChannels)
+  {
+    switch (theChannels)
+    {
+      case 1:  return GL_RED_SNORM;
+      case 2:  return GL_RG_SNORM;
+      case 3:  return GL_RGB_SNORM;
+      case 4:  return GL_RGBA_SNORM;
+      default: return GL_NONE;
+    }
+  }
+};
+#endif
+
+// =======================================================================
+// function : Create
+// purpose  :
+// =======================================================================
+template<class theCompType, int theNbComps>
+inline OpenGl_TextureFormat OpenGl_TextureFormat::Create()
+{
+  OpenGl_TextureFormat aFormat;
+  aFormat.SetNbComponents (theNbComps);
+  aFormat.SetInternalFormat (OpenGl_TextureFormatSelector<theCompType>::Internal (theNbComps));
+  aFormat.SetDataType (OpenGl_TextureFormatSelector<theCompType>::DataType());
+  GLenum aPixelFormat = GL_NONE;
+  switch (theNbComps)
+  {
+    case 1: aPixelFormat = GL_RED;  break;
+    case 2: aPixelFormat = GL_RG;   break;
+    case 3: aPixelFormat = GL_RGB;  break;
+    case 4: aPixelFormat = GL_RGBA; break;
+  }
+  aFormat.SetPixelFormat (aPixelFormat);
+  return aFormat;
+}
+
+#endif // _OpenGl_TextureFormat_HeaderFile
index c8bbd176192f2d8141d168a338fb05b184201162..3341c1f1506b24efbaa0517b8e862fffd5e0890c 100644 (file)
@@ -301,9 +301,11 @@ bool OpenGl_TileSampler::upload (const Handle(OpenGl_Context)& theContext,
     ||  theOffsetsTexture->SizeY() != (int )anOffsets.SizeY
     || !theOffsetsTexture->IsValid())
     {
-      theOffsetsTexture->Release (theContext.operator->());
-      if (!theOffsetsTexture->Init (theContext, GL_RG32I, GL_RG_INTEGER, GL_INT,
-                                    (int )anOffsets.SizeX, (int )anOffsets.SizeY, Graphic3d_TOT_2D))
+      theOffsetsTexture->Release (theContext.get());
+      if (!theOffsetsTexture->Init (theContext,
+                                    OpenGl_TextureFormat::FindSizedFormat (theContext, GL_RG32I),
+                                    Graphic3d_Vec2i ((int )anOffsets.SizeX, (int )anOffsets.SizeY),
+                                    Graphic3d_TOT_2D))
       {
         hasErrors = true;
       }
index 17f44efa7ce0297533fcbabfeb815de53ca7c1d6..d016a2e2d58ddb85490db7d9a1d1d03ffb76e104 100644 (file)
@@ -57,7 +57,8 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
   myCurrLightSourceState (theCounter->Increment()),
   myLightsRevision       (0),
   myLastLightSourceState (0, 0),
-  myFboColorFormat       (GL_RGBA8),
+  mySRgbState            (-1),
+  myFboColorFormat       (GL_SRGB8_ALPHA8), // note that GL_SRGB8 is not required to be renderable, unlike GL_RGB8, GL_RGBA8, GL_SRGB8_ALPHA8
   myFboDepthFormat       (GL_DEPTH24_STENCIL8),
   myToFlipOutput         (Standard_False),
   myFrameCounter         (0),
@@ -132,13 +133,12 @@ OpenGl_View::~OpenGl_View()
 }
 
 // =======================================================================
-// function : ReleaseGlResources
+// function : releaseSrgbResources
 // purpose  :
 // =======================================================================
-void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
+void OpenGl_View::releaseSrgbResources (const Handle(OpenGl_Context)& theCtx)
 {
-  myGraduatedTrihedron.Release (theCtx.get());
-  myFrameStatsPrs.Release (theCtx.get());
+  myRenderParams.RebuildRayTracingShaders = true;
 
   if (!myTextureEnv.IsNull())
   {
@@ -184,6 +184,22 @@ void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
   myFullScreenQuad           .Release (theCtx.get());
   myFullScreenQuadFlip       .Release (theCtx.get());
 
+  // Technically we should also re-initialize all sRGB/RGB8 color textures.
+  // But for now consider this sRGB disabling/enabling to be done at application start-up
+  // and re-create dynamically only frame buffers.
+}
+
+// =======================================================================
+// function : ReleaseGlResources
+// purpose  :
+// =======================================================================
+void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
+{
+  myGraduatedTrihedron.Release (theCtx.get());
+  myFrameStatsPrs.Release (theCtx.get());
+
+  releaseSrgbResources (theCtx);
+
   releaseRaytraceResources (theCtx);
 }
 
@@ -259,7 +275,7 @@ void OpenGl_View::initTextureEnv (const Handle(OpenGl_Context)& theContext)
   Handle(Image_PixMap) anImage = myTextureEnvData->GetImage();
   if (!anImage.IsNull())
   {
-    aTextureEnv->Init (theContext, *anImage.operator->(), myTextureEnvData->Type());
+    aTextureEnv->Init (theContext, *anImage, myTextureEnvData->Type(), true);
   }
 }
 
index 87e6605ce82b97fe84d16631f8ff03e681156bd5..daf3f8a84d25d7a2c3ade2753280725ffcfb0b29 100644 (file)
@@ -78,6 +78,7 @@ public:
   //! Default destructor.
   Standard_EXPORT virtual ~OpenGl_View();
 
+  //! Release OpenGL resources.
   Standard_EXPORT void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
 
   //! Deletes and erases the view.
@@ -424,6 +425,9 @@ private:
 
 private:
 
+  //! Release sRGB resources (frame-buffers, textures, etc.).
+  void releaseSrgbResources (const Handle(OpenGl_Context)& theCtx);
+
   //! Copy content of Back buffer to the Front buffer.
   bool copyBackToFront();
 
@@ -490,6 +494,7 @@ protected: //! @name Rendering properties
 
   //! Two framebuffers (left and right views) store cached main presentation
   //! of the view (without presentation of immediate layers).
+  Standard_Integer           mySRgbState;             //!< track sRGB state
   GLint                      myFboColorFormat;        //!< sized format for color attachments
   GLint                      myFboDepthFormat;        //!< sized format for depth-stencil attachments
   OpenGl_ColorFormats        myFboOitColorConfig;     //!< selected color format configuration for OIT color attachments
index e64e55906b16eea6c61d1d7b599ffdfc3c1bb5f9..5530426c076da9122866b785078fa32beb207a6d 100644 (file)
@@ -393,6 +393,11 @@ OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const OpenGl_Aspects* theA
                                     anIndex == 0 ? 1.0f : anIndex,
                                     anIndex == 0 ? 1.0f : 1.0f / anIndex);
 
+  aResMat.Ambient  = theGlContext->Vec4FromQuantityColor (aResMat.Ambient);
+  aResMat.Diffuse  = theGlContext->Vec4FromQuantityColor (aResMat.Diffuse);
+  aResMat.Specular = theGlContext->Vec4FromQuantityColor (aResMat.Specular);
+  aResMat.Emission = theGlContext->Vec4FromQuantityColor (aResMat.Emission);
+
   // Serialize physically-based material properties
   const Graphic3d_BSDF& aBSDF = aSrcMat.BSDF();
 
@@ -1095,6 +1100,10 @@ TCollection_AsciiString OpenGl_View::generateShaderPrefix (const Handle(OpenGl_C
   {
     aPrefixString += TCollection_AsciiString ("\n#define TRANSPARENT_SHADOWS");
   }
+  if (!theGlContext->ToRenderSRGB())
+  {
+    aPrefixString += TCollection_AsciiString ("\n#define THE_SHIFT_sRGB");
+  }
 
   // If OpenGL driver supports bindless textures and texturing
   // is actually used, activate texturing in ray-tracing mode
@@ -1866,12 +1875,16 @@ Standard_Boolean OpenGl_View::updateRaytraceBuffers (const Standard_Integer
       // workaround for some NVIDIA drivers
       myRaytraceVisualErrorTexture[aViewIter]->Release (theGlContext.operator->());
       myRaytraceTileSamplesTexture[aViewIter]->Release (theGlContext.operator->());
-      myRaytraceVisualErrorTexture[aViewIter]->Init (theGlContext, GL_R32I, GL_RED_INTEGER, GL_INT,
-                                                     myTileSampler.NbTilesX(), myTileSampler.NbTilesY(), Graphic3d_TOT_2D);
+      myRaytraceVisualErrorTexture[aViewIter]->Init (theGlContext,
+                                                     OpenGl_TextureFormat::FindSizedFormat (theGlContext, GL_R32I),
+                                                     Graphic3d_Vec2i (myTileSampler.NbTilesX(), myTileSampler.NbTilesY()),
+                                                     Graphic3d_TOT_2D);
       if (!myRaytraceParameters.AdaptiveScreenSamplingAtomic)
       {
-        myRaytraceTileSamplesTexture[aViewIter]->Init (theGlContext, GL_R32I, GL_RED_INTEGER, GL_INT,
-                                                       myTileSampler.NbTilesX(), myTileSampler.NbTilesY(), Graphic3d_TOT_2D);
+        myRaytraceTileSamplesTexture[aViewIter]->Init (theGlContext,
+                                                       OpenGl_TextureFormat::FindSizedFormat (theGlContext, GL_R32I),
+                                                       Graphic3d_Vec2i (myTileSampler.NbTilesX(), myTileSampler.NbTilesY()),
+                                                       Graphic3d_TOT_2D);
       }
     }
     else // non-adaptive mode
@@ -2564,24 +2577,18 @@ Standard_Boolean OpenGl_View::setUniformState (const Standard_Integer        the
       static_cast<GLsizei> (aTextures.size()), reinterpret_cast<const OpenGl_Vec2u*> (&aTextures.front()));
   }
 
-  // Set background colors (only gradient background supported)
+  // Set background colors (only vertical gradient background supported)
+  OpenGl_Vec4 aBackColorTop = myBgColor, aBackColorBot = myBgColor;
   if (myBackgrounds[Graphic3d_TOB_GRADIENT] != NULL
    && myBackgrounds[Graphic3d_TOB_GRADIENT]->IsDefined())
   {
-    theProgram->SetUniform (theGlContext,
-      myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (0));
-    theProgram->SetUniform (theGlContext,
-      myUniformLocations[theProgramId][OpenGl_RT_uBackColorBot], myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (1));
-  }
-  else
-  {
-    const OpenGl_Vec4& aBackColor = myBgColor;
-
-    theProgram->SetUniform (theGlContext,
-      myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], aBackColor);
-    theProgram->SetUniform (theGlContext,
-      myUniformLocations[theProgramId][OpenGl_RT_uBackColorBot], aBackColor);
+    aBackColorTop = myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (0);
+    aBackColorBot = myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (1);
   }
+  aBackColorTop = theGlContext->Vec4FromQuantityColor (aBackColorTop);
+  aBackColorBot = theGlContext->Vec4FromQuantityColor (aBackColorBot);
+  theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], aBackColorTop);
+  theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uBackColorBot], aBackColorBot);
 
   // Set environment map parameters
   const Standard_Boolean toDisableEnvironmentMap = myTextureEnv.IsNull()
index fd0acf55bb09b85ed1f85d146ee949228d588332..4298543d14b3b88ad6b633eba9f5f1a944cef281 100644 (file)
@@ -180,10 +180,20 @@ void OpenGl_View::Redraw()
   ++myFrameCounter;
   const Graphic3d_StereoMode   aStereoMode  = myRenderParams.StereoMode;
   Graphic3d_Camera::Projection aProjectType = myCamera->ProjectionType();
-  Handle(OpenGl_Context)       aCtx         = myWorkspace->GetGlContext();
+  const Handle(OpenGl_Context)& aCtx        = myWorkspace->GetGlContext();
   aCtx->FrameStats()->FrameStart (myWorkspace->View(), false);
   aCtx->SetLineFeather (myRenderParams.LineFeather);
 
+  const Standard_Integer anSRgbState = aCtx->ToRenderSRGB() ? 1 : 0;
+  if (mySRgbState != -1
+   && mySRgbState != anSRgbState)
+  {
+    releaseSrgbResources (aCtx);
+    initTextureEnv (aCtx);
+  }
+  mySRgbState = anSRgbState;
+  aCtx->ShaderManager()->UpdateSRgbState();
+
   // release pending GL resources
   aCtx->ReleaseDelayed();
 
@@ -799,7 +809,7 @@ void OpenGl_View::redraw (const Graphic3d_Camera::Projection theProjection,
   glClearDepthf (1.0f);
 #endif
 
-  const OpenGl_Vec4& aBgColor = myBgColor;
+  const OpenGl_Vec4 aBgColor = aCtx->Vec4FromQuantityColor (myBgColor);
   glClearColor (aBgColor.r(), aBgColor.g(), aBgColor.b(), 0.0f);
 
   glClear (toClear);
index c812775bcab797da2d7b3b71a19beda3acaae603..918688f74f82077dd3b6becff1bc15e4d84bcb03 100644 (file)
@@ -192,6 +192,13 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
   EGLSurface anEglSurf = EGL_NO_SURFACE;
   if ((EGLContext )theGContext == EGL_NO_CONTEXT)
   {
+    // EGL_KHR_gl_colorspace extension specifies if OpenGL should write into window buffer as into sRGB or RGB framebuffer
+    //const int aSurfAttribs[] =
+    //{
+    //  EGL_GL_COLORSPACE_KHR, !theCaps->sRGBDisable ? EGL_GL_COLORSPACE_SRGB_KHR : EGL_GL_COLORSPACE_LINEAR_KHR,
+    //  EGL_NONE,
+    //};
+
     // create new surface
     anEglSurf = eglCreateWindowSurface (anEglDisplay,
                                         anEglConfig,
@@ -221,6 +228,8 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
         {
           EGL_WIDTH,  myWidth,
           EGL_HEIGHT, myHeight,
+          // EGL_KHR_gl_colorspace extension specifies if OpenGL should write into window buffer as into sRGB or RGB framebuffer
+          //EGL_GL_COLORSPACE_KHR, !theCaps->sRGBDisable ? EGL_GL_COLORSPACE_SRGB_KHR : EGL_GL_COLORSPACE_LINEAR_KHR,
           EGL_NONE
         };
         anEglSurf = eglCreatePbufferSurface (anEglDisplay, anEglConfig, aSurfAttribs);
@@ -365,6 +374,10 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
         WGL_COLOR_BITS_ARB,     24,
         WGL_DEPTH_BITS_ARB,     24,
         WGL_STENCIL_BITS_ARB,   8,
+        // WGL_EXT_colorspace extension specifies if OpenGL should write into window buffer as into sRGB or RGB framebuffer
+        //WGL_COLORSPACE_EXT, !theCaps->sRGBDisable ? WGL_COLORSPACE_SRGB_EXT : WGL_COLORSPACE_LINEAR_EXT,
+        // requires WGL_ARB_framebuffer_sRGB or WGL_EXT_framebuffer_sRGB extensions
+        //WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT, !theCaps->sRGBDisable ? GL_TRUE : GL_FALSE,
         WGL_ACCELERATION_ARB,   theCaps->contextNoAccel ? WGL_NO_ACCELERATION_ARB : WGL_FULL_ACCELERATION_ARB,
         0, 0,
       };
index 71f074b58518f08a3d9e6ffabdfff9fb3607749a..edfe12b7d33aee2cfff6457d75c152966f481261 100644 (file)
@@ -54,8 +54,9 @@ namespace
 // function : Init
 // purpose  :
 // =======================================================================
-void OpenGl_Material::Init (const Graphic3d_MaterialAspect& theMat,
-                            const Quantity_Color&           theInteriorColor)
+void OpenGl_Material::Init (const OpenGl_Context& theCtx,
+                            const Graphic3d_MaterialAspect& theMat,
+                            const Quantity_Color& theInteriorColor)
 {
   ChangeShine()        = 128.0f * theMat.Shininess();
   ChangeTransparency() = theMat.Alpha();
@@ -82,6 +83,11 @@ void OpenGl_Material::Init (const Graphic3d_MaterialAspect& theMat,
       break;
     }
   }
+
+  Ambient  = theCtx.Vec4FromQuantityColor (Ambient);
+  Diffuse  = theCtx.Vec4FromQuantityColor (Diffuse);
+  Specular = theCtx.Vec4FromQuantityColor (Specular);
+  Emission = theCtx.Vec4FromQuantityColor (Emission);
 }
 
 // =======================================================================
@@ -341,7 +347,7 @@ Handle(OpenGl_FrameBuffer) OpenGl_Workspace::FBOCreate (const Standard_Integer t
   const Handle(OpenGl_Context)& aCtx = GetGlContext();
   aCtx->BindTextures (Handle(OpenGl_TextureSet)());
   Handle(OpenGl_FrameBuffer) aFrameBuffer = new OpenGl_FrameBuffer();
-  if (!aFrameBuffer->Init (aCtx, theWidth, theHeight, GL_RGBA8, GL_DEPTH24_STENCIL8, 0))
+  if (!aFrameBuffer->Init (aCtx, theWidth, theHeight, GL_SRGB8_ALPHA8, GL_DEPTH24_STENCIL8, 0))
   {
     aFrameBuffer->Release (aCtx.operator->());
     return Handle(OpenGl_FrameBuffer)();
index 87457bda7ececfbf02653e90c5f77ab57f7097d1..0660ff45cd5bff840e023d66a993c8f324c9b976 100644 (file)
@@ -1103,8 +1103,8 @@ static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc,
 
   Handle(AIS_Shape) anAisIO = new AIS_Shape(aShape);
 
-  Quantity_Color aColF(0.0, 0.4, 0.0, Quantity_TOC_RGB);
-  Quantity_Color aColB(0.0, 0.0, 0.6, Quantity_TOC_RGB);
+  Quantity_Color aColF(0.0, 0.4, 0.0, Quantity_TOC_sRGB);
+  Quantity_Color aColB(0.0, 0.0, 0.6, Quantity_TOC_sRGB);
 
   Handle(Prs3d_Drawer) aDrawer = anAisIO->Attributes();
   Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
@@ -1130,9 +1130,9 @@ static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc,
   anAISContext->Display (anAisIO, 1, 0, Standard_True);
 
   Standard_Real r, g, b; 
-  aShadingAspect->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB);
+  aShadingAspect->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_sRGB);
   di << "Info: color on front side (" << r << "," << g << "," << b << ")\n";
-  aShadingAspect->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB);
+  aShadingAspect->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_sRGB);
   di << "Info: color on back side (" << r << "," << g << "," << b << ")\n";
 
   return 0;
@@ -1163,8 +1163,8 @@ static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc,
   AISContext->Display (ais, 1, 0, Standard_False);
   AISContext->SetMaterial (ais, Graphic3d_NOM_SHINY_PLASTIC, Standard_False);
 
-  Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB); 
-  Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB); 
+  Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_sRGB);
+  Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_sRGB);
   Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect(); 
 
   Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE); 
index dfce9c34fe33f95f2789e14595915fc072ea9cc2..2f835f57846f6df17851e04f6160256423fedc30 100644 (file)
@@ -1688,7 +1688,7 @@ static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, c
   XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1);
   TDataStd_Name::Set(lab1, "Box1");
         
-  Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
+  Quantity_Color yellow(Quantity_NOC_YELLOW);
   XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen);
   XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0);
 
@@ -1731,7 +1731,7 @@ static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, c
   TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
   XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->UpdateAssemblies();
 
-  Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
+  Quantity_Color yellow(Quantity_NOC_YELLOW);
   XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen);
   XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0);
 
index 404cae0bda375c0015aedb9c3ea5d9a1a4f90d37..92f512e846531d28fb5f85faae6bcdaacab4e9fb 100644 (file)
@@ -95,8 +95,9 @@ NCollection_Vec3<float> Quantity_Color::valuesOf (const Quantity_NameOfColor the
   const NCollection_Vec3<float>& anRgb = THE_COLORS[theName].RgbValues;
   switch (theType)
   {
-    case Quantity_TOC_RGB: return anRgb;
-    case Quantity_TOC_HLS: return Convert_sRGB_To_HLS (anRgb);
+    case Quantity_TOC_RGB:  return anRgb;
+    case Quantity_TOC_sRGB: return Convert_LinearRGB_To_sRGB (anRgb);
+    case Quantity_TOC_HLS:  return Convert_LinearRGB_To_HLS (anRgb);
   }
   throw Standard_ProgramError("Internal error");
 }
@@ -190,10 +191,18 @@ Quantity_Color::Quantity_Color (const Standard_Real theR1, const Standard_Real t
       myRgb.SetValues (float(theR1), float(theR2), float(theR3));
       break;
     }
+    case Quantity_TOC_sRGB:
+    {
+      Quantity_ColorValidateRgbRange(theR1, theR2, theR3);
+      myRgb.SetValues (Convert_sRGB_To_LinearRGB (float(theR1)),
+                       Convert_sRGB_To_LinearRGB (float(theR2)),
+                       Convert_sRGB_To_LinearRGB (float(theR3)));
+      break;
+    }
     case Quantity_TOC_HLS:
     {
       Quantity_ColorValidateHlsRange(theR1, theR2, theR3);
-      myRgb = Convert_HLS_To_sRGB (NCollection_Vec3<float> (float(theR1), float(theR2), float(theR3)));
+      myRgb = Convert_HLS_To_LinearRGB (NCollection_Vec3<float> (float(theR1), float(theR2), float(theR3)));
       break;
     }
   }
@@ -215,11 +224,11 @@ Quantity_Color::Quantity_Color (const NCollection_Vec3<float>& theRgb)
 // =======================================================================
 void Quantity_Color::ChangeContrast (const Standard_Real theDelta)
 {
-  NCollection_Vec3<float> aHls = Convert_sRGB_To_HLS (myRgb);
+  NCollection_Vec3<float> aHls = Convert_LinearRGB_To_HLS (myRgb);
   aHls[2] += aHls[2] * Standard_ShortReal (theDelta) / 100.0f; // saturation
   if (!((aHls[2] > 1.0f) || (aHls[2] < 0.0f)))
   {
-    myRgb = Convert_HLS_To_sRGB (aHls);
+    myRgb = Convert_HLS_To_LinearRGB (aHls);
   }
 }
 
@@ -229,11 +238,11 @@ void Quantity_Color::ChangeContrast (const Standard_Real theDelta)
 // =======================================================================
 void Quantity_Color::ChangeIntensity (const Standard_Real theDelta)
 {
-  NCollection_Vec3<float> aHls = Convert_sRGB_To_HLS (myRgb);
+  NCollection_Vec3<float> aHls = Convert_LinearRGB_To_HLS (myRgb);
   aHls[1] += aHls[1] * Standard_ShortReal (theDelta) / 100.0f; // light
   if (!((aHls[1] > 1.0f) || (aHls[1] < 0.0f)))
   {
-    myRgb = Convert_HLS_To_sRGB (aHls);
+    myRgb = Convert_HLS_To_LinearRGB (aHls);
   }
 }
 
@@ -252,10 +261,18 @@ void Quantity_Color::SetValues (const Standard_Real theR1, const Standard_Real t
       myRgb.SetValues (float(theR1), float(theR2), float(theR3));
       break;
     }
+    case Quantity_TOC_sRGB:
+    {
+      Quantity_ColorValidateRgbRange(theR1, theR2, theR3);
+      myRgb.SetValues (Convert_sRGB_To_LinearRGB (float(theR1)),
+                       Convert_sRGB_To_LinearRGB (float(theR2)),
+                       Convert_sRGB_To_LinearRGB (float(theR3)));
+      break;
+    }
     case Quantity_TOC_HLS:
     {
       Quantity_ColorValidateHlsRange(theR1, theR2, theR3);
-      myRgb = Convert_HLS_To_sRGB (NCollection_Vec3<float> (float(theR1), float(theR2), float(theR3)));
+      myRgb = Convert_HLS_To_LinearRGB (NCollection_Vec3<float> (float(theR1), float(theR2), float(theR3)));
       break;
     }
   }
@@ -269,8 +286,8 @@ void Quantity_Color::Delta (const Quantity_Color& theColor,
                             Standard_Real& theDC,
                             Standard_Real& theDI) const
 {
-  const NCollection_Vec3<float> aHls1 = Convert_sRGB_To_HLS (myRgb);
-  const NCollection_Vec3<float> aHls2 = Convert_sRGB_To_HLS (theColor.myRgb);
+  const NCollection_Vec3<float> aHls1 = Convert_LinearRGB_To_HLS (myRgb);
+  const NCollection_Vec3<float> aHls2 = Convert_LinearRGB_To_HLS (theColor.myRgb);
   theDC = Standard_Real (aHls1[2] - aHls2[2]); // saturation
   theDI = Standard_Real (aHls1[1] - aHls2[1]); // light
 }
@@ -315,9 +332,16 @@ void Quantity_Color::Values (Standard_Real& theR1, Standard_Real& theR2, Standar
       theR3 = myRgb.b();
       break;
     }
+    case Quantity_TOC_sRGB:
+    {
+      theR1 = Convert_LinearRGB_To_sRGB (myRgb.r());
+      theR2 = Convert_LinearRGB_To_sRGB (myRgb.g());
+      theR3 = Convert_LinearRGB_To_sRGB (myRgb.b());
+      break;
+    }
     case Quantity_TOC_HLS:
     {
-      const NCollection_Vec3<float> aHls = Convert_sRGB_To_HLS (myRgb);
+      const NCollection_Vec3<float> aHls = Convert_LinearRGB_To_HLS (myRgb);
       theR1 = aHls[0];
       theR2 = aHls[1];
       theR3 = aHls[2];
index baaa2655925921fc5de705b2b9c5c8b338da0f37..9c2d1ceb3c5399f200ad4a2311afb43681ca75d8 100644 (file)
 #include <NCollection_Vec4.hxx>
 
 //! This class allows the definition of an RGB color as triplet of 3 normalized floating point values (red, green, blue).
+//!
+//! Although Quantity_Color can be technically used for pass-through storage of RGB triplet in any color space,
+//! other OCCT interfaces taking/returning Quantity_Color would expect them in linear space.
+//! Therefore, take a look into methods converting to and from non-linear sRGB color space, if needed;
+//! for instance, application usually providing color picking within 0..255 range in sRGB color space.
 class Quantity_Color
 {
 public:
@@ -83,10 +88,10 @@ public:
   //! Returns the Hue component (hue angle) of the color
   //! in degrees within range [0.0; 360.0], 0.0 being Red.
   //! -1.0 is a special value reserved for grayscale color (S should be 0.0)
-  Standard_Real Hue() const { return Convert_sRGB_To_HLS (myRgb)[0]; }
+  Standard_Real Hue() const { return Convert_LinearRGB_To_HLS (myRgb)[0]; }
 
   //! Returns the Light component (value of the lightness) of the color within range [0.0; 1.0].
-  Standard_Real Light() const { return Convert_sRGB_To_HLS (myRgb)[1]; }
+  Standard_Real Light() const { return Convert_LinearRGB_To_HLS (myRgb)[1]; }
 
   //! Increases or decreases the intensity (variation of the lightness).
   //! The delta is a percentage. Any value greater than zero will increase the intensity.
@@ -94,7 +99,7 @@ public:
   Standard_EXPORT void ChangeIntensity (const Standard_Real theDelta);
 
   //! Returns the Saturation component (value of the saturation) of the color within range [0.0; 1.0].
-  Standard_Real Saturation() const { return Convert_sRGB_To_HLS (myRgb)[2]; }
+  Standard_Real Saturation() const { return Convert_LinearRGB_To_HLS (myRgb)[2]; }
 
   //! Increases or decreases the contrast (variation of the saturation).
   //! The delta is a percentage. Any value greater than zero will increase the contrast.
@@ -175,7 +180,7 @@ public:
   static TCollection_AsciiString ColorToHex (const Quantity_Color& theColor,
                                              const bool theToPrefixHash = true)
   {
-    NCollection_Vec3<Standard_ShortReal> anSRgb = (NCollection_Vec3<Standard_ShortReal> )theColor;
+    NCollection_Vec3<Standard_ShortReal> anSRgb = Convert_LinearRGB_To_sRGB ((NCollection_Vec3<Standard_ShortReal> )theColor);
     NCollection_Vec3<Standard_Integer> anSRgbInt (anSRgb * 255.0f + NCollection_Vec3<Standard_ShortReal> (0.5f));
     char aBuff[10];
     Sprintf (aBuff, theToPrefixHash ? "#%02X%02X%02X" : "%02X%02X%02X",
@@ -203,6 +208,8 @@ public:
 
   //! Convert the color value to ARGB integer value, with alpha equals to 0.
   //! So the output is formatted as 0x00RRGGBB.
+  //! Note that this unpacking does NOT involve non-linear sRGB -> linear RGB conversion,
+  //! as would be usually expected for RGB color packed into 4 bytes.
   //! @param theColor [in] color to convert
   //! @param theARGB [out] result color encoded as integer
   static void Color2argb (const Quantity_Color& theColor,
@@ -216,14 +223,16 @@ public:
              |  (aColor.b() & 0xff));
   }
 
-  //! Convert integer ARGB value to Color. Alpha bits are ignored
+  //! Convert integer ARGB value to Color. Alpha bits are ignored.
+  //! Note that this packing does NOT involve linear -> non-linear sRGB conversion,
+  //! as would be usually expected to preserve higher (for human eye) color precision in 4 bytes.
   static void Argb2color (const Standard_Integer theARGB,
                           Quantity_Color& theColor)
   {
     const NCollection_Vec3<Standard_Real> aColor (static_cast <Standard_Real> ((theARGB & 0xff0000) >> 16),
                                                   static_cast <Standard_Real> ((theARGB & 0x00ff00) >> 8),
                                                   static_cast <Standard_Real> ((theARGB & 0x0000ff)));
-    theColor.SetValues (aColor.r() / 255.0, aColor.g() / 255.0, aColor.b() / 255.0, Quantity_TOC_RGB);
+    theColor.SetValues (aColor.r() / 255.0, aColor.g() / 255.0, aColor.b() / 255.0, Quantity_TOC_sRGB);
   }
 
 public:
@@ -292,7 +301,7 @@ public:
   //! Set the value used to compare two colors for equality.
   Standard_EXPORT static void SetEpsilon (const Standard_Real theEpsilon);
 
-  //! Converts HLS components into RGB ones.
+  //! Converts HLS components into sRGB ones.
   static void HlsRgb (const Standard_Real theH, const Standard_Real theL, const Standard_Real theS,
                       Standard_Real& theR, Standard_Real& theG, Standard_Real& theB)
   {
@@ -302,7 +311,7 @@ public:
     theB = anRgb[2];
   }
 
-  //! Converts RGB components into HLS ones.
+  //! Converts sRGB components into HLS ones.
   static void RgbHls (const Standard_Real theR, const Standard_Real theG, const Standard_Real theB,
                       Standard_Real& theH, Standard_Real& theL, Standard_Real& theS)
   {
index b7ade567a5a82adb7a65ae0e9f0848ba7667b90a..40183b20a871d0f15020247586250744d0f0e475 100644 (file)
@@ -78,7 +78,7 @@ namespace
     for (Standard_Integer aColorComponentIndex = 2; aColorComponentIndex >= 0; --aColorComponentIndex)
     {
       const Standard_ShortReal aColorComponent = takeColorComponentFromInteger (theColorInteger, theColorComponentBase);
-      aColor[aColorComponentIndex]             = aColorComponent;
+      aColor[aColorComponentIndex]             = Quantity_Color::Convert_sRGB_To_LinearRGB (aColorComponent);
     }
     if (theColorInteger != 0)
     {
index 7c3cbdb2b65d048f6151635718a26de3f29efd45..3b9eb2fa727477ee7cd9559ae26ccad41a98e2c8 100644 (file)
@@ -125,7 +125,7 @@ public:
   static TCollection_AsciiString ColorToHex (const Quantity_ColorRGBA& theColor,
                                              const bool theToPrefixHash = true)
   {
-    NCollection_Vec4<Standard_ShortReal> anSRgb = (NCollection_Vec4<Standard_ShortReal> )theColor;
+    NCollection_Vec4<Standard_ShortReal> anSRgb = Convert_LinearRGB_To_sRGB ((NCollection_Vec4<Standard_ShortReal> )theColor);
     NCollection_Vec4<Standard_Integer> anSRgbInt (anSRgb * 255.0f + NCollection_Vec4<Standard_ShortReal> (0.5f));
     char aBuff[12];
     Sprintf (aBuff, theToPrefixHash ? "#%02X%02X%02X%02X" : "%02X%02X%02X%02X",
index 95e45f7f349c6b307c36cc7765c6e13398ab0e10..2382eadeece4c0ec23a6246b2ec6b88b442052ec 100644 (file)
 RawColor(BLACK               , 0x000000, 0.000000, 0.000000, 0.000000),
-RawColor(MATRABLUE           , 0x0000BF, 0.000000, 0.000000, 0.750000),
-RawColor(MATRAGRAY           , 0x999999, 0.600000, 0.600000, 0.600000),
-RawColor(ALICEBLUE           , 0xF0F8FF, 0.941176, 0.972549, 1.000000),
-RawColor(ANTIQUEWHITE        , 0xFAEBD7, 0.980392, 0.921569, 0.843137),
-RawColor(ANTIQUEWHITE1       , 0xFFEFDB, 1.000000, 0.937255, 0.858824),
-RawColor(ANTIQUEWHITE2       , 0xEEDFCC, 0.933333, 0.874510, 0.800000),
-RawColor(ANTIQUEWHITE3       , 0xCDC0B0, 0.803922, 0.752941, 0.690196),
-RawColor(ANTIQUEWHITE4       , 0x8B8378, 0.545098, 0.513725, 0.470588),
-RawColor(AQUAMARINE1         , 0x7FFFD4, 0.498039, 1.000000, 0.831373),
-RawColor(AQUAMARINE2         , 0x76EEC6, 0.462745, 0.933333, 0.776471),
-RawColor(AQUAMARINE4         , 0x458B74, 0.270588, 0.545098, 0.454902),
-RawColor(AZURE               , 0xF0FFFF, 0.941176, 1.000000, 1.000000),
-RawColor(AZURE2              , 0xE0EEEE, 0.878431, 0.933333, 0.933333),
-RawColor(AZURE3              , 0xC1CDCD, 0.756863, 0.803922, 0.803922),
-RawColor(AZURE4              , 0x838B8B, 0.513725, 0.545098, 0.545098),
-RawColor(BEIGE               , 0xF5F5DC, 0.960784, 0.960784, 0.862745),
-RawColor(BISQUE              , 0xFFE4C4, 1.000000, 0.894118, 0.768627),
-RawColor(BISQUE2             , 0xEED5B7, 0.933333, 0.835294, 0.717647),
-RawColor(BISQUE3             , 0xCDB79E, 0.803922, 0.717647, 0.619608),
-RawColor(BISQUE4             , 0x8B7D6B, 0.545098, 0.490196, 0.419608),
-RawColor(BLANCHEDALMOND      , 0xFFEBCD, 1.000000, 0.921569, 0.803922),
+RawColor(MATRABLUE           , 0x0000BF, 0.000000, 0.000000, 0.522522),
+RawColor(MATRAGRAY           , 0x999999, 0.318547, 0.318547, 0.318547),
+RawColor(ALICEBLUE           , 0xF0F8FF, 0.871366, 0.938686, 1.000000),
+RawColor(ANTIQUEWHITE        , 0xFAEBD7, 0.955973, 0.830771, 0.679542),
+RawColor(ANTIQUEWHITE1       , 0xFFEFDB, 1.000000, 0.863158, 0.708377),
+RawColor(ANTIQUEWHITE2       , 0xEEDFCC, 0.854992, 0.737911, 0.603827),
+RawColor(ANTIQUEWHITE3       , 0xCDC0B0, 0.610496, 0.527115, 0.434154),
+RawColor(ANTIQUEWHITE4       , 0x8B8378, 0.258183, 0.226965, 0.187821),
+RawColor(AQUAMARINE1         , 0x7FFFD4, 0.212231, 1.000000, 0.658376),
+RawColor(AQUAMARINE2         , 0x76EEC6, 0.181164, 0.854992, 0.564712),
+RawColor(AQUAMARINE4         , 0x458B74, 0.059511, 0.258183, 0.174647),
+RawColor(AZURE               , 0xF0FFFF, 0.871366, 1.000000, 1.000000),
+RawColor(AZURE2              , 0xE0EEEE, 0.745404, 0.854992, 0.854992),
+RawColor(AZURE3              , 0xC1CDCD, 0.533277, 0.610496, 0.610496),
+RawColor(AZURE4              , 0x838B8B, 0.226965, 0.258183, 0.258183),
+RawColor(BEIGE               , 0xF5F5DC, 0.913098, 0.913098, 0.715693),
+RawColor(BISQUE              , 0xFFE4C4, 1.000000, 0.775823, 0.552011),
+RawColor(BISQUE2             , 0xEED5B7, 0.854992, 0.665387, 0.473531),
+RawColor(BISQUE3             , 0xCDB79E, 0.610496, 0.473531, 0.341915),
+RawColor(BISQUE4             , 0x8B7D6B, 0.258183, 0.205079, 0.147027),
+RawColor(BLANCHEDALMOND      , 0xFFEBCD, 1.000000, 0.830771, 0.610496),
 RawColor(BLUE                , 0x0000FF, 0.000000, 0.000000, 1.000000),
-RawColor(BLUE2               , 0x0000EE, 0.000000, 0.000000, 0.933333),
-RawColor(BLUE3               , 0x0000CD, 0.000000, 0.000000, 0.803922),
-RawColor(BLUE4               , 0x00008B, 0.000000, 0.000000, 0.545098),
-RawColor(BLUEVIOLET          , 0x8A2BE2, 0.541176, 0.168627, 0.886275),
-RawColor(BROWN               , 0xA52A2A, 0.647059, 0.164706, 0.164706),
-RawColor(BROWN1              , 0xFF4040, 1.000000, 0.250980, 0.250980),
-RawColor(BROWN2              , 0xEE3B3B, 0.933333, 0.231373, 0.231373),
-RawColor(BROWN3              , 0xCD3333, 0.803922, 0.200000, 0.200000),
-RawColor(BROWN4              , 0x8B2323, 0.545098, 0.137255, 0.137255),
-RawColor(BURLYWOOD           , 0xDEB887, 0.870588, 0.721569, 0.529412),
-RawColor(BURLYWOOD1          , 0xFFD39B, 1.000000, 0.827451, 0.607843),
-RawColor(BURLYWOOD2          , 0xEEC591, 0.933333, 0.772549, 0.568627),
-RawColor(BURLYWOOD3          , 0xCDAA7D, 0.803922, 0.666667, 0.490196),
-RawColor(BURLYWOOD4          , 0x8B7355, 0.545098, 0.450980, 0.333333),
-RawColor(CADETBLUE           , 0x5F9EA0, 0.372549, 0.619608, 0.627451),
-RawColor(CADETBLUE1          , 0x98F5FF, 0.596078, 0.960784, 1.000000),
-RawColor(CADETBLUE2          , 0x8EE5EE, 0.556863, 0.898039, 0.933333),
-RawColor(CADETBLUE3          , 0x7AC5CD, 0.478431, 0.772549, 0.803922),
-RawColor(CADETBLUE4          , 0x53868B, 0.325490, 0.525490, 0.545098),
-RawColor(CHARTREUSE          , 0x7FFF00, 0.498039, 1.000000, 0.000000),
-RawColor(CHARTREUSE2         , 0x76EE00, 0.462745, 0.933333, 0.000000),
-RawColor(CHARTREUSE3         , 0x66CD00, 0.400000, 0.803922, 0.000000),
-RawColor(CHARTREUSE4         , 0x458B00, 0.270588, 0.545098, 0.000000),
-RawColor(CHOCOLATE           , 0xD2691E, 0.823529, 0.411765, 0.117647),
-RawColor(CHOCOLATE1          , 0xFF7F24, 1.000000, 0.498039, 0.141176),
-RawColor(CHOCOLATE2          , 0xEE7621, 0.933333, 0.462745, 0.129412),
-RawColor(CHOCOLATE3          , 0xCD661D, 0.803922, 0.400000, 0.113725),
-RawColor(CHOCOLATE4          , 0x8B4513, 0.545098, 0.270588, 0.074510),
-RawColor(CORAL               , 0xFF7F50, 1.000000, 0.498039, 0.313725),
-RawColor(CORAL1              , 0xFF7256, 1.000000, 0.447059, 0.337255),
-RawColor(CORAL2              , 0xEE6A50, 0.933333, 0.415686, 0.313725),
-RawColor(CORAL3              , 0xCD5B45, 0.803922, 0.356863, 0.270588),
-RawColor(CORAL4              , 0x8B3E2F, 0.545098, 0.243137, 0.184314),
-RawColor(CORNFLOWERBLUE      , 0x6495ED, 0.392157, 0.584314, 0.929412),
-RawColor(CORNSILK1           , 0xFFF8DC, 1.000000, 0.972549, 0.862745),
-RawColor(CORNSILK2           , 0xEEE8CD, 0.933333, 0.909804, 0.803922),
-RawColor(CORNSILK3           , 0xCDC8B1, 0.803922, 0.784314, 0.694118),
-RawColor(CORNSILK4           , 0x8B8878, 0.545098, 0.533333, 0.470588),
+RawColor(BLUE2               , 0x0000EE, 0.000000, 0.000000, 0.854992),
+RawColor(BLUE3               , 0x0000CD, 0.000000, 0.000000, 0.610496),
+RawColor(BLUE4               , 0x00008B, 0.000000, 0.000000, 0.258183),
+RawColor(BLUEVIOLET          , 0x8A2BE2, 0.254152, 0.024158, 0.760525),
+RawColor(BROWN               , 0xA52A2A, 0.376262, 0.023153, 0.023153),
+RawColor(BROWN1              , 0xFF4040, 1.000000, 0.051269, 0.051269),
+RawColor(BROWN2              , 0xEE3B3B, 0.854992, 0.043735, 0.043735),
+RawColor(BROWN3              , 0xCD3333, 0.610496, 0.033105, 0.033105),
+RawColor(BROWN4              , 0x8B2323, 0.258183, 0.016807, 0.016807),
+RawColor(BURLYWOOD           , 0xDEB887, 0.730460, 0.479321, 0.242281),
+RawColor(BURLYWOOD1          , 0xFFD39B, 1.000000, 0.651406, 0.327778),
+RawColor(BURLYWOOD2          , 0xEEC591, 0.854992, 0.558340, 0.283148),
+RawColor(BURLYWOOD3          , 0xCDAA7D, 0.610496, 0.401978, 0.205079),
+RawColor(BURLYWOOD4          , 0x8B7355, 0.258183, 0.171441, 0.090842),
+RawColor(CADETBLUE           , 0x5F9EA0, 0.114435, 0.341915, 0.351533),
+RawColor(CADETBLUE1          , 0x98F5FF, 0.313988, 0.913098, 1.000000),
+RawColor(CADETBLUE2          , 0x8EE5EE, 0.270498, 0.783537, 0.854992),
+RawColor(CADETBLUE3          , 0x7AC5CD, 0.194617, 0.558340, 0.610496),
+RawColor(CADETBLUE4          , 0x53868B, 0.086500, 0.238397, 0.258183),
+RawColor(CHARTREUSE          , 0x7FFF00, 0.212231, 1.000000, 0.000000),
+RawColor(CHARTREUSE2         , 0x76EE00, 0.181164, 0.854992, 0.000000),
+RawColor(CHARTREUSE3         , 0x66CD00, 0.132868, 0.610496, 0.000000),
+RawColor(CHARTREUSE4         , 0x458B00, 0.059511, 0.258183, 0.000000),
+RawColor(CHOCOLATE           , 0xD2691E, 0.644479, 0.141264, 0.012983),
+RawColor(CHOCOLATE1          , 0xFF7F24, 1.000000, 0.212231, 0.017642),
+RawColor(CHOCOLATE2          , 0xEE7621, 0.854992, 0.181164, 0.015209),
+RawColor(CHOCOLATE3          , 0xCD661D, 0.610496, 0.132868, 0.012286),
+RawColor(CHOCOLATE4          , 0x8B4513, 0.258183, 0.059511, 0.006512),
+RawColor(CORAL               , 0xFF7F50, 1.000000, 0.212231, 0.080220),
+RawColor(CORAL1              , 0xFF7256, 1.000000, 0.168270, 0.093059),
+RawColor(CORAL2              , 0xEE6A50, 0.854992, 0.144128, 0.080220),
+RawColor(CORAL3              , 0xCD5B45, 0.610496, 0.104617, 0.059511),
+RawColor(CORAL4              , 0x8B3E2F, 0.258183, 0.048172, 0.028426),
+RawColor(CORNFLOWERBLUE      , 0x6495ED, 0.127438, 0.300544, 0.846874),
+RawColor(CORNSILK1           , 0xFFF8DC, 1.000000, 0.938686, 0.715693),
+RawColor(CORNSILK2           , 0xEEE8CD, 0.854992, 0.806952, 0.610496),
+RawColor(CORNSILK3           , 0xCDC8B1, 0.610496, 0.577581, 0.439658),
+RawColor(CORNSILK4           , 0x8B8878, 0.258183, 0.246201, 0.187821),
 RawColor(CYAN                , 0x00FFFF, 0.000000, 1.000000, 1.000000),
-RawColor(CYAN2               , 0x00EEEE, 0.000000, 0.933333, 0.933333),
-RawColor(CYAN3               , 0x00CDCD, 0.000000, 0.803922, 0.803922),
-RawColor(CYAN4               , 0x008B8B, 0.000000, 0.545098, 0.545098),
-RawColor(DARKGOLDENROD       , 0xB8860B, 0.721569, 0.525490, 0.043137),
-RawColor(DARKGOLDENROD1      , 0xFFB90F, 1.000000, 0.725490, 0.058824),
-RawColor(DARKGOLDENROD2      , 0xEEAD0E, 0.933333, 0.678431, 0.054902),
-RawColor(DARKGOLDENROD3      , 0xCD950C, 0.803922, 0.584314, 0.047059),
-RawColor(DARKGOLDENROD4      , 0x8B6508, 0.545098, 0.396078, 0.031373),
-RawColor(DARKGREEN           , 0x006400, 0.000000, 0.392157, 0.000000),
-RawColor(DARKKHAKI           , 0xBDB76B, 0.741176, 0.717647, 0.419608),
-RawColor(DARKOLIVEGREEN      , 0x556B2F, 0.333333, 0.419608, 0.184314),
-RawColor(DARKOLIVEGREEN1     , 0xCAFF70, 0.792157, 1.000000, 0.439216),
-RawColor(DARKOLIVEGREEN2     , 0xBCEE68, 0.737255, 0.933333, 0.407843),
-RawColor(DARKOLIVEGREEN3     , 0xA2CD5A, 0.635294, 0.803922, 0.352941),
-RawColor(DARKOLIVEGREEN4     , 0x6E8B3D, 0.431373, 0.545098, 0.239216),
-RawColor(DARKORANGE          , 0xFF8C00, 1.000000, 0.549020, 0.000000),
-RawColor(DARKORANGE1         , 0xFF7F00, 1.000000, 0.498039, 0.000000),
-RawColor(DARKORANGE2         , 0xEE7600, 0.933333, 0.462745, 0.000000),
-RawColor(DARKORANGE3         , 0xCD6600, 0.803922, 0.400000, 0.000000),
-RawColor(DARKORANGE4         , 0x8B4500, 0.545098, 0.270588, 0.000000),
-RawColor(DARKORCHID          , 0x9932CC, 0.600000, 0.196078, 0.800000),
-RawColor(DARKORCHID1         , 0xBF3EFF, 0.749020, 0.243137, 1.000000),
-RawColor(DARKORCHID2         , 0xB23AEE, 0.698039, 0.227451, 0.933333),
-RawColor(DARKORCHID3         , 0x9A32CD, 0.603922, 0.196078, 0.803922),
-RawColor(DARKORCHID4         , 0x68228B, 0.407843, 0.133333, 0.545098),
-RawColor(DARKSALMON          , 0xE9967A, 0.913725, 0.588235, 0.478431),
-RawColor(DARKSEAGREEN        , 0x8FBC8F, 0.560784, 0.737255, 0.560784),
-RawColor(DARKSEAGREEN1       , 0xC1FFC1, 0.756863, 1.000000, 0.756863),
-RawColor(DARKSEAGREEN2       , 0xB4EEB4, 0.705882, 0.933333, 0.705882),
-RawColor(DARKSEAGREEN3       , 0x9BCD9B, 0.607843, 0.803922, 0.607843),
-RawColor(DARKSEAGREEN4       , 0x698B69, 0.411765, 0.545098, 0.411765),
-RawColor(DARKSLATEBLUE       , 0x483D8B, 0.282353, 0.239216, 0.545098),
-RawColor(DARKSLATEGRAY1      , 0x97FFFF, 0.592157, 1.000000, 1.000000),
-RawColor(DARKSLATEGRAY2      , 0x8DEEEE, 0.552941, 0.933333, 0.933333),
-RawColor(DARKSLATEGRAY3      , 0x79CDCD, 0.474510, 0.803922, 0.803922),
-RawColor(DARKSLATEGRAY4      , 0x528B8B, 0.321569, 0.545098, 0.545098),
-RawColor(DARKSLATEGRAY       , 0x2F4F4F, 0.184314, 0.309804, 0.309804),
-RawColor(DARKTURQUOISE       , 0x00CED1, 0.000000, 0.807843, 0.819608),
-RawColor(DARKVIOLET          , 0x9400D3, 0.580392, 0.000000, 0.827451),
-RawColor(DEEPPINK            , 0xFF1493, 1.000000, 0.078431, 0.576471),
-RawColor(DEEPPINK2           , 0xEE1289, 0.933333, 0.070588, 0.537255),
-RawColor(DEEPPINK3           , 0xCD1076, 0.803922, 0.062745, 0.462745),
-RawColor(DEEPPINK4           , 0x8B0A50, 0.545098, 0.039216, 0.313725),
-RawColor(DEEPSKYBLUE1        , 0x00BFFF, 0.000000, 0.749020, 1.000000),
-RawColor(DEEPSKYBLUE2        , 0x00B2EE, 0.000000, 0.698039, 0.933333),
-RawColor(DEEPSKYBLUE3        , 0x009ACD, 0.000000, 0.603922, 0.803922),
-RawColor(DEEPSKYBLUE4        , 0x00688B, 0.000000, 0.407843, 0.545098),
-RawColor(DODGERBLUE1         , 0x1E90FF, 0.117647, 0.564706, 1.000000),
-RawColor(DODGERBLUE2         , 0x1C86EE, 0.109804, 0.525490, 0.933333),
-RawColor(DODGERBLUE3         , 0x1874CD, 0.094118, 0.454902, 0.803922),
-RawColor(DODGERBLUE4         , 0x104E8B, 0.062745, 0.305882, 0.545098),
-RawColor(FIREBRICK           , 0xB22222, 0.698039, 0.133333, 0.133333),
-RawColor(FIREBRICK1          , 0xFF3030, 1.000000, 0.188235, 0.188235),
-RawColor(FIREBRICK2          , 0xEE2C2C, 0.933333, 0.172549, 0.172549),
-RawColor(FIREBRICK3          , 0xCD2626, 0.803922, 0.149020, 0.149020),
-RawColor(FIREBRICK4          , 0x8B1A1A, 0.545098, 0.101961, 0.101961),
-RawColor(FLORALWHITE         , 0xFFFAF0, 1.000000, 0.980392, 0.941176),
-RawColor(FORESTGREEN         , 0x228B22, 0.133333, 0.545098, 0.133333),
-RawColor(GAINSBORO           , 0xDCDCDC, 0.862745, 0.862745, 0.862745),
-RawColor(GHOSTWHITE          , 0xF8F8FF, 0.972549, 0.972549, 1.000000),
-RawColor(GOLD                , 0xFFD700, 1.000000, 0.843137, 0.000000),
-RawColor(GOLD2               , 0xEEC900, 0.933333, 0.788235, 0.000000),
-RawColor(GOLD3               , 0xCDAD00, 0.803922, 0.678431, 0.000000),
-RawColor(GOLD4               , 0x8B7500, 0.545098, 0.458824, 0.000000),
-RawColor(GOLDENROD           , 0xDAA520, 0.854902, 0.647059, 0.125490),
-RawColor(GOLDENROD1          , 0xFFC125, 1.000000, 0.756863, 0.145098),
-RawColor(GOLDENROD2          , 0xEEB422, 0.933333, 0.705882, 0.133333),
-RawColor(GOLDENROD3          , 0xCD9B1D, 0.803922, 0.607843, 0.113725),
-RawColor(GOLDENROD4          , 0x8B6914, 0.545098, 0.411765, 0.078431),
-RawColor(GRAY                , 0xC0C0C0, 0.752941, 0.752941, 0.752941),
+RawColor(CYAN2               , 0x00EEEE, 0.000000, 0.854992, 0.854992),
+RawColor(CYAN3               , 0x00CDCD, 0.000000, 0.610496, 0.610496),
+RawColor(CYAN4               , 0x008B8B, 0.000000, 0.258183, 0.258183),
+RawColor(DARKGOLDENROD       , 0xB8860B, 0.479321, 0.238397, 0.003347),
+RawColor(DARKGOLDENROD1      , 0xFFB90F, 1.000000, 0.485150, 0.004777),
+RawColor(DARKGOLDENROD2      , 0xEEAD0E, 0.854992, 0.417885, 0.004391),
+RawColor(DARKGOLDENROD3      , 0xCD950C, 0.610496, 0.300544, 0.003677),
+RawColor(DARKGOLDENROD4      , 0x8B6508, 0.258183, 0.130136, 0.002428),
+RawColor(DARKGREEN           , 0x006400, 0.000000, 0.127438, 0.000000),
+RawColor(DARKKHAKI           , 0xBDB76B, 0.508881, 0.473531, 0.147027),
+RawColor(DARKOLIVEGREEN      , 0x556B2F, 0.090842, 0.147027, 0.028426),
+RawColor(DARKOLIVEGREEN1     , 0xCAFF70, 0.590619, 1.000000, 0.162030),
+RawColor(DARKOLIVEGREEN2     , 0xBCEE68, 0.502887, 0.854992, 0.138432),
+RawColor(DARKOLIVEGREEN3     , 0xA2CD5A, 0.361307, 0.610496, 0.102242),
+RawColor(DARKOLIVEGREEN4     , 0x6E8B3D, 0.155927, 0.258183, 0.046665),
+RawColor(DARKORANGE          , 0xFF8C00, 1.000000, 0.262251, 0.000000),
+RawColor(DARKORANGE1         , 0xFF7F00, 1.000000, 0.212231, 0.000000),
+RawColor(DARKORANGE2         , 0xEE7600, 0.854992, 0.181164, 0.000000),
+RawColor(DARKORANGE3         , 0xCD6600, 0.610496, 0.132868, 0.000000),
+RawColor(DARKORANGE4         , 0x8B4500, 0.258183, 0.059511, 0.000000),
+RawColor(DARKORCHID          , 0x9932CC, 0.318547, 0.031896, 0.603827),
+RawColor(DARKORCHID1         , 0xBF3EFF, 0.520996, 0.048172, 1.000000),
+RawColor(DARKORCHID2         , 0xB23AEE, 0.445201, 0.042311, 0.854992),
+RawColor(DARKORCHID3         , 0x9A32CD, 0.323144, 0.031896, 0.610496),
+RawColor(DARKORCHID4         , 0x68228B, 0.138432, 0.015996, 0.258183),
+RawColor(DARKSALMON          , 0xE9967A, 0.814846, 0.304987, 0.194617),
+RawColor(DARKSEAGREEN        , 0x8FBC8F, 0.274677, 0.502887, 0.274677),
+RawColor(DARKSEAGREEN1       , 0xC1FFC1, 0.533277, 1.000000, 0.533277),
+RawColor(DARKSEAGREEN2       , 0xB4EEB4, 0.456411, 0.854992, 0.456411),
+RawColor(DARKSEAGREEN3       , 0x9BCD9B, 0.327778, 0.610496, 0.327778),
+RawColor(DARKSEAGREEN4       , 0x698B69, 0.141264, 0.258183, 0.141264),
+RawColor(DARKSLATEBLUE       , 0x483D8B, 0.064803, 0.046665, 0.258183),
+RawColor(DARKSLATEGRAY1      , 0x97FFFF, 0.309469, 1.000000, 1.000000),
+RawColor(DARKSLATEGRAY2      , 0x8DEEEE, 0.266355, 0.854992, 0.854992),
+RawColor(DARKSLATEGRAY3      , 0x79CDCD, 0.191202, 0.610496, 0.610496),
+RawColor(DARKSLATEGRAY4      , 0x528B8B, 0.084376, 0.258183, 0.258183),
+RawColor(DARKSLATEGRAY       , 0x2F4F4F, 0.028426, 0.078187, 0.078187),
+RawColor(DARKTURQUOISE       , 0x00CED1, 0.000000, 0.617206, 0.637597),
+RawColor(DARKVIOLET          , 0x9400D3, 0.296138, 0.000000, 0.651406),
+RawColor(DEEPPINK            , 0xFF1493, 1.000000, 0.006995, 0.291771),
+RawColor(DEEPPINK2           , 0xEE1289, 0.854992, 0.006049, 0.250158),
+RawColor(DEEPPINK3           , 0xCD1076, 0.610496, 0.005182, 0.181164),
+RawColor(DEEPPINK4           , 0x8B0A50, 0.258183, 0.003035, 0.080220),
+RawColor(DEEPSKYBLUE1        , 0x00BFFF, 0.000000, 0.520996, 1.000000),
+RawColor(DEEPSKYBLUE2        , 0x00B2EE, 0.000000, 0.445201, 0.854992),
+RawColor(DEEPSKYBLUE3        , 0x009ACD, 0.000000, 0.323144, 0.610496),
+RawColor(DEEPSKYBLUE4        , 0x00688B, 0.000000, 0.138432, 0.258183),
+RawColor(DODGERBLUE1         , 0x1E90FF, 0.012983, 0.278894, 1.000000),
+RawColor(DODGERBLUE2         , 0x1C86EE, 0.011612, 0.238397, 0.854992),
+RawColor(DODGERBLUE3         , 0x1874CD, 0.009134, 0.174647, 0.610496),
+RawColor(DODGERBLUE4         , 0x104E8B, 0.005182, 0.076185, 0.258183),
+RawColor(FIREBRICK           , 0xB22222, 0.445201, 0.015996, 0.015996),
+RawColor(FIREBRICK1          , 0xFF3030, 1.000000, 0.029557, 0.029557),
+RawColor(FIREBRICK2          , 0xEE2C2C, 0.854992, 0.025187, 0.025187),
+RawColor(FIREBRICK3          , 0xCD2626, 0.610496, 0.019382, 0.019382),
+RawColor(FIREBRICK4          , 0x8B1A1A, 0.258183, 0.010330, 0.010330),
+RawColor(FLORALWHITE         , 0xFFFAF0, 1.000000, 0.955973, 0.871366),
+RawColor(FORESTGREEN         , 0x228B22, 0.015996, 0.258183, 0.015996),
+RawColor(GAINSBORO           , 0xDCDCDC, 0.715693, 0.715693, 0.715693),
+RawColor(GHOSTWHITE          , 0xF8F8FF, 0.938686, 0.938686, 1.000000),
+RawColor(GOLD                , 0xFFD700, 1.000000, 0.679542, 0.000000),
+RawColor(GOLD2               , 0xEEC900, 0.854992, 0.584078, 0.000000),
+RawColor(GOLD3               , 0xCDAD00, 0.610496, 0.417885, 0.000000),
+RawColor(GOLD4               , 0x8B7500, 0.258183, 0.177889, 0.000000),
+RawColor(GOLDENROD           , 0xDAA520, 0.701102, 0.376262, 0.014444),
+RawColor(GOLDENROD1          , 0xFFC125, 1.000000, 0.533277, 0.018500),
+RawColor(GOLDENROD2          , 0xEEB422, 0.854992, 0.456411, 0.015996),
+RawColor(GOLDENROD3          , 0xCD9B1D, 0.610496, 0.327778, 0.012286),
+RawColor(GOLDENROD4          , 0x8B6914, 0.258183, 0.141264, 0.006995),
+RawColor(GRAY                , 0xC0C0C0, 0.527115, 0.527115, 0.527115),
 RawColor(GRAY0               , 0x000000, 0.000000, 0.000000, 0.000000),
-RawColor(GRAY1               , 0x030303, 0.011765, 0.011765, 0.011765),
-RawColor(GRAY2               , 0x050505, 0.019608, 0.019608, 0.019608),
-RawColor(GRAY3               , 0x080808, 0.031373, 0.031373, 0.031373),
-RawColor(GRAY4               , 0x0A0A0A, 0.039216, 0.039216, 0.039216),
-RawColor(GRAY5               , 0x0D0D0D, 0.050980, 0.050980, 0.050980),
-RawColor(GRAY6               , 0x0F0F0F, 0.058824, 0.058824, 0.058824),
-RawColor(GRAY7               , 0x121212, 0.070588, 0.070588, 0.070588),
-RawColor(GRAY8               , 0x141414, 0.078431, 0.078431, 0.078431),
-RawColor(GRAY9               , 0x171717, 0.090196, 0.090196, 0.090196),
-RawColor(GRAY10              , 0x1A1A1A, 0.101961, 0.101961, 0.101961),
-RawColor(GRAY11              , 0x1C1C1C, 0.109804, 0.109804, 0.109804),
-RawColor(GRAY12              , 0x1F1F1F, 0.121569, 0.121569, 0.121569),
-RawColor(GRAY13              , 0x212121, 0.129412, 0.129412, 0.129412),
-RawColor(GRAY14              , 0x242424, 0.141176, 0.141176, 0.141176),
-RawColor(GRAY15              , 0x262626, 0.149020, 0.149020, 0.149020),
-RawColor(GRAY16              , 0x292929, 0.160784, 0.160784, 0.160784),
-RawColor(GRAY17              , 0x2B2B2B, 0.168627, 0.168627, 0.168627),
-RawColor(GRAY18              , 0x2E2E2E, 0.180392, 0.180392, 0.180392),
-RawColor(GRAY19              , 0x303030, 0.188235, 0.188235, 0.188235),
-RawColor(GRAY20              , 0x333333, 0.200000, 0.200000, 0.200000),
-RawColor(GRAY21              , 0x363636, 0.211765, 0.211765, 0.211765),
-RawColor(GRAY22              , 0x383838, 0.219608, 0.219608, 0.219608),
-RawColor(GRAY23              , 0x3B3B3B, 0.231373, 0.231373, 0.231373),
-RawColor(GRAY24              , 0x3D3D3D, 0.239216, 0.239216, 0.239216),
-RawColor(GRAY25              , 0x404040, 0.250980, 0.250980, 0.250980),
-RawColor(GRAY26              , 0x424242, 0.258824, 0.258824, 0.258824),
-RawColor(GRAY27              , 0x454545, 0.270588, 0.270588, 0.270588),
-RawColor(GRAY28              , 0x474747, 0.278431, 0.278431, 0.278431),
-RawColor(GRAY29              , 0x4A4A4A, 0.290196, 0.290196, 0.290196),
-RawColor(GRAY30              , 0x4D4D4D, 0.301961, 0.301961, 0.301961),
-RawColor(GRAY31              , 0x4F4F4F, 0.309804, 0.309804, 0.309804),
-RawColor(GRAY32              , 0x525252, 0.321569, 0.321569, 0.321569),
-RawColor(GRAY33              , 0x545454, 0.329412, 0.329412, 0.329412),
-RawColor(GRAY34              , 0x575757, 0.341176, 0.341176, 0.341176),
-RawColor(GRAY35              , 0x595959, 0.349020, 0.349020, 0.349020),
-RawColor(GRAY36              , 0x5C5C5C, 0.360784, 0.360784, 0.360784),
-RawColor(GRAY37              , 0x5E5E5E, 0.368627, 0.368627, 0.368627),
-RawColor(GRAY38              , 0x616161, 0.380392, 0.380392, 0.380392),
-RawColor(GRAY39              , 0x636363, 0.388235, 0.388235, 0.388235),
-RawColor(GRAY40              , 0x666666, 0.400000, 0.400000, 0.400000),
-RawColor(GRAY41              , 0x696969, 0.411765, 0.411765, 0.411765),
-RawColor(GRAY42              , 0x6B6B6B, 0.419608, 0.419608, 0.419608),
-RawColor(GRAY43              , 0x6E6E6E, 0.431373, 0.431373, 0.431373),
-RawColor(GRAY44              , 0x707070, 0.439216, 0.439216, 0.439216),
-RawColor(GRAY45              , 0x737373, 0.450980, 0.450980, 0.450980),
-RawColor(GRAY46              , 0x757575, 0.458824, 0.458824, 0.458824),
-RawColor(GRAY47              , 0x787878, 0.470588, 0.470588, 0.470588),
-RawColor(GRAY48              , 0x7A7A7A, 0.478431, 0.478431, 0.478431),
-RawColor(GRAY49              , 0x7D7D7D, 0.490196, 0.490196, 0.490196),
-RawColor(GRAY50              , 0x7F7F7F, 0.498039, 0.498039, 0.498039),
-RawColor(GRAY51              , 0x828282, 0.509804, 0.509804, 0.509804),
-RawColor(GRAY52              , 0x858585, 0.521569, 0.521569, 0.521569),
-RawColor(GRAY53              , 0x878787, 0.529412, 0.529412, 0.529412),
-RawColor(GRAY54              , 0x8A8A8A, 0.541176, 0.541176, 0.541176),
-RawColor(GRAY55              , 0x8C8C8C, 0.549020, 0.549020, 0.549020),
-RawColor(GRAY56              , 0x8F8F8F, 0.560784, 0.560784, 0.560784),
-RawColor(GRAY57              , 0x919191, 0.568627, 0.568627, 0.568627),
-RawColor(GRAY58              , 0x949494, 0.580392, 0.580392, 0.580392),
-RawColor(GRAY59              , 0x969696, 0.588235, 0.588235, 0.588235),
-RawColor(GRAY60              , 0x999999, 0.600000, 0.600000, 0.600000),
-RawColor(GRAY61              , 0x9C9C9C, 0.611765, 0.611765, 0.611765),
-RawColor(GRAY62              , 0x9E9E9E, 0.619608, 0.619608, 0.619608),
-RawColor(GRAY63              , 0xA1A1A1, 0.631373, 0.631373, 0.631373),
-RawColor(GRAY64              , 0xA3A3A3, 0.639216, 0.639216, 0.639216),
-RawColor(GRAY65              , 0xA6A6A6, 0.650980, 0.650980, 0.650980),
-RawColor(GRAY66              , 0xA8A8A8, 0.658824, 0.658824, 0.658824),
-RawColor(GRAY67              , 0xABABAB, 0.670588, 0.670588, 0.670588),
-RawColor(GRAY68              , 0xADADAD, 0.678431, 0.678431, 0.678431),
-RawColor(GRAY69              , 0xB0B0B0, 0.690196, 0.690196, 0.690196),
-RawColor(GRAY70              , 0xB3B3B3, 0.701961, 0.701961, 0.701961),
-RawColor(GRAY71              , 0xB5B5B5, 0.709804, 0.709804, 0.709804),
-RawColor(GRAY72              , 0xB8B8B8, 0.721569, 0.721569, 0.721569),
-RawColor(GRAY73              , 0xBABABA, 0.729412, 0.729412, 0.729412),
-RawColor(GRAY74              , 0xBDBDBD, 0.741176, 0.741176, 0.741176),
-RawColor(GRAY75              , 0xBFBFBF, 0.749020, 0.749020, 0.749020),
-RawColor(GRAY76              , 0xC2C2C2, 0.760784, 0.760784, 0.760784),
-RawColor(GRAY77              , 0xC4C4C4, 0.768627, 0.768627, 0.768627),
-RawColor(GRAY78              , 0xC7C7C7, 0.780392, 0.780392, 0.780392),
-RawColor(GRAY79              , 0xC9C9C9, 0.788235, 0.788235, 0.788235),
-RawColor(GRAY80              , 0xCCCCCC, 0.800000, 0.800000, 0.800000),
-RawColor(GRAY81              , 0xCFCFCF, 0.811765, 0.811765, 0.811765),
-RawColor(GRAY82              , 0xD1D1D1, 0.819608, 0.819608, 0.819608),
-RawColor(GRAY83              , 0xD4D4D4, 0.831373, 0.831373, 0.831373),
-RawColor(GRAY85              , 0xD9D9D9, 0.850980, 0.850980, 0.850980),
-RawColor(GRAY86              , 0xDBDBDB, 0.858824, 0.858824, 0.858824),
-RawColor(GRAY87              , 0xDEDEDE, 0.870588, 0.870588, 0.870588),
-RawColor(GRAY88              , 0xE0E0E0, 0.878431, 0.878431, 0.878431),
-RawColor(GRAY89              , 0xE3E3E3, 0.890196, 0.890196, 0.890196),
-RawColor(GRAY90              , 0xE5E5E5, 0.898039, 0.898039, 0.898039),
-RawColor(GRAY91              , 0xE8E8E8, 0.909804, 0.909804, 0.909804),
-RawColor(GRAY92              , 0xEBEBEB, 0.921569, 0.921569, 0.921569),
-RawColor(GRAY93              , 0xEDEDED, 0.929412, 0.929412, 0.929412),
-RawColor(GRAY94              , 0xF0F0F0, 0.941176, 0.941176, 0.941176),
-RawColor(GRAY95              , 0xF2F2F2, 0.949020, 0.949020, 0.949020),
-RawColor(GRAY97              , 0xF7F7F7, 0.968627, 0.968627, 0.968627),
-RawColor(GRAY98              , 0xFAFAFA, 0.980392, 0.980392, 0.980392),
-RawColor(GRAY99              , 0xFCFCFC, 0.988235, 0.988235, 0.988235),
+RawColor(GRAY1               , 0x030303, 0.000911, 0.000911, 0.000911),
+RawColor(GRAY2               , 0x050505, 0.001518, 0.001518, 0.001518),
+RawColor(GRAY3               , 0x080808, 0.002428, 0.002428, 0.002428),
+RawColor(GRAY4               , 0x0A0A0A, 0.003035, 0.003035, 0.003035),
+RawColor(GRAY5               , 0x0D0D0D, 0.004025, 0.004025, 0.004025),
+RawColor(GRAY6               , 0x0F0F0F, 0.004777, 0.004777, 0.004777),
+RawColor(GRAY7               , 0x121212, 0.006049, 0.006049, 0.006049),
+RawColor(GRAY8               , 0x141414, 0.006995, 0.006995, 0.006995),
+RawColor(GRAY9               , 0x171717, 0.008568, 0.008568, 0.008568),
+RawColor(GRAY10              , 0x1A1A1A, 0.010330, 0.010330, 0.010330),
+RawColor(GRAY11              , 0x1C1C1C, 0.011612, 0.011612, 0.011612),
+RawColor(GRAY12              , 0x1F1F1F, 0.013702, 0.013702, 0.013702),
+RawColor(GRAY13              , 0x212121, 0.015209, 0.015209, 0.015209),
+RawColor(GRAY14              , 0x242424, 0.017642, 0.017642, 0.017642),
+RawColor(GRAY15              , 0x262626, 0.019382, 0.019382, 0.019382),
+RawColor(GRAY16              , 0x292929, 0.022174, 0.022174, 0.022174),
+RawColor(GRAY17              , 0x2B2B2B, 0.024158, 0.024158, 0.024158),
+RawColor(GRAY18              , 0x2E2E2E, 0.027321, 0.027321, 0.027321),
+RawColor(GRAY19              , 0x303030, 0.029557, 0.029557, 0.029557),
+RawColor(GRAY20              , 0x333333, 0.033105, 0.033105, 0.033105),
+RawColor(GRAY21              , 0x363636, 0.036890, 0.036890, 0.036890),
+RawColor(GRAY22              , 0x383838, 0.039546, 0.039546, 0.039546),
+RawColor(GRAY23              , 0x3B3B3B, 0.043735, 0.043735, 0.043735),
+RawColor(GRAY24              , 0x3D3D3D, 0.046665, 0.046665, 0.046665),
+RawColor(GRAY25              , 0x404040, 0.051269, 0.051269, 0.051269),
+RawColor(GRAY26              , 0x424242, 0.054480, 0.054480, 0.054480),
+RawColor(GRAY27              , 0x454545, 0.059511, 0.059511, 0.059511),
+RawColor(GRAY28              , 0x474747, 0.063010, 0.063010, 0.063010),
+RawColor(GRAY29              , 0x4A4A4A, 0.068478, 0.068478, 0.068478),
+RawColor(GRAY30              , 0x4D4D4D, 0.074214, 0.074214, 0.074214),
+RawColor(GRAY31              , 0x4F4F4F, 0.078187, 0.078187, 0.078187),
+RawColor(GRAY32              , 0x525252, 0.084376, 0.084376, 0.084376),
+RawColor(GRAY33              , 0x545454, 0.088656, 0.088656, 0.088656),
+RawColor(GRAY34              , 0x575757, 0.095307, 0.095307, 0.095307),
+RawColor(GRAY35              , 0x595959, 0.099899, 0.099899, 0.099899),
+RawColor(GRAY36              , 0x5C5C5C, 0.107023, 0.107023, 0.107023),
+RawColor(GRAY37              , 0x5E5E5E, 0.111932, 0.111932, 0.111932),
+RawColor(GRAY38              , 0x616161, 0.119538, 0.119538, 0.119538),
+RawColor(GRAY39              , 0x636363, 0.124772, 0.124772, 0.124772),
+RawColor(GRAY40              , 0x666666, 0.132868, 0.132868, 0.132868),
+RawColor(GRAY41              , 0x696969, 0.141264, 0.141264, 0.141264),
+RawColor(GRAY42              , 0x6B6B6B, 0.147027, 0.147027, 0.147027),
+RawColor(GRAY43              , 0x6E6E6E, 0.155927, 0.155927, 0.155927),
+RawColor(GRAY44              , 0x707070, 0.162030, 0.162030, 0.162030),
+RawColor(GRAY45              , 0x737373, 0.171441, 0.171441, 0.171441),
+RawColor(GRAY46              , 0x757575, 0.177889, 0.177889, 0.177889),
+RawColor(GRAY47              , 0x787878, 0.187821, 0.187821, 0.187821),
+RawColor(GRAY48              , 0x7A7A7A, 0.194617, 0.194617, 0.194617),
+RawColor(GRAY49              , 0x7D7D7D, 0.205079, 0.205079, 0.205079),
+RawColor(GRAY50              , 0x7F7F7F, 0.212231, 0.212231, 0.212231),
+RawColor(GRAY51              , 0x828282, 0.223228, 0.223228, 0.223228),
+RawColor(GRAY52              , 0x858585, 0.234551, 0.234551, 0.234551),
+RawColor(GRAY53              , 0x878787, 0.242281, 0.242281, 0.242281),
+RawColor(GRAY54              , 0x8A8A8A, 0.254152, 0.254152, 0.254152),
+RawColor(GRAY55              , 0x8C8C8C, 0.262251, 0.262251, 0.262251),
+RawColor(GRAY56              , 0x8F8F8F, 0.274677, 0.274677, 0.274677),
+RawColor(GRAY57              , 0x919191, 0.283148, 0.283148, 0.283148),
+RawColor(GRAY58              , 0x949494, 0.296138, 0.296138, 0.296138),
+RawColor(GRAY59              , 0x969696, 0.304987, 0.304987, 0.304987),
+RawColor(GRAY60              , 0x999999, 0.318547, 0.318547, 0.318547),
+RawColor(GRAY61              , 0x9C9C9C, 0.332452, 0.332452, 0.332452),
+RawColor(GRAY62              , 0x9E9E9E, 0.341915, 0.341915, 0.341915),
+RawColor(GRAY63              , 0xA1A1A1, 0.356401, 0.356401, 0.356401),
+RawColor(GRAY64              , 0xA3A3A3, 0.366253, 0.366253, 0.366253),
+RawColor(GRAY65              , 0xA6A6A6, 0.381326, 0.381326, 0.381326),
+RawColor(GRAY66              , 0xA8A8A8, 0.391573, 0.391573, 0.391573),
+RawColor(GRAY67              , 0xABABAB, 0.407240, 0.407240, 0.407240),
+RawColor(GRAY68              , 0xADADAD, 0.417885, 0.417885, 0.417885),
+RawColor(GRAY69              , 0xB0B0B0, 0.434154, 0.434154, 0.434154),
+RawColor(GRAY70              , 0xB3B3B3, 0.450786, 0.450786, 0.450786),
+RawColor(GRAY71              , 0xB5B5B5, 0.462077, 0.462077, 0.462077),
+RawColor(GRAY72              , 0xB8B8B8, 0.479321, 0.479321, 0.479321),
+RawColor(GRAY73              , 0xBABABA, 0.491021, 0.491021, 0.491021),
+RawColor(GRAY74              , 0xBDBDBD, 0.508881, 0.508881, 0.508881),
+RawColor(GRAY75              , 0xBFBFBF, 0.520996, 0.520996, 0.520996),
+RawColor(GRAY76              , 0xC2C2C2, 0.539479, 0.539479, 0.539479),
+RawColor(GRAY77              , 0xC4C4C4, 0.552011, 0.552011, 0.552011),
+RawColor(GRAY78              , 0xC7C7C7, 0.571125, 0.571125, 0.571125),
+RawColor(GRAY79              , 0xC9C9C9, 0.584078, 0.584078, 0.584078),
+RawColor(GRAY80              , 0xCCCCCC, 0.603827, 0.603827, 0.603827),
+RawColor(GRAY81              , 0xCFCFCF, 0.623961, 0.623961, 0.623961),
+RawColor(GRAY82              , 0xD1D1D1, 0.637597, 0.637597, 0.637597),
+RawColor(GRAY83              , 0xD4D4D4, 0.658376, 0.658376, 0.658376),
+RawColor(GRAY85              , 0xD9D9D9, 0.693871, 0.693871, 0.693871),
+RawColor(GRAY86              , 0xDBDBDB, 0.708377, 0.708377, 0.708377),
+RawColor(GRAY87              , 0xDEDEDE, 0.730460, 0.730460, 0.730460),
+RawColor(GRAY88              , 0xE0E0E0, 0.745404, 0.745404, 0.745404),
+RawColor(GRAY89              , 0xE3E3E3, 0.768151, 0.768151, 0.768151),
+RawColor(GRAY90              , 0xE5E5E5, 0.783537, 0.783537, 0.783537),
+RawColor(GRAY91              , 0xE8E8E8, 0.806952, 0.806952, 0.806952),
+RawColor(GRAY92              , 0xEBEBEB, 0.830771, 0.830771, 0.830771),
+RawColor(GRAY93              , 0xEDEDED, 0.846874, 0.846874, 0.846874),
+RawColor(GRAY94              , 0xF0F0F0, 0.871366, 0.871366, 0.871366),
+RawColor(GRAY95              , 0xF2F2F2, 0.887924, 0.887924, 0.887924),
+RawColor(GRAY97              , 0xF7F7F7, 0.930110, 0.930110, 0.930110),
+RawColor(GRAY98              , 0xFAFAFA, 0.955973, 0.955973, 0.955973),
+RawColor(GRAY99              , 0xFCFCFC, 0.973445, 0.973445, 0.973445),
 RawColor(GREEN               , 0x00FF00, 0.000000, 1.000000, 0.000000),
-RawColor(GREEN2              , 0x00EE00, 0.000000, 0.933333, 0.000000),
-RawColor(GREEN3              , 0x00CD00, 0.000000, 0.803922, 0.000000),
-RawColor(GREEN4              , 0x008B00, 0.000000, 0.545098, 0.000000),
-RawColor(GREENYELLOW         , 0xADFF2F, 0.678431, 1.000000, 0.184314),
-RawColor(HONEYDEW            , 0xF0FFF0, 0.941176, 1.000000, 0.941176),
-RawColor(HONEYDEW2           , 0xE0EEE0, 0.878431, 0.933333, 0.878431),
-RawColor(HONEYDEW3           , 0xC1CDC1, 0.756863, 0.803922, 0.756863),
-RawColor(HONEYDEW4           , 0x838B83, 0.513725, 0.545098, 0.513725),
-RawColor(HOTPINK             , 0xFF69B4, 1.000000, 0.411765, 0.705882),
-RawColor(HOTPINK1            , 0xFF6EB4, 1.000000, 0.431373, 0.705882),
-RawColor(HOTPINK2            , 0xEE6AA7, 0.933333, 0.415686, 0.654902),
-RawColor(HOTPINK3            , 0xCD6090, 0.803922, 0.376471, 0.564706),
-RawColor(HOTPINK4            , 0x8B3A62, 0.545098, 0.227451, 0.384314),
-RawColor(INDIANRED           , 0xCD5C5C, 0.803922, 0.360784, 0.360784),
-RawColor(INDIANRED1          , 0xFF6A6A, 1.000000, 0.415686, 0.415686),
-RawColor(INDIANRED2          , 0xEE6363, 0.933333, 0.388235, 0.388235),
-RawColor(INDIANRED3          , 0xCD5555, 0.803922, 0.333333, 0.333333),
-RawColor(INDIANRED4          , 0x8B3A3A, 0.545098, 0.227451, 0.227451),
-RawColor(IVORY               , 0xFFFFF0, 1.000000, 1.000000, 0.941176),
-RawColor(IVORY2              , 0xEEEEE0, 0.933333, 0.933333, 0.878431),
-RawColor(IVORY3              , 0xCDCDC1, 0.803922, 0.803922, 0.756863),
-RawColor(IVORY4              , 0x8B8B83, 0.545098, 0.545098, 0.513725),
-RawColor(KHAKI               , 0xF0E68C, 0.941176, 0.901961, 0.549020),
-RawColor(KHAKI1              , 0xFFF68F, 1.000000, 0.964706, 0.560784),
-RawColor(KHAKI2              , 0xEEE685, 0.933333, 0.901961, 0.521569),
-RawColor(KHAKI3              , 0xCDC673, 0.803922, 0.776471, 0.450980),
-RawColor(KHAKI4              , 0x8B864E, 0.545098, 0.525490, 0.305882),
-RawColor(LAVENDER            , 0xE6E6FA, 0.901961, 0.901961, 0.980392),
-RawColor(LAVENDERBLUSH1      , 0xFFF0F5, 1.000000, 0.941176, 0.960784),
-RawColor(LAVENDERBLUSH2      , 0xEEE0E5, 0.933333, 0.878431, 0.898039),
-RawColor(LAVENDERBLUSH3      , 0xCDC1C5, 0.803922, 0.756863, 0.772549),
-RawColor(LAVENDERBLUSH4      , 0x8B8386, 0.545098, 0.513725, 0.525490),
-RawColor(LAWNGREEN           , 0x7CFC00, 0.486275, 0.988235, 0.000000),
-RawColor(LEMONCHIFFON1       , 0xFFFACD, 1.000000, 0.980392, 0.803922),
-RawColor(LEMONCHIFFON2       , 0xEEE9BF, 0.933333, 0.913725, 0.749020),
-RawColor(LEMONCHIFFON3       , 0xCDC9A5, 0.803922, 0.788235, 0.647059),
-RawColor(LEMONCHIFFON4       , 0x8B8970, 0.545098, 0.537255, 0.439216),
-RawColor(LIGHTBLUE           , 0xADD8E6, 0.678431, 0.847059, 0.901961),
-RawColor(LIGHTBLUE1          , 0xBFEFFF, 0.749020, 0.937255, 1.000000),
-RawColor(LIGHTBLUE2          , 0xB2DFEE, 0.698039, 0.874510, 0.933333),
-RawColor(LIGHTBLUE3          , 0x9AC0CD, 0.603922, 0.752941, 0.803922),
-RawColor(LIGHTBLUE4          , 0x68838B, 0.407843, 0.513725, 0.545098),
-RawColor(LIGHTCORAL          , 0xF08080, 0.941176, 0.501961, 0.501961),
-RawColor(LIGHTCYAN           , 0xE0FFFF, 0.878431, 1.000000, 1.000000),
-RawColor(LIGHTCYAN2          , 0xD1EEEE, 0.819608, 0.933333, 0.933333),
-RawColor(LIGHTCYAN3          , 0xB4CDCD, 0.705882, 0.803922, 0.803922),
-RawColor(LIGHTCYAN4          , 0x7A8B8B, 0.478431, 0.545098, 0.545098),
-RawColor(LIGHTGOLDENROD      , 0xEEDD82, 0.933333, 0.866667, 0.509804),
-RawColor(LIGHTGOLDENROD1     , 0xFFEC8B, 1.000000, 0.925490, 0.545098),
-RawColor(LIGHTGOLDENROD2     , 0xEEDC82, 0.933333, 0.862745, 0.509804),
-RawColor(LIGHTGOLDENROD3     , 0xCDBE70, 0.803922, 0.745098, 0.439216),
-RawColor(LIGHTGOLDENROD4     , 0x8B814C, 0.545098, 0.505882, 0.298039),
-RawColor(LIGHTGOLDENRODYELLOW, 0xFAFAD2, 0.980392, 0.980392, 0.823529),
-RawColor(LIGHTGRAY           , 0xD3D3D3, 0.827451, 0.827451, 0.827451),
-RawColor(LIGHTPINK           , 0xFFB6C1, 1.000000, 0.713725, 0.756863),
-RawColor(LIGHTPINK1          , 0xFFAEB9, 1.000000, 0.682353, 0.725490),
-RawColor(LIGHTPINK2          , 0xEEA2AD, 0.933333, 0.635294, 0.678431),
-RawColor(LIGHTPINK3          , 0xCD8C95, 0.803922, 0.549020, 0.584314),
-RawColor(LIGHTPINK4          , 0x8B5F65, 0.545098, 0.372549, 0.396078),
-RawColor(LIGHTSALMON1        , 0xFFA07A, 1.000000, 0.627451, 0.478431),
-RawColor(LIGHTSALMON2        , 0xEE9572, 0.933333, 0.584314, 0.447059),
-RawColor(LIGHTSALMON3        , 0xCD8162, 0.803922, 0.505882, 0.384314),
-RawColor(LIGHTSALMON4        , 0x8B5742, 0.545098, 0.341176, 0.258824),
-RawColor(LIGHTSEAGREEN       , 0x20B2AA, 0.125490, 0.698039, 0.666667),
-RawColor(LIGHTSKYBLUE        , 0x87CEFA, 0.529412, 0.807843, 0.980392),
-RawColor(LIGHTSKYBLUE1       , 0xB0E2FF, 0.690196, 0.886275, 1.000000),
-RawColor(LIGHTSKYBLUE2       , 0xA4D3EE, 0.643137, 0.827451, 0.933333),
-RawColor(LIGHTSKYBLUE3       , 0x8DB6CD, 0.552941, 0.713725, 0.803922),
-RawColor(LIGHTSKYBLUE4       , 0x607B8B, 0.376471, 0.482353, 0.545098),
-RawColor(LIGHTSLATEBLUE      , 0x8470FF, 0.517647, 0.439216, 1.000000),
-RawColor(LIGHTSLATEGRAY      , 0x778899, 0.466667, 0.533333, 0.600000),
-RawColor(LIGHTSTEELBLUE      , 0xB0C4DE, 0.690196, 0.768627, 0.870588),
-RawColor(LIGHTSTEELBLUE1     , 0xCAE1FF, 0.792157, 0.882353, 1.000000),
-RawColor(LIGHTSTEELBLUE2     , 0xBCD2EE, 0.737255, 0.823529, 0.933333),
-RawColor(LIGHTSTEELBLUE3     , 0xA2B5CD, 0.635294, 0.709804, 0.803922),
-RawColor(LIGHTSTEELBLUE4     , 0x6E7B8B, 0.431373, 0.482353, 0.545098),
-RawColor(LIGHTYELLOW         , 0xFFFFE0, 1.000000, 1.000000, 0.878431),
-RawColor(LIGHTYELLOW2        , 0xEEEED1, 0.933333, 0.933333, 0.819608),
-RawColor(LIGHTYELLOW3        , 0xCDCDB4, 0.803922, 0.803922, 0.705882),
-RawColor(LIGHTYELLOW4        , 0x8B8B7A, 0.545098, 0.545098, 0.478431),
-RawColor(LIMEGREEN           , 0x32CD32, 0.196078, 0.803922, 0.196078),
-RawColor(LINEN               , 0xFAF0E6, 0.980392, 0.941176, 0.901961),
+RawColor(GREEN2              , 0x00EE00, 0.000000, 0.854992, 0.000000),
+RawColor(GREEN3              , 0x00CD00, 0.000000, 0.610496, 0.000000),
+RawColor(GREEN4              , 0x008B00, 0.000000, 0.258183, 0.000000),
+RawColor(GREENYELLOW         , 0xADFF2F, 0.417885, 1.000000, 0.028426),
+RawColor(HONEYDEW            , 0xF0FFF0, 0.871366, 1.000000, 0.871366),
+RawColor(HONEYDEW2           , 0xE0EEE0, 0.745404, 0.854992, 0.745404),
+RawColor(HONEYDEW3           , 0xC1CDC1, 0.533277, 0.610496, 0.533277),
+RawColor(HONEYDEW4           , 0x838B83, 0.226965, 0.258183, 0.226965),
+RawColor(HOTPINK             , 0xFF69B4, 1.000000, 0.141264, 0.456411),
+RawColor(HOTPINK1            , 0xFF6EB4, 1.000000, 0.155927, 0.456411),
+RawColor(HOTPINK2            , 0xEE6AA7, 0.854992, 0.144128, 0.386430),
+RawColor(HOTPINK3            , 0xCD6090, 0.610496, 0.116971, 0.278894),
+RawColor(HOTPINK4            , 0x8B3A62, 0.258183, 0.042311, 0.122139),
+RawColor(INDIANRED           , 0xCD5C5C, 0.610496, 0.107023, 0.107023),
+RawColor(INDIANRED1          , 0xFF6A6A, 1.000000, 0.144128, 0.144128),
+RawColor(INDIANRED2          , 0xEE6363, 0.854992, 0.124772, 0.124772),
+RawColor(INDIANRED3          , 0xCD5555, 0.610496, 0.090842, 0.090842),
+RawColor(INDIANRED4          , 0x8B3A3A, 0.258183, 0.042311, 0.042311),
+RawColor(IVORY               , 0xFFFFF0, 1.000000, 1.000000, 0.871366),
+RawColor(IVORY2              , 0xEEEEE0, 0.854992, 0.854992, 0.745404),
+RawColor(IVORY3              , 0xCDCDC1, 0.610496, 0.610496, 0.533277),
+RawColor(IVORY4              , 0x8B8B83, 0.258183, 0.258183, 0.226965),
+RawColor(KHAKI               , 0xF0E68C, 0.871366, 0.791299, 0.262251),
+RawColor(KHAKI1              , 0xFFF68F, 1.000000, 0.921582, 0.274677),
+RawColor(KHAKI2              , 0xEEE685, 0.854992, 0.791299, 0.234551),
+RawColor(KHAKI3              , 0xCDC673, 0.610496, 0.564712, 0.171441),
+RawColor(KHAKI4              , 0x8B864E, 0.258183, 0.238397, 0.076185),
+RawColor(LAVENDER            , 0xE6E6FA, 0.791299, 0.791299, 0.955973),
+RawColor(LAVENDERBLUSH1      , 0xFFF0F5, 1.000000, 0.871366, 0.913098),
+RawColor(LAVENDERBLUSH2      , 0xEEE0E5, 0.854992, 0.745404, 0.783537),
+RawColor(LAVENDERBLUSH3      , 0xCDC1C5, 0.610496, 0.533277, 0.558340),
+RawColor(LAVENDERBLUSH4      , 0x8B8386, 0.258183, 0.226965, 0.238397),
+RawColor(LAWNGREEN           , 0x7CFC00, 0.201557, 0.973445, 0.000000),
+RawColor(LEMONCHIFFON1       , 0xFFFACD, 1.000000, 0.955973, 0.610496),
+RawColor(LEMONCHIFFON2       , 0xEEE9BF, 0.854992, 0.814846, 0.520996),
+RawColor(LEMONCHIFFON3       , 0xCDC9A5, 0.610496, 0.584078, 0.376262),
+RawColor(LEMONCHIFFON4       , 0x8B8970, 0.258183, 0.250158, 0.162030),
+RawColor(LIGHTBLUE           , 0xADD8E6, 0.417885, 0.686686, 0.791299),
+RawColor(LIGHTBLUE1          , 0xBFEFFF, 0.520996, 0.863158, 1.000000),
+RawColor(LIGHTBLUE2          , 0xB2DFEE, 0.445201, 0.737911, 0.854992),
+RawColor(LIGHTBLUE3          , 0x9AC0CD, 0.323144, 0.527115, 0.610496),
+RawColor(LIGHTBLUE4          , 0x68838B, 0.138432, 0.226965, 0.258183),
+RawColor(LIGHTCORAL          , 0xF08080, 0.871366, 0.215861, 0.215861),
+RawColor(LIGHTCYAN           , 0xE0FFFF, 0.745404, 1.000000, 1.000000),
+RawColor(LIGHTCYAN2          , 0xD1EEEE, 0.637597, 0.854992, 0.854992),
+RawColor(LIGHTCYAN3          , 0xB4CDCD, 0.456411, 0.610496, 0.610496),
+RawColor(LIGHTCYAN4          , 0x7A8B8B, 0.194617, 0.258183, 0.258183),
+RawColor(LIGHTGOLDENROD      , 0xEEDD82, 0.854992, 0.723056, 0.223228),
+RawColor(LIGHTGOLDENROD1     , 0xFFEC8B, 1.000000, 0.838799, 0.258183),
+RawColor(LIGHTGOLDENROD2     , 0xEEDC82, 0.854992, 0.715693, 0.223228),
+RawColor(LIGHTGOLDENROD3     , 0xCDBE70, 0.610496, 0.514918, 0.162030),
+RawColor(LIGHTGOLDENROD4     , 0x8B814C, 0.258183, 0.219526, 0.072272),
+RawColor(LIGHTGOLDENRODYELLOW, 0xFAFAD2, 0.955973, 0.955973, 0.644479),
+RawColor(LIGHTGRAY           , 0xD3D3D3, 0.651406, 0.651406, 0.651406),
+RawColor(LIGHTPINK           , 0xFFB6C1, 1.000000, 0.467783, 0.533277),
+RawColor(LIGHTPINK1          , 0xFFAEB9, 1.000000, 0.423268, 0.485150),
+RawColor(LIGHTPINK2          , 0xEEA2AD, 0.854992, 0.361307, 0.417885),
+RawColor(LIGHTPINK3          , 0xCD8C95, 0.610496, 0.262251, 0.300544),
+RawColor(LIGHTPINK4          , 0x8B5F65, 0.258183, 0.114435, 0.130136),
+RawColor(LIGHTSALMON1        , 0xFFA07A, 1.000000, 0.351533, 0.194617),
+RawColor(LIGHTSALMON2        , 0xEE9572, 0.854992, 0.300544, 0.168270),
+RawColor(LIGHTSALMON3        , 0xCD8162, 0.610496, 0.219526, 0.122139),
+RawColor(LIGHTSALMON4        , 0x8B5742, 0.258183, 0.095307, 0.054480),
+RawColor(LIGHTSEAGREEN       , 0x20B2AA, 0.014444, 0.445201, 0.401978),
+RawColor(LIGHTSKYBLUE        , 0x87CEFA, 0.242281, 0.617206, 0.955973),
+RawColor(LIGHTSKYBLUE1       , 0xB0E2FF, 0.434154, 0.760525, 1.000000),
+RawColor(LIGHTSKYBLUE2       , 0xA4D3EE, 0.371237, 0.651406, 0.854992),
+RawColor(LIGHTSKYBLUE3       , 0x8DB6CD, 0.266355, 0.467783, 0.610496),
+RawColor(LIGHTSKYBLUE4       , 0x607B8B, 0.116971, 0.198069, 0.258183),
+RawColor(LIGHTSLATEBLUE      , 0x8470FF, 0.230740, 0.162030, 1.000000),
+RawColor(LIGHTSLATEGRAY      , 0x778899, 0.184475, 0.246201, 0.318547),
+RawColor(LIGHTSTEELBLUE      , 0xB0C4DE, 0.434154, 0.552011, 0.730460),
+RawColor(LIGHTSTEELBLUE1     , 0xCAE1FF, 0.590619, 0.752942, 1.000000),
+RawColor(LIGHTSTEELBLUE2     , 0xBCD2EE, 0.502887, 0.644479, 0.854992),
+RawColor(LIGHTSTEELBLUE3     , 0xA2B5CD, 0.361307, 0.462077, 0.610496),
+RawColor(LIGHTSTEELBLUE4     , 0x6E7B8B, 0.155927, 0.198069, 0.258183),
+RawColor(LIGHTYELLOW         , 0xFFFFE0, 1.000000, 1.000000, 0.745404),
+RawColor(LIGHTYELLOW2        , 0xEEEED1, 0.854992, 0.854992, 0.637597),
+RawColor(LIGHTYELLOW3        , 0xCDCDB4, 0.610496, 0.610496, 0.456411),
+RawColor(LIGHTYELLOW4        , 0x8B8B7A, 0.258183, 0.258183, 0.194617),
+RawColor(LIMEGREEN           , 0x32CD32, 0.031896, 0.610496, 0.031896),
+RawColor(LINEN               , 0xFAF0E6, 0.955973, 0.871366, 0.791299),
 RawColor(MAGENTA             , 0xFF00FF, 1.000000, 0.000000, 1.000000),
-RawColor(MAGENTA2            , 0xEE00EE, 0.933333, 0.000000, 0.933333),
-RawColor(MAGENTA3            , 0xCD00CD, 0.803922, 0.000000, 0.803922),
-RawColor(MAGENTA4            , 0x8B008B, 0.545098, 0.000000, 0.545098),
-RawColor(MAROON              , 0xB03060, 0.690196, 0.188235, 0.376471),
-RawColor(MAROON1             , 0xFF34B3, 1.000000, 0.203922, 0.701961),
-RawColor(MAROON2             , 0xEE30A7, 0.933333, 0.188235, 0.654902),
-RawColor(MAROON3             , 0xCD2990, 0.803922, 0.160784, 0.564706),
-RawColor(MAROON4             , 0x8B1C62, 0.545098, 0.109804, 0.384314),
-RawColor(MEDIUMAQUAMARINE    , 0x66CDAA, 0.400000, 0.803922, 0.666667),
-RawColor(MEDIUMORCHID        , 0xBA55D3, 0.729412, 0.333333, 0.827451),
-RawColor(MEDIUMORCHID1       , 0xE066FF, 0.878431, 0.400000, 1.000000),
-RawColor(MEDIUMORCHID2       , 0xD15FEE, 0.819608, 0.372549, 0.933333),
-RawColor(MEDIUMORCHID3       , 0xB452CD, 0.705882, 0.321569, 0.803922),
-RawColor(MEDIUMORCHID4       , 0x7A378B, 0.478431, 0.215686, 0.545098),
-RawColor(MEDIUMPURPLE        , 0x9370DB, 0.576471, 0.439216, 0.858824),
-RawColor(MEDIUMPURPLE1       , 0xAB82FF, 0.670588, 0.509804, 1.000000),
-RawColor(MEDIUMPURPLE2       , 0x9F79EE, 0.623529, 0.474510, 0.933333),
-RawColor(MEDIUMPURPLE3       , 0x8968CD, 0.537255, 0.407843, 0.803922),
-RawColor(MEDIUMPURPLE4       , 0x5D478B, 0.364706, 0.278431, 0.545098),
-RawColor(MEDIUMSEAGREEN      , 0x3CB371, 0.235294, 0.701961, 0.443137),
-RawColor(MEDIUMSLATEBLUE     , 0x7B68EE, 0.482353, 0.407843, 0.933333),
-RawColor(MEDIUMSPRINGGREEN   , 0x00FA9A, 0.000000, 0.980392, 0.603922),
-RawColor(MEDIUMTURQUOISE     , 0x48D1CC, 0.282353, 0.819608, 0.800000),
-RawColor(MEDIUMVIOLETRED     , 0xC71585, 0.780392, 0.082353, 0.521569),
-RawColor(MIDNIGHTBLUE        , 0x191970, 0.098039, 0.098039, 0.439216),
-RawColor(MINTCREAM           , 0xF5FFFA, 0.960784, 1.000000, 0.980392),
-RawColor(MISTYROSE           , 0xFFE4E1, 1.000000, 0.894118, 0.882353),
-RawColor(MISTYROSE2          , 0xEED5D2, 0.933333, 0.835294, 0.823529),
-RawColor(MISTYROSE3          , 0xCDB7B5, 0.803922, 0.717647, 0.709804),
-RawColor(MISTYROSE4          , 0x8B7D7B, 0.545098, 0.490196, 0.482353),
-RawColor(MOCCASIN            , 0xFFE4B5, 1.000000, 0.894118, 0.709804),
-RawColor(NAVAJOWHITE1        , 0xFFDEAD, 1.000000, 0.870588, 0.678431),
-RawColor(NAVAJOWHITE2        , 0xEECFA1, 0.933333, 0.811765, 0.631373),
-RawColor(NAVAJOWHITE3        , 0xCDB38B, 0.803922, 0.701961, 0.545098),
-RawColor(NAVAJOWHITE4        , 0x8B795E, 0.545098, 0.474510, 0.368627),
-RawColor(NAVYBLUE            , 0x000080, 0.000000, 0.000000, 0.501961),
-RawColor(OLDLACE             , 0xFDF5E6, 0.992157, 0.960784, 0.901961),
-RawColor(OLIVEDRAB           , 0x6B8E23, 0.419608, 0.556863, 0.137255),
-RawColor(OLIVEDRAB1          , 0xC0FF3E, 0.752941, 1.000000, 0.243137),
-RawColor(OLIVEDRAB2          , 0xB3EE3A, 0.701961, 0.933333, 0.227451),
-RawColor(OLIVEDRAB3          , 0x9ACD32, 0.603922, 0.803922, 0.196078),
-RawColor(OLIVEDRAB4          , 0x698B22, 0.411765, 0.545098, 0.133333),
-RawColor(ORANGE              , 0xFFA500, 1.000000, 0.647059, 0.000000),
-RawColor(ORANGE2             , 0xEE9A00, 0.933333, 0.603922, 0.000000),
-RawColor(ORANGE3             , 0xCD8500, 0.803922, 0.521569, 0.000000),
-RawColor(ORANGE4             , 0x8B5A00, 0.545098, 0.352941, 0.000000),
-RawColor(ORANGERED           , 0xFF4500, 1.000000, 0.270588, 0.000000),
-RawColor(ORANGERED2          , 0xEE4000, 0.933333, 0.250980, 0.000000),
-RawColor(ORANGERED3          , 0xCD3700, 0.803922, 0.215686, 0.000000),
-RawColor(ORANGERED4          , 0x8B2500, 0.545098, 0.145098, 0.000000),
-RawColor(ORCHID              , 0xDA70D6, 0.854902, 0.439216, 0.839216),
-RawColor(ORCHID1             , 0xFF83FA, 1.000000, 0.513725, 0.980392),
-RawColor(ORCHID2             , 0xEE7AE9, 0.933333, 0.478431, 0.913725),
-RawColor(ORCHID3             , 0xCD69C9, 0.803922, 0.411765, 0.788235),
-RawColor(ORCHID4             , 0x8B4789, 0.545098, 0.278431, 0.537255),
-RawColor(PALEGOLDENROD       , 0xEEE8AA, 0.933333, 0.909804, 0.666667),
-RawColor(PALEGREEN           , 0x98FB98, 0.596078, 0.984314, 0.596078),
-RawColor(PALEGREEN1          , 0x9AFF9A, 0.603922, 1.000000, 0.603922),
-RawColor(PALEGREEN2          , 0x90EE90, 0.564706, 0.933333, 0.564706),
-RawColor(PALEGREEN3          , 0x7CCD7C, 0.486275, 0.803922, 0.486275),
-RawColor(PALEGREEN4          , 0x548B54, 0.329412, 0.545098, 0.329412),
-RawColor(PALETURQUOISE       , 0xAFEEEE, 0.686275, 0.933333, 0.933333),
-RawColor(PALETURQUOISE1      , 0xBBFFFF, 0.733333, 1.000000, 1.000000),
-RawColor(PALETURQUOISE2      , 0xAEEEEE, 0.682353, 0.933333, 0.933333),
-RawColor(PALETURQUOISE3      , 0x96CDCD, 0.588235, 0.803922, 0.803922),
-RawColor(PALETURQUOISE4      , 0x668B8B, 0.400000, 0.545098, 0.545098),
-RawColor(PALEVIOLETRED       , 0xDB7093, 0.858824, 0.439216, 0.576471),
-RawColor(PALEVIOLETRED1      , 0xFF82AB, 1.000000, 0.509804, 0.670588),
-RawColor(PALEVIOLETRED2      , 0xEE799F, 0.933333, 0.474510, 0.623529),
-RawColor(PALEVIOLETRED3      , 0xCD6889, 0.803922, 0.407843, 0.537255),
-RawColor(PALEVIOLETRED4      , 0x8B475D, 0.545098, 0.278431, 0.364706),
-RawColor(PAPAYAWHIP          , 0xFFEFD5, 1.000000, 0.937255, 0.835294),
-RawColor(PEACHPUFF           , 0xFFDAB9, 1.000000, 0.854902, 0.725490),
-RawColor(PEACHPUFF2          , 0xEECBAD, 0.933333, 0.796078, 0.678431),
-RawColor(PEACHPUFF3          , 0xCDAF95, 0.803922, 0.686275, 0.584314),
-RawColor(PEACHPUFF4          , 0x8B7765, 0.545098, 0.466667, 0.396078),
-RawColor(PERU                , 0xCD853F, 0.803922, 0.521569, 0.247059),
-RawColor(PINK                , 0xFFC0CB, 1.000000, 0.752941, 0.796078),
-RawColor(PINK1               , 0xFFB5C5, 1.000000, 0.709804, 0.772549),
-RawColor(PINK2               , 0xEEA9B8, 0.933333, 0.662745, 0.721569),
-RawColor(PINK3               , 0xCD919E, 0.803922, 0.568627, 0.619608),
-RawColor(PINK4               , 0x8B636C, 0.545098, 0.388235, 0.423529),
-RawColor(PLUM                , 0xDDA0DD, 0.866667, 0.627451, 0.866667),
-RawColor(PLUM1               , 0xFFBBFF, 1.000000, 0.733333, 1.000000),
-RawColor(PLUM2               , 0xEEAEEE, 0.933333, 0.682353, 0.933333),
-RawColor(PLUM3               , 0xCD96CD, 0.803922, 0.588235, 0.803922),
-RawColor(PLUM4               , 0x8B668B, 0.545098, 0.400000, 0.545098),
-RawColor(POWDERBLUE          , 0xB0E0E6, 0.690196, 0.878431, 0.901961),
-RawColor(PURPLE              , 0xA020F0, 0.627451, 0.125490, 0.941176),
-RawColor(PURPLE1             , 0x9B30FF, 0.607843, 0.188235, 1.000000),
-RawColor(PURPLE2             , 0x912CEE, 0.568627, 0.172549, 0.933333),
-RawColor(PURPLE3             , 0x7D26CD, 0.490196, 0.149020, 0.803922),
-RawColor(PURPLE4             , 0x551A8B, 0.333333, 0.101961, 0.545098),
+RawColor(MAGENTA2            , 0xEE00EE, 0.854992, 0.000000, 0.854992),
+RawColor(MAGENTA3            , 0xCD00CD, 0.610496, 0.000000, 0.610496),
+RawColor(MAGENTA4            , 0x8B008B, 0.258183, 0.000000, 0.258183),
+RawColor(MAROON              , 0xB03060, 0.434154, 0.029557, 0.116971),
+RawColor(MAROON1             , 0xFF34B3, 1.000000, 0.034340, 0.450786),
+RawColor(MAROON2             , 0xEE30A7, 0.854992, 0.029557, 0.386430),
+RawColor(MAROON3             , 0xCD2990, 0.610496, 0.022174, 0.278894),
+RawColor(MAROON4             , 0x8B1C62, 0.258183, 0.011612, 0.122139),
+RawColor(MEDIUMAQUAMARINE    , 0x66CDAA, 0.132868, 0.610496, 0.401978),
+RawColor(MEDIUMORCHID        , 0xBA55D3, 0.491021, 0.090842, 0.651406),
+RawColor(MEDIUMORCHID1       , 0xE066FF, 0.745404, 0.132868, 1.000000),
+RawColor(MEDIUMORCHID2       , 0xD15FEE, 0.637597, 0.114435, 0.854992),
+RawColor(MEDIUMORCHID3       , 0xB452CD, 0.456411, 0.084376, 0.610496),
+RawColor(MEDIUMORCHID4       , 0x7A378B, 0.194617, 0.038204, 0.258183),
+RawColor(MEDIUMPURPLE        , 0x9370DB, 0.291771, 0.162030, 0.708377),
+RawColor(MEDIUMPURPLE1       , 0xAB82FF, 0.407240, 0.223228, 1.000000),
+RawColor(MEDIUMPURPLE2       , 0x9F79EE, 0.346704, 0.191202, 0.854992),
+RawColor(MEDIUMPURPLE3       , 0x8968CD, 0.250158, 0.138432, 0.610496),
+RawColor(MEDIUMPURPLE4       , 0x5D478B, 0.109462, 0.063010, 0.258183),
+RawColor(MEDIUMSEAGREEN      , 0x3CB371, 0.045186, 0.450786, 0.165132),
+RawColor(MEDIUMSLATEBLUE     , 0x7B68EE, 0.198069, 0.138432, 0.854992),
+RawColor(MEDIUMSPRINGGREEN   , 0x00FA9A, 0.000000, 0.955973, 0.323144),
+RawColor(MEDIUMTURQUOISE     , 0x48D1CC, 0.064803, 0.637597, 0.603827),
+RawColor(MEDIUMVIOLETRED     , 0xC71585, 0.571125, 0.007499, 0.234551),
+RawColor(MIDNIGHTBLUE        , 0x191970, 0.009721, 0.009721, 0.162030),
+RawColor(MINTCREAM           , 0xF5FFFA, 0.913098, 1.000000, 0.955973),
+RawColor(MISTYROSE           , 0xFFE4E1, 1.000000, 0.775823, 0.752942),
+RawColor(MISTYROSE2          , 0xEED5D2, 0.854992, 0.665387, 0.644479),
+RawColor(MISTYROSE3          , 0xCDB7B5, 0.610496, 0.473531, 0.462077),
+RawColor(MISTYROSE4          , 0x8B7D7B, 0.258183, 0.205079, 0.198069),
+RawColor(MOCCASIN            , 0xFFE4B5, 1.000000, 0.775823, 0.462077),
+RawColor(NAVAJOWHITE1        , 0xFFDEAD, 1.000000, 0.730460, 0.417885),
+RawColor(NAVAJOWHITE2        , 0xEECFA1, 0.854992, 0.623961, 0.356401),
+RawColor(NAVAJOWHITE3        , 0xCDB38B, 0.610496, 0.450786, 0.258183),
+RawColor(NAVAJOWHITE4        , 0x8B795E, 0.258183, 0.191202, 0.111932),
+RawColor(NAVYBLUE            , 0x000080, 0.000000, 0.000000, 0.215861),
+RawColor(OLDLACE             , 0xFDF5E6, 0.982251, 0.913098, 0.791299),
+RawColor(OLIVEDRAB           , 0x6B8E23, 0.147027, 0.270498, 0.016807),
+RawColor(OLIVEDRAB1          , 0xC0FF3E, 0.527115, 1.000000, 0.048172),
+RawColor(OLIVEDRAB2          , 0xB3EE3A, 0.450786, 0.854992, 0.042311),
+RawColor(OLIVEDRAB3          , 0x9ACD32, 0.323144, 0.610496, 0.031896),
+RawColor(OLIVEDRAB4          , 0x698B22, 0.141264, 0.258183, 0.015996),
+RawColor(ORANGE              , 0xFFA500, 1.000000, 0.376262, 0.000000),
+RawColor(ORANGE2             , 0xEE9A00, 0.854992, 0.323144, 0.000000),
+RawColor(ORANGE3             , 0xCD8500, 0.610496, 0.234551, 0.000000),
+RawColor(ORANGE4             , 0x8B5A00, 0.258183, 0.102242, 0.000000),
+RawColor(ORANGERED           , 0xFF4500, 1.000000, 0.059511, 0.000000),
+RawColor(ORANGERED2          , 0xEE4000, 0.854992, 0.051269, 0.000000),
+RawColor(ORANGERED3          , 0xCD3700, 0.610496, 0.038204, 0.000000),
+RawColor(ORANGERED4          , 0x8B2500, 0.258183, 0.018500, 0.000000),
+RawColor(ORCHID              , 0xDA70D6, 0.701102, 0.162030, 0.672444),
+RawColor(ORCHID1             , 0xFF83FA, 1.000000, 0.226965, 0.955973),
+RawColor(ORCHID2             , 0xEE7AE9, 0.854992, 0.194617, 0.814846),
+RawColor(ORCHID3             , 0xCD69C9, 0.610496, 0.141264, 0.584078),
+RawColor(ORCHID4             , 0x8B4789, 0.258183, 0.063010, 0.250158),
+RawColor(PALEGOLDENROD       , 0xEEE8AA, 0.854992, 0.806952, 0.401978),
+RawColor(PALEGREEN           , 0x98FB98, 0.313988, 0.964687, 0.313988),
+RawColor(PALEGREEN1          , 0x9AFF9A, 0.323144, 1.000000, 0.323144),
+RawColor(PALEGREEN2          , 0x90EE90, 0.278894, 0.854992, 0.278894),
+RawColor(PALEGREEN3          , 0x7CCD7C, 0.201557, 0.610496, 0.201557),
+RawColor(PALEGREEN4          , 0x548B54, 0.088656, 0.258183, 0.088656),
+RawColor(PALETURQUOISE       , 0xAFEEEE, 0.428691, 0.854992, 0.854992),
+RawColor(PALETURQUOISE1      , 0xBBFFFF, 0.496933, 1.000000, 1.000000),
+RawColor(PALETURQUOISE2      , 0xAEEEEE, 0.423268, 0.854992, 0.854992),
+RawColor(PALETURQUOISE3      , 0x96CDCD, 0.304987, 0.610496, 0.610496),
+RawColor(PALETURQUOISE4      , 0x668B8B, 0.132868, 0.258183, 0.258183),
+RawColor(PALEVIOLETRED       , 0xDB7093, 0.708377, 0.162030, 0.291771),
+RawColor(PALEVIOLETRED1      , 0xFF82AB, 1.000000, 0.223228, 0.407240),
+RawColor(PALEVIOLETRED2      , 0xEE799F, 0.854992, 0.191202, 0.346704),
+RawColor(PALEVIOLETRED3      , 0xCD6889, 0.610496, 0.138432, 0.250158),
+RawColor(PALEVIOLETRED4      , 0x8B475D, 0.258183, 0.063010, 0.109462),
+RawColor(PAPAYAWHIP          , 0xFFEFD5, 1.000000, 0.863158, 0.665387),
+RawColor(PEACHPUFF           , 0xFFDAB9, 1.000000, 0.701102, 0.485150),
+RawColor(PEACHPUFF2          , 0xEECBAD, 0.854992, 0.597201, 0.417885),
+RawColor(PEACHPUFF3          , 0xCDAF95, 0.610496, 0.428691, 0.300544),
+RawColor(PEACHPUFF4          , 0x8B7765, 0.258183, 0.184475, 0.130136),
+RawColor(PERU                , 0xCD853F, 0.610496, 0.234551, 0.049707),
+RawColor(PINK                , 0xFFC0CB, 1.000000, 0.527115, 0.597201),
+RawColor(PINK1               , 0xFFB5C5, 1.000000, 0.462077, 0.558340),
+RawColor(PINK2               , 0xEEA9B8, 0.854992, 0.396755, 0.479321),
+RawColor(PINK3               , 0xCD919E, 0.610496, 0.283148, 0.341915),
+RawColor(PINK4               , 0x8B636C, 0.258183, 0.124772, 0.149959),
+RawColor(PLUM                , 0xDDA0DD, 0.723056, 0.351533, 0.723056),
+RawColor(PLUM1               , 0xFFBBFF, 1.000000, 0.496933, 1.000000),
+RawColor(PLUM2               , 0xEEAEEE, 0.854992, 0.423268, 0.854992),
+RawColor(PLUM3               , 0xCD96CD, 0.610496, 0.304987, 0.610496),
+RawColor(PLUM4               , 0x8B668B, 0.258183, 0.132868, 0.258183),
+RawColor(POWDERBLUE          , 0xB0E0E6, 0.434154, 0.745404, 0.791299),
+RawColor(PURPLE              , 0xA020F0, 0.351533, 0.014444, 0.871366),
+RawColor(PURPLE1             , 0x9B30FF, 0.327778, 0.029557, 1.000000),
+RawColor(PURPLE2             , 0x912CEE, 0.283148, 0.025187, 0.854992),
+RawColor(PURPLE3             , 0x7D26CD, 0.205079, 0.019382, 0.610496),
+RawColor(PURPLE4             , 0x551A8B, 0.090842, 0.010330, 0.258183),
 RawColor(RED                 , 0xFF0000, 1.000000, 0.000000, 0.000000),
-RawColor(RED2                , 0xEE0000, 0.933333, 0.000000, 0.000000),
-RawColor(RED3                , 0xCD0000, 0.803922, 0.000000, 0.000000),
-RawColor(RED4                , 0x8B0000, 0.545098, 0.000000, 0.000000),
-RawColor(ROSYBROWN           , 0xBC8F8F, 0.737255, 0.560784, 0.560784),
-RawColor(ROSYBROWN1          , 0xFFC1C1, 1.000000, 0.756863, 0.756863),
-RawColor(ROSYBROWN2          , 0xEEB4B4, 0.933333, 0.705882, 0.705882),
-RawColor(ROSYBROWN3          , 0xCD9B9B, 0.803922, 0.607843, 0.607843),
-RawColor(ROSYBROWN4          , 0x8B6969, 0.545098, 0.411765, 0.411765),
-RawColor(ROYALBLUE           , 0x4169E1, 0.254902, 0.411765, 0.882353),
-RawColor(ROYALBLUE1          , 0x4876FF, 0.282353, 0.462745, 1.000000),
-RawColor(ROYALBLUE2          , 0x436EEE, 0.262745, 0.431373, 0.933333),
-RawColor(ROYALBLUE3          , 0x3A5FCD, 0.227451, 0.372549, 0.803922),
-RawColor(ROYALBLUE4          , 0x27408B, 0.152941, 0.250980, 0.545098),
-RawColor(SADDLEBROWN         , 0x8B4513, 0.545098, 0.270588, 0.074510),
-RawColor(SALMON              , 0xFA8072, 0.980392, 0.501961, 0.447059),
-RawColor(SALMON1             , 0xFF8C69, 1.000000, 0.549020, 0.411765),
-RawColor(SALMON2             , 0xEE8262, 0.933333, 0.509804, 0.384314),
-RawColor(SALMON3             , 0xCD7054, 0.803922, 0.439216, 0.329412),
-RawColor(SALMON4             , 0x8B4C39, 0.545098, 0.298039, 0.223529),
-RawColor(SANDYBROWN          , 0xF4A460, 0.956863, 0.643137, 0.376471),
-RawColor(SEAGREEN            , 0x2E8B57, 0.180392, 0.545098, 0.341176),
-RawColor(SEAGREEN1           , 0x54FF9F, 0.329412, 1.000000, 0.623529),
-RawColor(SEAGREEN2           , 0x4EEE94, 0.305882, 0.933333, 0.580392),
-RawColor(SEAGREEN3           , 0x43CD80, 0.262745, 0.803922, 0.501961),
-RawColor(SEAGREEN4           , 0x2E8B57, 0.180392, 0.545098, 0.341176),
-RawColor(SEASHELL            , 0xFFF5EE, 1.000000, 0.960784, 0.933333),
-RawColor(SEASHELL2           , 0xEEE5DE, 0.933333, 0.898039, 0.870588),
-RawColor(SEASHELL3           , 0xCDC5BF, 0.803922, 0.772549, 0.749020),
-RawColor(SEASHELL4           , 0x8B8682, 0.545098, 0.525490, 0.509804),
-RawColor(BEET                , 0x8E388E, 0.556863, 0.219608, 0.556863),
-RawColor(TEAL                , 0x388E8E, 0.219608, 0.556863, 0.556863),
-RawColor(SIENNA              , 0xA0522D, 0.627451, 0.321569, 0.176471),
-RawColor(SIENNA1             , 0xFF8247, 1.000000, 0.509804, 0.278431),
-RawColor(SIENNA2             , 0xEE7942, 0.933333, 0.474510, 0.258824),
-RawColor(SIENNA3             , 0xCD6839, 0.803922, 0.407843, 0.223529),
-RawColor(SIENNA4             , 0x8B4726, 0.545098, 0.278431, 0.149020),
-RawColor(SKYBLUE             , 0x87CEEB, 0.529412, 0.807843, 0.921569),
-RawColor(SKYBLUE1            , 0x87CEFF, 0.529412, 0.807843, 1.000000),
-RawColor(SKYBLUE2            , 0x7EC0EE, 0.494118, 0.752941, 0.933333),
-RawColor(SKYBLUE3            , 0x6CA6CD, 0.423529, 0.650980, 0.803922),
-RawColor(SKYBLUE4            , 0x4A708B, 0.290196, 0.439216, 0.545098),
-RawColor(SLATEBLUE           , 0x6A5ACD, 0.415686, 0.352941, 0.803922),
-RawColor(SLATEBLUE1          , 0x836FFF, 0.513725, 0.435294, 1.000000),
-RawColor(SLATEBLUE2          , 0x7A67EE, 0.478431, 0.403922, 0.933333),
-RawColor(SLATEBLUE3          , 0x6959CD, 0.411765, 0.349020, 0.803922),
-RawColor(SLATEBLUE4          , 0x473C8B, 0.278431, 0.235294, 0.545098),
-RawColor(SLATEGRAY1          , 0xC6E2FF, 0.776471, 0.886275, 1.000000),
-RawColor(SLATEGRAY2          , 0xB9D3EE, 0.725490, 0.827451, 0.933333),
-RawColor(SLATEGRAY3          , 0x9FB6CD, 0.623529, 0.713725, 0.803922),
-RawColor(SLATEGRAY4          , 0x6C7B8B, 0.423529, 0.482353, 0.545098),
-RawColor(SLATEGRAY           , 0x708090, 0.439216, 0.501961, 0.564706),
-RawColor(SNOW                , 0xFFFAFA, 1.000000, 0.980392, 0.980392),
-RawColor(SNOW2               , 0xEEE9E9, 0.933333, 0.913725, 0.913725),
-RawColor(SNOW3               , 0xCDC9C9, 0.803922, 0.788235, 0.788235),
-RawColor(SNOW4               , 0x8B8989, 0.545098, 0.537255, 0.537255),
-RawColor(SPRINGGREEN         , 0x00FF7F, 0.000000, 1.000000, 0.498039),
-RawColor(SPRINGGREEN2        , 0x00EE76, 0.000000, 0.933333, 0.462745),
-RawColor(SPRINGGREEN3        , 0x00CD66, 0.000000, 0.803922, 0.400000),
-RawColor(SPRINGGREEN4        , 0x008B45, 0.000000, 0.545098, 0.270588),
-RawColor(STEELBLUE           , 0x4682B4, 0.274510, 0.509804, 0.705882),
-RawColor(STEELBLUE1          , 0x63B8FF, 0.388235, 0.721569, 1.000000),
-RawColor(STEELBLUE2          , 0x5CACEE, 0.360784, 0.674510, 0.933333),
-RawColor(STEELBLUE3          , 0x4F94CD, 0.309804, 0.580392, 0.803922),
-RawColor(STEELBLUE4          , 0x36648B, 0.211765, 0.392157, 0.545098),
-RawColor(TAN                 , 0xD2B48C, 0.823529, 0.705882, 0.549020),
-RawColor(TAN1                , 0xFFA54F, 1.000000, 0.647059, 0.309804),
-RawColor(TAN2                , 0xEE9A49, 0.933333, 0.603922, 0.286275),
-RawColor(TAN3                , 0xCD853F, 0.803922, 0.521569, 0.247059),
-RawColor(TAN4                , 0x8B5A2B, 0.545098, 0.352941, 0.168627),
-RawColor(THISTLE             , 0xD8BFD8, 0.847059, 0.749020, 0.847059),
-RawColor(THISTLE1            , 0xFFE1FF, 1.000000, 0.882353, 1.000000),
-RawColor(THISTLE2            , 0xEED2EE, 0.933333, 0.823529, 0.933333),
-RawColor(THISTLE3            , 0xCDB5CD, 0.803922, 0.709804, 0.803922),
-RawColor(THISTLE4            , 0x8B7B8B, 0.545098, 0.482353, 0.545098),
-RawColor(TOMATO              , 0xFF6347, 1.000000, 0.388235, 0.278431),
-RawColor(TOMATO2             , 0xEE5C42, 0.933333, 0.360784, 0.258824),
-RawColor(TOMATO3             , 0xCD4F39, 0.803922, 0.309804, 0.223529),
-RawColor(TOMATO4             , 0x8B3626, 0.545098, 0.211765, 0.149020),
-RawColor(TURQUOISE           , 0x40E0D0, 0.250980, 0.878431, 0.815686),
-RawColor(TURQUOISE1          , 0x00F5FF, 0.000000, 0.960784, 1.000000),
-RawColor(TURQUOISE2          , 0x00E5EE, 0.000000, 0.898039, 0.933333),
-RawColor(TURQUOISE3          , 0x00C5CD, 0.000000, 0.772549, 0.803922),
-RawColor(TURQUOISE4          , 0x00868B, 0.000000, 0.525490, 0.545098),
-RawColor(VIOLET              , 0xEE82EE, 0.933333, 0.509804, 0.933333),
-RawColor(VIOLETRED           , 0xD02090, 0.815686, 0.125490, 0.564706),
-RawColor(VIOLETRED1          , 0xFF3E96, 1.000000, 0.243137, 0.588235),
-RawColor(VIOLETRED2          , 0xEE3A8C, 0.933333, 0.227451, 0.549020),
-RawColor(VIOLETRED3          , 0xCD3278, 0.803922, 0.196078, 0.470588),
-RawColor(VIOLETRED4          , 0x8B2252, 0.545098, 0.133333, 0.321569),
-RawColor(WHEAT               , 0xF5DEB3, 0.960784, 0.870588, 0.701961),
-RawColor(WHEAT1              , 0xFFE7BA, 1.000000, 0.905882, 0.729412),
-RawColor(WHEAT2              , 0xEED8AE, 0.933333, 0.847059, 0.682353),
-RawColor(WHEAT3              , 0xCDBA96, 0.803922, 0.729412, 0.588235),
-RawColor(WHEAT4              , 0x8B7E66, 0.545098, 0.494118, 0.400000),
-RawColor(WHITESMOKE          , 0xF5F5F5, 0.960784, 0.960784, 0.960784),
+RawColor(RED2                , 0xEE0000, 0.854992, 0.000000, 0.000000),
+RawColor(RED3                , 0xCD0000, 0.610496, 0.000000, 0.000000),
+RawColor(RED4                , 0x8B0000, 0.258183, 0.000000, 0.000000),
+RawColor(ROSYBROWN           , 0xBC8F8F, 0.502887, 0.274677, 0.274677),
+RawColor(ROSYBROWN1          , 0xFFC1C1, 1.000000, 0.533277, 0.533277),
+RawColor(ROSYBROWN2          , 0xEEB4B4, 0.854992, 0.456411, 0.456411),
+RawColor(ROSYBROWN3          , 0xCD9B9B, 0.610496, 0.327778, 0.327778),
+RawColor(ROSYBROWN4          , 0x8B6969, 0.258183, 0.141264, 0.141264),
+RawColor(ROYALBLUE           , 0x4169E1, 0.052861, 0.141264, 0.752942),
+RawColor(ROYALBLUE1          , 0x4876FF, 0.064803, 0.181164, 1.000000),
+RawColor(ROYALBLUE2          , 0x436EEE, 0.056128, 0.155927, 0.854992),
+RawColor(ROYALBLUE3          , 0x3A5FCD, 0.042311, 0.114435, 0.610496),
+RawColor(ROYALBLUE4          , 0x27408B, 0.020289, 0.051269, 0.258183),
+RawColor(SADDLEBROWN         , 0x8B4513, 0.258183, 0.059511, 0.006512),
+RawColor(SALMON              , 0xFA8072, 0.955973, 0.215861, 0.168270),
+RawColor(SALMON1             , 0xFF8C69, 1.000000, 0.262251, 0.141264),
+RawColor(SALMON2             , 0xEE8262, 0.854992, 0.223228, 0.122139),
+RawColor(SALMON3             , 0xCD7054, 0.610496, 0.162030, 0.088656),
+RawColor(SALMON4             , 0x8B4C39, 0.258183, 0.072272, 0.040915),
+RawColor(SANDYBROWN          , 0xF4A460, 0.904662, 0.371237, 0.116971),
+RawColor(SEAGREEN            , 0x2E8B57, 0.027321, 0.258183, 0.095307),
+RawColor(SEAGREEN1           , 0x54FF9F, 0.088656, 1.000000, 0.346704),
+RawColor(SEAGREEN2           , 0x4EEE94, 0.076185, 0.854992, 0.296138),
+RawColor(SEAGREEN3           , 0x43CD80, 0.056128, 0.610496, 0.215861),
+RawColor(SEAGREEN4           , 0x2E8B57, 0.027321, 0.258183, 0.095307),
+RawColor(SEASHELL            , 0xFFF5EE, 1.000000, 0.913098, 0.854992),
+RawColor(SEASHELL2           , 0xEEE5DE, 0.854992, 0.783537, 0.730460),
+RawColor(SEASHELL3           , 0xCDC5BF, 0.610496, 0.558340, 0.520996),
+RawColor(SEASHELL4           , 0x8B8682, 0.258183, 0.238397, 0.223228),
+RawColor(BEET                , 0x8E388E, 0.270498, 0.039546, 0.270498),
+RawColor(TEAL                , 0x388E8E, 0.039546, 0.270498, 0.270498),
+RawColor(SIENNA              , 0xA0522D, 0.351533, 0.084376, 0.026241),
+RawColor(SIENNA1             , 0xFF8247, 1.000000, 0.223228, 0.063010),
+RawColor(SIENNA2             , 0xEE7942, 0.854992, 0.191202, 0.054480),
+RawColor(SIENNA3             , 0xCD6839, 0.610496, 0.138432, 0.040915),
+RawColor(SIENNA4             , 0x8B4726, 0.258183, 0.063010, 0.019382),
+RawColor(SKYBLUE             , 0x87CEEB, 0.242281, 0.617206, 0.830771),
+RawColor(SKYBLUE1            , 0x87CEFF, 0.242281, 0.617206, 1.000000),
+RawColor(SKYBLUE2            , 0x7EC0EE, 0.208637, 0.527115, 0.854992),
+RawColor(SKYBLUE3            , 0x6CA6CD, 0.149959, 0.381326, 0.610496),
+RawColor(SKYBLUE4            , 0x4A708B, 0.068478, 0.162030, 0.258183),
+RawColor(SLATEBLUE           , 0x6A5ACD, 0.144128, 0.102242, 0.610496),
+RawColor(SLATEBLUE1          , 0x836FFF, 0.226965, 0.158961, 1.000000),
+RawColor(SLATEBLUE2          , 0x7A67EE, 0.194617, 0.135634, 0.854992),
+RawColor(SLATEBLUE3          , 0x6959CD, 0.141264, 0.099899, 0.610496),
+RawColor(SLATEBLUE4          , 0x473C8B, 0.063010, 0.045186, 0.258183),
+RawColor(SLATEGRAY1          , 0xC6E2FF, 0.564712, 0.760525, 1.000000),
+RawColor(SLATEGRAY2          , 0xB9D3EE, 0.485150, 0.651406, 0.854992),
+RawColor(SLATEGRAY3          , 0x9FB6CD, 0.346704, 0.467783, 0.610496),
+RawColor(SLATEGRAY4          , 0x6C7B8B, 0.149959, 0.198069, 0.258183),
+RawColor(SLATEGRAY           , 0x708090, 0.162030, 0.215861, 0.278894),
+RawColor(SNOW                , 0xFFFAFA, 1.000000, 0.955973, 0.955973),
+RawColor(SNOW2               , 0xEEE9E9, 0.854992, 0.814846, 0.814846),
+RawColor(SNOW3               , 0xCDC9C9, 0.610496, 0.584078, 0.584078),
+RawColor(SNOW4               , 0x8B8989, 0.258183, 0.250158, 0.250158),
+RawColor(SPRINGGREEN         , 0x00FF7F, 0.000000, 1.000000, 0.212231),
+RawColor(SPRINGGREEN2        , 0x00EE76, 0.000000, 0.854992, 0.181164),
+RawColor(SPRINGGREEN3        , 0x00CD66, 0.000000, 0.610496, 0.132868),
+RawColor(SPRINGGREEN4        , 0x008B45, 0.000000, 0.258183, 0.059511),
+RawColor(STEELBLUE           , 0x4682B4, 0.061246, 0.223228, 0.456411),
+RawColor(STEELBLUE1          , 0x63B8FF, 0.124772, 0.479321, 1.000000),
+RawColor(STEELBLUE2          , 0x5CACEE, 0.107023, 0.412543, 0.854992),
+RawColor(STEELBLUE3          , 0x4F94CD, 0.078187, 0.296138, 0.610496),
+RawColor(STEELBLUE4          , 0x36648B, 0.036890, 0.127438, 0.258183),
+RawColor(TAN                 , 0xD2B48C, 0.644479, 0.456411, 0.262251),
+RawColor(TAN1                , 0xFFA54F, 1.000000, 0.376262, 0.078187),
+RawColor(TAN2                , 0xEE9A49, 0.854992, 0.323144, 0.066626),
+RawColor(TAN3                , 0xCD853F, 0.610496, 0.234551, 0.049707),
+RawColor(TAN4                , 0x8B5A2B, 0.258183, 0.102242, 0.024158),
+RawColor(THISTLE             , 0xD8BFD8, 0.686686, 0.520996, 0.686686),
+RawColor(THISTLE1            , 0xFFE1FF, 1.000000, 0.752942, 1.000000),
+RawColor(THISTLE2            , 0xEED2EE, 0.854992, 0.644479, 0.854992),
+RawColor(THISTLE3            , 0xCDB5CD, 0.610496, 0.462077, 0.610496),
+RawColor(THISTLE4            , 0x8B7B8B, 0.258183, 0.198069, 0.258183),
+RawColor(TOMATO              , 0xFF6347, 1.000000, 0.124772, 0.063010),
+RawColor(TOMATO2             , 0xEE5C42, 0.854992, 0.107023, 0.054480),
+RawColor(TOMATO3             , 0xCD4F39, 0.610496, 0.078187, 0.040915),
+RawColor(TOMATO4             , 0x8B3626, 0.258183, 0.036890, 0.019382),
+RawColor(TURQUOISE           , 0x40E0D0, 0.051269, 0.745404, 0.630757),
+RawColor(TURQUOISE1          , 0x00F5FF, 0.000000, 0.913098, 1.000000),
+RawColor(TURQUOISE2          , 0x00E5EE, 0.000000, 0.783537, 0.854992),
+RawColor(TURQUOISE3          , 0x00C5CD, 0.000000, 0.558340, 0.610496),
+RawColor(TURQUOISE4          , 0x00868B, 0.000000, 0.238397, 0.258183),
+RawColor(VIOLET              , 0xEE82EE, 0.854992, 0.223228, 0.854992),
+RawColor(VIOLETRED           , 0xD02090, 0.630757, 0.014444, 0.278894),
+RawColor(VIOLETRED1          , 0xFF3E96, 1.000000, 0.048172, 0.304987),
+RawColor(VIOLETRED2          , 0xEE3A8C, 0.854992, 0.042311, 0.262251),
+RawColor(VIOLETRED3          , 0xCD3278, 0.610496, 0.031896, 0.187821),
+RawColor(VIOLETRED4          , 0x8B2252, 0.258183, 0.015996, 0.084376),
+RawColor(WHEAT               , 0xF5DEB3, 0.913098, 0.730460, 0.450786),
+RawColor(WHEAT1              , 0xFFE7BA, 1.000000, 0.799102, 0.491021),
+RawColor(WHEAT2              , 0xEED8AE, 0.854992, 0.686686, 0.423268),
+RawColor(WHEAT3              , 0xCDBA96, 0.610496, 0.491021, 0.304987),
+RawColor(WHEAT4              , 0x8B7E66, 0.258183, 0.208637, 0.132868),
+RawColor(WHITESMOKE          , 0xF5F5F5, 0.913098, 0.913098, 0.913098),
 RawColor(YELLOW              , 0xFFFF00, 1.000000, 1.000000, 0.000000),
-RawColor(YELLOW2             , 0xEEEE00, 0.933333, 0.933333, 0.000000),
-RawColor(YELLOW3             , 0xCDCD00, 0.803922, 0.803922, 0.000000),
-RawColor(YELLOW4             , 0x8B8B00, 0.545098, 0.545098, 0.000000),
-RawColor(YELLOWGREEN         , 0x9ACD32, 0.603922, 0.803922, 0.196078),
+RawColor(YELLOW2             , 0xEEEE00, 0.854992, 0.854992, 0.000000),
+RawColor(YELLOW3             , 0xCDCD00, 0.610496, 0.610496, 0.000000),
+RawColor(YELLOW4             , 0x8B8B00, 0.258183, 0.258183, 0.000000),
+RawColor(YELLOWGREEN         , 0x9ACD32, 0.323144, 0.610496, 0.031896),
 RawColor(WHITE               , 0xFFFFFF, 1.000000, 1.000000, 1.000000),
index 5077aba59b1054d2d9c7aa2b451f86fe0f5d2398..ba70a48f1af77a4c35e9978319d25f5a0e450ada 100644 (file)
@@ -21,6 +21,7 @@
 enum Quantity_TypeOfColor
 {
   Quantity_TOC_RGB,  //!< normalized linear RGB (red, green, blue) values within range [0..1] for each component
+  Quantity_TOC_sRGB, //!< normalized non-linear gamma-shifted RGB (red, green, blue) values within range [0..1] for each component
   Quantity_TOC_HLS,  //!< hue + light + saturation components, where:
                      //!  - First component is the Hue (H) angle in degrees within range [0.0; 360.0], 0.0 being Red;
                      //!    value -1.0 is a special value reserved for grayscale color (S should be 0.0).
index 4b2465f7ed59adf21f6ced5acbb6682b69e4024b..0aa323471351127a2f3a03f221394177fc86abc1 100644 (file)
@@ -436,7 +436,7 @@ bool RWGltf_GltfJsonParser::gltfParseStdMaterial (Handle(RWGltf_MaterialCommon)&
   else if (gltfReadVec4   (anAmb, anAmbVal)
         && validateColor4 (anAmb))
   {
-    theMat->AmbientColor = Quantity_Color (anAmb.r(), anAmb.g(), anAmb.b(), Quantity_TOC_RGB);
+    theMat->AmbientColor = Quantity_Color (anAmb.r(), anAmb.g(), anAmb.b(), Quantity_TOC_sRGB);
   }
 
   if (aDiffVal != NULL
@@ -447,14 +447,14 @@ bool RWGltf_GltfJsonParser::gltfParseStdMaterial (Handle(RWGltf_MaterialCommon)&
   else if (gltfReadVec4   (aDiff, aDiffVal)
         && validateColor4 (aDiff))
   {
-    theMat->DiffuseColor = Quantity_Color (aDiff.r(), aDiff.g(), aDiff.b(), Quantity_TOC_RGB);
+    theMat->DiffuseColor = Quantity_Color (aDiff.r(), aDiff.g(), aDiff.b(), Quantity_TOC_sRGB);
     theMat->Transparency = float(1.0 - aDiff.a());
   }
 
   if (gltfReadVec4   (anEmi, anEmiVal)
    && validateColor4 (anEmi))
   {
-    theMat->EmissiveColor = Quantity_Color (anEmi.r(), anEmi.g(), anEmi.b(), Quantity_TOC_RGB);
+    theMat->EmissiveColor = Quantity_Color (anEmi.r(), anEmi.g(), anEmi.b(), Quantity_TOC_sRGB);
   }
 
   if (aSpecVal != NULL
@@ -465,7 +465,7 @@ bool RWGltf_GltfJsonParser::gltfParseStdMaterial (Handle(RWGltf_MaterialCommon)&
   if (gltfReadVec4   (aSpec, aSpecVal)
    && validateColor4 (aSpec))
   {
-    theMat->SpecularColor = Quantity_Color (aSpec.r(), aSpec.g(), aSpec.b(), Quantity_TOC_RGB);
+    theMat->SpecularColor = Quantity_Color (aSpec.r(), aSpec.g(), aSpec.b(), Quantity_TOC_sRGB);
   }
 
   if (aShinVal != NULL
index 7266cf964dc7e82fb9385811982a024d2a6c60af..de8523df15f266b55110168eebfd2006d3cc689a 100644 (file)
@@ -36,10 +36,10 @@ public:
   Standard_ShortReal      Transparency;
 
   RWGltf_MaterialCommon()
-  : AmbientColor (0.1, 0.1, 0.1, Quantity_TOC_RGB),
-    DiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_RGB),
-    SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_RGB),
-    EmissiveColor(0.0, 0.0, 0.0, Quantity_TOC_RGB),
+  : AmbientColor (0.1, 0.1, 0.1, Quantity_TOC_sRGB),
+    DiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_sRGB),
+    SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_sRGB),
+    EmissiveColor(Quantity_NOC_BLACK),
     Shininess (1.0f),
     Transparency (0.0f) {}
 
index b47bea5b7c92070f90b0abbbcffc24b47d80b3ff..5d680cedd471a9188aa29a7fd8920a528e34bc12 100644 (file)
@@ -32,9 +32,9 @@ struct RWObj_Material
   Standard_ShortReal      Transparency;
 
   RWObj_Material()
-  : AmbientColor (0.1, 0.1, 0.1, Quantity_TOC_RGB),
-    DiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_RGB),
-    SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_RGB),
+  : AmbientColor (0.1, 0.1, 0.1, Quantity_TOC_sRGB),
+    DiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_sRGB),
+    SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_sRGB),
     Shininess (1.0f),
     Transparency (0.0f) {}
 
index f7cafc277801f13699ab3f460cd3995809028de5..ef78e8ff1bf7728c1bd96a26c279a62fa44e0f83 100644 (file)
@@ -177,7 +177,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
       aPos = aNext;
       if (validateColor (aColor))
       {
-        aMat.AmbientColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_RGB);
+        aMat.AmbientColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_sRGB);
         hasAspect = true;
       }
     }
@@ -191,7 +191,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
       aPos = aNext;
       if (validateColor (aColor))
       {
-        aMat.DiffuseColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_RGB);
+        aMat.DiffuseColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_sRGB);
         hasAspect = true;
       }
     }
@@ -205,7 +205,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
       aPos = aNext;
       if (validateColor (aColor))
       {
-        aMat.SpecularColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_RGB);
+        aMat.SpecularColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_sRGB);
         hasAspect = true;
       }
     }
index c89fee4c66eb773a9034d2e205367f7f6a614328..673d98c55781d15efc1fc2d265d4e1da43e8df8d 100644 (file)
@@ -1098,7 +1098,7 @@ static void MakeSTEPStyles (STEPConstruct_Styles &Styles,
         }
         else {
           // default white color
-          surfColor = Styles.EncodeColor(Quantity_Color(1,1,1,Quantity_TOC_RGB),DPDCs,ColRGBs);
+          surfColor = Styles.EncodeColor(Quantity_Color(Quantity_NOC_WHITE),DPDCs,ColRGBs);
           PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent );
           if ( isComponent ) 
             setDefaultInstanceColor( override, PSA);
@@ -1857,7 +1857,7 @@ static Standard_Boolean createSHUOStyledItem (const XCAFPrs_Style& style,
   // set default color for invisible SHUO.
   Standard_Boolean isSetDefaultColor = Standard_False;
   if (surfColor.IsNull() && curvColor.IsNull() && !style.IsVisible() ) {
-    surfColor = Styles.EncodeColor ( Quantity_Color( 1, 1, 1, Quantity_TOC_RGB ) );
+    surfColor = Styles.EncodeColor ( Quantity_Color(Quantity_NOC_WHITE) );
     isSetDefaultColor = Standard_True;
   }
   Handle(StepVisual_PresentationStyleAssignment) PSA =
index 565e13d342a1be010225b5c1be05ddf25ac9e5fa..8bb1b3c45acce646a86a1eb7e693d3243d4e29ea 100644 (file)
@@ -632,7 +632,9 @@ Handle(StepVisual_Colour) STEPConstruct_Styles::EncodeColor(const Quantity_Color
   else {
     Handle(TCollection_HAsciiString) ColName = new TCollection_HAsciiString ( "" );
     Handle(StepVisual_ColourRgb) ColRGB = new StepVisual_ColourRgb;
-    ColRGB->Init ( ColName, C.Red(), C.Green(), C.Blue() );
+    NCollection_Vec3<Standard_Real> aColor_sRGB;
+    C.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
+    ColRGB->Init ( ColName, aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b() );
     return ColRGB;
   }
 }
@@ -675,14 +677,18 @@ Handle(StepVisual_Colour) STEPConstruct_Styles::EncodeColor
   }
   else {
     Handle(StepVisual_ColourRgb) ColRGB;
-    gp_Pnt P(C.Red(),C.Green(),C.Blue());
+    gp_Pnt P;
+    C.Values (P.ChangeCoord().ChangeData()[0],
+              P.ChangeCoord().ChangeData()[1],
+              P.ChangeCoord().ChangeData()[2],
+              Quantity_TOC_sRGB);
     if(ColRGBs.IsBound(P)) {
       ColRGB = Handle(StepVisual_ColourRgb)::DownCast(ColRGBs.Find(P));
       if(!ColRGB.IsNull()) return ColRGB;
     }
     Handle(TCollection_HAsciiString) ColName = new TCollection_HAsciiString ( "" );
     ColRGB = new StepVisual_ColourRgb;
-    ColRGB->Init ( ColName, C.Red(), C.Green(), C.Blue() );
+    ColRGB->Init ( ColName, P.Coord (1), P.Coord (2), P.Coord (3) );
     ColRGBs.Bind(P,ColRGB);
     return ColRGB;
   }
@@ -703,10 +709,10 @@ Standard_Boolean STEPConstruct_Styles::DecodeColor (const Handle(StepVisual_Colo
       if(norm<rgb->Green()) norm = rgb->Green();
       if(norm<rgb->Blue()) norm = rgb->Blue();
       Col.SetValues(rgb->Red()/norm, rgb->Green()/norm,
-                    rgb->Blue()/norm, Quantity_TOC_RGB);
+                    rgb->Blue()/norm, Quantity_TOC_sRGB);
     }
     else
-      Col.SetValues(rgb->Red(), rgb->Green(), rgb->Blue(), Quantity_TOC_RGB);
+      Col.SetValues(rgb->Red(), rgb->Green(), rgb->Blue(), Quantity_TOC_sRGB);
     return Standard_True;
   }
   else if ( Colour->IsKind (STANDARD_TYPE(StepVisual_PreDefinedColour)) ) {
index 8067fb0f38b7dd0bcc66ea7fa5955d1f14dd3b5b..640aaaac1ff90b7625c025f5008a10d53aa3f8ab 100644 (file)
@@ -144,8 +144,12 @@ void main (void)
   aColor = ToneMappingFilmic (aColor, uWhitePoint);
 #endif // TONE_MAPPING
 
+#ifdef THE_SHIFT_sRGB
   // apply gamma correction (we use gamma = 2)
   OutColor = vec4 (sqrt (aColor.rgb), 0.f);
+#else
+  OutColor = vec4 (aColor.rgb, 0.f);
+#endif
 
 #else // not PATH_TRACING
 
index 8dfe1afcb3e836345603ac6a4e13ac7078ff445d..1c7991535a0ef82b5b3d9e16b5c14ccd94cc3032 100644 (file)
@@ -703,12 +703,15 @@ vec3 IntersectLight (in SRay theRay, in int theDepth, in float theHitDistance, o
   {
     if (theDepth + uSphereMapForBack == 0) // view ray and map is hidden
     {
-      aTotalRadiance = pow (BackgroundColor().rgb, vec3 (2.f));
+      aTotalRadiance = BackgroundColor().rgb;
     }
     else
     {
-      aTotalRadiance = pow (FetchEnvironment (Latlong (theRay.Direct)).rgb, vec3 (2.f));
+      aTotalRadiance = FetchEnvironment (Latlong (theRay.Direct)).rgb;
     }
+  #ifdef THE_SHIFT_sRGB
+    aTotalRadiance = pow (aTotalRadiance, vec3 (2.f));
+  #endif
   }
   
   return aTotalRadiance;
index 59193993c04d7ce5bf0963ab874ec54646fd5a01..0ffbec6fc34782de5325a70ad7071ed9470e3d48 100644 (file)
@@ -147,8 +147,12 @@ static const char Shaders_Display_fs[] =
   "  aColor = ToneMappingFilmic (aColor, uWhitePoint);\n"
   "#endif // TONE_MAPPING\n"
   "\n"
+  "#ifdef THE_SHIFT_sRGB\n"
   "  // apply gamma correction (we use gamma = 2)\n"
   "  OutColor = vec4 (sqrt (aColor.rgb), 0.f);\n"
+  "#else\n"
+  "  OutColor = vec4 (aColor.rgb, 0.f);\n"
+  "#endif\n"
   "\n"
   "#else // not PATH_TRACING\n"
   "\n"
index f33cc5bb397e2a084c80189290f0c64420163e9f..bf84c5a7ede72d769dbec81e068ff48b971cf163 100644 (file)
@@ -706,12 +706,15 @@ static const char Shaders_PathtraceBase_fs[] =
   "  {\n"
   "    if (theDepth + uSphereMapForBack == 0) // view ray and map is hidden\n"
   "    {\n"
-  "      aTotalRadiance = pow (BackgroundColor().rgb, vec3 (2.f));\n"
+  "      aTotalRadiance = BackgroundColor().rgb;\n"
   "    }\n"
   "    else\n"
   "    {\n"
-  "      aTotalRadiance = pow (FetchEnvironment (Latlong (theRay.Direct)).rgb, vec3 (2.f));\n"
+  "      aTotalRadiance = FetchEnvironment (Latlong (theRay.Direct)).rgb;\n"
   "    }\n"
+  "  #ifdef THE_SHIFT_sRGB\n"
+  "    aTotalRadiance = pow (aTotalRadiance, vec3 (2.f));\n"
+  "  #endif\n"
   "  }\n"
   "  \n"
   "  return aTotalRadiance;\n"
index 51a5286e32512f904d8e005c7aa71a938f0c1850..e6bebe89a1fb6940ca30d6926b6b64fc70429db0 100644 (file)
@@ -695,7 +695,7 @@ namespace
       theColor = Quantity_Color (Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
                                  Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
                                  Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
-                                 Quantity_TOC_RGB);
+                                 Quantity_TOC_sRGB);
     }
 
   protected:
index 6a09de4b878a9cbac253dbb510f886e1db6c65fe..fb722051bad0dc9fa663c8125c2077bea8353db3 100644 (file)
@@ -218,7 +218,7 @@ namespace
     {
       aRealColor /= static_cast<Standard_ShortReal> (THE_MAX_INTEGER_COLOR_COMPONENT);
     }
-    theColor = Quantity_ColorRGBA (aRealColor);
+    theColor = Quantity_ColorRGBA (Quantity_ColorRGBA::Convert_sRGB_To_LinearRGB (aRealColor));
     return true;
   }
 
@@ -2491,7 +2491,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         aChangeSet->FaceBoundaryColor = Quantity_Color (aNames.Value (3).IntegerValue() / 255.0,
                                                         aNames.Value (4).IntegerValue() / 255.0,
                                                         aNames.Value (5).IntegerValue() / 255.0,
-                                                        Quantity_TOC_RGB);
+                                                        Quantity_TOC_sRGB);
         aNames.Remove (5);
         aNames.Remove (4);
         aNames.Remove (3);
index c2f92520aa39fe7742e877f4a8faceb0acc9f9d2..998ae81073b0181eeddb636075e78e7e3110b79b 100644 (file)
@@ -1090,9 +1090,9 @@ static Standard_Integer VListMaterials (Draw_Interpretor& theDI,
     if (aMatFile.is_open())
     {
       aMatFile << "newmtl " << aMatName << "\n";
-      aMatFile << "Ka " << anAmbient << "\n";
-      aMatFile << "Kd " << aDiffuse  << "\n";
-      aMatFile << "Ks " << aSpecular << "\n";
+      aMatFile << "Ka " << Quantity_Color::Convert_LinearRGB_To_sRGB (anAmbient) << "\n";
+      aMatFile << "Kd " << Quantity_Color::Convert_LinearRGB_To_sRGB (aDiffuse)  << "\n";
+      aMatFile << "Ks " << Quantity_Color::Convert_LinearRGB_To_sRGB (aSpecular) << "\n";
       aMatFile << "Ns " << aShiness  << "\n";
       if (aMat.Transparency() >= 0.0001)
       {
index 357e3d6f8e70a7864da18f9eff811a065b92f287..cf5499ecfa6a592cb45a5db12f41681fc6e87696 100644 (file)
@@ -5845,7 +5845,7 @@ void V3d_LineItem::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePre
                             const Standard_Integer /*theMode*/)
 {
   thePresentation->Clear();
-  Quantity_Color aColor (1.0, 0, 0, Quantity_TOC_RGB);
+  Quantity_Color aColor (Quantity_NOC_RED);
   Standard_Integer aWidth, aHeight;
   ViewerTest::CurrentView()->Window()->Size (aWidth, aHeight);
   Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
@@ -6780,6 +6780,7 @@ static int VCaps (Draw_Interpretor& theDI,
 
   if (theArgNb < 2)
   {
+    theDI << "sRGB:    " << (aCaps->sRGBDisable       ? "0" : "1") << "\n";
     theDI << "VBO:     " << (aCaps->vboDisable        ? "0" : "1") << "\n";
     theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
     theDI << "SoftMode:" << (aCaps->contextNoAccel    ? "1" : "0") << "\n";
@@ -6835,6 +6836,16 @@ static int VCaps (Draw_Interpretor& theDI,
       }
       aCaps->usePolygonMode = toEnable;
     }
+    else if (anArgCase == "-srgb")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->sRGBDisable = !toEnable;
+    }
     else if (anArgCase == "-vbo")
     {
       Standard_Boolean toEnable = Standard_True;
@@ -7063,16 +7074,19 @@ static int VReadPixel (Draw_Interpretor& theDI,
     return 1;
   }
 
-  bool toShowName = false, toShowHls = false, toShowHex = false;
+  bool toShowName = false, toShowHls = false, toShowHex = false, toShow_sRGB = false;
   for (Standard_Integer anIter = 3; anIter < theArgNb; ++anIter)
   {
     TCollection_AsciiString aParam (theArgVec[anIter]);
     aParam.LowerCase();
     if (aParam == "-rgb"
-     || aParam == "rgb")
+     || aParam == "rgb"
+     || aParam == "-srgb"
+     || aParam == "srgb")
     {
       aFormat     = Image_Format_RGB;
       aBufferType = Graphic3d_BT_RGB;
+      toShow_sRGB = aParam == "-srgb" || aParam == "srgb";
     }
     else if (aParam == "-hls"
           || aParam == "hls")
@@ -7088,10 +7102,13 @@ static int VReadPixel (Draw_Interpretor& theDI,
       aBufferType = Graphic3d_BT_RGB;
     }
     else if (aParam == "-rgba"
-          || aParam == "rgba")
+          || aParam == "rgba"
+          || aParam == "-srgba"
+          || aParam == "srgba")
     {
       aFormat     = Image_Format_RGBA;
       aBufferType = Graphic3d_BT_RGBA;
+      toShow_sRGB = aParam == "-srgba" || aParam == "srgba";
     }
     else if (aParam == "-rgbaf"
           || aParam == "rgbaf")
@@ -7144,7 +7161,7 @@ static int VReadPixel (Draw_Interpretor& theDI,
   }
   theDI.Reset();
 
-  Quantity_ColorRGBA aColor = anImage.PixelColor (anX, anY);
+  Quantity_ColorRGBA aColor = anImage.PixelColor (anX, anY, true);
   if (toShowName)
   {
     if (aBufferType == Graphic3d_BT_RGBA)
@@ -7178,6 +7195,11 @@ static int VReadPixel (Draw_Interpretor& theDI,
         {
           theDI << aColor.GetRGB().Hue() << " " << aColor.GetRGB().Light() << " " << aColor.GetRGB().Saturation();
         }
+        else if (toShow_sRGB)
+        {
+          const Graphic3d_Vec4 aColor_sRGB = Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB ((Graphic3d_Vec4 )aColor);
+          theDI << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b();
+        }
         else
         {
           theDI << aColor.GetRGB().Red() << " " << aColor.GetRGB().Green() << " " << aColor.GetRGB().Blue();
@@ -7186,7 +7208,8 @@ static int VReadPixel (Draw_Interpretor& theDI,
       }
       case Graphic3d_BT_RGBA:
       {
-        theDI << aColor.GetRGB().Red() << " " << aColor.GetRGB().Green() << " " << aColor.GetRGB().Blue() << " " << aColor.Alpha();
+        const Graphic3d_Vec4 aVec4 = toShow_sRGB ? Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB ((Graphic3d_Vec4 )aColor) : (Graphic3d_Vec4 )aColor;
+        theDI << aVec4.r() << " " << aVec4.g() << " " << aVec4.b() << " " << aVec4.a();
         break;
       }
       case Graphic3d_BT_Depth:
@@ -13928,13 +13951,14 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "\n\t\t:  greenMagentaSimple",
     __FILE__, VStereo, group);
   theCommands.Add ("vcaps",
-            "vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}] [-polygonMode {0|1}]"
+            "vcaps [-sRGB {0|1}] [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}] [-polygonMode {0|1}]"
     "\n\t\t:       [-compatibleProfile {0|1}]"
     "\n\t\t:       [-vsync {0|1}] [-useWinBuffer {0|1}]"
     "\n\t\t:       [-quadBuffer {0|1}] [-stereo {0|1}]"
     "\n\t\t:       [-softMode {0|1}] [-noupdate|-update]"
     "\n\t\t:       [-noExtensions {0|1}] [-maxVersion Major Minor]"
     "\n\t\t: Modify particular graphic driver options:"
+    "\n\t\t:  sRGB     - enable/disable sRGB rendering"
     "\n\t\t:  FFP      - use fixed-function pipeline instead of"
     "\n\t\t:             built-in GLSL programs"
     "\n\t\t:            (requires compatible profile)"
@@ -13960,7 +13984,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     " with f option returns free memory in bytes",
     __FILE__, VMemGpu, group);
   theCommands.Add ("vreadpixel",
-    "vreadpixel xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [-name|-hex]"
+    "vreadpixel xPixel yPixel [{rgb|rgba|sRGB|sRGBa|depth|hls|rgbf|rgbaf}=rgba] [-name|-hex]"
     " : Read pixel value for active view",
     __FILE__, VReadPixel, group);
   theCommands.Add("diffimage",
index 272816b5f808a8b4103cf4efab5a20e8afe9cec6..7922483d0f325f5abc19cebfd0a7c0195b697948 100644 (file)
 
 Vrml_DirectionalLight::Vrml_DirectionalLight():
   myOnOff(Standard_True),
-  myIntensity(1)
+  myIntensity(1),
+  myColor (Quantity_NOC_WHITE),
+  myDirection (0, 0, -1)
 {
-  gp_Vec tmpVec(0,0,-1);
-  myDirection = tmpVec;
-
-  Quantity_Color tmpColor(1,1,1,Quantity_TOC_RGB);
-  myColor = tmpColor;
+  //
 }
 
  Vrml_DirectionalLight::Vrml_DirectionalLight(const Standard_Boolean aOnOff, 
@@ -106,8 +104,10 @@ Standard_OStream& Vrml_DirectionalLight::Print(Standard_OStream& anOStream) cons
       Abs(myColor.Green() - 1) > 0.0001 || 
       Abs(myColor.Blue() - 1) > 0.0001 )
    {
+    NCollection_Vec3<Standard_Real> aColor_sRGB;
+    myColor.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
     anOStream  << "    color\t";
-    anOStream << myColor.Red() << " " << myColor.Green() << " " << myColor.Blue() << "\n";
+    anOStream << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b() << "\n";
    }
 
  if ( Abs(myDirection.X() - 0) > 0.0001 || 
index 050481ff17852a756b88a59d18a8d7a6f4e37832..3ca8b27e0d1200b9b03e499dc5cbbb85a055ec65 100644 (file)
@@ -51,21 +51,10 @@ Vrml_Material::Vrml_Material(const Handle(Quantity_HArray1OfColor)& aAmbientColo
 
  Vrml_Material::Vrml_Material()
 {
- Quantity_Color tmpcolor;
-// myAmbientColor  = new Quantity_HArray1OfColor(1,1);
-    tmpcolor.SetValues(0.2, 0.2, 0.2, Quantity_TOC_RGB);
- myAmbientColor  = new Quantity_HArray1OfColor(1,1,tmpcolor);
-//    myAmbientColor->SetValue(1, tmpcolor);
-// myDiffuseColor  = new Quantity_HArray1OfColor(1,1);
-    tmpcolor.SetValues(0.8, 0.8, 0.8, Quantity_TOC_RGB);
- myDiffuseColor  = new Quantity_HArray1OfColor(1,1,tmpcolor);
-//    myDiffuseColor->SetValue(1, tmpcolor);
- mySpecularColor = new Quantity_HArray1OfColor(1,1);
-    tmpcolor.SetValues(0, 0, 0, Quantity_TOC_RGB);
-    mySpecularColor->SetValue(1, tmpcolor);
- myEmissiveColor = new Quantity_HArray1OfColor(1,1);
-    tmpcolor.SetValues(0, 0, 0, Quantity_TOC_RGB);
-    myEmissiveColor->SetValue(1, tmpcolor);
+ myAmbientColor  = new Quantity_HArray1OfColor (1, 1, Quantity_Color (0.2, 0.2, 0.2, Quantity_TOC_sRGB));
+ myDiffuseColor  = new Quantity_HArray1OfColor (1, 1, Quantity_Color (0.8, 0.8, 0.8, Quantity_TOC_sRGB));
+ mySpecularColor = new Quantity_HArray1OfColor (1, 1, Quantity_NOC_BLACK);
+ myEmissiveColor = new Quantity_HArray1OfColor (1, 1, Quantity_NOC_BLACK);
 
  myShininess     = new TColStd_HArray1OfReal (1,1,0.2);
  myTransparency  = new TColStd_HArray1OfReal (1,1,0);
@@ -149,6 +138,7 @@ Handle(TColStd_HArray1OfReal) Vrml_Material::Transparency() const
 
 Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const 
 {
+ NCollection_Vec3<Standard_Real> aColor_sRGB;
  Standard_Integer i;
  anOStream  << "Material {\n";
 
@@ -160,7 +150,8 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const
   anOStream  << "    ambientColor [\n\t";
   for ( i = myAmbientColor->Lower(); i <= myAmbientColor->Upper(); i++ )
     {
-     anOStream << myAmbientColor->Value(i).Red() << ' ' << myAmbientColor->Value(i).Green() << ' ' << myAmbientColor->Value(i).Blue();
+     myAmbientColor->Value(i).Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
+     anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b();
      if ( i < myAmbientColor->Length() )
        anOStream  << ",\n\t"; // ,,,,,,,,,,
     }
@@ -175,7 +166,8 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const
   anOStream  << "    diffuseColor [\n\t";
   for ( i = myDiffuseColor->Lower(); i <= myDiffuseColor->Upper(); i++ )
     {
-     anOStream << myDiffuseColor->Value(i).Red() << ' ' << myDiffuseColor->Value(i).Green() << ' ' << myDiffuseColor->Value(i).Blue();
+     myDiffuseColor->Value(i).Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
+     anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b();
      if ( i < myDiffuseColor->Length() )
        anOStream  << ",\n\t";
     }
@@ -190,7 +182,8 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const
    anOStream  << "    specularColor [\n\t";
    for ( i = mySpecularColor->Lower(); i <= mySpecularColor->Upper(); i++ )
      {
-     anOStream << mySpecularColor->Value(i).Red() << ' ' << mySpecularColor->Value(i).Green() << ' ' << mySpecularColor->Value(i).Blue();
+     mySpecularColor->Value(i).Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
+     anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b();
      if ( i < mySpecularColor->Length() )
        anOStream  << ",\n\t";
      }
@@ -205,7 +198,8 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const
   anOStream  << "    emissiveColor [\n\t";
   for ( i = myEmissiveColor->Lower(); i <= myEmissiveColor->Upper(); i++ )
     {
-     anOStream << myEmissiveColor->Value(i).Red() << ' ' << myEmissiveColor->Value(i).Green() << ' ' << myEmissiveColor->Value(i).Blue();
+     myEmissiveColor->Value(i).Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
+     anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b();
      if ( i < myEmissiveColor->Length() )
        anOStream  << ",\n\t";
     }
index 5585fec0df2643b47d157c79ffd6a489000f8045..d1d24d84a79b8fdd1f752d4c72a8add8946968f1 100644 (file)
 
 Vrml_PointLight::Vrml_PointLight():
   myOnOff(Standard_True),
-  myIntensity(1)
+  myIntensity(1),
+  myColor (Quantity_NOC_WHITE),
+  myLocation (0, 0, 1)
 {
-  gp_Vec tmpVec(0,0,1);
-  myLocation = tmpVec;
-
-  Quantity_Color tmpColor(1,1,1,Quantity_TOC_RGB);
-  myColor = tmpColor;
+  //
 }
 
  Vrml_PointLight::Vrml_PointLight( const Standard_Boolean aOnOff, 
@@ -106,8 +104,10 @@ Standard_OStream& Vrml_PointLight::Print(Standard_OStream& anOStream) const
       Abs(myColor.Green() - 1) > 0.0001 || 
       Abs(myColor.Blue() - 1) > 0.0001 )
    {
+    NCollection_Vec3<Standard_Real> aColor_sRGB;
+    myColor.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
     anOStream  << "    color\t";
-    anOStream << myColor.Red() << " " << myColor.Green() << " " << myColor.Blue() << "\n";
+    anOStream << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b() << "\n";
    }
 
  if ( Abs(myLocation.X() - 0) > 0.0001 || 
index 23f2e51f626d3b57cd3f97c33d621f6b33a6a969..605098cfc233441249561892d5d463d4b17f92c4 100644 (file)
 Vrml_SpotLight::Vrml_SpotLight():
   myOnOff(Standard_True),
   myIntensity(1),
+  myColor (Quantity_NOC_WHITE),
+  myLocation (0, 0, 1),
+  myDirection (0, 0, -1),
   myDropOffRate(0), 
   myCutOffAngle(0.785398) 
 {
-  gp_Vec tmpVec(0,0,1);
-  myLocation = tmpVec;
-
-  tmpVec.SetCoord(0,0,-1);
-  myDirection = tmpVec;
-
-  Quantity_Color tmpColor(1,1,1,Quantity_TOC_RGB);
-  myColor = tmpColor;
+  //
 }
 
  Vrml_SpotLight::Vrml_SpotLight( const Standard_Boolean aOnOff, 
@@ -147,8 +143,10 @@ Standard_OStream& Vrml_SpotLight::Print(Standard_OStream& anOStream) const
      Abs(myColor.Green() - 1) > 0.0001 || 
      Abs(myColor.Blue() - 1) > 0.0001 )
    {
+    NCollection_Vec3<Standard_Real> aColor_sRGB;
+    myColor.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
     anOStream  << "    color\t";
-    anOStream << myColor.Red() << " " << myColor.Green() << " " << myColor.Blue() << "\n";
+    anOStream << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b() << "\n";
    }
 
  if ( Abs(myLocation.X() - 0) > 0.0001 || 
index a61110f833a52d93bd06272e5cd60c7ae48f17be..32fc7a446d13d015eafdb8e81fd2a77165cc4051 100644 (file)
@@ -46,10 +46,7 @@ VrmlAPI_Writer::VrmlAPI_Writer()
 {
   myDrawer = new VrmlConverter_Drawer;
   myDeflection = -1;
-  Quantity_Color color;
-  color.SetValues(0, 0, 0, Quantity_TOC_RGB);
-  Handle(Quantity_HArray1OfColor) Col1 = new Quantity_HArray1OfColor(1,1);
-  Col1->SetValue(1,color);
+  Handle(Quantity_HArray1OfColor) Col1 = new Quantity_HArray1OfColor (1, 1, Quantity_NOC_BLACK);
   Handle(TColStd_HArray1OfReal) kik1 = new TColStd_HArray1OfReal(1,1,0.0);
   Handle(TColStd_HArray1OfReal) kik2 = new TColStd_HArray1OfReal(1,1,0.1);
   myFrontMaterial = new Vrml_Material(Col1,Col1, Col1, Col1, kik1, kik2);
@@ -76,10 +73,7 @@ void VrmlAPI_Writer::ResetToDefaults()
   myShininess = 0.1;
   Handle(TColStd_HArray1OfReal) kik1 = new TColStd_HArray1OfReal(1,1,myTransparency);
   Handle(TColStd_HArray1OfReal) kik2 = new TColStd_HArray1OfReal(1,1,myShininess);
-  Handle(Quantity_HArray1OfColor) Col = new Quantity_HArray1OfColor(1,1);
-  Quantity_Color color; 
-  color.SetValues(0, 0, 0, Quantity_TOC_RGB);
-  Col->SetValue(1,color);
+  Handle(Quantity_HArray1OfColor) Col = new Quantity_HArray1OfColor(1, 1, Quantity_NOC_BLACK);
   //
   myFrontMaterial->SetAmbientColor(Col); myFrontMaterial->SetTransparency(kik1);myFrontMaterial->SetShininess(kik2);
   myPointsMaterial->SetAmbientColor(Col); myPointsMaterial->SetTransparency(kik1);myPointsMaterial->SetShininess(kik2);
@@ -91,13 +85,8 @@ void VrmlAPI_Writer::ResetToDefaults()
   myUnfreeBoundsMaterial->SetAmbientColor(Col); myUnfreeBoundsMaterial->SetTransparency(kik1);myUnfreeBoundsMaterial->SetShininess(kik2);
   //
   //
-  Handle(Quantity_HArray1OfColor) Col2 = new Quantity_HArray1OfColor(1,1);
-  color.SetValues(0.75, 0.75, 0.75, Quantity_TOC_RGB);
-  Col2->SetValue(1,color);
-  Handle(Quantity_HArray1OfColor) Col3 = new Quantity_HArray1OfColor(1,1);
-  color.SetValues(0.82, 0.79, 0.42, Quantity_TOC_RGB);
-  Col3->SetValue(1,color);
-  
+  Handle(Quantity_HArray1OfColor) Col2 = new Quantity_HArray1OfColor(1, 1, Quantity_Color (0.75, 0.75, 0.75, Quantity_TOC_sRGB));
+  Handle(Quantity_HArray1OfColor) Col3 = new Quantity_HArray1OfColor(1, 1, Quantity_Color (0.82, 0.79, 0.42, Quantity_TOC_sRGB));
   myUisoMaterial->SetDiffuseColor(Col2);
   myVisoMaterial->SetDiffuseColor(Col2);
   myFreeBoundsMaterial->SetDiffuseColor(Col2);
index 4d31eca00594f0a51325920ea0b85ec3639b0289..68473de2af4bbee83ee6757f3a21b34985af096d 100644 (file)
@@ -52,7 +52,7 @@ class VrmlData_Color : public VrmlData_ArrayVec3d
    */
   inline const Quantity_Color Color (const Standard_Integer i) const
   { return Quantity_Color (Value(i).X(), Value(i).Y(), Value(i).Z(),
-                           Quantity_TOC_RGB); }
+                           Quantity_TOC_sRGB); }
 
   /**
    * Set the array data
index 4f7be176087f27ade1faa4a47a8b44f446170c5e..7361efc9a5c53b993661ed840a682021c0520f3b 100644 (file)
@@ -36,9 +36,9 @@ VrmlData_Material::VrmlData_Material ()
   : myAmbientIntensity        (0.2),
     myShininess               (0.2),
     myTransparency            (0.),
-    myDiffuseColor            (0.8, 0.8, 0.8, Quantity_TOC_RGB),
-    myEmissiveColor           (0., 0., 0., Quantity_TOC_RGB),
-    mySpecularColor           (0., 0., 0., Quantity_TOC_RGB)
+    myDiffuseColor            (0.8, 0.8, 0.8, Quantity_TOC_sRGB),
+    myEmissiveColor           (Quantity_NOC_BLACK),
+    mySpecularColor           (Quantity_NOC_BLACK)
 {}
 
 //=======================================================================
@@ -55,9 +55,9 @@ VrmlData_Material::VrmlData_Material (const VrmlData_Scene&  theScene,
     myAmbientIntensity        (theAmbientIntens < 0. ? 0.2 : theAmbientIntens),
     myShininess               (theShininess     < 0. ? 0.2 : theShininess),
     myTransparency            (theTransparency  < 0  ? 0.  : theTransparency),
-    myDiffuseColor            (0.8, 0.8, 0.8, Quantity_TOC_RGB),
-    myEmissiveColor           (0., 0., 0., Quantity_TOC_RGB),
-    mySpecularColor           (0., 0., 0., Quantity_TOC_RGB)
+    myDiffuseColor            (0.8, 0.8, 0.8, Quantity_TOC_sRGB),
+    myEmissiveColor           (Quantity_NOC_BLACK),
+    mySpecularColor           (Quantity_NOC_BLACK)
 {}
 
 
@@ -169,11 +169,11 @@ VrmlData_ErrorStatus VrmlData_Material::Read (VrmlData_InBuffer& theBuffer)
     myShininess         = anIntensity[1];
     myTransparency      = anIntensity[2];
     myDiffuseColor.SetValues  (aColor[0].X(), aColor[0].Y(), aColor[0].Z(),
-                               Quantity_TOC_RGB);
+                               Quantity_TOC_sRGB);
     myEmissiveColor.SetValues (aColor[1].X(), aColor[1].Y(), aColor[1].Z(),
-                               Quantity_TOC_RGB);
+                               Quantity_TOC_sRGB);
     mySpecularColor.SetValues (aColor[2].X(), aColor[2].Y(), aColor[2].Z(),
-                               Quantity_TOC_RGB);
+                               Quantity_TOC_sRGB);
   }
   return aStatus;
 }
@@ -193,7 +193,7 @@ VrmlData_ErrorStatus VrmlData_Material::Write (const char * thePrefix) const
   {
     char buf[128];
     Standard_Real val[3];
-    Quantity_TypeOfColor bidType (Quantity_TOC_RGB);
+    const Quantity_TypeOfColor bidType = Quantity_TOC_sRGB;
     const Standard_Real aConf (0.001 * Precision::Confusion());
 
     if (OK(aStatus) && fabs(myAmbientIntensity - 0.2) > aConf) {
@@ -252,7 +252,7 @@ Standard_Boolean VrmlData_Material::IsDefault () const
       myTransparency                 < aConf)
   {
     Standard_Real val[3][3];
-    Quantity_TypeOfColor bidType (Quantity_TOC_RGB);
+    const Quantity_TypeOfColor bidType = Quantity_TOC_sRGB;
     myDiffuseColor.Values  (val[0][0], val[0][1], val[0][2], bidType);
     myEmissiveColor.Values (val[1][0], val[1][1], val[1][2], bidType);
     mySpecularColor.Values (val[2][0], val[2][1], val[2][2], bidType);
index 151d5f9b61f905401771677661f0c3db0884e43e..99c5fffdfcb11ba79b45ed289349fbbd1271156f 100644 (file)
@@ -546,11 +546,11 @@ Handle(VrmlData_Appearance) VrmlData_ShapeConvert::defaultMaterialFace () const
     const Handle(VrmlData_Material) aMaterial =
       new VrmlData_Material (myScene, 0L, 1.0, 0.022, 0.);
     aMaterial->SetDiffuseColor (Quantity_Color(0.780392, 0.568627, 0.113725,
-                                               Quantity_TOC_RGB));
+                                               Quantity_TOC_sRGB));
     aMaterial->SetEmissiveColor(Quantity_Color(0.329412, 0.223529, 0.027451,
-                                               Quantity_TOC_RGB));
+                                               Quantity_TOC_sRGB));
     aMaterial->SetSpecularColor(Quantity_Color(0.992157, 0.941176, 0.807843,
-                                               Quantity_TOC_RGB));
+                                               Quantity_TOC_sRGB));
     myScene.AddNode (aMaterial, Standard_False);
     anAppearance = new VrmlData_Appearance (myScene, aNodeName);
     anAppearance->SetMaterial (aMaterial);
@@ -903,11 +903,13 @@ Handle(VrmlData_Appearance) VrmlData_ShapeConvert::makeMaterialFromColor(
   }
   else
   {
-    aNodeName.AssignCat(aColor.GetRGB().Red());
+    NCollection_Vec3<Standard_Real> aColor_sRGB;
+    aColor.GetRGB().Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
+    aNodeName.AssignCat(aColor_sRGB.r());
     aNodeName.AssignCat("_");
-    aNodeName.AssignCat(aColor.GetRGB().Green());
+    aNodeName.AssignCat(aColor_sRGB.g());
     aNodeName.AssignCat("_");
-    aNodeName.AssignCat(aColor.GetRGB().Blue());
+    aNodeName.AssignCat(aColor_sRGB.b());
   }
 
   Handle(VrmlData_Appearance) anAppearance =
index 134de5bed17bd97f0241ce86e445b76856e3beab..b8856aba7d936de4ff5c9d6422b86a2b61a3a047 100644 (file)
@@ -2,42 +2,38 @@ puts "========"
 puts "Texture 2D transformation (UV coordinates generation)"
 puts "========"
 
-vclear
-vclose ALL
-vinit View1
-
 set aTexture [locate_data_file bug26122_texture_trsf_ref.png]
 pload MODELING VISUALIZATION
 box b 1 1 1
 explode b F
-vclear
-vclose ALL
-vinit View1 w=512 h=512
-vtop
-vsetdispmode 1
-vdisplay b_6
-vfit
-
-vcaps -ffp 1
-vtexture b_6 $aTexture -modulate off
-vdump $::imagedir/${::casename}_identity_ffp.png
-vcaps -ffp 0
-vdump $::imagedir/${::casename}_identity_glsl.png
-
-vcaps -ffp 1
-vtexture b_6 $aTexture -origin 0.0 0.0 -scale 1.25 0.5
-vdump $::imagedir/${::casename}_scale_ffp.png
-vcaps -ffp 0
-vdump $::imagedir/${::casename}_scale_glsl.png
-
-vcaps -ffp 1
-vtexture b_6 $aTexture -origin 0.25 -0.25 -scale 1.0 1.0
-vdump $::imagedir/${::casename}_translate_ffp.png
-vcaps -ffp 0
-vdump $::imagedir/${::casename}_translate_glsl.png
-
-vcaps -ffp 1
-vtexture b_6 $aTexture -origin 0.25 -0.25 -scale 1.1 0.8
-vdump $::imagedir/${::casename}_ffp.png
-vcaps -ffp 0
-vdump $::imagedir/${::casename}_glsl.png
+
+for { set aPass 0 } { $aPass < 2 } { incr aPass } {
+  vclear
+  vclose ALL
+
+  set aSuffix ""
+  if { $aPass == 0 } {
+    set aSuffix "ffp"
+    vcaps -ffp 1
+  } else {
+    set aSuffix "glsl"
+    vcaps -ffp 0
+  }
+
+  vinit View1 w=512 h=512
+  vtop
+  vdisplay -dispMode 1 b_6
+  vfit
+
+  vtexture b_6 $aTexture -modulate off
+  vdump $::imagedir/${::casename}_identity_${aSuffix}.png
+
+  vtexture b_6 $aTexture -origin 0.0 0.0 -scale 1.25 0.5
+  vdump $::imagedir/${::casename}_scale_${aSuffix}.png
+
+  vtexture b_6 $aTexture -origin 0.25 -0.25 -scale 1.0 1.0
+  vdump $::imagedir/${::casename}_translate_${aSuffix}.png
+
+  vtexture b_6 $aTexture -origin 0.25 -0.25 -scale 1.1 0.8
+  vdump $::imagedir/${::casename}_${aSuffix}.png
+}
index 7bb7faf56cf2f19128552fac50dfa2f165743e2f..a5c60278792e172c627a8c107b0b0570225eba7c 100644 (file)
@@ -6,34 +6,34 @@ set aTexture [locate_data_file bug26122_texture_trsf_ref.png]
 pload MODELING VISUALIZATION
 box b 1 1 1
 explode b F
-vclear
-vclose ALL
-vinit View1 w=512 h=512
-vtop
-vsetdispmode 1
-vdisplay b_6
-vfit
-
-vcaps -ffp 1
-vtexture b_6 $aTexture -modulate off
-vdump $::imagedir/${::casename}_identity_ffp.png
-vcaps -ffp 0
-vdump $::imagedir/${::casename}_identity_glsl.png
-
-vcaps -ffp 1
-vtexture b_6 $aTexture -trsfTranslate 0.0 0.0 -trsfScale 0.8 2.0
-vdump $::imagedir/${::casename}_scale_ffp.png
-vcaps -ffp 0
-vdump $::imagedir/${::casename}_scale_glsl.png
-
-vcaps -ffp 1
-vtexture b_6 $aTexture -trsfTranslate 0.25 -0.25 -trsfScale 1.0 1.0
-vdump $::imagedir/${::casename}_translate_ffp.png
-vcaps -ffp 0
-vdump $::imagedir/${::casename}_translate_glsl.png
-
-vcaps -ffp 1
-vtexture b_6 $aTexture -trsfTranslate 0.25 -0.25 -trsfScale 1.1 0.8
-vdump $::imagedir/${::casename}_ffp.png
-vcaps -ffp 0
-vdump $::imagedir/${::casename}_glsl.png
+
+for { set aPass 0 } { $aPass < 2 } { incr aPass } {
+  vclear
+  vclose ALL
+
+  set aSuffix ""
+  if { $aPass == 0 } {
+    set aSuffix "ffp"
+    vcaps -ffp 1
+  } else {
+    set aSuffix "glsl"
+    vcaps -ffp 0
+  }
+
+  vinit View1 w=512 h=512
+  vtop
+  vdisplay -dispMode 1 b_6
+  vfit
+
+  vtexture b_6 $aTexture -modulate off
+  vdump $::imagedir/${::casename}_identity_${aSuffix}.png
+
+  vtexture b_6 $aTexture -trsfTranslate 0.0 0.0 -trsfScale 0.8 2.0
+  vdump $::imagedir/${::casename}_scale_${aSuffix}.png
+
+  vtexture b_6 $aTexture -trsfTranslate 0.25 -0.25 -trsfScale 1.0 1.0
+  vdump $::imagedir/${::casename}_translate_${aSuffix}.png
+
+  vtexture b_6 $aTexture -trsfTranslate 0.25 -0.25 -trsfScale 1.1 0.8
+  vdump $::imagedir/${::casename}_${aSuffix}.png
+}