Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

GLSL Validator

The GLSL validator is a tool for validating WebGL shaders, with support for adding prefixes to your shaders, leading to compatibility with libraries such as THREE.js, which automatically pass in variables into your shaders.

For more details, see post here


Add the directory containing the command to your path, then invoke using FILE [FILE ...]

Example output

If there any errors in the passed in shader files, they will be displayed along with the line they occured on:

The tool can also be used to generate the shader assembly instructions to give you an idea of how compute intensive it is. Note this is just a guide, actual instruction will be driver dependent.

Prefix files

In order to keep the ANGLE compiler happy, we prepend prefix files to the GLSL files being checked, which contain the code that a library will pass in.

The prefix files that the validator will use are prefix/prefix.frag and prefix/prefix.vert for fragment and vertex shaders, respectively. Example prefix files for various libraries can also be found in the prefix directory, e.g. prefix.threejs.vert.

To not load the prefix files, use the --raw flag.

Validation engine

To validate the GLSL code, the ANGLE compiler is used. Binaries have been taken from the Sublime Text GL Validator

CGC compiler

The tool uses the Cg Toolkit to get an estimate (it is driver dependant) of the shader instructions a given shader will output. The required binary for this to function is: cgc, which (on OSX) can be obtained by downloading the Cg Toolkit from and then using Show package contents to extract the cgc binary from Items/NVIDIA_Cg.tgz (the installer did not work for me). l


Command line tool for validating GLSL files







No releases published


No packages published