import { ShaderMaterial } from "three";
import shader_fg from './visualize.frag.glsl';
import shader_vx from './visualize.vert.glsl';

export class OctahedralDepthVisualizationMaterial extends ShaderMaterial {


    constructor() {


        super({
            fragmentShader: shader_fg,
            vertexShader: shader_vx,
            lights: false,
            uniforms: {
                uResolution: {
                    value: 1
                },
                fScale: { value: 1 },
                tDepth: {
                    value: null
                }
            }
        })


    }

    set scale(v) {
        this.uniforms.fScale.value = 1 / v;
        this.uniformsNeedUpdate = true;
    }

    /**
     *
     * @param {THREE.DataTexture} v
     */
    set texture(v) {
        this.uniforms.tDepth.value = v;
        this.uniforms.uResolution.value = v.image.width;

        this.uniformsNeedUpdate = true;
    }

}