New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal/shader: utility functions to treat normalized values #2644
Comments
For #1870, we might have to have these functions:
|
By the way, to use |
In the pixel mode, we don't treat texels even for destination textures, right? |
Right. What I'm asking is this: given a target of 400x400, will //kage:pixel-mode
func Fragment(position vec4, _ vec2, _ vec4) vec4 {
origin, _ := imageDstRegionOnTexture()
dstPosition := position.xy - origin
} But without pixel mode, this is currently much harder to do? Or is this step already unnecessary? EDIT: I know that for many subimages |
If you are talking about how to get [0, 1] value, yes, this is a little much harder, but it's still possible. See https://github.com/hajimehoshi/ebiten/blob/2.5/examples/shader/texel.go (texel mode) vs https://github.com/hajimehoshi/ebiten/blob/main/examples/shader/texel.go (pixel mode).
For a sub-image, I think we should provide a function to return [0, 1] assuming the sub-image's left-upper is (0, 0) and right-bottom is (1, 1). But this might be ambiguous. Let me think. |
No, I'm talking about how to get the |
This requires more discussion. I'll reset the milestone. |
Operating System
What feature would you like to be added?
I propose to add these functions
func normalizeDstPosition(pos vec2) vec2
: convertspos
in pixels to [0, 1] of the destination image.func normalizeSrcPosition(pos vec2) vec2
: convertspos
in texles to [0, 1] of the source image.Note that the units might be affected by #1431.
For more details, see
https://docs.google.com/document/d/1lJTKxMqyyO-LxNS4KmuNakQwlhdBgzkmP2LNwpJk5bg/edit#bookmark=id.b8qzndnzk6yq
TBD: Do we need inverted functions?
Why is this needed?
From the discussion of #2639, we found that normalizing positions of textures to [0, 1] is very common. To do this, users need to understand how images and textures work in Ebitengine, and to write some tricky code with an origin and a texture. Thus, it should be very useful to have utility functions to do that for Kage.
For more details, see https://docs.google.com/document/d/1lJTKxMqyyO-LxNS4KmuNakQwlhdBgzkmP2LNwpJk5bg/edit?usp=sharing
The text was updated successfully, but these errors were encountered: