admin管理员组

文章数量:1334327

I'm trying to modify the positions of the points of a plane object in p5.js. The coordinates are modified in a vertex-shader.

The sketch.js part :

shader(postShader);
postShader.setUniform('time', millis());
background(200);
noStroke();
fill(255);
sphere(100,100);
plane(300,300,100,100);

The shader part :

uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;
attribute vec3 aPosition;
attribute vec3 aNormal;
attribute vec2 aTexCoord;
varying vec2 vTexCoord;
varying vec3 v_normal;

void main() {
  vec3 newPosition = aPosition;
  float offsetZ = .3 * sin( aPosition.x * 20.0);
  newPosition.z += offsetZ;
  gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(newPosition, 1.0);
  v_normal = aNormal;
  v_normal.z += offsetZ;
  vTexCoord = aTexCoord;
}

The view I get : .png

As you can see, the transformation is applied to the sphere but not to the plane.

How do I fix this?

本文标签: 3dProblem modifying the Ycoordinate of a plane in p5jsStack Overflow