Esempio n. 1
0
 public void UpdatePreivew(PreivewContent content)
 {
     if (content == null)
     {
         return;
     }
     InvokeOnMain(() =>
     {
         try
         {
             content.Save();
             ResourceCache.ReloadResourceWithDependencies("Shaders/GLSL/_temp.glsl");
             ResourceCache.ReloadResourceWithDependencies("Techniques/_temp.xml");
             ResourceCache.ReloadResourceWithDependencies("Materials/_temp.xml");
             if (PreviewNode == null)
             {
                 CreateSceneImpl();
                 SetupViewport();
             }
         }
         catch (Exception ex)
         {
             OnError?.Invoke(this, new OnErrorEventArgs(ex));
         }
     });
 }
        public PreivewContent Generate(Script script, string name, Connection pinAndNode = null)
        {
            var glslgraph = new ScriptHelper <TranslatedMaterialGraph.NodeInfo>(script);

            glslgraph.Add(new NodeHelper <TranslatedMaterialGraph.NodeInfo> {
                Type = NodeTypes.Undefine, Value = "DX11"
            });
            glslgraph.Nodes.Add(
                new NodeHelper <TranslatedMaterialGraph.NodeInfo> {
                Type = NodeTypes.Define, Value = "GLSL"
            });
            var hlslgraph = new ScriptHelper <TranslatedMaterialGraph.NodeInfo>(script);

            hlslgraph.Add(
                new NodeHelper <TranslatedMaterialGraph.NodeInfo> {
                Type = NodeTypes.Undefine, Value = "GL_ES"
            });
            hlslgraph.Add(new NodeHelper <TranslatedMaterialGraph.NodeInfo> {
                Type = NodeTypes.Undefine, Value = "GL3"
            });
            hlslgraph.Nodes.Add(
                new NodeHelper <TranslatedMaterialGraph.NodeInfo> {
                Type = NodeTypes.Define, Value = "HLSL"
            });
            var glslcontext = new ShaderGeneratorContext(glslgraph, name, pinAndNode);
            var hlslcontext = new ShaderGeneratorContext(hlslgraph, name, pinAndNode);

            var content = new PreivewContent
            {
                GLSLShader  = new GLSLTemplate(glslcontext).TransformText(),
                HLSLShader  = new HLSLTemplate(hlslcontext).TransformText(),
                Technique   = new TechniqueTemplate(glslcontext).TransformText(),
                Material    = new MaterialTemplate(glslcontext).TransformText(),
                UrhoContext = _context,
                Name        = name
            };

            return(content);
        }