Ejemplo n.º 1
0
 public void LoadShader(string path, string shaderContent)
 {
     Controller.Context.DisposeTextures();
     string[] shaderParts = shaderContent.Split("*///");
     if (shaderParts.Length > 1)
     {
         try
         {
             string metadataJson = shaderParts[0].Skip(2).ToSystemString();
             shaderMetadata = JsonConvert.DeserializeObject <YALCTShaderMetadata>(metadataJson);
             if (shaderMetadata.ResourcePaths != null)
             {
                 for (int i = 0; i < shaderMetadata.ResourcePaths.Length; i++)
                 {
                     // get absolute path
                     YALCTFilePickerItem item            = shaderMetadata.ResourcePaths[i];
                     YALCTFilePickerItem transformedItem = item;
                     transformedItem.FullPath        = Path.Combine(path, item.FullPath);
                     shaderMetadata.ResourcePaths[i] = transformedItem;
                     Controller.Context.LoadTexture(transformedItem);
                 }
             }
             fragmentCode = shaderParts[1].Trim('\r', '\n');
         }
         catch
         {
             // no metadata found, just load the entire code
             LoadShaderDefault(shaderContent);
         }
     }
     else
     {
         LoadShaderDefault(shaderContent);
     }
     SplitLines();
     Apply();
 }
Ejemplo n.º 2
0
 private void LoadShaderDefault(string shaderContent)
 {
     shaderMetadata = YALCTShaderMetadata.Default();
     fragmentCode   = shaderContent;
 }