ACBob / VoxelThingYeah

Voxel Game Engine
1 stars 1 forks source link

Improve shader #include #26

Closed ACBob closed 2 years ago

ACBob commented 3 years ago

GLSL Is fine and dandy and all, but we've got a LOT of repeated code.\ We need some kind of pre-processor with an #include directive. Although similar functionality may be achieved with Open GL 4.5's new shiny feature to compile multiple shaders together, but that's boring (and not at all portable to something like vulcan).

This is a stupid easy concept, simply take a file, search it for #include, use the second argument as a file path, handle that file and its' #includes, and then glue together by replacing each #include with the file at the end.\ Handling circular includes should be easy, just see if any of the included files cause the file to include itself.

Implementation? Regex or something.

ACBob commented 3 years ago

Searching the included file for a 'main' definition and then prefixing or removing it would also be a bonus.\ If prefixed, multiple shaders may be mock-achieved by specifying in the vertex which shader to use and then switch-casing to the prefixed main function.

ACBob commented 3 years ago

There is one that works, but it probably uses a bunch more memory than is needed

ACBob commented 2 years ago

Have something that works, don't need much more than that. Only improvements would be memory-wise and that doesn't need an issue.