Forum Replies Created
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
DCXCParticipant
明白了,谢谢
DCXCParticipant谢谢回复,glsl没法debug,我转成javascript了,初学glsl,不知道转对没有。
不管怎样,根本上看,这个pack+unpack的逻辑是把一个[-1,1]范围内的值线性转换到[0,1]吗?- This reply was modified 3 years, 8 months ago by DCXC.
DCXCParticipant框架封装的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); } } }
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)