OutputShader.hx 809 B

12345678910111213141516171819202122232425262728
  1. package h3d.pass;
  2. class OutputShader {
  3. var shaderCache : hxsl.Cache;
  4. var currentOutput : hxsl.ShaderList;
  5. public function new(?output:Array<hxsl.Output>) {
  6. shaderCache = hxsl.Cache.get();
  7. currentOutput = new hxsl.ShaderList(null);
  8. setOutput(output);
  9. }
  10. public function setOutput( ?output : Array<hxsl.Output> ) {
  11. if( output == null ) output = [Value("output.color")];
  12. currentOutput.s = shaderCache.getLinkShader(output);
  13. }
  14. public function compileShaders( globals : hxsl.Globals, shaders : hxsl.ShaderList, mode : hxsl.RuntimeShader.LinkMode = Default ) {
  15. globals.resetChannels();
  16. for( s in shaders ) s.updateConstants(globals);
  17. currentOutput.next = shaders;
  18. var s = shaderCache.link(currentOutput, mode);
  19. currentOutput.next = null;
  20. return s;
  21. }
  22. }