MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0030136Open CASCADE[OCCT] OCCT:Visualizationpublic2018-09-12 16:482018-09-19 14:19
Reporterkgv 
Assigned Tomnv 
PrioritynormalSeverityminor 
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version[OCCT] 7.3.0 
Target Version[OCCT] 7.4.0*Fixed in Version 
Summary0030136: Visualization, TKOpenGl - Graphic3d_TOSM_FACET does not work on mobile devices
DescriptionEnabling Graphic3d_TOSM_FACET produces incorrect result on tested mobile devices - see attached screenshots.

Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_ShaderProgram)& theProgram,
                                                               
const Standard_Integer        theBits,
                                                               const Standard_Boolean        theIsFlatNormal)

{
  #define thePhongCompLight "computeLighting (normalize (Normal), normalize (View), Position, gl_FrontFacing)"

#if defined(GL_ES_VERSION_2_0)
  const bool isFlatNormal = theIsFlatNormal
                         && (myContext->IsGlGreaterEqual (3, 0)
                          || myContext->oesStdDerivatives);
#else
  const bool isFlatNormal = theIsFlatNormal;
#endif


Note that isFlatNormal is expected to be TRUE on both devices (they report OpenGL ES 3.0 and OpenGL ES 3.2 support).
Steps To ReproduceNot required
TagsNo tags attached.
Test case number
Attached Filespng file icon Screenshot_20180912-162918.png (86,718 bytes) 2018-09-12 16:48
jpg file icon Screenshot_20180912-163029_CAD Assistant.jpg (373,164 bytes) 2018-09-12 16:48
png file icon FlatShadingES31.png (214,631 bytes) 2018-09-13 18:01
jpg file icon testResults.JPG (63,809 bytes) 2018-09-18 08:29
jpg file icon tegra4_flat_shading1_KO.jpg (861,833 bytes) 2018-09-19 11:32
jpg file icon tegra4_flat_shading2_KO.jpg (1,526,082 bytes) 2018-09-19 11:32

- Relationships
child of 0028069closedbugmaster Open CASCADE Visualization, TKOpenGl - handle flat shading model within GLSL programs 

-  Notes
(0079178)
mnv (developer)
2018-09-13 18:02

Problem on mobile devices with OpenGl ES 3.1+ is potentially (because tested only on devices with Adreno GPU) solved. Need to test it on more devices with different GPU.
(0079197)
git (administrator)
2018-09-14 18:01

Branch CR30136 has been created by mnv.

SHA-1: 51407de00f4939fd9cc49df20102e0a13d903caa


Detailed log of new commits:

Author: mnv
Date: Thu Sep 13 17:47:51 2018 +0300

    0030136: Visualization, TKOpenGl - Graphic3d_TOSM_FACET does not work on mobile devices
    
    Fixed unexpected behaviour of gl_FrontFacing on mobile devices with Adreno GPU (OpenGl ES 3.1+).
    Added graphic3d_limit for using with OpenGl ES 3.0.
(0079218)
git (administrator)
2018-09-17 16:54

Branch CR30136_1 has been created by mnv.

SHA-1: 6a1e3dcb9ca673d399da2e9913c94ccfc4062217


Detailed log of new commits:

Author: mnv
Date: Thu Sep 13 17:47:51 2018 +0300

    0030136: Visualization, TKOpenGl - Graphic3d_TOSM_FACET does not work on mobile devices
    
    Added new type of graphic3d limit Graphic3d_TypeOfLimit_HasFlatShading.
    Added workaround for unexpected behaviour of mobile devices with Adreno GPU.
    Added new complex flag hasFlatShading to OpenGl_Context for indicating support of flat shading.
(0079219)
git (administrator)
2018-09-17 16:57

Branch CR30136_1 has been updated forcibly by mnv.

SHA-1: 033cb273d59b86df1c0d1f29c7eff835eed2e1d5
(0079227)
mnv (developer)
2018-09-18 08:29

Patch is ready for review.
(0079229)
kgv (developer)
2018-09-18 09:56

+    case Graphic3d_TypeOfLimit_HasFlatShading:
+      return !aCtx.IsNull() && aCtx->hasFlatShading != OpenGl_FeatureNotAvailable && 
aCtx->hasHighp ? 1 : 0;

This code is confusing - it is expected that hasFlatShading already considers hasHighp value.

+    hasFlatShading = IsGlGreaterEqual (3, 0) ? OpenGl_FeatureInCore :
+                     CheckExtension ("GL_OES_standard_derivatives") ? OpenGl_FeatureInExtensions

+                                                                    : OpenGl_FeatureNotAvailable;

Within nested comparisons, it is better using braces:
  hasFlatShading = IsGlGreaterEqual (3, 0)
                 ? OpenGl_FeatureInCore
                 : (CheckExtension ("GL_OES_standard_derivatives")
                  ? OpenGl_FeatureInExtensions
                  : OpenGl_FeatureNotAvailable);


+  TCollection_AsciiString Vendor() const { return myVendor; }

const TCollection_AsciiString&

+  Graphic3d_TypeOfLimit_HasFlatShading,                 //!< indicates whether flat shading is supported.

...
+  OpenGl_FeatureFlag     hasFlatShading;     //!< Complex flag indicating support of Flat shading 
(always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_standard_derivatives)

Please clarify associated enumeration value "Flat shading (Graphic3d_TOSM_FACET)" in comments.

+  if (myVendor.Search("Qualcomm") != -1)

Please put "Adreno" and description of observed misbehavior in comments.

+#if !defined(GL_ES_VERSION_2_0)
+  const TCollection_AsciiString aNormalCorrection = EOL"  if (!gl_FrontFacing) { Normal = -Normal; 
}";
+#else
+  const TCollection_AsciiString aNormalCorrection = (myContext->Vendor().Search("Qualcomm") 
!= -1) ? EOL"  if (gl_FrontFacing) { Normal = -Normal; }"
+                                                                                                   : 
EOL"  if (!gl_FrontFacing) { Normal = -Normal; }";
+#endif

I would expect that this workaround should be applied to Normal computations using dFdx/dFdy (which are buggy), not to reversion gl_FrontFacing (which cannot be buggy, otherwise we would have artifacts in other programs using gl_FrontFacing).

Please also emit a TRACE message about applied workaround.
(0079238)
git (administrator)
2018-09-18 14:14

Branch CR30136_2 has been created by mnv.

SHA-1: a4e77ea81b9e32b25938312202508774b7048794


Detailed log of new commits:

Author: mnv
Date: Thu Sep 13 17:47:51 2018 +0300

    0030136: Visualization, TKOpenGl - Graphic3d_TOSM_FACET does not work on mobile devices
    
    Added new type of graphic3d limit Graphic3d_TypeOfLimit_HasFlatShading.
    Added workaround for unexpected behaviour of mobile devices with Adreno GPU.
    Added new complex flag hasFlatShading to OpenGl_Context for indicating support of flat shading.
(0079239)
git (administrator)
2018-09-18 14:14

Branch CR30136_1 has been updated by mnv.

SHA-1: 0201c1acc2e1a4c3b37625210100f4308b0430cc


Detailed log of new commits:

Author: mnv
Date: Tue Sep 18 14:05:33 2018 +0300

    Review comments.

(0079259)
git (administrator)
2018-09-19 14:19

Branch CR30136_2 has been updated forcibly by mnv.

SHA-1: 065bd49889036e846c5abc6b2aa40dc047872ac2

- Issue History
Date Modified Username Field Change
2018-09-12 16:48 kgv New Issue
2018-09-12 16:48 kgv Assigned To => mnv
2018-09-12 16:48 kgv File Added: Screenshot_20180912-162918.png
2018-09-12 16:48 kgv File Added: Screenshot_20180912-163029_CAD Assistant.jpg
2018-09-12 16:49 kgv Description Updated View Revisions
2018-09-12 17:22 kgv Relationship added child of 0028069
2018-09-12 17:22 kgv Relationship added child of 0030021
2018-09-12 17:27 kgv Status new => assigned
2018-09-13 18:01 mnv File Added: FlatShadingES31.png
2018-09-13 18:02 mnv Note Added: 0079178
2018-09-14 18:01 git Note Added: 0079197
2018-09-17 16:54 git Note Added: 0079218
2018-09-17 16:57 git Note Added: 0079219
2018-09-18 08:29 mnv Note Added: 0079227
2018-09-18 08:29 mnv Assigned To mnv => kgv
2018-09-18 08:29 mnv Status assigned => resolved
2018-09-18 08:29 mnv Steps to Reproduce Updated View Revisions
2018-09-18 08:29 mnv File Added: testResults.JPG
2018-09-18 09:56 kgv Note Added: 0079229
2018-09-18 09:56 kgv Assigned To kgv => mnv
2018-09-18 09:56 kgv Status resolved => assigned
2018-09-18 14:14 git Note Added: 0079238
2018-09-18 14:14 git Note Added: 0079239
2018-09-19 11:32 kgv File Added: tegra4_flat_shading1_KO.jpg
2018-09-19 11:32 kgv File Added: tegra4_flat_shading2_KO.jpg
2018-09-19 14:19 git Note Added: 0079259


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker