Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.48k stars 174 forks source link

gl_FrontFacing yields different results on HTML5 and D3D11-Krom #1405

Closed MoritzBrueckner closed 2 years ago

MoritzBrueckner commented 2 years ago

Describe the bug When using gl_FrontFacing in a shader and the cull mode is set to None, its result differs between the html5 target and the Krom target using D3D11. In the attached example project, a blue sqare is drawn in case gl_FrontFacing is true (this happens on Krom) and a red square is drawn in the opposite case (happens on html5).

I noticed that front- and back-facing is set differently based on the cull mode in the backend sources for those targets (permalinks for d3d11, OpenGL and html5), is this because of a different default winding order? Maybe this is related to this issue?

To Reproduce Example project: FrontFaceTest.zip

Run the attached project. On vanilla Krom the drawn geometry is incorrect (not a rect but some line-like thingy), but you can still see the blue color. When using Armorcore, the geometry is correct and you see the blue color.

Expected behavior Both targets should show the same color.

Screenshots Krom: Krom screnshot

HTML5: grafik

The different positions of the rectangle are due to different timings when doing the screenshots, the example project is based on https://github.com/Kha-Samples/Shader-G2/ where the rectangle moves.

Execution Environment:

Additional context Original issue: https://github.com/armory3d/armory/issues/2371

RobDangerous commented 2 years ago

Maybe fixed in the latest Kinc-revision.

PS: To test OpenGL/Direct3D11 differences, just compile directly for OpenGL and Direct3D 11 - no need for Krom detours, that just makes it more complicated for everyone.

RobDangerous commented 2 years ago

Checked with your sample in Kha with Direct3D11 and a new Krom build that's actually largely unrelated to the version of Krom you are using is triggered.

MoritzBrueckner commented 2 years ago

Can confirm that it's fixed now, thanks a lot!