getGFXStencilTexture在webgl2.0无法直接使用

想试一下depthTexture,环境是webgl1.0的话引擎是可以直接生成图像没问题的,但是在webgl2.0下面读出来的图是没有数据的,如果想在webgl2.0下使用的话我现在是手动改pass的sampler,设置成读取 gl.NEAREST才行。

提出的主要的问题是我这样用是不是对的,因为webgl1.0的话是不需要加那两行sampler改动直接就可以生成图像的。

    this.renderTex = new RenderTexture();
    this.renderTex.reset({
        width: 960,
        height: 640,
        colorFormat: RenderTexture.PixelFormat.RGBA8888,
        depthStencilFormat: RenderTexture.DepthStencilFormat.DEPTH_24_STENCIL_8,
    });
    
    const cameraComp = this.getComponent(CameraComponent);
    cameraComp.targetTexture = this.renderTex;
    const pass = this.model.material.passes[0];
    const binding = pass.getBinding('shadowMap');

    //webgl2.0
    pass.properties.shadowMap.samplerHash = renderer.genSamplerHash([Filter.NEAREST, Filter.NEAREST]); // genSamplerHash gl.NEAREST
    pass.resetTexture('shadowMap')

    pass.bindTextureView(binding, this.renderTex.getGFXStencilTexture());
1赞