Replies: 3 comments 15 replies
-
Unfortunately we cannot do that due to Metal's restrictions: all the arguments are arguments, and Metal shaders cannot treat global variables. |
Beta Was this translation helpful? Give feedback.
-
As we will no longer have to treat texels (#1431), do we still need |
Beta Was this translation helpful? Give feedback.
-
Following up the discussion from #1870, I think it's imperative that multiple image sizes are supported. Is this possible under current circumstances? If not, how can this be resolved? For example, would it be resolved if we turned off atlasing for all source and destination images when using a custom shader? Coincidentally, this would fix all inconsistencies and problems with the current Kage API, and simplify things considerably (so there's no need to know about or work with the internal atlas, including origins, texture sizes vs atlas sizes, etc). |
Beta Was this translation helpful? Give feedback.
-
There are currently multiple open issues about Kage (#2639, #2640, #1431). This has led to some extense debate over whether the current API is easy enough to use, practical, what changes may be needed, which parts are too complex and may actually be considered "bugs", etc.
The following was a comment on one of these issues, but it was rather out of scope, so I'm moving it here instead. The comment is basically a "proposal" of my "ideal model" for Kage in terms of usability. There are some implementation and compatibility hurdles that make it not viable for v2 and probably also impractical or undesirable even for v3, but I think it's useful as a "what would be nice to have" reference and to have some discussion over the direction we are heading towards in the long run. For a comparison, Hajime's current proposal can be found in this google doc, though one really needs to read through the whole doc and issues to have a good grasp on the situation.
Notice that this discussion is in the spirit of "maybe now is a good time to try to find a user-friendlier long-term plan", not "Hajime's proposal is wrong, we should be doing this instead". This proposal is focused on the model, not the implementation or syntax. Let's keep it constructive.
My model considers a
func Fragment() vec4
with no inputs. The main goal of the model is to offer two sets of functions: one predictable and easy to use that doesn't care much about performance and batching breaks, and another more "low level". The syntax is given as pseudo-code, not final.The "easy to use" set of functions:
The "low-level" set of functions:
Notice that actual functionality and calls are almost the same that we already have or that Hajime's proposal adds (most parts of this proposal could be implemented through a pre-processor, e.g., on
kage-desk/display
). The only notable points are:Fragment()
is not a direct goal of my model, but it spares the average user from having to deal with input arguments that require understanding internal intricacies of Ebitengine (e.g. atlases and borders) to be used properly.imageSrcRegionOnTexture()
function and return value, which is a lie / hack (as different source images can have different origins) that's compensated later onimageSrcNAt()
. I dislike this and prefer the more explicit and magic-freeTextures[N].RawTexelMapping()
. For those wondering,Textures[N].Mapping()
would return the same value for all source textures instead (could also be written asTextureMapping()
or something).Attributes
is also suggested (see #2640). This is not a core part of this model, but it's motivated by the fact that many shaders operate with simple quads, and when you only have four vertices, being able to pass some values that would typically be hidden uniforms as attributes can actually make sense (not too much overhead, no batching breaking). We would still need to expose something likeImage.AtlasOrigin()
on the CPU side to make this really useful, but that's a story for another day.The main debate and interest point for the discussion of this "proposal" is mostly whether Kage users think a simpler model is required or not. I feel the users in the current issue discussions are too knowledgeable of Kage and may be slightly biased to understimate the complexity of the shaders, both in their current version and with the suggested changes to fix the withstanding issues. As the main writer of the kage-desk tutorial, I often take more the stance of "how would you explain this to noobs", and in this sense, I think we can do better. But maybe not! Please share your opinions on the topic.
Beta Was this translation helpful? Give feedback.
All reactions