> Code Sample Pack
> Reference Guide
> Overview of GLSL Hacker
> Live Coding
> Hack your first GLSL Code
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
What is GLSL Hacker?
GLSL Hacker is cross-platform tool for fast real time 3D prototyping and coding. GLSL Hacker is available on all popular desktop platforms: Windows, Linux and OSX (64-bit on all platforms).
GLSL Hacker is based on widely used standards such as GLSL (OpenGL Shading Language), Lua and Python. In a word, GLSL Hacker can be seen as a highly revamped version of GeeXLab.
Compared to GeeXLab, GLSL Hacker offers a programming interface (or API) with a lower level of abstraction. This low level API requires more lines of codes but allows a better control of the rendering. GLSL Hacker API has also high level functions like the loading of 3D models or textures. Here is a code snippet:Objects creation:
camera = gh_camera.create_persp(60, 1.333, 0.1, 1000.0) ground_tex = gh_texture.create_from_file("ground.jpg", 0, 0) ground_mesh = gh_mesh.create_plane(100, 100, 10, 10) -- texture_gpu_prog is a GLSL program defined in XML. glsl_prog = gh_node.getid("texture_gpu_prog")
gh_renderer.clear_color_depth_buffers(0, 0, 0, 1.0, 1.0) gh_camera.bind(camera) gh_gpu_program.bind(glsl_prog) gh_texture.bind(ground_tex, 0) gh_object.render(ground_mesh)
Sounds easy, isn'it? It's because GLSL Hacker is easy to use! And with higher level libraries like Moon3D, even a kid can code with GLSL Hacker ;)
The best way to learn GLSL Hacker is to study and hack the demos provided in the Code Sample Pack and to test them in GLSL Hacker.
How does GLSL Hacker work?
GLSL Hacker works like an internet browser: you load (or drag'n'drop) a source code file (the 3D scene) and GLSL Hacker plays it. That's all.
The entry point is a XML file. This file simply holds the different scripts (Lua , Python, GLSL) that make up the 3D scene. There are several types of scripts:
A scene can have one or several scripts of the same type. What's more, Lua and Python scripts can be present in the same scene. For example, a scene with two INIT scripts (one Lua, and one Python), three FRAME scripts (two Lua and one Python) is perfectly valid.
The following diagram shows when the different scripts are executed:
The execution order of scripts is defined by the order of scripts in the XML file.
A scene in GLSL Hacker is made up of nodes. Nearly everything is node: a GLSL program, a texture, a mesh.
The different scripts have an unique goal: interacting with scene nodes. Scripts can be used to create or destroy nodes, to set parameters, to update parameters and to render nodes. Renderable nodes are the Object nodes. You can not render a GPU program (a GLSL program) but you can render a mesh.