Kode/Kha

gl_FrontFacing yields different results on HTML5 and D3D11-Krom

MoritzBrueckner opened this issue · 3 comments

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:

  • Host system (where you compile your code): Windows 10
  • Target system (where you run your code): Windows 10
  • IDE used (if any): VS Codium
  • Kha revision: 4c9bc0b
  • Kinc revision: a0f14bcbc4056f7af0248ccbce5218b0fe003a06
  • Using latest Kode/Krom and Armorcore binaries
  • Kha build output (Using Kha...):
    Using Kha (4c9bc0bb, M Kinc, M Tools/khamake) from [...]\Kha
    Creating Kha project.
    Compiling shader 1 of 1 (frontface_test.frag.glsl).
    Compiling shader 1 of 8 (painter-colored.frag.glsl).
    Compiling shader 2 of 8 (painter-colored.vert.glsl).
    Compiling shader 3 of 8 (painter-image.frag.glsl).
    Compiling shader 4 of 8 (painter-image.vert.glsl).
    Compiling shader 5 of 8 (painter-text.frag.glsl).
    Compiling shader 6 of 8 (painter-text.vert.glsl).
    Compiling shader 7 of 8 (painter-video.frag.glsl).
    Compiling shader 8 of 8 (painter-video.vert.glsl).
    Done.
    
    Kinc shows up as modified because Kha's Kinc version doesn't yet point to the latest master, the Khamake version has html5 devtools enabled upon startup. Other than that there are no changes.

Additional context
Original issue: armory3d/armory#2371

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.

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.

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