Created
December 19, 2018 18:41
-
-
Save AndrewRayCode/ca760ec669dd90ae81824d1e51dce46a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ----- Given this shader: | |
vec4 some_noise_fn() { | |
return vec4(1.0, 2.0, 3.0, 4.0); | |
} | |
void main() { | |
return some_noise_fn(); | |
} | |
// ---- Let's replace the noise function, but now, this noise function can take in a *uniform*, | |
// which is what GLSL calls variables users can dynamically pass from their game engine into the shader: | |
uniform float noise_strength; | |
vec4 other_noise_fn() { | |
return vec4(5.0, 5.0, 5.0, noise_strength); | |
} | |
// ---- Here's what the final progam looks like with the function replaced (the hole filled) | |
uniform float noise_strength; | |
vec4 some_noise_fn() { | |
return vec4(5.0, 5.0, 5.0, noise_strength); | |
} | |
void main() { | |
return some_noise_fn(); | |
} | |
// So you see, it's not just filling the "hole" (function body) - it's also mangling the AST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment