Skip to content

Commit bdc8310

Browse files
committed
Fix panorama()
1 parent 0995029 commit bdc8310

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/webgl/p5.RendererGL.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ class RendererGL extends Renderer {
18381838
this.sphereMapping.setUniform("uFovY", this.states.curCamera.cameraFOV);
18391839
this.sphereMapping.setUniform("uAspect", this.states.curCamera.aspectRatio);
18401840
this.sphereMapping.setUniform("uNewNormalMatrix", this.scratchMat3.mat3);
1841-
this.sphereMapping.setUniform("uSampler", img);
1841+
this.sphereMapping.setUniform("uEnvMap", img);
18421842
return this.sphereMapping;
18431843
}
18441844

src/webgl/shaders/sphereMapping.frag

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
precision highp float;
44

5-
uniform sampler2D uSampler;
5+
uniform sampler2D uEnvMap;
66
uniform mat3 uNewNormalMatrix;
77
uniform float uFovY;
88
uniform float uAspect;
@@ -11,7 +11,6 @@ varying vec2 vTexCoord;
1111

1212
void main() {
1313
float uFovX = uFovY * uAspect;
14-
vec4 newTexColor = texture2D(uSampler, vTexCoord);
1514
float angleY = mix(uFovY/2.0, -uFovY/2.0, vTexCoord.y);
1615
float angleX = mix(uFovX/2.0, -uFovX/2.0, vTexCoord.x);
1716
vec3 rotatedNormal = vec3( angleX, angleY, 1.0 );
@@ -22,6 +21,6 @@ void main() {
2221
vec2 suv;
2322
suv.y = 0.5 + 0.5 * (-rotatedNormal.y);
2423
suv.x = atan(rotatedNormal.z, rotatedNormal.x) / (2.0 * PI) + 0.5;
25-
newTexColor = texture2D(uSampler, suv.xy);
24+
vec4 newTexColor = texture2D(uEnvMap, suv.xy);
2625
gl_FragColor = newTexColor;
2726
}

0 commit comments

Comments
 (0)