0032201: Visualization, TKOpenGl - unify Phong/PBR material properties getters
[occt.git] / src / Shaders / Shaders_Declarations_glsl.pxx
index 8c1adec..0485a49 100644 (file)
@@ -206,22 +206,15 @@ static const char Shaders_Declarations_glsl[] =
   "float occPBRMaterial_NormalizedRoughness(in bool theIsFront); //!< Normalized roughness coefficient\n"
   "vec3  occPBRMaterial_Emission(in bool theIsFront); //!< Light intensity emitted by material\n"
   "float occPBRMaterial_IOR(in bool theIsFront);      //!< Index of refraction\n"
+  "#define occMaterial_Emission occPBRMaterial_Emission\n"
+  "#define occMaterial_Color occPBRMaterial_Color\n"
   "#else\n"
-  "// Front material properties accessors\n"
-  "vec4  occFrontMaterial_Emission(void);           //!< Emission color\n"
-  "vec4  occFrontMaterial_Ambient(void);            //!< Ambient  reflection\n"
-  "vec4  occFrontMaterial_Diffuse(void);            //!< Diffuse  reflection\n"
-  "vec4  occFrontMaterial_Specular(void);           //!< Specular reflection\n"
-  "float occFrontMaterial_Shininess(void);          //!< Specular exponent\n"
-  "float occFrontMaterial_Transparency(void);       //!< Transparency coefficient\n"
-  "\n"
-  "// Back material properties accessors\n"
-  "vec4  occBackMaterial_Emission(void);            //!< Emission color\n"
-  "vec4  occBackMaterial_Ambient(void);             //!< Ambient  reflection\n"
-  "vec4  occBackMaterial_Diffuse(void);             //!< Diffuse  reflection\n"
-  "vec4  occBackMaterial_Specular(void);            //!< Specular reflection\n"
-  "float occBackMaterial_Shininess(void);           //!< Specular exponent\n"
-  "float occBackMaterial_Transparency(void);        //!< Transparency coefficient\n"
+  "vec4  occMaterial_Diffuse(in bool theIsFront);     //!< Diffuse  reflection\n"
+  "vec3  occMaterial_Specular(in bool theIsFront);    //!< Specular reflection\n"
+  "float occMaterial_Shininess(in bool theIsFront);   //!< Specular exponent\n"
+  "vec3  occMaterial_Ambient(in bool theIsFront);     //!< Ambient  reflection\n"
+  "vec3  occMaterial_Emission(in bool theIsFront);    //!< Emission color\n"
+  "#define occMaterial_Color occMaterial_Diffuse\n"
   "#endif\n"
   "\n"
   "#ifdef THE_HAS_DEFAULT_SAMPLER\n"
@@ -230,24 +223,24 @@ static const char Shaders_Declarations_glsl[] =
   "uniform sampler2D           occSampler0; //!< current active sampler;\n"
   "#endif                                   //!  occSampler1, occSampler2,... should be defined in GLSL program body for multitexturing\n"
   "\n"
-  "#if defined(THE_HAS_TEXTURE_COLOR)\n"
-  "#define occTextureColor(theMatColor, theTexCoord) (theMatColor * occTexture2D(occSamplerBaseColor, theTexCoord))\n"
+  "#if defined(THE_HAS_TEXTURE_COLOR) && defined(FRAGMENT_SHADER)\n"
+  "#define occMaterialBaseColor(theIsFront, theTexCoord) (occMaterial_Color(theIsFront) * occTexture2D(occSamplerBaseColor, theTexCoord))\n"
   "#else\n"
-  "#define occTextureColor(theMatColor, theTexCoord) theMatColor\n"
+  "#define occMaterialBaseColor(theIsFront, theTexCoord) occMaterial_Color(theIsFront)\n"
   "#endif\n"
   "\n"
   "#if defined(THE_HAS_TEXTURE_OCCLUSION) && defined(FRAGMENT_SHADER)\n"
   "uniform sampler2D occSamplerOcclusion;   //!< R occlusion texture sampler\n"
-  "#define occTextureOcclusion(theColor, theTexCoord) theColor *= occTexture2D(occSamplerOcclusion, theTexCoord).r;\n"
+  "#define occMaterialOcclusion(theColor, theTexCoord) theColor *= occTexture2D(occSamplerOcclusion, theTexCoord).r;\n"
   "#else\n"
-  "#define occTextureOcclusion(theColor, theTexCoord)\n"
+  "#define occMaterialOcclusion(theColor, theTexCoord)\n"
   "#endif\n"
   "\n"
   "#if defined(THE_HAS_TEXTURE_EMISSIVE) && defined(FRAGMENT_SHADER)\n"
   "uniform sampler2D occSamplerEmissive;    //!< RGB emissive texture sampler\n"
-  "#define occTextureEmissive(theMatEmis, theTexCoord) (theMatEmis * occTexture2D(occSamplerEmissive, theTexCoord).rgb)\n"
+  "#define occMaterialEmission(theIsFront, theTexCoord) (occMaterial_Emission(theIsFront) * occTexture2D(occSamplerEmissive, theTexCoord).rgb)\n"
   "#else\n"
-  "#define occTextureEmissive(theMatEmis, theTexCoord) theMatEmis\n"
+  "#define occMaterialEmission(theIsFront, theTexCoord) occMaterial_Emission(theIsFront)\n"
   "#endif\n"
   "\n"
   "#if defined(THE_HAS_TEXTURE_NORMAL) && defined(FRAGMENT_SHADER)\n"
@@ -259,11 +252,11 @@ static const char Shaders_Declarations_glsl[] =
   "\n"
   "#if defined(THE_HAS_TEXTURE_METALROUGHNESS) && defined(FRAGMENT_SHADER)\n"
   "uniform sampler2D occSamplerMetallicRoughness; //!< BG metallic-roughness texture sampler\n"
-  "#define occTextureRoughness(theRoug, theTexCoord) (theRoug * occTexture2D(occSamplerMetallicRoughness, theTexCoord).g)\n"
-  "#define occTextureMetallic(theMet,   theTexCoord) (theMet  * occTexture2D(occSamplerMetallicRoughness, theTexCoord).b)\n"
+  "#define occMaterialRoughness(theIsFront, theTexCoord) (occPBRMaterial_NormalizedRoughness(theIsFront) * occTexture2D(occSamplerMetallicRoughness, theTexCoord).g)\n"
+  "#define occMaterialMetallic(theIsFront,  theTexCoord) (occPBRMaterial_Metallic(theIsFront) * occTexture2D(occSamplerMetallicRoughness, theTexCoord).b)\n"
   "#else\n"
-  "#define occTextureRoughness(theRoug, theTexCoord) theRoug\n"
-  "#define occTextureMetallic(theMet,   theTexCoord) theMet\n"
+  "#define occMaterialRoughness(theIsFront, theTexCoord) occPBRMaterial_NormalizedRoughness(theIsFront)\n"
+  "#define occMaterialMetallic(theIsFront,  theTexCoord) occPBRMaterial_Metallic(theIsFront)\n"
   "#endif\n"
   "\n"
   "uniform               vec4      occColor;              //!< color value (in case of disabled lighting)\n"