Results 1 to 9 of 9

Thread: Basic example on passing value from ThinBASIC to shader

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,129
    Rep Power
    732

    Basic example on passing value from ThinBASIC to shader

    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.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Petr Schreiber; 19-05-2013 at 15:30.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •