Open jampekka opened 7 years ago
you can always do this via shader materials, I guess. the situation in your image is dealt with like this.
Is that supposed to be a way of faking anisotropy?
@makc I'm already using anisotropy (the screenshot is a zoom to a "far-away" segment). With shader material one would have to probably implement the whole shader "from scratch"?
@mrdoob It's used usually in conjunction with anisotropy. I think it's quite widely supported by 3D engines, and eg the COLLADA spec has a mip-bias option for textures.
I could take a shot at implementing it, but I don't understand very well how it should be integrated. There's no easy way such as gl.texParameterf
type method of specifying it, in contrast to eg anisotropy, so it has to go to the shader. I guess the proper way would be to have a GLSL preprocessor directive to turn such a uniform on when needed? Eg something like:
#ifdef USE_MAP
#ifdef USE_MIPMAP_BIAS
vec4 texelColor = texture2D( map, vUv, mipmapBias );
#else
vec4 texelColor = texture2D( map, vUv );
#endif
texelColor = mapTexelToLinear( texelColor );
diffuseColor *= texelColor;
#endif
and a conditional declaration of mipmapBias
in eg map_pars_fragment.glsl
, something like
#ifdef USE_MAP
uniform sampler2D map;
#ifdef USE_MIPMAP_BIAS
uniform float mipmapBias;
#endif
#endif
Would this make any sense?
Currently there doesn't seem to be any way to enable mipmap bias for textures. For some uses (eg ground/road textures) a negative mipmap bias is often used to tune blur/aliasing trade-off.
I can hack the bias globally by adding it as a third parameter to
texture2D
in eg. map_fragment.glsl, but unfortunately I have no idea how to nicely implement this forthree.js
.Below is an example of adding such bias (rendered using
THREE.LinearMipMapLinearFilter
and 16x anisotropy, 3x blowup):