Ejemplo n.º 1
0
        public void CanSerializeDescriptor()
        {
            var node = new BlockNode();

            node.Init(s_DescriptorA);
            node.OnBeforeSerialize();

            Assert.AreEqual("Test.BlockA", node.serializedDescriptor);
        }
Ejemplo n.º 2
0
        public void CanInitializeBlockNode()
        {
            var node = new BlockNode();

            node.Init(s_DescriptorA);

            Assert.IsNotNull(node.descriptor);
            Assert.AreEqual(s_DescriptorA, node.descriptor);
            Assert.AreEqual("Test.BlockA", $"{node.descriptor.tag}.{node.descriptor.name}");
        }
Ejemplo n.º 3
0
        public void CanGetBlockIndex()
        {
            GraphData graph = new GraphData();

            graph.AddContexts();

            var node = new BlockNode();

            node.Init(s_DescriptorA);
            graph.AddBlock(node, graph.fragmentContext, 0);

            Assert.AreEqual(0, node.index);
        }
Ejemplo n.º 4
0
        public void CanGetRequirementsFromBlockNode()
        {
            var node = new BlockNode();

            node.Init(s_DescriptorB);

            var iMayRequireNormals = node as IMayRequireNormal;

            Assert.IsNotNull(iMayRequireNormals);

            var neededCoordinateSpace = iMayRequireNormals.RequiresNormal(ShaderStageCapability.Fragment);

            Assert.AreEqual(NeededCoordinateSpace.World, neededCoordinateSpace);
        }
Ejemplo n.º 5
0
        public void CanAddBlockNodeToContext()
        {
            GraphData graph = new GraphData();

            graph.AddContexts();

            var node = new BlockNode();

            node.Init(s_DescriptorA);
            graph.AddBlock(node, graph.fragmentContext, 0);

            Assert.AreEqual(0, graph.edges.Count());
            Assert.AreEqual(1, graph.GetNodes <BlockNode>().Count());
            Assert.AreEqual(1, graph.fragmentContext.blocks.Count());
        }
Ejemplo n.º 6
0
        public void CanCreateSlotFromCustomSlotBlockDescriptor()
        {
            var node = new BlockNode();

            node.Init(s_CustomSlotDescriptor);
            List <MaterialSlot> slots = new List <MaterialSlot>();

            node.GetSlots(slots);

            Assert.IsNotNull(slots);
            Assert.AreEqual(1, slots.Count);
            Assert.AreNotEqual(s_MaterialSlot, slots[0]); //We actually WANT to create a new slot in this case
            Assert.AreEqual(s_MaterialSlot.displayName, slots[0].displayName);
            Assert.AreEqual(s_MaterialSlot.valueType, slots[0].valueType);
            Assert.AreEqual(s_MaterialSlot.value, ((Vector3MaterialSlot)slots[0]).value);
        }
Ejemplo n.º 7
0
        public void CanInsertBlockNodeToContext()
        {
            GraphData graph = new GraphData();

            graph.AddContexts();

            var nodeA = new BlockNode();

            nodeA.Init(s_DescriptorA);
            graph.AddBlock(nodeA, graph.fragmentContext, 0);

            var nodeB = new BlockNode();

            nodeB.Init(s_DescriptorA);
            graph.AddBlock(nodeB, graph.fragmentContext, 0);

            Assert.AreEqual(0, graph.edges.Count());
            Assert.AreEqual(2, graph.GetNodes <BlockNode>().Count());
            Assert.AreEqual(2, graph.fragmentContext.blocks.Count());
            Assert.AreEqual(nodeB, graph.fragmentContext.blocks[0].value);
        }
Ejemplo n.º 8
0
        public void CanCreateSlotFromBlockDescriptor()
        {
            var node = new BlockNode();

            node.Init(s_DescriptorA);
            List <MaterialSlot> slots = new List <MaterialSlot>();

            node.GetSlots(slots);

            Assert.IsNotNull(slots);
            Assert.AreEqual(1, slots.Count);

            var vector3Slot = slots[0] as Vector1MaterialSlot;

            Assert.IsNotNull(vector3Slot);
            Assert.AreEqual(0, vector3Slot.id);
            Assert.AreEqual(s_DescriptorA.displayName, vector3Slot.RawDisplayName());
            Assert.AreEqual(s_DescriptorA.name, vector3Slot.shaderOutputName);
            Assert.AreEqual(SlotType.Input, vector3Slot.slotType);
            Assert.AreEqual(((FloatControl)s_DescriptorA.control).value, vector3Slot.value);
            Assert.AreEqual(s_DescriptorA.shaderStage.GetShaderStageCapability(), vector3Slot.stageCapability);
        }
Ejemplo n.º 9
0
        public void CanFilterBlockNodeByShaderStage()
        {
            GraphData graph = new GraphData();

            graph.AddContexts();

            var node = new BlockNode();

            node.Init(s_DescriptorA);

            var contextView = new ContextView("Test", graph.vertexContext, null);
            var methodInfo  = typeof(StackNode).GetMethod("AcceptsElement", BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(GraphElement), typeof(int).MakeByRefType(), typeof(int) }, null);

            Assert.IsNotNull(methodInfo);

            var acceptsElement = (bool)methodInfo.Invoke(contextView, new object[] { new MaterialNodeView()
                                                                                     {
                                                                                         userData = node
                                                                                     }, 0, 0 });

            Assert.IsFalse(acceptsElement);
        }