Skip to content

Instantly share code, notes, and snippets.

@haxiomic
Last active August 29, 2015 14:06
Show Gist options
  • Save haxiomic/41a60ec8a5a6605093de to your computer and use it in GitHub Desktop.
Save haxiomic/41a60ec8a5a6605093de to your computer and use it in GitHub Desktop.
shaderblox
  • Allocation management with reference counting in ShaderBase
  • better inheritance with glsl parser

A few other ideas:

#defines, defines could be used to replace branching in shaders because is so expensive (http://stackoverflow.com/a/14836396/4038621), and alter constants

say you've got some shader:

#ifdef ENABLE_MOTION_BLUR
  motionBlur();
#endif

maybe you can change the define with program.ENABLE_MOTION_BLUR = true / false, which will prepend #define ENABLE_MOTION_BLUR to the shader. It'll recompile automatically the next time the shader activates (checkout Firefox's built in Shader Editor if you've not seen it). So this sort of thing would be useful as maybe quality settings in a game. It might be more natural with shader.define(...) and shader.undefine(...), I'm not sure


Auto optimization, we could pass all the shaders through https://github.com/aras-p/glsl-optimizer which seems to have quite an impact on mobile targets http://aras-p.info/blog/2010/09/29/glsl-optimizer/. Annoying thing is we'd have to ship binaries with shaderblox


Generate setters and getters for shader uniforms so we'll be able to set vectors with shader.mouse = mouseVector, instead of shader.mouse.data = mouseVector, as well setting the dirty flag

Perhaps it's worth also using abstracts and their @:from magics for the uniforms so the types can be flexible but still fast on static systems

eg

@:from 
static public function fromTypedef(o:{x:Float, y:Float})
	return new Vector2(x,y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment