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条)