Graphic3d_ShaderManager::stdComputeLighting() now multiplies vertex color by material color.
Accessors to standard materials have been modified within *Declarations.glsl* (*occFrontMaterial_Diffuse()* -> *occMaterial_Diffuse(bool)* and similar).
Applications defining custom GLSL programs should take into account syntax changes.
+
+@subsection upgrade_occt760_noral_colors Nodal color modulation
+
+Nodal color vertex attribute is now modulated in the same way as a color texture - color is multiplied by material coefficients (diffuse/ambient/specular in case of a common material definition).
+Existing code defining nodal colors should be updated to:
+- Use *Graphic3d_TOSM_UNLIT* shading model when lighting is not needed.
+- Adjust diffuse/ambient material coefficients, which have been previously ignored.
+- Remove code multiplying nodal colors, intended to compensate over-brightness due to addition of specular color from material definition, as specular component is now also modulated by a vertex color.
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
Handle(Graphic3d_AspectFillArea3d) anAspect = myDrawer->ShadingAspect()->Aspect();
- const Standard_Real anAmbient = 0.2;
+ const Standard_Real anAmbient = 1.0;
if (hasVNormals)
{
gp_Vec3f aNormal;
}
}
- TCollection_AsciiString aGetMatAmbient = "occMaterial_Ambient(theIsFront);";
- TCollection_AsciiString aGetMatDiffuse = "occMaterial_Diffuse(theIsFront);";
- if (theHasVertColor)
- {
- aGetMatAmbient = "getVertColor().rgb;";
- aGetMatDiffuse = "getVertColor();";
- }
-
if (!theIsPBR)
{
return TCollection_AsciiString()
EOL" Specular = vec3 (0.0);"
EOL" vec3 aPoint = thePoint.xyz / thePoint.w;"
+ aLightsLoop
- + EOL" vec3 aMatAmbient = " + aGetMatAmbient
- + EOL" vec4 aMatDiffuse = " + aGetMatDiffuse
- + EOL" vec3 aMatSpecular = occMaterial_Specular(theIsFront);"
+ + EOL" vec3 aMatAmbient = occMaterial_Ambient(theIsFront);"
+ EOL" vec4 aMatDiffuse = occMaterial_Diffuse(theIsFront);"
+ EOL" vec3 aMatSpecular = occMaterial_Specular(theIsFront);"
EOL" vec4 aColor = vec4(Ambient * aMatAmbient + Diffuse * aMatDiffuse.rgb + Specular * aMatSpecular, aMatDiffuse.a);"
+ + (theHasVertColor ?
+ EOL" aColor *= getVertColor();" : "")
+ (theHasTexColor ?
EOL"#if defined(THE_HAS_TEXTURE_COLOR) && defined(FRAGMENT_SHADER)"
EOL" aColor *= occTexture2D(occSamplerBaseColor, TexCoord.st / TexCoord.w);"
EOL" in bool theIsFront)"
EOL"{"
EOL" DirectLighting = vec3(0.0);"
- EOL" BaseColor = " + (theHasVertColor ? "getVertColor();" : "occMaterialBaseColor(theIsFront, TexCoord.st / TexCoord.w);")
+ EOL" BaseColor = occMaterialBaseColor(theIsFront, TexCoord.st / TexCoord.w)" + (theHasVertColor ? " * getVertColor()" : "") + ";"
+ EOL" Emission = occMaterialEmission(theIsFront, TexCoord.st / TexCoord.w);"
EOL" Metallic = occMaterialMetallic(theIsFront, TexCoord.st / TexCoord.w);"
EOL" NormalizedRoughness = occMaterialRoughness(theIsFront, TexCoord.st / TexCoord.w);"
gp_Dir aDefNorm( 0., 0., 1. );
// Prepare for scaling the incoming colors
- const Standard_Real anColorRatio = !IsReflect ? 0.44f : 0.5f;
+ const Standard_Real anColorRatio = 1.0;
for (it.Reset(); it.More(); it.Next())
{
// aStyle = (Aspect_InteriorStyle)aStyleInt;
anAsp = new Graphic3d_AspectFillArea3d (
- Aspect_IS_SOLID, Quantity_NOC_GRAY, anEdgeColor,
+ Aspect_IS_SOLID, Quantity_NOC_WHITE, anEdgeColor,
anEdgeType, anEdgeWidth, aMaterial[ 0 ], aMaterial[ 1 ] );
}
aMat.SetSpecularColor(Quantity_Color (Graphic3d_Vec3 (0.50f)));
Handle(Graphic3d_AspectFillArea3d) anAspect
= new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID,
- Quantity_NOC_RED,
+ Quantity_NOC_WHITE,
Quantity_NOC_YELLOW,
Aspect_TOL_SOLID,
1.0,
if (myPArray.IsNull())
{
myPArray = Graphic3d_ArrayOfPrimitives::CreateArray (thePrimType, aVertexNum, aBoundNum, aEdgeNum, anArrayFlags);
+ if (myPArray->HasVertexColors())
+ {
+ myDrawer->SetupOwnShadingAspect();
+ Graphic3d_MaterialAspect aMat (Graphic3d_NameOfMaterial_Plastified);
+ aMat.SetSpecularColor (Quantity_NOC_BLACK);
+ aMat.SetEmissiveColor (Quantity_NOC_BLACK);
+ aMat.SetAmbientColor (Quantity_Color (Graphic3d_Vec3 (0.5f)));
+ aMat.SetDiffuseColor (Quantity_Color (Graphic3d_Vec3 (0.5f)));
+ myDrawer->ShadingAspect()->SetMaterial (aMat);
+ myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
+ }
}
else
{
vfit
vdump $imagedir/${casename}_1.png
vdrawparray a -patch triangles -deinterleaved -mutable v 10 0 0 {*}$c2 v 11 0 0 {*}$c2 v 11 1 0 {*}$c2 v 11 1 0 {*}$c1 v 10 1 0 {*}$c1 v 10 0 0 {*}$c1
-if { [vreadpixel 200 150 rgb name] != "RED" } { puts "Error: array was not updated" }
-if { [vreadpixel 200 250 rgb name] != "BLUE" } { puts "Error: array was not updated" }
+if { [vreadpixel 200 150 rgb name] != "RED2" } { puts "Error: array was not updated" }
+if { [vreadpixel 200 250 rgb name] != "BLUE2" } { puts "Error: array was not updated" }
vdump $imagedir/${casename}_2.png
--- /dev/null
+puts "============"
+puts "0032198: Visualization, TKOpenGl - per-vertex lighting ignores back/front material colors"
+puts "============"
+puts ""
+
+set aVerts {
+ {{0 55 0} { 0 75 0} {20 55 0}}
+ {{0 75 0} { 0 55 20} {20 55 0}}
+ {{0 55 0} { 0 55 20} { 0 75 0}}
+ {{0 55 0} {20 55 0} { 0 55 20}}
+}
+set aColors {
+ {{1.0 0.0 0.0} {0.0 1.0 0.0} {0.0 0.0 1.0}}
+ {{1.0 1.0 0.0} {1.0 1.0 1.0} {0.0 1.0 1.0}}
+ {{0.5 0.0 0.0} {0.0 0.0 0.5} {0.0 0.5 0.0}}
+ {{0.5 0.5 0.0} {0.0 0.5 0.5} {0.5 0.0 0.5}}
+}
+set aNormals {
+ { 0 0 -1}
+ { 1 1 1}
+ {-1 0 0}
+ { 0 -1 0}
+}
+
+proc genTris {theFrom theTo theColors} {
+ set aTris ""
+ for {set t $theFrom} {$t <= $theTo} {incr t} {
+ for {set n 0} {$n < 3} {incr n} {
+ set aVert [lindex $::aVerts $t]
+ set aCol [lindex $::aColors $t]
+ set aNorm [lindex $::aNormals $t]
+ set aTris "$aTris v [lindex $aVert $n] n $aNorm"
+ if { $theColors == 1 } { set aTris "$aTris c [lindex $aCol $n]" }
+ }
+ }
+ return $aTris
+}
+
+set aTris1 [genTris 0 3 0]
+set aTris1c [genTris 0 3 1]
+set aTris2 [genTris 0 1 0]
+set aTris2c [genTris 0 1 1]
+
+pload MODELING VISUALIZATION
+vclear
+vinit View1
+vviewparams -scale 10 -proj -0.3 -0.7 0.6 -up 0.013 0.65 0.75 -at 35.4 61.8 31.5
+vdrawparray t1 triangles {*}$aTris1
+vdrawparray t1c triangles {*}$aTris1c
+vdrawparray t2 triangles {*}$aTris2
+vdrawparray t2c triangles {*}$aTris2c
+vdrawparray t3 triangles {*}$aTris2
+vdrawparray t3c triangles {*}$aTris2c
+vlocation t1 -location 0 0 0
+vlocation t2 -location 30 0 0
+vlocation t3 -location 60 0 0
+vlocation t1c -location 0 0 30
+vlocation t2c -location 30 0 30
+vlocation t3c -location 60 0 30
+vaspects t1 -color GREEN -backfaceColor RED
+vaspects t2 -color GREEN -backfaceColor RED
+vaspects t1c -color GREEN -backfaceColor RED
+vaspects t2c -color GREEN -backfaceColor RED
+vaspects t3 -color WHITE -backfaceColor WHITE
+vaspects t3c -color WHITE -backfaceColor WHITE
+
+vrenderparams -shadingModel VERT
+vdump ${imagedir}/${casename}_vert.png
+vrenderparams -shadingModel PHONG
+vdump ${imagedir}/${casename}_phong.png
+vrenderparams -shadingModel FLAT
+vdump ${imagedir}/${casename}_flat.png
+vrenderparams -shadingModel UNLIT
+vdump ${imagedir}/${casename}_unlit.png
+vrenderparams -shadingModel PBR
+vdump ${imagedir}/${casename}_pbr.png