示例#1
0
        public static CubeNode Create()
        {
            RenderMethodBuilder blendBuilder, finalBuilder;
            {
                var vs       = new VertexShader(Shaders.initVert);
                var fs       = new FragmentShader(Shaders.initFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("vVertex", CubeModel.positions);
                blendBuilder = new RenderMethodBuilder(provider, map);
            }
            {
                var vs       = new VertexShader(Shaders.peelVert);// reuse blend vertex shader.
                var fs       = new FragmentShader(Shaders.peelFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("vVertex", CubeModel.positions);
                finalBuilder = new RenderMethodBuilder(provider, map);
            }

            var model = new CubeModel();
            var node  = new CubeNode(model, blendBuilder, finalBuilder);

            node.Initialize();

            return(node);
        }
示例#2
0
        public PeelingNode(Scene scene)
        {
            this.ShowDepthPeeling = true;

            this.query = new Query();

            {
                var colors = new vec4[] { new vec4(1, 0, 0, 0.5f), new vec4(0, 1, 0, 0.5f), new vec4(0, 0, 1, 0.5f) };

                var groupNode = new GroupNode();
                for (int k = -1; k < 2; k++)
                {
                    for (int j = -1; j < 2; j++)
                    {
                        int index = 0;
                        for (int i = -1; i < 2; i++)
                        {
                            vec3 worldPosition = new vec3(i * 2, j * 2, k * 2);
                            var  cubeNode      = CubeNode.Create();
                            cubeNode.WorldPosition = worldPosition;
                            cubeNode.Color         = colors[index++];

                            groupNode.Children.Add(cubeNode);
                        }
                    }
                }
                this.Children.Add(groupNode);

                this.cubeNodeGroup = groupNode;
            }
            {
                var quad = QuadNode.Create(scene);
                this.fullscreenQuad = quad;
            }
        }