Fragment shader on plane with modified vertices

前端 未结 1 327
隐瞒了意图╮
隐瞒了意图╮ 2021-01-26 15:19

I have a PlaneGeometry and I\'m randomly animating the vertices in order to create random spikes. I use this FragmentShader :

void main() {
       vec3 light = v         


        
相关标签:
1条回答
  • 2021-01-26 16:03

    Your "spikes" do not have different vertex normals because you didn't change the vertex normals; they are all ( 0, 1, 0 ). This is something you could have checked yourself in the console.

    Also, when you modify the vertices of a quad ( a face of the plane ), the four vertices are likely no longer planar. This will cause you all sorts of problems. ( google non-planar quads. )

    You can avoid these problems by triangulating the PlaneGeometry first:

    THREE.GeometryUtils.triangulateQuads( geometry );
    

    Be advised that this function recomputes vertex normals. Have a look at the source so you understand what it is doing.

    three.js r.58

    0 讨论(0)
提交回复
热议问题