hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
10.74k stars 649 forks source link

enable to choose samplers (nearest and linear) at a Kage program #2962

Open hajimehoshi opened 4 months ago

hajimehoshi commented 4 months ago

Operating System

What feature would you like to be added?

Now Kage doesn't provide a linear sampler and a user has to do their own linear interpolation. This is troublesome. We want an option to specify a sampler.

Why is this needed?

A linear fileter is useful (e.g. implementing a SDF font).

hajimehoshi commented 4 months ago

Hmm, this might not match well with the current pixel mode, where an integer position is specified.

Other notes:

OpenGL: there is no way to choose a sampler in GLSL programatically. This is bound to a texture by glTexParameteri. As of OpenGL 3.3, a sampler object is available. DirectX: A sampler can be chosen in HLSL? Metal: A sampler can be chosen in MSL.

hajimehoshi commented 4 months ago

So, "why not both"? We can have funcitons to get a texel data without interpolations (like texelFetch) and with interpolations (like texture2D)?

Zyko0 commented 4 months ago

Just my opinion, but I don't think it's necessary, and I couldn't imagine a clean way to integrate the notion of samplers in ebitengine/kage. Also, linear sampler is one example, but there are many different filtering techniques, so when should we stop? (linear, bilinear, trilinear, etc...) I would rather write an example implementation in Kage, or (what this issue aims for) wait for other user inputs 😅

hajimehoshi commented 4 months ago

Thanks,

Also, linear sampler is one example, but there are many different filtering techniques, so when should we stop? (linear, bilinear, trilinear, etc...)

IIUC nearest and linear are the two common preset filter in various libraries/GPU. There are no other such filters