Skip to content

Automates adding #define directives to GLSL shader files for conditional compilation

Notifications You must be signed in to change notification settings

th3or14/glsl-precompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python application

Description

Automates adding #define directives to GLSL shader files for conditional compilation.

Usage

Let's say you have a GLSL shader file in.glsl

// some comments

#version 460

// other code

and you would like to add #define A 1 and #define B 2 to it before compiling. Then running

python precompiler.py -D A=1 -D B=2 -i in.glsl -o out.glsl

produces out.glsl

// some comments

#version 460
#define A 1
#define B 2

// other code

with the desired defines inserted after #version directive. Defines are inserted after #version directive because it must occur in a shader before anything else, except for comments and white space.

Requirements

  • Python (minimal tested version is 3.8)

About

Automates adding #define directives to GLSL shader files for conditional compilation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published