]> OCCT Git - occt.git/commitdiff
Fix per-vertex rendering CR0-ww-depot-750
authorsshutina <svetlana.shutina@opencascade.com>
Wed, 12 Nov 2025 13:59:30 +0000 (13:59 +0000)
committersshutina <svetlana.shutina@opencascade.com>
Wed, 12 Nov 2025 14:00:15 +0000 (14:00 +0000)
per-vertex lighting ignored back/front material colors

src/OpenGl/OpenGl_ShaderManager.cxx

index 3c8f75f89b436827749c07ace70ff178a3839ce6..72f1ee5c0418c02a30daa868c80996979a199cb1 100644 (file)
@@ -2346,19 +2346,14 @@ TCollection_AsciiString OpenGl_ShaderManager::stdComputeLighting (Standard_Integ
 
   TCollection_AsciiString aGetMatAmbient = "theIsFront ? occFrontMaterial_Ambient()  : occBackMaterial_Ambient();";
   TCollection_AsciiString aGetMatDiffuse = "theIsFront ? occFrontMaterial_Diffuse()  : occBackMaterial_Diffuse();";
-  if (theHasVertColor)
-  {
-    aGetMatAmbient = "getVertColor();";
-    aGetMatDiffuse = "getVertColor();";
-  }
 
   if (!theIsPBR)
   {
     return TCollection_AsciiString()
-    + THE_FUNC_lightDef
-    + Shaders_PointLightAttenuation_glsl
-    + aLightsFunc
-    + EOL
+      + THE_FUNC_lightDef
+      + Shaders_PointLightAttenuation_glsl
+      + aLightsFunc
+      + EOL
       EOL"vec4 computeLighting (in vec3 theNormal,"
       EOL"                      in vec3 theView,"
       EOL"                      in vec4 thePoint,"
@@ -2368,16 +2363,19 @@ TCollection_AsciiString OpenGl_ShaderManager::stdComputeLighting (Standard_Integ
       EOL"  Diffuse  = vec3 (0.0);"
       EOL"  Specular = vec3 (0.0);"
       EOL"  vec3 aPoint = thePoint.xyz / thePoint.w;"
-    + aLightsLoop
-    + EOL"  vec4 aMatAmbient  = " + aGetMatAmbient
-    + EOL"  vec4 aMatDiffuse  = " + aGetMatDiffuse
-    + EOL"  vec4 aMatSpecular = theIsFront ? occFrontMaterial_Specular() : occBackMaterial_Specular();"
-      EOL"  vec3 aColor = Ambient * aMatAmbient.rgb + Diffuse * aMatDiffuse.rgb + Specular * aMatSpecular.rgb;"
-      EOL"  occTextureOcclusion(aColor, TexCoord.st);"
-    + (theHasEmissive
-    ? EOL"  vec4 aMatEmission = theIsFront ? occFrontMaterial_Emission() : occBackMaterial_Emission();"
-      EOL"  aColor += aMatEmission.rgb;" : "")
-    + EOL"  return vec4 (aColor, aMatDiffuse.a);"
+      + aLightsLoop
+      + EOL"  vec4 aMatAmbient  = " + aGetMatAmbient
+      + EOL"  vec4 aMatDiffuse  = " + aGetMatDiffuse
+      + EOL"  vec4 aMatSpecular = theIsFront ? occFrontMaterial_Specular() : occBackMaterial_Specular();"
+      + EOL"  vec3 aVertColor = " + (theHasVertColor ? "getVertColor().rgb;" : "vec3(1.0);")
+      + EOL"  vec3 aColor = Ambient * aMatAmbient.rgb * aVertColor"
+      + EOL"                + Diffuse * aMatDiffuse.rgb * aVertColor"
+      + EOL"                + Specular * aMatSpecular.rgb;"
+      + EOL"  occTextureOcclusion(aColor, TexCoord.st);"
+      + (theHasEmissive
+        ? EOL"  vec4 aMatEmission = theIsFront ? occFrontMaterial_Emission() : occBackMaterial_Emission();"
+        EOL"  aColor += aMatEmission.rgb;" : "")
+      + EOL"  return vec4 (aColor, aMatDiffuse.a);"
       EOL"}";
   }
   else