|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
ScGraph - Fun with livecoding shadersHi list, the last few days i hacked a little bit on shader support in ScGraph. It's a dirty hack and mainly just for fun. So, if you ever wanted to play around with vertex and fragment shaders, check this out [1] (beware wrong linebreaks).. See [2] for a download link. Beware: If you want shader support you have to define HAVE_SHADERS=1 in the Makefile.include. If you want shaders and your GPU doesn't support them scgraph might crash.. I'm working on exposing uniforms, too, so that there is a way to pass data to the shader program from control rate units. Stay tuned.. :D Regards, Flo [1] n = NetAddr("localhost", 37291) Server.default = s = Server.new("scgraph", n) // no more initTree(). Group 1 is created automatically now // create something that renders something and uses shader program 6 // which is not loaded yet.. {GGLRenderer.gr(GShaderProgram.gr(6,1) + GTranslate.gr(GCube.gr, [SinOsc.kr(1.21212121),SinOsc.kr(1,phase:1),0]))}.play // create something that renders something and uses shader program 5, // which is also not loaded yet.. {GGLRenderer.gr(GShaderProgram.gr(5,1) + GTranslate.gr(GCube.gr, [SinOsc.kr(1.21212121),SinOsc.kr(1,phase:1),0]))}.play // clean up ( n.sendMsg( "/clearShaderPrograms" ); ) // format is ["/loadShaderProgram", index, source1, isVertexShader1, source2, isVertexShader2, ...] // the sources will get compiled and linked together into a // shader program indexable by index. Shader programs are shared // between al GLRenderers. // set shader program 6. here we only define a fragment shader ( n.sendMsg ( "/loadShaderProgram", 6, " void main() { gl_FragColor = vec4(0.5 + 0.5 * sin(float(gl_FragCoord.x)/10.0),0.5 + 0.5 * sin(float(gl_FragCoord.y)/10.0),0.5 + 0.5 * sin(float(gl_FragCoord.y*gl_FragCoord.x)/100000.0),1.0); } ", 0); ) // set shader program 5. this one has a vertex and a fragment shader ( n.sendMsg ( "/loadShaderProgram", 5, " void main() { gl_FragColor = vec4(0.1,0.9,0.1,1.0); } ", 0, " void main(void) { vec4 a = gl_Vertex; a.x = a.x * 0.05 + a.y; a.y = a.y * 1.5 + 0.2 * a.x; a.z = a.z * 0.3; gl_Position = gl_ModelViewProjectionMatrix * a; } ", 1); ) [2] http://tapas.affenbande.org/scgraph/scgraph-0.8.tgz -- Palimm Palimm! http://tapas.affenbande.org |
|
|
Re: ScGraph - Fun with livecoding shadersAffengeil!
Till On 22.06.2008, at 17:05, Florian Schmidt wrote: > > Hi list, > > > the last few days i hacked a little bit on shader support in > ScGraph. It's a dirty hack and mainly just for fun. So, if you ever > wanted to play around with vertex and fragment shaders, check this > out [1] (beware wrong linebreaks).. > > > See [2] for a download link. Beware: If you want shader support you > have to define HAVE_SHADERS=1 in the Makefile.include. If you want > shaders and your GPU doesn't support them scgraph might crash.. > > > I'm working on exposing uniforms, too, so that there is a way to > pass data to the shader program from control rate units. Stay > tuned.. :D > > > Regards, > > Flo > > > > [1] > > n = NetAddr("localhost", 37291) > > Server.default = s = Server.new("scgraph", n) > > > // no more initTree(). Group 1 is created automatically now > > > // create something that renders something and uses shader program 6 > > // which is not loaded yet.. > > {GGLRenderer.gr(GShaderProgram.gr(6,1) + GTranslate.gr(GCube.gr, > [SinOsc.kr(1.21212121),SinOsc.kr(1,phase:1),0]))}.play > > > // create something that renders something and uses shader program 5, > > // which is also not loaded yet.. > > {GGLRenderer.gr(GShaderProgram.gr(5,1) + GTranslate.gr(GCube.gr, > [SinOsc.kr(1.21212121),SinOsc.kr(1,phase:1),0]))}.play > > > > // clean up > > ( > > n.sendMsg( > > "/clearShaderPrograms" > > ); > > ) > > > // format is ["/loadShaderProgram", index, source1, isVertexShader1, > source2, isVertexShader2, ...] > > // the sources will get compiled and linked together into a > > // shader program indexable by index. Shader programs are shared > > // between al GLRenderers. > > > // set shader program 6. here we only define a fragment shader > > ( > > n.sendMsg > > ( > > "/loadShaderProgram", > > 6, > > " > > void main() > > { > > gl_FragColor = vec4(0.5 + 0.5 * sin(float(gl_FragCoord.x)/10.0),0.5 > + 0.5 * sin(float(gl_FragCoord.y)/10.0),0.5 + 0.5 * > sin(float(gl_FragCoord.y*gl_FragCoord.x)/100000.0),1.0); > > } > > ", > > 0); > > ) > > > > // set shader program 5. this one has a vertex and a fragment shader > > ( > > n.sendMsg > > ( > > "/loadShaderProgram", > > 5, > > " > > void main() > > { > > gl_FragColor = vec4(0.1,0.9,0.1,1.0); > > } > > ", > > 0, > > " > > void main(void) > > { > > vec4 a = gl_Vertex; > > a.x = a.x * 0.05 + a.y; > > a.y = a.y * 1.5 + 0.2 * a.x; > > a.z = a.z * 0.3; > > gl_Position = gl_ModelViewProjectionMatrix * a; > > } > > ", > > 1); > > ) > > > > [2] http://tapas.affenbande.org/scgraph/scgraph-0.8.tgz > > > > -- > > Palimm Palimm! > > http://tapas.affenbande.org > > _______________________________________________ sc-users mailing list info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880 archive: http://www.listarc.bham.ac.uk/marchives/sc-users/ search: http://www.listarc.bham.ac.uk/lists/sc-users/search/ |
| Free Forum Powered by Nabble | Forum Help |