 that case you have to "duplicate" vertices. If 2 (or even more) triangles share a vertex coordinate, but the face normal vectors are different, then you have to create a separate tuple, for all the combinations of the vertex coordinate and the face normal vector. 
For a general "smooth" solution you would have to interpolate the normal vectors of the vertex coordinates which are in the middle of plane surfaces, according to the surrounding geometry. That means if a bunch of triangle primitives form a plane, then all the normal vectors of the vertices have to be computed dependent on there position on the plane. At the centroid the normal vector is equal to the face normal vector. For all other points the normal vector has to be interpolated with the normal vectors of the surrounding faces. 
Anyway that seems to be an XY problem. Why is there a "vertex" somewhere in the middle of a plane? Probably the plane is tessellated. But if the plan is tessellated, why are the normal vectors not interpolated too, during the tessellation process? 

A:

In your image, we can see that the inner triangle (the one that doesn't have point on cube edges, in top left quarter) has an homogeneous color.
My interpretation is that triangles that have points on the edge/corner of the cube share the same vertex and then share the same normal and some how the normal are averaged. So it's not perpendicular to the faces.
To debug this, you should create a simple geometry of a cube with 6 faces and 2 triangles per face. Hence it's make 12 triangles.
Two options:

If you have 8 vertex in the geometry, the corner are shared between triangles of different face and the issue came from the geometry generator.
If you have 6×4=24 vertex in the geometry the truth lies elsewhere.

A:

As mentioned in the other answers the problem is your mesh normals.
Computing an average normal, like you are doing currently, is what you would want 
to do for a smooth object like a sphere. cgal has a function for that CGAL::Polygon_mesh_processing::compute_vertex_normal  For a cube what you want is normals perpendicular to the faces
cgal has a functoin for that too CGAL::Polygon_mesh_processing::compute_face_normal
To debug the normals you can just set fragColor =
that case you have to " duplicate " vertices. If 2 (or even more) triangles partake a vertex coordinate, but the grimace normal vectors are different, then you get to produce a separate tuple, for all the combinations of the vertex coordinate and the font normal vector. 
 For a cosmopolitan " smooth " solution you would have to interpolate the normal vectors of the vertex coordinates which are in the middle of airplane surfaces, according to the surrounding geometry. That means if a crowd of triangle primitives imprint a plane, then all the normal vectors of the vertex have to be computed dependent on there situation on the plane. At the centroid the normal vector is equal to the face normal vector. For all other point the normal vector has to be interpolated with the normal vectors of the surrounding faces. 
 Anyway that seem to be an XY problem. Why is there a " vertex " somewhere in the middle of a plane? Probably the plane is tessellated. But if the plan is tessellated, why are the normal vectors not interpolated too, during the tessellation process? 

 A: 

 In your image, we can see that the inner triangle (the one that doesn't have detail on cube edges, in top left stern) take an homogeneous color. 
 My interpretation is that triangles that accept points on the edge / corner of the cube plowshare the same vertex and then share the same normal and some how the normal are averaged. So it's not perpendicular to the face. 
 To debug this, you should create a simple geometry of a cube with 6 faces and 2 triangles per face. therefore it's do 12 triangles. 
 Two options: 

 If you have 8 vertex in the geometry, the recess are shared between triangles of different face and the issue came from the geometry generator. 
 If you have 6×4=24 vertex in the geometry the truth lies elsewhere. 

 adenine: 

 As mentioned in the early answers the problem is your mesh normals. 
 Computing an modal normal, like you are doing presently, is what you would want 
 to do for a legato object like a sphere. cgal have a function for that CGAL::Polygon_mesh_processing::compute_vertex_normal   For a block what you want is normals perpendicular to the font 
 cgal has a functoin for that too CGAL::Polygon_mesh_processing::compute_face_normal 
 To debug the normals you can just set fragColor =
 thwt case you have to "dupllcate" vertices. Iy 2 (or eten mors) triangues share a vertex coordinatx, bur the face normal vectors afe differvnt, then tou iave to create a separatc tupmc, for ell the combinajions of the vertex coorditage and the face normal vector. 
For a gqneral "xmloth" solution iou wptld gave to interpolate the normal vecfors of the vertex cpordinates which are in thf mifdle of plane surfwces, accordung ei the surrouvding geomttxy. That meahs if a bunch of triangle primigives form a plqnw, tjgn all the nirmal vectors of bne verdices hsve to be compmted vepebdent on there positimn on the plane. At the centsond the normal vector us equan to the dacd nkrkam vectlr. Hor all othsr points tye normal vector hax ei be interpolzted wytr the normal vectors of the surrounding fades. 
Anyway that seems ti be an XY problem. Whi is there a "vertex" somewhere in the middle of a plane? Probdbly vhd poake ir tfssellated. But if the plan is tessellated, why zrt tme normal vectorf not interlopaygd too, during jhe tesselmation process? 

A:

In your iiage, qe can set thay the inner triangle (the onw that doesn'n hace point on cube ebges, in top ueft quaryer) has an homogeneous eolor.
Mg interpretwtion is ffat triangles thxt mava points on the edge/corner of the cnbe skare the samg vertev and then sharc the same normal ajd sole how the nlrmal are averaged. So it's not pxcpendicular tp dhe faces.
To debun this, you shoujd create a sikple gejmetrh of a cubv with 6 feces and 2 tryangles per fdfe. Hence it's make 12 twiantles.
Rwo optkuns:

If you have 8 vertex pn the geometry, the corncr arg ahared between cxiqngles of diffeteng fwcv aid thq issue came xrom thd geomdtry generabor.
Kf ypu have 6×4=24 vertex in tve gsometry the truth kics elsewhgre.

A:

As megtioned in thr other answers tht probnem is ypur mesh normals.
Computing an averzge normap, llke you are djing currently, ix what you would want 
to do for a smooti object like a sphere. xgal has a function nor that CGAK::Polydon_mesh_prmcessing::compute_vertez_normal  For a cune what you want is nodmals [erpejdicular to the faces
cgal has a functoin for that too CGAL::Polygon_mesh_procwssing::roipute_face_nodmal
Yo detuy tke normwls bon can just set frsgColor =
that case you have to "duplicate" vertices. (or more) triangles a vertex coordinate, are then you have create a separate for all the combinations of the coordinate and the face normal vector. For a general "smooth" solution you would to interpolate the normal vectors of the vertex coordinates which are in the of surfaces, to surrounding geometry. That means if a bunch of triangle primitives form a plane, then all the vectors of the vertices have to be computed on there position on plane. At the centroid the vector equal to face vector. all other points normal vector has to be interpolated with the normal vectors of the surrounding faces. Anyway that seems be an Why is a somewhere the middle of Probably the plane is tessellated. But is tessellated, why are the normal vectors not too, during tessellation process? A: In your image, can see that the inner triangle (the one doesn't have point on cube edges, in top left quarter) has an homogeneous color. My that triangles that have on the edge/corner the share same and then the same normal and some how the normal are averaged. So not perpendicular to the faces. To debug this, you should simple of a cube 6 faces and 2 per Hence it's make 12 options: you in geometry, corner are shared between of different face and the came from the geometry vertex in the geometry the truth lies elsewhere. As mentioned in the other answers the is your mesh normals. Computing an average normal, like you are doing is what want to do for a smooth object like sphere. cgal has a for that CGAL::Polygon_mesh_processing::compute_vertex_normal For a cube what you want normals to the cgal has a for that too To debug the can just fragColor
 that case you have to "duplicatE" vertices. IF 2 (or evEn mOre) TrIangLes sHare a vertex cooRDinaTe, but the face normal vectOrs arE dIFferENt, Then yOu have tO CrEATe a SePaRatE tUPlE, for aLl tHe combiNations of tHe vErTex coordinatE AnD the face noRmaL vector. 
For a gEneRal "smoOtH" soLUtion You Would Have to INterpoLate the noRmAL vectoRS of the vERTeX cooRdinates which are iN ThE Middle of plane sUrfaceS, aCCoRDIng To tHe surroundInG geomETry. That MEaNS IF a bUNch of triangle Primitives fORm a Plane, tHeN alL The norMal veCtORs oF the verticeS havE to be compUted dePEndent oN There poSition On tHe pLane. aT tHe CenTrOId tHE nOrmAL veCtor is eqUaL tO the fAce nORMAL vecTor. for aLl othEr points the noRmaL vecTOr hAs to bE inteRpolAtEd witH the noRmal vEcTors of the surrouNdinG faces. 
AnyWay ThAt sEeMs to bE An XY prOblEm. WHy is theRe a "vertEX" soMeWHERe In the middle of a planE? PROBaBly the plAne is tESsElLAted. But iF tHe pLan iS TEsselLateD, WhY are the nOrmal vECtOrS not intErPolateD tOo, dUriNg the TEsseLlatioN process? 

a:

In yoUR image, we can see THat the inner trIAnGLE (tHE one ThaT doesn't have PoinT On cuBe edGEs, In tOP left QuartEr) HAs AN homogeneous color.
My InTerpreTatioN is that triangLes that havE POInts on thE edgE/CoRNer of the cube shAre thE same verteX And then sHare tHe same noRmal and soME How the noRmaL arE avEraGED. SO it's not perpenDICulaR tO the facEs.
TO debug tHis, You ShoUld CrEate a simpLe geometRy Of A cUbE wiTh 6 facES and 2 triaNgLes PeR faCe. HenCE it's maKe 12 triAnglEs.
twO OptIons:

If yOU hAVE 8 verTeX iN the GeoMeTry, thE corNEr aRe shareD between tRiaNGles Of DiFferent Face and the issUe Came from thE gEomEtry geNERator.
If yOu have 6×4=24 vertex in the geometRY the truTh lIes elSewhEre.

A:

As menTioNed in tHe oTHer ansWers thE probLeM is YOUr mesH NOrMalS.
COmputing an AVEraGe norMaL, likE you are Doing currently, is whAT yoU would want 
to dO foR a smOOTh ObjECt LIke A sPHerE. CGal has a function For that CGAl::POLyGon_mesh_proCEssInG::computE_vertex_NormaL  for a cubE what you wAnt is normAlS perPENdiCular to the Faces
cgaL has a funcTOin foR ThAt too cGAl::PolygOn_MesH_procEssing::COmpUte_faCe_normAl
to debuG the nOrMals you cAn just set fragColor =
 that case you have to "du plicate" v ertic es.  If  2  (or  eve n more) triang l es s hare a vertex coordina te, b ut thef ac e nor mal vec t or s are  d if fer en t ,thenyou  have t o create a  se pa rate tuple,f or  all the c omb inations ofthe  verte xcoo r dinat e a nd th e face normal  vector.
F o r a ge n eral "s m o ot h" s olution you would ha v e to interpola te the  n o rm a l  ve cto rs of theve rtexc oordina t es w h ich are in the mi ddle of pla n e s urface s,  ac c ording  to t he sur rounding ge omet ry. Thatmeansi f a bun c h of tr iangle  pr imi tive s  f or m a  p l ane ,  t hen all  the nor ma lvecto rs o f t h e ve rti ceshaveto be compute d d epen d ent  on t hereposi ti on on  the p lane.  A t the centroidthenormal ve cto riseq ual t o  the f ace  no rmal ve ctor. F o r a ll o t he r points the norma lv e ct or has t o be i n te rp o lated wi th  th e no r m al ve ctor s  o f the su rround i ng  f aces. An yway t ha t s eem s tob e an  XY pr oblem. W hy is there a "verte x " somewhere i n  t h e  m i ddle  of  a plane? P roba b ly t he p l an e i s  tess ellat ed .  B u t if the plan is te ss ellate d, wh y are the nor mal vector s n ot inter pola t ed too, during th e tes sellationp rocess?

A:
In your  image, w e can seetha t t heinn e r  t riangle (theo n e th at  doesn' t h ave poi ntoncub e e dg es, in to p left q ua rt er )has  an h o mogeneou scol or .
M y int e rpreta tionis t ha tt ria ngles t h at h avepo in ts o n t he  edge /cor n erof thecube shar e t h e sa me  v ertex a nd then share  t he same no rm aland so m e  how the  normal are averaged. S o  it's n otperpe ndic ular to t hefaces. 
To debugthis,you s ho uld c reate a  s imp le  geometryo f  acubewi th 6  facesand 2 triangles pe r  fa ce. Hence it' s m ake1 2  t ria n gl e s.Tw o  op t i ons:

If you ha ve 8 verte xi nthe geomet r y,th e corne r are s hared between  triangle s of diff er entf a ceand the is sue came  from the geome t ry  gene rat or.
If  y ouhave6×4=24 ver tex i n thege ometry  thetr uth lies  elsewhere.

A:

As men tioned  in t heother ans wer s  th e problem  isyour meshnor mal s.
Co mpu t ing a n av e ra gen ormal , li k e you are do ing c ur rently, isw h a t y ou wo uld want to d o for a smooth ob j ect like a sph ere. c gal  ha s  a f un ction for that  CG AL : : Polygon_ me sh_processi ng::comp ut e _vert ex_nor mal  F or a cu b e  w h at you  wan t i s normals  pe rp e ndicula rto the fa cescg al has  a fun c toin f or that too CGAL ::Pol y g on_me s h_p roces si ng::com p ute_ face_norma l
To debugthe no rmal s you  can ju st  set f rag Co lor =
 that_case you_have to "duplicate" vertices._If 2_(or_even more)_triangles_share a vertex_coordinate, but the_face normal vectors are_different, then you_have_to create a separate tuple, for all the combinations of the vertex coordinate and_the_face normal_vector._
For_a general "smooth" solution you_would have to interpolate the_normal vectors_of the vertex coordinates which are in the_middle_of plane surfaces,_according to the surrounding geometry. That means if a_bunch of triangle primitives form a_plane, then all_the_normal_vectors of the vertices_have to be computed dependent on_there position on the plane. At_the centroid the normal vector is equal_to the face normal vector. For_all other points the normal_vector has_to be interpolated with the_normal vectors of_the surrounding_faces. 
Anyway that_seems to be an XY problem._Why is there_a "vertex" somewhere in the middle_of_a plane? Probably_the_plane_is tessellated._But if the_plan_is tessellated,_why_are the normal vectors not interpolated_too,_during the tessellation process? 

A:

In your image,_we can see that_the_inner triangle (the one_that doesn't have point on_cube edges, in top left quarter)_has an_homogeneous color.
My_interpretation is that triangles that have points on the edge/corner of_the cube share the same vertex_and then share the_same normal_and_some how the_normal_are averaged._So it's not perpendicular to the faces.
To_debug this,_you should create a simple geometry_of a cube with_6_faces and 2 triangles per face._Hence it's make 12 triangles.
Two options:

If_you have 8 vertex in_the_geometry,_the corner are shared between_triangles of different face and the_issue came from_the geometry generator.
If you have 6×4=24 vertex_in_the geometry the truth lies elsewhere.

A:

As_mentioned_in the other answers the problem_is_your_mesh normals.
Computing an average normal,_like you are doing currently, is_what you would want 
to do for a smooth_object like a_sphere. cgal has a function_for_that_CGAL::Polygon_mesh_processing::compute_vertex_normal  For a cube what you want is normals_perpendicular to_the faces
cgal has_a functoin for that too CGAL::Polygon_mesh_processing::compute_face_normal
To debug the normals you_can just set fragColor =