Skip to content

Instantly share code, notes, and snippets.

@AndrewRayCode
Created December 19, 2018 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewRayCode/ca760ec669dd90ae81824d1e51dce46a to your computer and use it in GitHub Desktop.
Save AndrewRayCode/ca760ec669dd90ae81824d1e51dce46a to your computer and use it in GitHub Desktop.
// ----- 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