Skip to content

Commit

Permalink
fix: fix shaders for webgl2
Browse files Browse the repository at this point in the history
  • Loading branch information
piellardj authored and Sceat committed Nov 18, 2024
1 parent 4627c2c commit 49ee7c0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/core/game/rendering/godrays_pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ class GodraysPass extends Pass {
uCameraNear: { value: 0 },
uCameraFar: { value: 0 },
},
vertexShader: `attribute vec2 aCorner;
glslVersion: "300 es",
vertexShader: `in vec2 aCorner;
varying vec2 vUv;
out vec2 vUv;
void main(void) {
gl_Position = vec4(aCorner, 0.0, 1.0);
Expand All @@ -132,17 +133,19 @@ class GodraysPass extends Pass {
uniform float uCameraNear;
uniform float uCameraFar;
varying vec2 vUv;
in vec2 vUv;
out vec4 fragColor;
void main(void) {
float fragCoordZ = texture2D(uDepthTexture, vUv).x;
float fragCoordZ = texture(uDepthTexture, vUv).x;
float viewZ = perspectiveDepthToViewZ(fragCoordZ, uCameraNear, uCameraFar);
float orthoZ = viewZToOrthographicDepth(viewZ, uCameraNear, uCameraFar);
if (orthoZ > 0.99) {
discard;
}
gl_FragColor = vec4(0, 0, 0, 1);
fragColor = vec4(0, 0, 0, 1);
}`,
})

Expand Down

0 comments on commit 49ee7c0

Please sign in to comment.