anvaka / VivaGraphJS

Graph drawing library for JavaScript
Other
3.75k stars 425 forks source link

WebGL - Use different shaders in same graph #94

Closed Matthi0uw closed 9 years ago

Matthi0uw commented 10 years ago

Hello, I'm sorry for the number of messages that I post, but at least it shows my interest for VivaGraph.

I would like to make a graph in WebGL with 2 kind of nodes : circle / square (without using image on nodes).

The form of each node is specified in Fragment shaders (like here) and WebGL renderer use this program. How can I switch between different shaders ?

Thank you !

Matthi0uw commented 10 years ago

Hi, Instead of calling several shader, I would like to add an extra parameter to my nodes as you already do for color or size. But I don't understand how to have the value of parameter in the fragment shader. Can you explain it ? Thx !

anvaka commented 10 years ago

This is driven by getLocations API, then setting value is driven by vertexAttribPointer()

You can also find more examples inside webglImageNodeProgram.js