Results 1 to 9 of 9

Thread: Basic example on passing value from ThinBASIC to shader

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    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

  2. #2

    Re: Basic example on passing value from ThinBASIC to shader

    Looks nice!

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Basic example on passing value from ThinBASIC to shader

    Smart, elegant, flicker free, fast, interpreted and ... just 200 lines of code.

    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Basic example on passing value from ThinBASIC to shader

    Petr, when do you find the time? I know how busy you are and yet you throw us surprises often. I guess just like Eros and Mike you guys find a way!
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Basic example on passing value from ThinBASIC to shader

    Hi Kent,

    nice to see you here after while!
    I have less free time comparing to past years, but the passion still moves things forward.

    Eros, thanks Did you tested it on ATi?
    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

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Basic example on passing value from ThinBASIC to shader

    Quote Originally Posted by Petr Schreiber
    Eros, thanks Did you tested it on ATi?
    Yes. On "ATI Radeon Mobility X1600 512Mb"
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

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

    Re: Basic example on passing value from ThinBASIC to shader

    Thanks,

    great to know GLSL works reliably there!
    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

  8. #8
    Nice tiny shader variable exampler good job.

    There is only one mistake in sub Car_Render()
    Looks like on code line 212 there are one tbgl_PopMatrix() without a tbgl_PushMatrix() in front.

    Internal it would be end in an OpenGL error "matrix stack underrun".
    (more harmless as an stack overrun)

    Joshy
    (Sorry about my bad English.)

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Good catch, fixed.


    Petr
    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
  •