Problems with setting uniform float on opengl (observed on Windows 11 and HTML5)
smallfx opened this issue · 1 comments
Describe the bug
Example code here: https://github.com/smallfx/kha_issues
I am on Windows 11, and I'm experiencing some weirdness with the opengl graphics target when compiling for Windows and HTML5. (in the case of HTML5 I guess it would be opengl es?)
Anecdotally this was also observed on Windows 10 after upgrading to a recent version of Kha, although I can't test that anymore because I upgraded to 11.
For the OpenGL graphics target, it seems like setting a uniform float using my_cool_framebuffer.g4.setFloat() does not take effect.
It should be noted that it can be observed to take effect properly when compiling with default graphics (as mentioned above).
(It should also be noted that I am using a custom g2 (aptly named CustomG2) to more closely replicate my engine's setup and to have a custom useCanvas function. In my engine it is also used to add additional things to the vertex structure by default, etc.)
To Reproduce
Steps to reproduce the behavior:
- Be on Windows (I am on Windows 11, platform seems irrelevant for HTML5's case though. also observed on macOS when compiling for HTML5)
- In CMD or Windows Terminal,
cdto thekha_issuescloned git repo directory. - Run
node <KHA_DIRECTORY>\Tools\khamake\khamake.js --run --graphics opengl(compiling for HTML5 results in the same thing) - Witness the following behavior (no darkening effect despite the call to
g4.setFloat())

Expected behavior
It is expected that setting the screenDarkenUniform uniform with g4.setFloat() would darken the rendered image according to the shader specified in the custom pipeline.
Execution Environment:
- Host system (where you compile your code): Windows 11 (either Win or macOS when compiling for HTML5)
- Target system (where you run your code): Windows 11 native (or Chromium-based browser when HTML5)
- IDE used (if any): vim
- Kha revision: latest ( commit hash 2a4fbae )
- Kha build output (Using Kha...):
Creating Kha project.
Exporting asset 1 of 1 (chests.png).
Compiling shader 1 of 1 (game-processing.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).
Using Kinc (git-error) from C:\Users\jaxyn\Documents\GAMEDEV\Kha\Kinc
kincfile found.
Creating Windows project files.
Compiling...
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.0.2
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
.NET Framework ���� Microsoft (R) Build Engine �o�[�W���� 17.0.0+c9eb9dd64
Copyright (C) Microsoft Corporation.All rights reserved.
Build time: 0m 39s
Starting Kinc
Initializing a new default audio device.
Falling back to the system's preferred WASAPI mix format.
Starting application
- Application output (if it runs): no output, it just runs.
There's two bugs in your program:
- You have to add a call like
gameBuffer.g4.setPipeline(gameProcessingPipeline);before the setFloat call so the correct pipeline is set (g2.pipeline = whatever doesn't actually set the pipeline but just remembers it for whenever it actually draws something next). - brighten is never set so the result can be anything (didn't cause trouble here but might cause trouble on some other graphics target).