Exemple #1
0
        private SceneNodeBase GetRootElement()
        {
            //var lightPosition = new vec3(0, 3, 5) * 2;
            //var localLight = new SpotLight(lightPosition, new vec3(0, 0, 0), 60, 1, 500) { Color = new vec3(1, 1, 1), };
            //var lightContainer = new LightContainerNode(localLight);
            var group = new GroupNode();

            {
                {
                    var teapot = DepthTeapotNode.Create();
                    teapot.RotateSpeed = 1;
                    group.Children.Add(teapot);
                    //lightContainer.Children.Add(teapot);
                }
                {
                    var ground = DepthGroundNode.Create();
                    ground.Color         = Color.Gray.ToVec4();
                    ground.Scale        *= 30;
                    ground.WorldPosition = new vec3(0, -3, 0);
                    group.Children.Add(ground);
                    //lightContainer.Children.Add(ground);
                }
            }

            //var rectangle = RectangleNode.Create();
            //rectangle.TextureSource = localLight;

            //group.Children.Add(lightContainer);
            //group.Children.Add(rectangle);

            return(group);
        }
Exemple #2
0
        // this fragment shader is not needed.
        //        private const string fragmentCode =
        //            @"#version 330 core
        //
        //out float fragmentdepth;
        //
        //void main(void) {
        //    fragmentdepth = gl_FragCoord.z;
        //}
        //";

        /// <summary>
        /// Render teapot to framebuffer in modern opengl.
        /// </summary>
        /// <returns></returns>
        public static DepthTeapotNode Create()
        {
            RenderMethodBuilder shadowmapBuilder;
            {
                var vs       = new VertexShader(vertexCode);
                var provider = new ShaderArray(vs);
                var map      = new AttributeMap();
                map.Add(inPosition, Teapot.strPosition);
                shadowmapBuilder = new RenderMethodBuilder(provider, map);
            }
            var model = new Teapot();
            var node  = new DepthTeapotNode(model, shadowmapBuilder);

            node.Initialize();

            return(node);
        }