oframe / ogl

Minimal WebGL Library
https://oframe.github.io/ogl/examples
3.77k stars 213 forks source link

minFilter for Texture has to be set manually #92

Closed SiddharthSham closed 3 years ago

SiddharthSham commented 3 years ago

When using WebGL1 and setting generateMipmaps: false, the texture refuses to render (only displays black, the default empty texture) . Setting minFilter: this.gl.LINEAR solves this issue.

Is there something I'm doing wrong, or is this a bug?

gordonnl commented 3 years ago

I would need more info about your circumstance - perhaps create a code sandbox outlining the issue?

I have a feeling that your texture's width or height is not a power of two, but as I said, I don't have enough info to help further.

gordonnl commented 3 years ago

Closing this as I don't believe it's a bug, however feel free to reply with a working example. Also StackOverflow is probably a better place for individual support.

SiddharthSham commented 3 years ago

You're right, my texture was non-power-of-2. Because of the defaults I thought that OGL was internally handling that and switching to the right filtering, but apparently not.

This is not a bug, but implementing this could be a feature. Shall I raise a PR?

gordonnl commented 3 years ago

Yeah interesting, it actually does handle it for you if you leave generateMipmaps set to true.

https://github.com/oframe/ogl/blob/84fce47dea6a3920ac98a4eebe02518a7fc724fa/src/core/Texture.js#L179-L183

I assume it wouldn't be too difficult to rework that check to make sure ALL of the settings are correct (mipmap, wrapping, filtering), however I don't have all of the possible use-cases in my mind at the current time. Please feel free to create a PR!