我想为THREE.js中的效果生成渲染帧的自定义Mip贴图,但尚不清楚如何实现。我要在每帧之后再次重新生成Mip贴图。
This example显示了如何为纹理生成mipmap,但是看起来mipmaps
数组需要image
或canvas
标签的句柄,该标签是renderTarget纹理不具有。理想情况下,我希望能够执行以下操作:
var rt = new THREE.WebGLRenderTarget()
// initialize and render to the target
var mipmaps = [];
var width = rt.width / 2;
var height = rt.height / 2;
while( width > 2 && height > 2) {
var mip = new THREE.WebGLRenderTarget({ width, height });
mipmaps.push(mip.texture); // mip.texture.image === undefined
// render to the new mipmap with a custom downsample shader
width /= 2;
height /= 2;
}
rt.texture.mipmaps = mipmaps;
// render using the original render target as a texture map and using
// the new mip maps as needed
这可能吗?我将如何实现?
谢谢!