Saturday 15 May 2010

three.js - Fragment shader on plane with modified vertices -


I have a plane gemetry and I randomly animate the corner to make random spikes. I use this FragmentShader:

  void main () {vec3 light = vec3 (cos (time), sin (time), 1.0); Light = normal (light); Float Depod = Max (0.0, dot) (vnormal, light); Gl_FragColor = vec4 (DPRD, DPRD, DPROD, 1.0); }   

I expected to have some faces of every spike in black, but instead I found a solid color. I placed a sphere on my plane and applied the same shader: Enter image details here < P> When I close the wire frame: enter image details here

not sure Is that what I think is happening on the plane ?! I thought that each spike is different in normal, so they should have different light.

"post-text" itemprop = "text"> Your "spike" does not have different headers because you have not changed the top normal; They are all (0, 1, 0). There is something that you could see in the console itself.

In addition, when you make a change in the corner of a tractor (the face of the plane), then four zeros can not be star. This will give you all kinds of problems. (Google non-planar quads.)

You can triangulate PlaneGeometry with these problems:

  Three. GeometryUtils.triangulateQuads (geometry);   

Recommend that this function reconnects the Corta Normals. Look at the source so you can understand what it is doing.

Three. JS r.58

No comments:

Post a Comment