As the title says, I want to customize the mipmap, so I specify the array to texture.mipmaps. The following is my code. Since there is no similar implementation in the documentation and example, I have not yet figured out how to implement it.
const envHdr = useEnvironment({ files: RES.texture.hdr })
envHdr.generateMipmaps = true
envHdr.minFilter = LinearMipMapLinearFilter
const fbo = useFBO(envHdr.image.width, envHdr.image.height, {
generateMipmaps: false,
minFilter: LinearMipMapLinearFilter,
magFilter: LinearFilter,
})
useEffect(() => {
if (!isInit.current) {
isInit.current = true
const mipmaps: Texture[] = []
gl.setRenderTarget(fbo)
fullScreenQuad.render(gl)
for (let i = 1; i < 5; i++) {
const mipmapsFbo = new WebGLRenderTarget(envHdr.image.width >> i, envHdr.image.height >> i, {
generateMipmaps: false,
})
uniforms.uMipmapLevel.value = i
uniforms.uRoughness.value = 0.2 * i
uniforms.uSamples.value = Math.max (8096, uniforms.uSamples.value * 2)
gl.setRenderTarget(mipmapsFbo)
fullScreenQuad.render(gl)
mipmaps.push(mipmapsFbo.texture)
}
gl.setRenderTarget(null)
fbo.texture.mipmaps = mipmaps
}
}, [])
After doing these preparations, I sampled fbo.texture through textureLod in the shader, but the result was always completely black.