when I use depth map with my project,different implementations have different results.
- code
this.shader = new pc.Shader(graphicsDevice, {
attributes: {
aPosition: pc.SEMANTIC_POSITION
},
vshader: [
"attribute vec2 aPosition;",
"",
"varying vec2 vUv0;",
"",
"void main(void)",
"{",
" gl_Position = vec4(aPosition, 0.0, 1.0);",
" vUv0 = aPosition.xy*0.5+0.5;",
"}"
].join("\n"),
fshader: [
"precision " + graphicsDevice.precision + " float;",
pc.shaderChunks.screenDepthPS,
"",
"varying vec2 vUv0;",
"",
"void main() {",
" float depth = getLinearScreenDepth(vUv0);",
" gl_FragColor = vec4(vec3(depth * 0.1), 1.0);",
"}"
].join("\n")
});
the result of this code is blank,and next
2.code
var psCode = "precision " + graphicsDevice.precision + " float;\n" +
pc.shaderChunks.screenDepthPS +
"\nvarying vec2 vUv0;\n"+
"void main() {\n"+
" float depth = getLinearScreenDepth(vUv0);\n"+
" gl_FragColor = vec4(vec3(depth * 0.1), 1.0);\n"+
"}";
this.shader = pc.shaderChunks.createShaderFromCode(graphicsDevice, pc.shaderChunks.fullscreenQuadVS, psCode, "mypost");
the result of code is right,Why is there such a situation.Thinks.