Quick Links
  • Homepage
        - Overview
        - Download
        - Screenshots
        - Community
  • Code Sample Pack
  • Reference Guide
  • Changelog
  • Overview of GLSL Hacker
  • Live Coding
  • Hack your first GLSL Code
  • Moon3D




  • GLSL Hacker Articles

    > Compute shaders on Radeon
    > Distance functions in GLSL
    > GLSL Interpolation Qualifiers
    > Tessellation Spacing Modes
    > Normal Visualizer with GS
    > 3D Surface Plots
    > Normal Mapping
    > Circle and Disc in GLSL
    > PhysX 3 Flag Demo
    > GLSL Hacker on Raspberry Pi
    GLSL Hacker

    Hack your first GLSL program

    This article will show you how to use GLSL Hacker and the live coding tools to hack and tweak a GLSL program. The following information is valid for Windows and OSX. The Linux version of GLSL Hacker does not have the live coding tools. See at the end of the page some tips to do live coding under Linux.


    1 - Launch GLSL Hacker, you should have something like this:

    GLSL Hacker platforms: Windows, Linux, MacOSX

    2 - Load a code sample from the Code Sample Pack. To load a file, you can use either the menu File > Load scene file or simpler (on Windows only), you can drag n drop the scene file onto GLSL Hacker. For example, load the following scene: GLSL_Simple/demo_gl2.xml. This simple demo shows a red spinning quad:

    GLSL Hacker platforms: Windows, Linux, MacOSX

    3 - Start the network GLSL live coding interface (network_live_updater_glsl.exe for Windows or network_live_updater_glsl.app for OSX). Enter the address of GLSL Hacker server: hostname (localhost if GLSL Hacker and the live updater are on the same machine) and the port (default: 45000) and click on Connect to GLSL Hacker. The live updater should list the current GLSL programs:

    GLSL Hacker - Network GLSL live updater - Windows / MacOSX

    4 - Click on the GLSL program name in the GPU program list and the different shaders that form the GLSL program are displayed int their respective edit box:

    GLSL Hacker - Network GLSL live updater - Windows / MacOSX

    5 - Now you're ready to do live coding. Just edit the shaders' source code and you will see immediatly the results of your modifications. For example change the following line in the pixel shader:

      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
    
    by
      gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
    
    And immediately you will have a yellow quad in GLSL Hacker:

    GLSL Hacker - Network GLSL live updater - Windows / MacOSX

    6 - Once you've done to tweak your shaders, just click on Disconnect from GLSL Hacker button to close you live coding session.

    The nice thing with the Network live coding interface is that you can control GLSL Hacker from another computer. For example, you can have GLSL Hacker running on Linux, and from a Mac OSX box, you can live code your GLSL programs...


    The Linux version of GLSL Hacker does not have the live coding tools. But that does not prevent to do live coding under the penguin OS. Here are two solutions:

    • 1 - Run GLSL Hacker under Linux and run the live coding interface on another computer with either Windows or OSX.
    • 2 - Run GLSL Hacker under Linux and run the Windows version of the live coding interface under Wine.



    (C)2012-2014 Geeks3D