Petr Schreiber
13-09-2009, 12:11
GLSL shaders are indeed very useful tool for creating unusual graphic output.
Sometimes you need to change shader behavior after compilation dynamically.
There is interesting mechanism, which allows change shader variable values according to your ThinBASIC variables.
The magic OpenGL commands to achieve this are two:
glGetUniformLocationARB - to retrieve "pointer" to shader variable
glUniform1fARB - to change variable located at "pointer" to other floating point value
The attached script demonstrates this technique in the easiest way. Just use slider to modify the variable value and watch the impact on shader in realtime.
Note: As this script demonstrates advanced technique, your card must be GLSL compatible. That means ideally support for OpenGL 2.0 or OpenGL 1.5 with extensions. Tested on GeForce 9500GT.
Sometimes you need to change shader behavior after compilation dynamically.
There is interesting mechanism, which allows change shader variable values according to your ThinBASIC variables.
The magic OpenGL commands to achieve this are two:
glGetUniformLocationARB - to retrieve "pointer" to shader variable
glUniform1fARB - to change variable located at "pointer" to other floating point value
The attached script demonstrates this technique in the easiest way. Just use slider to modify the variable value and watch the impact on shader in realtime.
Note: As this script demonstrates advanced technique, your card must be GLSL compatible. That means ideally support for OpenGL 2.0 or OpenGL 1.5 with extensions. Tested on GeForce 9500GT.