Commit Graph

103 Commits

Author SHA1 Message Date
Hajime Hoshi
db34930ae8 internal/graphics: add built-in Kage functions
This change adds these Kage functions:

* imageDstOrigin
* imageDstSrc
* imageSrcNOrigin
* imageSrcNSrc

and deprecates these functions:

* imageDstRegionOnTexture
* imageSrcRegionOnTexture

Closes #1870
2023-08-28 15:06:45 +09:00
Hajime Hoshi
101372a8c3 ebiten: allow different-size source images at DrawTrianglesShader (pixel mode)
Updates #1870
2023-08-28 01:39:43 +09:00
Hajime Hoshi
a9b2f5f9ca Revert "ebiten: panic if a non-existent uniform variable name is given"
This reverts commit 1b8580fab7.

Reason: some existing applications don't work with this fix.

Updates #2710
2023-08-24 14:15:19 +09:00
Hajime Hoshi
6fa8c02d4a internal/shader: bug fix: div between a matrix and a flaot failed
Closes #2719
2023-08-05 02:12:39 +09:00
Hajime Hoshi
63df6168d9 internal/shader: use plural forms for Kage compiler directives
This change renames

```
//kage:unit texel
//kage:unit pixel
```

to

```
//kage:unit texels
//kage:unit pixels
```

.

Closes #2717
2023-08-01 11:41:38 +09:00
Hajime Hoshi
a0ffd8dd25 ebiten: enable texCoord at DrawRectShader even without a source image
imageSrcRegionOnTexture will return (0, 0) to (width, height) for
the pixel-unit mode.

Closes #2166
2023-08-01 04:14:36 +09:00
Hajime Hoshi
1b8580fab7 ebiten: panic if a non-existent uniform variable name is given
Closes #2710
2023-07-29 20:24:42 +09:00
Hajime Hoshi
0b1c7404d5 ebiten: use zero values for an unspecified uniform variable
Closes #2709
2023-07-29 19:11:49 +09:00
Hajime Hoshi
d0e4023d88 internal/ui: add a length check for uniform variables 2023-07-29 18:59:36 +09:00
Hajime Hoshi
88be4c5b7c internal/shader: reland: bug fix: stricter type checks for the built-in cast-like functions
Closes #2712
2023-07-28 01:33:27 +09:00
Hajime Hoshi
8276a53dd6 ebiten: add TestShaderIVec 2023-07-23 16:42:39 +09:00
Hajime Hoshi
56b4cdc3c4 internal/graphics: use pixels for offsets 2023-04-26 00:38:23 +09:00
Hajime Hoshi
49582519c1 all: add a compiler directive kage:unit
This change adds a new compiler directive 'kage:unit' to Kage. This
takes one of these two values: 'pixel' and 'texel'. The default value
is 'texel'.

With the pixel-unit mode, all the built-in functions treats pixels
instead of texels, and the texCoord argument of Fragment is in pixels.
This simplifies shader programs as programs no longer have the notion
of texels.

With the texel-unit mode, the behavior is the same as the current
behavior.

