How to use glPolygonOffset inside fragmentShader to reduce z-fighting

Is it possible to use glPolygonOffset inside the fragmentShader of a PostProcessStage to reduce z-fighting of 3DTiles? I am getting the following error message:
“RuntimeError: Fragment shader failed to compile. Compile log: ERROR: 0:103: ‘glPolygonOffset’ : no matching overloaded function found”.
Thanks in advance!

Can you share a bit more context about your issue (a video, picture, or a Sandcastle perhaps). How are you generating your 3D Tiles?

Thank you for your fast reply. I have added the new Cesium OSM Building 3D Tiles and a ShadowMap to my scene. I am passing a custom GLSL fragmentshader to my PostProcessStage. I have set the depth bias to 0.0005 and the size of the ShadowMap to 8192 pixels. The following presentation suggested using a glPolygonOffset (page 18ff.): https://cesium.com/presentations/files/ShadowsAndCesiumImplementation.pdf.

I’m actually not able to activate shadows with Cesium OSM Buildings. I get the following error:

DeveloperError: normalized result is not a number
Error
    at new DeveloperError (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:83:13)
    at Function.Cartesian3.normalize (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:2040:13)
    at Ellipsoid.geodeticSurfaceNormal (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:3601:23)
    at Ellipsoid.cartesianToCartographic (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:3694:18)
    at fitShadowMapToScene (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:266739:40)
    at ShadowMap.update (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:266971:9)
    at updateShadowMaps (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:282471:17)
    at updateAndRenderPrimitives (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:282494:5)
    at executeCommandsInViewport (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:282266:7)
    at Scene.updateAndExecuteCommands (https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:282009:7)

Sandcastle I’m testing with. Do you not get this error when activating shadows? If so, can you share a Sandcastle of how you’re initializing your scene?

I do not add shadows to OSM Buildings or similar. I am adding a Cesium ShadowMap with a custom LightCamera to my Scene. I would really like to share a Sandcastle of my problem with you but it is really complex and not easy to rebuild. I can try to simplify my problem: How can I reduce z-fighting in my scene? Is it possible to call the OpenGL method glPolygonOffset inside the custom fragmentShader of the PostProcessStage as suggested by Sean Lilley in the presentation (page 21)?

Hey, I have read this post and can confirm that glPolygonOffset is supported (console.log(viewer.scene.shadowMap._polygonOffsetSupported) --> true). I think changing the light type from “pointlight” to “spotlight” might be a solution for my problem. But when I set the “isPointLight” parameter to false, no shadows are generated at all.
This is how i initialize my ShadowMap:
this.shadowMap = new Cesium.ShadowMap({ // @ts-ignore context: this.viewer.scene.context, lightCamera: this.lightCamera, enabled: true, isPointLight: true, pointLightRadius: this.visibilityRadius, maximumDistance: 200, size: 8092, softShadows: false, normalOffset: false, fromLightSource: false });

I am running on a windows computer with a Chrome browser (version 83). But I am also facing z-fighting when testing with Firefox, Edge or Internet Explorer.