3d - Problem modifying the Y-coordinate of a plane in p5.js - Stack Overflow

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

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742369042a4430887.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信