-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Texture lod bias #26564
Comments
IMO, the use cases which require a manual But because of the specific character of LOD bias, I don't think it's appropriate to introduce a new texture (or material) property. With a naive implementation we would end up with more uniforms that are not required most of the time. To prevent this, we would have to implement additional branches in JS and the GLSL chunks which increases complexity and maintainability. A global setting seems problematic as well since a texture LOD bias is usually not something that is equal for all textures in an app. Do you mind describing in more detail why you need control over what mipmap is going to be sampled? Is this control restricted to specific type of textures (like alpha maps)? |
Sure, I need it for SSAA (implementation similar to three's SSAARenderPass). Rendering SSAA in this manner with 2^n samples should be equivalent to rendering into a render target scaled by a factor of 2^sqrt(n) and then down scaling that render target to the original size with a linear filter. So, in order to achieve the same effect as rendering into a larger render target I'd like to introduce this texture lod bias of -log2(n)/2 when rendering individual samples in SSAA. Hopefully my explanation is clear enough |
Thanks for the additional details. I do not yet understand why you need a new texture property though. Do you modify built-in shaders for your SSAA implementation? |
SSAA doesn't use any custom shader. It just renders the scene 2^n times with a slight camera view offset each time and averages the results. If I wanted to incorporate the load bias I'd have to modify a lot of internal shaders (pretty much every material texture sample). The (very loose) pseudo code would be something like this:
A way this could work is by replacing all
Where TEXTURE_LOD_BIAS is a define that defaults to 0. If WebGL2 supported the TEXTURE_LOD_BIAS sampler parameter this would be much simpler to do as the property could be set on sampler objects and shaders wouldn't have to be touched. But alas it doesn't, and there are no extensions for it. WebGPU also douesn't support it. |
Description
Are there any plans to add a texture lod bias option to textures and materials?
It seems that WebGL2 specification doesn't contain TEXTURE_LOD_BIAS parameter for sampler objects, which makes this feature difficult.
The only way to do this in WebGL seems to be manually passing the bias into the
texture2D
function calls in shaders? Hopefully someone has a better idea?If I wanted to do this today I'd have to create my own material shaders which pass the lod bias uniform to every call to
texture2D
in all shaders.Solution
Texture
andMaterial
objects have atextureLodBias
parameter which biases mipmap selection when sampling textures.Alternatives
For my use case a global texture load bias applied to all material shaders would work as well.
Additional context
No response
The text was updated successfully, but these errors were encountered: