DCXC

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: 【作业1】请教下,shadowMap中深度的范围 #8120 Score: 0
    DCXC
    Participant

    明白了,谢谢

    in reply to: 【作业1】请教下,shadowMap中深度的范围 #8115 Score: 0
    DCXC
    Participant

    谢谢回复,glsl没法debug,我转成javascript了,初学glsl,不知道转对没有。
    不管怎样,根本上看,这个pack+unpack的逻辑是把一个[-1,1]范围内的值线性转换到[0,1]吗?

    • This reply was modified 3 years, 8 months ago by DCXC.
    in reply to: [作业1]关于CPU和GPU同步问题 #8092 Score: 0
    DCXC
    Participant

    框架封装的WebGLRenderer里面写得很清楚,是先draw light, 再Shadow pass,最后Camera pass。

    render() {
            const gl = this.gl;
    
            gl.clearColor(0.0, 0.0, 0.0, 1.0); // Clear to black, fully opaque
            gl.clearDepth(1.0); // Clear everything
            gl.enable(gl.DEPTH_TEST); // Enable depth testing
            gl.depthFunc(gl.LEQUAL); // Near things obscure far things
    
            console.assert(this.lights.length != 0, "No light");
            console.assert(this.lights.length == 1, "Multiple lights");
    
            for (let l = 0; l < this.lights.length; l++) {
                // Draw light
                // TODO: Support all kinds of transform
                this.lights[l].meshRender.mesh.transform.translate = this.lights[l].entity.lightPos;
                this.lights[l].meshRender.draw(this.camera);
    
                // Shadow pass
                if (this.lights[l].entity.hasShadowMap == true) {
                    for (let i = 0; i < this.shadowMeshes.length; i++) {
                        this.shadowMeshes[i].draw(this.camera);
                    }
                }
    
                // Camera pass
                for (let i = 0; i < this.meshes.length; i++) {
                    this.gl.useProgram(this.meshes[i].shader.program.glShaderProgram);
                    this.gl.uniform3fv(this.meshes[i].shader.program.uniforms.uLightPos, this.lights[l].entity.lightPos);
                    this.meshes[i].draw(this.camera);
                }
            }
        }
    
Viewing 3 posts - 1 through 3 (of 3 total)