mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0031293: Visualization, TKOpenGl - broken capping when PBR shading is ON
Division by 'w' component has been added in texture coordinates calculations in PBR functions.
This commit is contained in:
parent
9df71488b3
commit
c8bead4752
@ -2375,10 +2375,10 @@ TCollection_AsciiString OpenGl_ShaderManager::stdComputeLighting (Standard_Integ
|
|||||||
EOL" in bool theIsFront)"
|
EOL" in bool theIsFront)"
|
||||||
EOL"{"
|
EOL"{"
|
||||||
EOL" DirectLighting = vec3(0.0);"
|
EOL" DirectLighting = vec3(0.0);"
|
||||||
EOL" BaseColor = " + (theHasVertColor ? "getVertColor();" : "occTextureColor(occPBRMaterial_Color (theIsFront), TexCoord.st);")
|
EOL" BaseColor = " + (theHasVertColor ? "getVertColor();" : "occTextureColor(occPBRMaterial_Color (theIsFront), TexCoord.st / TexCoord.w);")
|
||||||
+ EOL" Emission = occTextureEmissive(occPBRMaterial_Emission (theIsFront), TexCoord.st);"
|
+ EOL" Emission = occTextureEmissive(occPBRMaterial_Emission (theIsFront), TexCoord.st / TexCoord.w);"
|
||||||
EOL" Metallic = occTextureMetallic(occPBRMaterial_Metallic (theIsFront), TexCoord.st);"
|
EOL" Metallic = occTextureMetallic(occPBRMaterial_Metallic (theIsFront), TexCoord.st / TexCoord.w);"
|
||||||
EOL" NormalizedRoughness = occTextureRoughness(occPBRMaterial_NormalizedRoughness (theIsFront), TexCoord.st);"
|
EOL" NormalizedRoughness = occTextureRoughness(occPBRMaterial_NormalizedRoughness (theIsFront), TexCoord.st / TexCoord.w);"
|
||||||
EOL" Roughness = occRoughness (NormalizedRoughness);"
|
EOL" Roughness = occRoughness (NormalizedRoughness);"
|
||||||
EOL" IOR = occPBRMaterial_IOR (theIsFront);"
|
EOL" IOR = occPBRMaterial_IOR (theIsFront);"
|
||||||
EOL" vec3 aPoint = thePoint.xyz / thePoint.w;"
|
EOL" vec3 aPoint = thePoint.xyz / thePoint.w;"
|
||||||
@ -2395,7 +2395,7 @@ TCollection_AsciiString OpenGl_ShaderManager::stdComputeLighting (Standard_Integ
|
|||||||
EOL" anIndirectLightingDiff *= occDiffIBLMap (theNormal).rgb;"
|
EOL" anIndirectLightingDiff *= occDiffIBLMap (theNormal).rgb;"
|
||||||
EOL" aColor += occLightAmbient.rgb * (anIndirectLightingDiff + anIndirectLightingSpec);"
|
EOL" aColor += occLightAmbient.rgb * (anIndirectLightingDiff + anIndirectLightingSpec);"
|
||||||
EOL" aColor += Emission;"
|
EOL" aColor += Emission;"
|
||||||
EOL" occTextureOcclusion(aColor, TexCoord.st);"
|
EOL" occTextureOcclusion(aColor, TexCoord.st / TexCoord.w);"
|
||||||
EOL" return vec4 (aColor, mix(1.0, BaseColor.a, aRefractionCoeff.x));"
|
EOL" return vec4 (aColor, mix(1.0, BaseColor.a, aRefractionCoeff.x));"
|
||||||
EOL"}";
|
EOL"}";
|
||||||
}
|
}
|
||||||
@ -2722,11 +2722,12 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
|
|||||||
// apply normal map texture
|
// apply normal map texture
|
||||||
aSrcFragExtraMain +=
|
aSrcFragExtraMain +=
|
||||||
EOL"#if defined(THE_HAS_TEXTURE_NORMAL)"
|
EOL"#if defined(THE_HAS_TEXTURE_NORMAL)"
|
||||||
EOL" vec4 aMapNormalValue = occTextureNormal(TexCoord.st / TexCoord.w);"
|
EOL" vec2 aTexCoord = TexCoord.st / TexCoord.w;"
|
||||||
|
EOL" vec4 aMapNormalValue = occTextureNormal(aTexCoord);"
|
||||||
EOL" if (aMapNormalValue.w > 0.5)"
|
EOL" if (aMapNormalValue.w > 0.5)"
|
||||||
EOL" {"
|
EOL" {"
|
||||||
EOL" aMapNormalValue.xyz = normalize (aMapNormalValue.xyz * 2.0 - vec3(1.0));"
|
EOL" aMapNormalValue.xyz = normalize (aMapNormalValue.xyz * 2.0 - vec3(1.0));"
|
||||||
EOL" mat2 aDeltaUVMatrix = mat2 (dFdx(TexCoord.st / TexCoord.w), dFdy(TexCoord.st / TexCoord.w));"
|
EOL" mat2 aDeltaUVMatrix = mat2 (dFdx(aTexCoord), dFdy(aTexCoord));"
|
||||||
EOL" aDeltaUVMatrix = mat2 (aDeltaUVMatrix[1][1], -aDeltaUVMatrix[0][1], -aDeltaUVMatrix[1][0], aDeltaUVMatrix[0][0]);"
|
EOL" aDeltaUVMatrix = mat2 (aDeltaUVMatrix[1][1], -aDeltaUVMatrix[0][1], -aDeltaUVMatrix[1][0], aDeltaUVMatrix[0][0]);"
|
||||||
EOL" mat2x3 aDeltaVectorMatrix = mat2x3 (dFdx (PositionWorld.xyz), dFdy (PositionWorld.xyz));"
|
EOL" mat2x3 aDeltaVectorMatrix = mat2x3 (dFdx (PositionWorld.xyz), dFdy (PositionWorld.xyz));"
|
||||||
EOL" aDeltaVectorMatrix = aDeltaVectorMatrix * aDeltaUVMatrix;"
|
EOL" aDeltaVectorMatrix = aDeltaVectorMatrix * aDeltaUVMatrix;"
|
||||||
|
9
tests/demo/samples/dimensionspbr
Normal file
9
tests/demo/samples/dimensionspbr
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
source $env(CSF_OCCTSamplesPath)/tcl/dimensions.tcl
|
||||||
|
vcaps -ffp 0
|
||||||
|
vrenderparams -shadingModel pbr
|
||||||
|
vlight -clear
|
||||||
|
vlight -add ambient -intensity 1
|
||||||
|
vlight -add directional -dir 0 0 -1 -head 1 -intensity 1
|
||||||
|
vdump $imagedir/${test_image}.png
|
||||||
|
|
||||||
|
puts "TEST COMPLETED"
|
Loading…
x
Reference in New Issue
Block a user