three.js - converting script shader to js shader -


got uniforms in e.g

uniforms: {      "time":  { type: "f", value: 0.0 }  }, 

where e.g.

attribute float customfrequency; attribute vec3 customcolor; go? tia (just added code trying convert)

<script type="x-shader/x-vertex" id="vertexshader"> uniform float time; attribute float customfrequency; attribute vec3 customcolor; varying vec3 vcolor; void main() {     vcolor = customcolor;     vec4 mvposition = modelviewmatrix * vec4( position, 1.0 );     gl_pointsize = size;     gl_position = projectionmatrix * mvposition; } </script> <script type="x-shader/x-fragment" id="fragmentshader"> varying vec3 vcolor;  void main() {     gl_fragcolor = vec4( vcolor, 1.0 );     gl_fragcolor = gl_fragcolor * texture2d( texture, gl_pointcoord ); } </script> 

apologies not formulating question - want create threejs shader above script in form of

three.basicshader = {     uniforms: {}, vertexshader: [         "void main() {",         "gl_position = projectionmatrix * modelviewmatrix * vec4( position, 1.0 );",     "}"     ].join("\n"),     fragmentshader: [         "void main() {",         "gl_fragcolor = vec4( 1.0, 0.0, 0.0, 0.5 );",     "}"     ].join("\n") }; 

and cannot find example using vertex attributes. tia

the question not clear, believe little bit confused on basic concepts.

shaders not supposed converted javascript. written in glsl language browser understands , passes on display driver.

uniforms way pass variables between javascript code , glsl shaders. need care uniforms on javascript side. other code in shader scripts part of shader glsl code, can't shared or converted javascript, , if want make changes them, need modify shader itself.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -