I have this code right now.
_var geometry = new THREE.Geometry();_
_var material = new THREE.ShaderMaterial();//There's some shader code in there._
_var len = 100;_
_for( var i = 0 ; i < len ; i++ ){_
_ geometry.vertices[ i ] = randomPos();//random position function_
_}_
_var mesh = new THREE.Points( geometry, material );_
Well, I now want to render different effects for each different vertex, can I understand that each vertex requires a different shader code? But is there a better way to do this, both from development and performance?
Or is it possible to create a bunch of particles to simulate what I want?
Of course, if the performance of the particle system (oh, now called points) is perfect, then I won’t have to worry about the shader.
Take a look into the examples about custom shaders. The vertex shader program is executed per vertex, maybe you could also explain your wanted result more detailed.
That’s the most enigmatic part of the question. Could you explain it more thoroughly?
Well, I looked at all the demos in v88, I didn’t find what I wanted, maybe I missed something? Let me describe my problem in more detail.
When I was in an through data to see such a site, the site in each model vertices created a, then use the shaders for current vertex color value, use the color value across the populated, implements a cool effect, looks like a painting, very impressive.
I want to copy this effect now, but the website forgot to save it after reading it. So I’m thinking now, I’ve created a Geometry, and I want to control the color value of each vertex by the shader, maybe I’m using a material that’s not reasonable, right? The default material for points is using BufferGeometry.
As I wrote in the code, I got the 100 random vertex position, now I know the position of the vertices, I want to by every vertex shaders to modify the style (I am on the ShaderMaterial shader code, modify the position, color, size, transparency, etc.), I how to get these in the shader code vertex position (scene is not only a material, it is impossible for me to all vertices, this is unreasonable).
In its v60 version, I see such a demo, use ShaderMaterial, and use the attributes to each vertex of the visible, Angle, the size, color, opacity, but in v88 (perhaps more early version) has the attributes of removed from the ShaderMaterial, into the BufferGeometry.
Well, I tried to use the BufferGeometry, but I found that I didn’t use this geometry. I have some custom attributes in them, I also hope that these parameters are attached to the material, and processed in the shader, but I don’t know how to deal with these parameters, I try to use cycle, and the parameters of each item into the shader, but all the vertices using a set of shaders.
This is the demo.