frostoven/Cosmosis

Change shader loader to allow using ShaderChunks

aggregate1166877 opened this issue · 2 comments

[Parent issue: #74]

Details:
The current shader loading mechanism uses flat text files. While this allows easy separation of concerns, it means we miss out on the hard work the Three.js team did on ShaderChunks.

  • Move the shaders directory into app/shaders.
  • Rewrite shader files as .js files.
  • Shaders should be stored as template strings that allow injecting JS variables.
  • Shaders and the functions that use them should not necessarily have the same names. For example, an item pickup might use a glow shader named wisp, which the user might not like and change so that pickups use a shader named blackbody instead. - Out of scope, will implement at a later stage.

As a side note, it turns out Three.js has an #include directive which can be used to import shader chunks defined within the library.