Closes #1431
2023-04-23 22:11:57 +09:00
Hajime Hoshi
818e27302c ebiten: skip tests with dfdx and dfdy
Updates #2583
2023-02-28 03:30:37 +09:00
Pierre Curto
4de807cc44
all: fix typos (#2558)
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2023-01-28 19:06:38 +09:00
divVerent
abece041f4
internal/graphicsdriver/opengl: fix state tracking of glBindTexture / glActiveTexture interaction (#2526)
After switching texture units using glActiveTexture, a different texture may
be bound. For now, let's just force the active texture state variable to zero
so the next glBindTexture call isn't skipped.

Closes #2525
2023-01-07 23:13:14 +09:00
Hajime Hoshi
e9e5d27d2c internal/shader: bug fix: % operators for integer vecs didn't work
Closes #1911
2022-11-21 01:39:20 +09:00
Hajime Hoshi
0b9cbaa1ed internal/shader: introduce integer vectors (ivec2, ivec3, ivec4)
Closes #1911
2022-11-21 00:31:23 +09:00
Hajime Hoshi
7961654927 internal/graphicsdriver/metal: bug fix: wrong alignment for vec3 2022-11-20 23:14:09 +09:00
Hajime Hoshi
bba196d1ec ebiten: allow array types for uniform variables
Closes #2448
2022-11-18 14:08:31 +09:00
Hajime Hoshi
1ecac8d834 all: allow integer uniform variables for Kage shaders
Closes #2305
Updates #2448
2022-11-13 01:49:24 +09:00
Artem Yadelskyi
10415d417a
all: replace interface{} with any (#2430)
Closes #2429
2022-11-03 15:33:09 +09:00
Hajime Hoshi
b0b64e3610 ebiten: use premultiplied-alpha format for ColorScale
Closes #2361
2022-10-02 14:41:50 +09:00
Hajime Hoshi
1f70307582 ebiten: add DrawRectShaderOptions.ColorScale
This change also introduces a new struct ColorScale.

Closes #2361
2022-09-30 21:44:48 +09:00
Hajime Hoshi
cf92158e33 ebiten: bug fix: add an indirect function call for a fragment shader
Closes #2245
Closes #2247
2022-08-17 16:37:37 +09:00
Hajime Hoshi
652cd169b2 ebiten: revert the changes for DrawRectShader
This reverts these commits:
- 9bd46cb2b5.
- f8c4634017.

This causes test failures on the Steam bot. See #2246.

Updates #2166
Closes #2246
2022-08-17 00:56:33 +09:00
Hajime Hoshi
9bd46cb2b5 ebiten: bug fix: assigning to arguments doesn't work with OpenGL
Updates #2166
2022-08-16 23:07:15 +09:00
Hajime Hoshi
f8c4634017 ebiten: always specify the source region at DrawRectShader
imageSrcRegionOnTexture should work even without any images.

Updates #2166
2022-08-16 22:43:33 +09:00
Hajime Hoshi
205245b094 internal/shader: implement a new built-in function discard
Closes #1969
2022-08-09 11:31:59 +09:00
Hajime Hoshi
0217ed0544 ebiten: add WritePixels replacing ReplacePixels
Closes #2236
2022-08-08 03:50:27 +09:00
Hajime Hoshi
c01821ca5c internal/shader: use all functions for vector comparisons
Updates #2186
2022-07-09 02:30:16 +09:00
Hajime Hoshi
bac34a4474 ebiten: add NewImageWithOptions and NewImageOptions
This change adds NewImageWithOptions, that creates a new image with
the given options.

NewImageWithOptions takes image.Rectangle instead of a width and a
height, then a user can create an image with an arbitrary bounds.
A left-upper position can be a negative number.

NewImageWithOptions can create an unmanged image, that is no longer
on an automatic internal texture atlas. A user can have finer controls
over the image.

This change also adds tests for this function.

Updates #2013
Updates #2017
Updates #2124
2022-06-15 02:20:19 +09:00
Hajime Hoshi
2d912a2387 internal/shaderir/hlsl: bug fix: wrong offset of uniform array variables
Closes #2038
2022-03-27 01:49:52 +09:00
Hajime Hoshi
aef00a5235 internal/shader: bug fix: wrong type deduction at (scalar)*(matrix)
Updates #2037
2022-03-27 01:22:54 +09:00
Hajime Hoshi
6bd3c81e27 internal/graphicsdriver/directx, internal/graphicsdriver/metal: bug fix: uniform matrix-array variables were passed wrongly
Updates #2036
2022-03-27 00:32:30 +09:00
Hajime Hoshi
f6d87f6ee8 internal/graphicsdriver/directx, internal/graphicsdriver/metal: bug fix: uniform matrix variables were passed wrongly
Updates #2036
2022-03-26 23:58:48 +09:00
Hajime Hoshi
79e93d3b12 internal/graphicsdriver: introduce the DirectX driver
Closes #1007
2022-03-26 20:09:34 +09:00
Hajime Hoshi
dcccd27629 internal/shaderir/msl: bug fix: mod for a vector and a scalar didn't work
Updates #2029
2022-03-26 02:57:38 +09:00
Hajime Hoshi
b96b75d51c ebiten: add TestShaderMatrixInitialize 2022-03-26 01:19:20 +09:00
Hajime Hoshi
31104c4e79 internal/processtest: remove TestShaderNoMain and add shadernomain.go
A shader compilation error breaks the state of the graphics command
queue, and this cannot be reused. Thus, a process test is appropriated.
2022-03-21 21:52:38 +09:00
Hajime Hoshi
81b9f91f86 internal/graphicscommand: compile shaders lazily
With DirectX, the graphics driver cannot be determined until the
main loop starts, as a transparent window cannot be treated with
DirectX so far. On the other hand, compiling shaders requires a
graphics driver as it requires information about Y directions of
NDCs and framebuffers.

This change delays compiling shaders until the graphics commands
are actually executed in the main loop.

Updates #1007
Updates #2019
2022-03-21 21:09:02 +09:00
Hajime Hoshi
9b1adf799d internal/shader: move syntax tests to internal/shader 2022-03-21 19:31:06 +09:00
Hajime Hoshi
3c1e64dd67 internal/shaderir/metal: bug fix: define the 'mod' function correctly
Closes #2006
2022-03-04 18:05:44 +09:00
Hajime Hoshi
84c680c6ed internal/shader: ban the operator div on a matrix
The operator div on a matrix doesn't work on Metal.
2022-01-21 03:37:34 +09:00
Hajime Hoshi
2e5b4954f3 internal/shader: bug fix: forbid mat + float
mat + float doesn't work on Metal.
2022-01-21 02:42:22 +09:00
Hajime Hoshi
99f003a17a internal/shader: bug fix: mat *= vec is not allowed
Updates #1971
2022-01-21 02:03:50 +09:00
Hajime Hoshi
0415773b94 internal/shader: bug fix: allow the *= operator for a vector and a matrix
Updates #1971
2022-01-21 01:59:58 +09:00
Hajime Hoshi
9efabfe56e internal/shader: add more tests
Updates #1971
2022-01-21 01:47:26 +09:00
Hajime Hoshi
8d2bf6525c internal/shader: bug fix: wrong type checkings for operator *
Updates #1971
2022-01-21 01:06:02 +09:00
Hajime Hoshi
406b8a4a08 ebiten: add more tests
Updates #1963
2022-01-17 20:54:02 +09:00