About Monkey 2 › Forums › Monkey 2 Development › sort of vague auto-ish shader idea
This topic contains 2 replies, has 3 voices, and was last updated by 
 DruggedBunny
 2 years, 2 months ago.
- 
		AuthorPosts
 - 
		
			
				
January 29, 2017 at 7:30 pm #6857
I’ve had these sort of half formed ideas for a while now, basically both a fragment and vert shader source should be very easy to parse out the attribute and uniform names. ( to basically produce a map of names to ID’s)
keeping to a set list of “basic” uniforms and attributes *all* shaders must have (the stuff all shaders have in common like vertex coordinates and UV and so forth) should allow any shaders written for this system to be thrown at the factory method for a Shader class and should just drop in place (you could try multiple different shaders with minimal changes – especially if they only used the “basic” uniforms and attributes)
The “common” variables would probably be used to set specific fields in the Shader for the sake of speed.
Additionally it should be very easy to “port” any old shaders that comes from webgl source code or wherever, just by renaming some of the variables…
I’m just throwing this out here in the hope someone has some thoughts on this, that might lead somewhere…
February 6, 2017 at 7:02 am #6966So this basically tells that if you write a special parser that understands specific source patterns, or comment tags, you would generate custom vertex attributes dynamically.
February 10, 2017 at 3:45 am #7070I’ve always thought it would be great to have a ‘ShaderFunction’ (or PixelShader/VertexShader/etc function types) that can be defined within the game’s Blitz/Monkey source, allowing only a very limited subset of the language that’s then translated to GLSL/whatever.
Crude example…
Monkey123456789101112131415PixelShader DOF (tex:Texture)Local pixel:Pixel ' ARGB data for current pixel the shader is working onpixel.Read (tex) ' Would also allow, eg. pixel.Read (tex, -1, -1) to read from upper-left neighbourLocal db:Pixel = DepthBuffer.Read () ' DepthBuffer = built-in texture referenceIf pixel.r And etc...pixel.r = whatever... etc...EndIfEnd… and of course mx2 would spit out the relevant .glsl and deal with all the setup as part of the build process.
I think making shaders much more accessible like this would get many more of us into shader programming!
 - 
		AuthorPosts
 
You must be logged in to reply to this topic.