Esempio n. 1
0
        public static CubeMapNode Create(IBufferSource model, string positionNameInIBufferSource, Texture cubemapTexture)
        {
            RenderMethodBuilder initBuilder, peelBuilder;
            {
                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", positionNameInIBufferSource);
                initBuilder = 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", positionNameInIBufferSource);
                peelBuilder = new RenderMethodBuilder(provider, map);
            }

            var node = new CubeMapNode(model, initBuilder, peelBuilder);

            node.SetTexture(cubemapTexture);
            node.Initialize();

            return(node);
        }
Esempio n. 2
0
        private SceneNodeBase GetTree()
        {
            var children = new List <SceneNodeBase>();
            {
                var     bitmap         = new Bitmap(@"cubemaps_skybox.png");
                Texture cubemapTexture = GetCubemapTexture(bitmap);
                bitmap.Dispose();
                var cubeMapNode = CubeMapNode.Create(new CubeModel(), CubeModel.strPosition, cubemapTexture);
                children.Add(cubeMapNode);
            }
            //{
            //    var bitmap = new Bitmap(@"cubemaps_skybox2.png");
            //    Texture cubemapTexture = GetCubemapTexture(bitmap);
            //    bitmap.Dispose();
            //    var cubeMapNode = CubeMapNode.Create(new CubeModel(), CubeModel.strPosition, cubemapTexture);
            //    cubeMapNode.Scale = new vec3(1, 1, 1) * 0.999f;
            //    children.Add(cubeMapNode);
            //}
            {
                var     bitmap         = new Bitmap(@"cube_skybox.png");
                Texture cubemapTexture = GetCubemapTexture(bitmap);
                bitmap.Dispose();
                var cubeMapNode       = CubeMapNode.Create(new CubeModel(), CubeModel.strPosition, cubemapTexture);
                var polygonModeSwitch = new PolygonModeSwitch(PolygonMode.Line);
                var lineWidthSwitch   = new LineWidthSwitch(1);
                cubeMapNode.RenderUnit.Methods[0].SwitchList.Add(polygonModeSwitch);
                cubeMapNode.RenderUnit.Methods[0].SwitchList.Add(lineWidthSwitch);
                cubeMapNode.RenderUnit.Methods[1].SwitchList.Add(polygonModeSwitch);
                cubeMapNode.RenderUnit.Methods[1].SwitchList.Add(lineWidthSwitch);
                children.Add(cubeMapNode);
            }
            {
                var     bitmap         = new Bitmap(@"cube_skybox.png");
                Texture cubemapTexture = GetCubemapTexture(bitmap);
                bitmap.Dispose();
                var cubeMapNode       = CubeMapNode.Create(new GroundModel(length: 4), CubeModel.strPosition, cubemapTexture);
                var polygonModeSwitch = new PolygonModeSwitch(PolygonMode.Line);
                var lineWidthSwitch   = new LineWidthSwitch(1);
                cubeMapNode.RenderUnit.Methods[0].SwitchList.Add(polygonModeSwitch);
                cubeMapNode.RenderUnit.Methods[0].SwitchList.Add(lineWidthSwitch);
                cubeMapNode.RenderUnit.Methods[1].SwitchList.Add(polygonModeSwitch);
                cubeMapNode.RenderUnit.Methods[1].SwitchList.Add(lineWidthSwitch);
                children.Add(cubeMapNode);
            }
            var peelingNode = new PeelingNode(children.ToArray());

            return(peelingNode);
        }