Exemplo n.º 1
0
        public void TestAllNodes(INodeFactory factory)
        {
            var node = factory.Build();

            foreach (var nodeOutputPin in node.OutputPins)
            {
                var script = new Script();
                script.Add(node);
                var type       = nodeOutputPin.Type;
                var connection = new Connection(node.Id, nodeOutputPin.Id);
                switch (type)
                {
                case PinTypes.LightMatrices:
                    return;

                case PinTypes.VertexLights:
                    return;

                case PinTypes.Sampler2D:
                {
                    var t = MaterialNodeRegistry.Instance.ResolveFactory(NodeTypes.Texture2DSampler2DVec2)
                            .Build();
                    script.Add(t);
                    t.InputPins[0].Connection = new Connection(node.Id, nodeOutputPin.Id);
                    type       = t.OutputPins[0].Type;
                    connection = new Connection(t.Id, t.OutputPins[0].Id);
                }
                break;

                case PinTypes.SamplerCube:
                {
                    var t = MaterialNodeRegistry.Instance.ResolveFactory(NodeTypes.TextureCubeSamplerCubeVec3)
                            .Build();
                    script.Add(t);
                    t.InputPins[0].Connection = new Connection(node.Id, nodeOutputPin.Id);
                    type       = t.OutputPins[0].Type;
                    connection = new Connection(t.Id, t.OutputPins[0].Id);
                }
                break;
                }

                var amb = new ScriptNode
                {
                    Type      = NodeTypes.Special.FinalColor,
                    Value     = "PASS",
                    InputPins = { new PinWithConnection {
                                      Id = "", Type = type
                                  } }
                };
                script.Add(amb);
                amb.InputPins[0].Connection = connection;

                var scriptHelper = new ScriptHelper <TranslatedMaterialGraph.NodeInfo>(script);
                TranslatedMaterialGraph.Preprocess(scriptHelper);
                var g = TranslatedMaterialGraph.Translate(scriptHelper);
                new GLSLPassTemplate(g).TransformText();
            }
        }
Exemplo n.º 2
0
 public GLSLPassTemplate(TranslatedMaterialGraph graph)
 {
     Graph = graph;
     VertexShaderGenerator            = new GLSLCodeGen(this);
     VertexShaderUniformsAndFunctions = new UniformsAndFunctions(
         graph.Script.Nodes.Where(_ => _.Extra != null && !_.Extra.RequiredInPixelShader),
         graph.VertexShaderUniforms, VertexShaderGenerator);
     PixelShaderGenerator            = new GLSLCodeGen(this);
     PixelShaderUniformsAndFunctions = new UniformsAndFunctions(
         graph.Script.Nodes.Where(_ => _.Extra != null && _.Extra.RequiredInPixelShader),
         graph.PixelShaderUniforms, PixelShaderGenerator);
 }
Exemplo n.º 3
0
 public GLSLPassTemplate(TranslatedMaterialGraph graph)
 {
     Graph = graph;
     VertexShaderGenerator            = new GLSLCodeGen(this);
     VertexShaderUniformsAndFunctions = new UniformsAndFunctions(
         graph.Script.Nodes.Where(_ =>
                                  _.Extra?.Attribution == TranslatedMaterialGraph.NodeAttribution.VertexShader),
         graph.VertexShaderUniforms, VertexShaderGenerator);
     PixelShaderGenerator            = new GLSLCodeGen(this);
     PixelShaderUniformsAndFunctions = new UniformsAndFunctions(
         graph.Script.Nodes.Where(_ =>
                                  _.Extra?.Attribution == TranslatedMaterialGraph.NodeAttribution.PixelShader),
         graph.PixelShaderUniforms, PixelShaderGenerator);
 }
Exemplo n.º 4
0
 protected string BuildPass(TranslatedMaterialGraph pass)
 {
     return(new GLSLPassTemplate(pass).TransformText());
 }
Exemplo n.º 5
0
 public HLSLPassTemplate(TranslatedMaterialGraph graph)
 {
     Graph = graph;
     VertexShaderGenerator = new HLSLCodeGen(this);
     PixelShaderGenerator  = new HLSLCodeGen(this);
 }