Kode / Kha

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

Shader fails on Linux (full build) but not WebGL or Windows (full build) #1308

Closed Domarius closed 3 years ago

Domarius commented 3 years ago

Describe the bug A fragment shader which works on WebGL and Windows full build, fails to work on Linux full build.

In both attached sample projects, a quad is drawn with a shader that replaces colours in the original image (paltest.png) with colours from the palette image (paltest_pal.png) by using the Red channel value from the original image as a X position, and the "palette index" as the Y position. So each row of pixels in the texture is a different "palette" that can be applied to the original image.

And then another quad is drawn using a standard shader and image, which works fine on Linux in either case.

To Reproduce Steps to reproduce the behavior:

  1. Extract the attached sample project, and clone Kha into the empty Kha subfolder. Linux shader fail.zip (Uses a modified version of Graphics2) TextureSample.zip (Simpler example, based off Texture sample project)
  2. Run the project with F5
  3. Press keys 1,2,3,4 to change the colours on the lefthand square, and 5,6,7,8 to change colours on the righthand square.
  4. Build the project for Linux (full build)
  5. Run the Linux build, and see that the coloured squares now show up as black squares on the red background and do not change colours when pressing the number keys. Also note that the squares seem to be drawn at a lower position than they should be.

Expected behavior The colours should still show as they do in the F5 WebGL preview, and Windows (full build), and should not change location.

Screenshots What's interesting is in these screenshots from the "Linux Shader Fail.zip" project, the affected quads seem to have moved down from their proper positions.

Linux shader fail.zip Correct output when viewed as WebGL or Windows (full build) image Incorrect output when viewed as Linux (full build) image

TextureSample.zip Correct output when viewed as WebGL or Windows (full build) image Incorrect output when viewed as Linux (full build) image

Execution Environment:

sh-dave commented 3 years ago

Hm, is this maybe a rendertarget issue with inverted y coordinates seeing that the quads are also displaced?

Project-Magenta commented 3 years ago

(unrelated, but your shrug has lost an arm. please escape the first arm)

Domarius commented 3 years ago

(unrelated, but your shrug has lost an arm. please escape the first arm)

Fixed - also it's Rob's shrug, not mine! That's the current Kha version in the output...

RobDangerous commented 3 years ago

That means it can not read the Git revision - which is not a good sign (but likely unrelated to the rendering problem).

Domarius commented 3 years ago

Since the default shader still works, it's worth pointing out one major difference between my shader and the default shader is I introduce a 2nd texture as a uniform variable.

Domarius commented 3 years ago

Closing this issue in favour of the new one I just created, #1310