最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论