Ejemplo n.º 1
0
        public static DrawModesNode Create(IBufferSource model, string position, string color, vec3 size)
        {
            RenderMethodBuilder smoothBulder, flatBuilder;
            var lineWidthSwitch = new LineWidthSwitch(7);
            {
                var vs    = new VertexShader(vertexCode);
                var fs    = new FragmentShader(fragmentCode);
                var array = new ShaderArray(vs, fs);
                var map   = new AttributeMap();
                map.Add("inPosition", position);
                map.Add("inColor", color);
                //var pointSizeSwitch = new PointSizeSwitch(7);
                smoothBulder = new RenderMethodBuilder(array, map, lineWidthSwitch);
            }
            {
                var vs    = new VertexShader(flatVertexCode);
                var fs    = new FragmentShader(flatFragmentCode);
                var array = new ShaderArray(vs, fs);
                var map   = new AttributeMap();
                map.Add("inPosition", position);
                map.Add("inColor", color);
                //var pointSizeSwitch = new PointSizeSwitch(7);
                flatBuilder = new RenderMethodBuilder(array, map, lineWidthSwitch);
            }
            var node = new DrawModesNode(model, position, smoothBulder, flatBuilder);

            node.Initialize();
            node.ModelSize = size;

            return(node);
        }
Ejemplo n.º 2
0
        public static OITNode Create(IBufferSource model, string position, string normal, vec3 size)
        {
            var builders = new RenderMethodBuilder[2];
            {
                var vs       = new VertexShader(buildListsVert, vPosition, vNormal);
                var fs       = new FragmentShader(buildListsFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add(vPosition, position);
                map.Add(vNormal, normal);
                builders[buildLists] = new RenderMethodBuilder(provider, map);
            }
            {
                var vs       = new VertexShader(resolveListsVert, vPosition, vNormal);
                var fs       = new FragmentShader(resolveListsFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add(vPosition, position);
                builders[resolveLists] = new RenderMethodBuilder(provider, map);
            }
            var node = new OITNode(model, position, builders);

            node.ModelSize = size;

            node.Initialize();

            return(node);
        }
Ejemplo n.º 3
0
        public static QuadNode Create()
        {
            RenderMethodBuilder blendBuilder, finalBuilder;
            {
                var vs       = new VertexShader(Shaders.blendVert);
                var fs       = new FragmentShader(Shaders.blendFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("vVertex", QuadModel.positions);
                blendBuilder = new RenderMethodBuilder(provider, map);
            }
            {
                var vs       = new VertexShader(Shaders.finalVert);// reuse blend vertex shader.
                var fs       = new FragmentShader(Shaders.finalFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("vVertex", QuadModel.positions);
                finalBuilder = new RenderMethodBuilder(provider, map);
            }

            var model = new QuadModel();
            var node  = new QuadNode(model, blendBuilder, finalBuilder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Render a teapot in modern opengl.
        /// </summary>
        /// <returns></returns>
        public static MultiTargetTeapotNode Create(bool adjacent = false)
        {
            IBufferSource model; vec3 size;

            if (adjacent)
            {
                var m = new AdjacentTeapot(); size = m.GetModelSize(); model = m;
            }
            else
            {
                var m = new Teapot(); size = m.GetModelSize(); model = m;
            }
            string position = adjacent ? AdjacentTeapot.strPosition : Teapot.strPosition;
            string color    = adjacent ? AdjacentTeapot.strColor : Teapot.strColor;

            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, position);
            map.Add(inColor, color);
            var builder = new RenderMethodBuilder(provider, map);
            var node    = new MultiTargetTeapotNode(model, position, builder);

            node.Initialize();
            node.ModelSize = size;

            return(node);
        }
Ejemplo n.º 5
0
        public static EdgeDetectNode Create()
        {
            RenderMethodBuilder compute, render;
            {
                var cs       = new CSharpGL.ComputeShader(computeShader);
                var provider = new ShaderArray(cs);
                var map      = new AttributeMap();
                compute = new RenderMethodBuilder(provider, map);
            }
            {
                var vs       = new VertexShader(vertexCode);
                var fs       = new FragmentShader(fragmentCode);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add(inPosition, RectangleModel.strPosition);
                map.Add(inUV, RectangleModel.strUV);
                render = new RenderMethodBuilder(provider, map);
            }

            var node = new EdgeDetectNode(new RectangleModel(), RectangleModel.strPosition, compute, render);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 6
0
        public static ParticleNode Create()
        {
            var blend = new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha);
            var depthTest = new DepthTestState(false);
            RenderMethodBuilder defaultBuilder, textureBuilder;
            {
                var vs       = new VertexShader(vert);
                var fs       = new FragmentShader(frag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                defaultBuilder = new RenderMethodBuilder(provider, map, blend, depthTest);
            }
            {
                var vs       = new VertexShader(vert);
                var fs       = new FragmentShader(texturedFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                textureBuilder = new RenderMethodBuilder(provider, map, blend, depthTest);
            }

            var model = new ParticleModel();
            var node  = new ParticleNode(model, defaultBuilder, textureBuilder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static RaycastingNode Create()
        {
            var model = new RaycastingModel();
            RenderMethodBuilder defaultBuilder, isosurfaceBuilder;
            {
                var vs       = new VertexShader(defaultVert);
                var fs       = new FragmentShader(defaultFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("vVertex", RaycastingModel.position);
                defaultBuilder = new RenderMethodBuilder(provider, map, new BlendSwitch(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha));
            }
            {
                var vs       = new VertexShader(isourfaceVert);
                var fs       = new FragmentShader(isosurfaceFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("vVertex", RaycastingModel.position);
                isosurfaceBuilder = new RenderMethodBuilder(provider, map, new BlendSwitch(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha));
            }

            var node = new RaycastingNode(model, defaultBuilder, isosurfaceBuilder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 8
0
        public static CubeNode Create()
        {
            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", CubeModel.positions);
                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", CubeModel.positions);
                peelBuilder = new RenderMethodBuilder(provider, map);
            }

            var model = new CubeModel();
            var node  = new CubeNode(model, initBuilder, peelBuilder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 9
0
        public static NoShadowNode Create(IBufferSource model, string position, string normal, vec3 size)
        {
            RenderMethodBuilder ambientBuilder, blinnPhongBuilder;
            {
                var vs    = new VertexShader(ambientVert);
                var fs    = new FragmentShader(ambientFrag);
                var array = new ShaderArray(vs, fs);
                var map   = new AttributeMap();
                map.Add("inPosition", position);
                ambientBuilder = new RenderMethodBuilder(array, map);
            }
            {
                var vs    = new VertexShader(blinnPhongVert);
                var fs    = new FragmentShader(blinnPhongFrag);
                var array = new ShaderArray(vs, fs);
                var map   = new AttributeMap();
                map.Add("inPosition", position);
                map.Add("inNormal", normal);
                blinnPhongBuilder = new RenderMethodBuilder(array, map);
            }

            var node = new NoShadowNode(model, ambientBuilder, blinnPhongBuilder);

            node.Initialize();
            node.ModelSize = size;

            return(node);
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static SimpleComputeNode Create()
        {
            var model = new SimpleCompute();
            RenderMethodBuilder reset, compute, render;
            {
                var cs       = new CSharpGL.ComputeShader(resetCompute);
                var map      = new AttributeMap();
                var provider = new ShaderArray(cs);
                reset = new RenderMethodBuilder(provider, map);
            }
            {
                var cs       = new CSharpGL.ComputeShader(computeShader);
                var map      = new AttributeMap();
                var provider = new ShaderArray(cs);
                compute = new RenderMethodBuilder(provider, map);
            }
            {
                var vs       = new VertexShader(renderVert);
                var fs       = new FragmentShader(renderFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("position", SimpleCompute.strPosition);
                render = new RenderMethodBuilder(provider, map);
            }

            var node = new SimpleComputeNode(model, reset, compute, render);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static RaycastNode Create()
        {
            var model = new BoundingBoxModel();
            RenderMethodBuilder backfaceBuilder, raycastingBuilder;
            {
                var vs       = new VertexShader(backfaceVert);
                var fs       = new FragmentShader(backfaceFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("position", BoundingBoxModel.strPosition);
                map.Add("boundingBox", BoundingBoxModel.strColor);
                backfaceBuilder = new RenderMethodBuilder(provider, map, new CullFaceSwitch(CullFaceMode.Front, true));
            }
            {
                var vs       = new VertexShader(raycastingVert);
                var fs       = new FragmentShader(raycastingFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("position", BoundingBoxModel.strPosition);
                map.Add("boundingBox", BoundingBoxModel.strColor);
                raycastingBuilder = new RenderMethodBuilder(provider, map, new CullFaceSwitch(CullFaceMode.Back, true));
            }

            var node = new RaycastNode(model, BoundingBoxModel.strPosition, backfaceBuilder, raycastingBuilder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 12
0
        public static PerspectiveNode Create()
        {
            // vertex buffer and index buffer.
            var model = new PerspectiveModel((float)(60.0 * Math.PI / 180.0), 1, 0.5f, 10);
            // vertex shader and fragment shader.
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            // which vertex buffer maps to which attribute in shader.
            var map = new AttributeMap();

            map.Add("inPosition", PerspectiveModel.strPosition);
            // build a render method.
            //var cullfaceSwitch = new CullFaceSwitch(CullFaceMode.Back);
            var polygonModeSwitch = new PolygonModeSwitch(PolygonMode.Line);
            var lineWidthSwitch   = new LineWidthSwitch(5);
            var builder           = new RenderMethodBuilder(array, map, polygonModeSwitch, lineWidthSwitch);
            // create node.
            var node = new PerspectiveNode(model, builder);

            // initialize node.
            node.Initialize();

            return(node);
        }
Ejemplo n.º 13
0
        public static EnvironmentMappingNode Create(Texture skybox,
                                                    IBufferSource model, string position, string normal)
        {
            RenderMethodBuilder reflectBuilder, refractBuilder;
            {
                var vs       = new VertexShader(vertexCode);
                var fs       = new FragmentShader(reflectFragmentCode);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add(inPosition, position);
                map.Add(inNormal, normal);
                reflectBuilder = new RenderMethodBuilder(provider, map);
            }
            {
                var vs       = new VertexShader(vertexCode);
                var fs       = new FragmentShader(refractFragmentCode);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add(inPosition, position);
                map.Add(inNormal, normal);
                refractBuilder = new RenderMethodBuilder(provider, map);
            }
            var node = new EnvironmentMappingNode(model, Teapot.strPosition, reflectBuilder, refractBuilder);

            node.skyboxTexture = skybox;

            node.Initialize();

            return(node);
        }
Ejemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static SlicesNode Create()
        {
            var model = new SlicesModel();
            RenderMethodBuilder defaultBuilder, classificationBuilder;
            {
                var vs       = new VertexShader(defaultVert);
                var fs       = new FragmentShader(defaultFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("vVertex", SlicesModel.position);
                defaultBuilder = new RenderMethodBuilder(provider, map, new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha));
            }
            {
                var vs       = new VertexShader(classificationVert);
                var fs       = new FragmentShader(classificationFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("vVertex", SlicesModel.position);
                classificationBuilder = new RenderMethodBuilder(provider, map, new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha));
            }

            var node = new SlicesNode(model, defaultBuilder, classificationBuilder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 15
0
        public static CubeNode Create(IBufferSource model, string positionNameInIBufferSource)
        {
            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("inPosiiton", 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("inPosiiton", positionNameInIBufferSource);
                peelBuilder = new RenderMethodBuilder(provider, map);
            }

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

            node.Initialize();

            return(node);
        }
Ejemplo n.º 16
0
        public static PointsNode Create(IBufferSource model, string position, string color, vec3 size)
        {
            RenderMethodBuilder randomBuilder, gl_VertexIDBuilder;
            {
                var vs    = new VertexShader(randomVert);
                var fs    = new FragmentShader(randomFrag);
                var array = new ShaderArray(vs, fs);
                var map   = new AttributeMap();
                map.Add("inPosition", position);
                map.Add("inColor", color);
                randomBuilder = new RenderMethodBuilder(array, map);
            }
            {
                var vs    = new VertexShader(gl_VertexIDVert);
                var fs    = new FragmentShader(gl_VertexIDFrag);
                var array = new ShaderArray(vs, fs);
                var map   = new AttributeMap();
                map.Add("inPosition", position);
                gl_VertexIDBuilder = new RenderMethodBuilder(array, map);
            }

            var node = new PointsNode(model, position, randomBuilder, gl_VertexIDBuilder);

            node.Initialize();
            node.ModelSize = size;

            return(node);
        }
Ejemplo n.º 17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="position"></param>
        /// <param name="normal"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static NormalNode Create(IBufferSource model, string position, string normal, vec3 size)
        {
            var builders = new RenderMethodBuilder[2];
            {
                // render model
                var vs       = new VertexShader(vertexShader, vPosition, vNormal);
                var fs       = new FragmentShader(fragmentShader);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add(vPosition, position);
                map.Add(vNormal, normal);
                builders[0] = new RenderMethodBuilder(provider, map);
            }
            {
                // render normal
                var vs       = new VertexShader(normalVertex, vPosition, vNormal);
                var gs       = new GeometryShader(normalGeometry);
                var fs       = new FragmentShader(normalFragment);
                var provider = new ShaderArray(vs, gs, fs);
                var map      = new AttributeMap();
                map.Add(vPosition, position);
                map.Add(vNormal, normal);
                builders[1] = new RenderMethodBuilder(provider, map);
            }

            var node = new NormalNode(model, position, builders);

            node.ModelSize = size;

            node.Initialize();

            return(node);
        }
Ejemplo n.º 18
0
        public static IntersectionNode Create()
        {
            // vertex buffer and index buffer.
            var model = new IntersectionModel();
            // vertex shader and fragment shader.
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            // which vertex buffer maps to which attribute in shader.
            var map = new AttributeMap();

            map.Add("inPosition", IntersectionModel.strPosition);
            // build a render method.
            var polygonModeSwitch = new PolygonModeSwitch(PolygonMode.Line);
            var lineWidthSwitch   = new LineWidthSwitch(5);
            var offsetSwitch      = new PolygonOffsetFillSwitch();
            var builder           = new RenderMethodBuilder(array, map, offsetSwitch, polygonModeSwitch, lineWidthSwitch);
            // create node.
            var node = new IntersectionNode(model, builder);

            // initialize node.
            node.Initialize();

            return(node);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Render teapot to framebuffer in modern opengl.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="position"></param>
        /// <param name="normal"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static ShadowMappingNode Create(IBufferSource model, string position, string normal, vec3 size)
        {
            RenderMethodBuilder shadowBuilder, lightBuilder;
            {
                var vs       = new VertexShader(shadowVertexCode);
                var provider = new ShaderArray(vs);
                var map      = new AttributeMap();
                map.Add(inPosition, position);
                shadowBuilder = new RenderMethodBuilder(provider, map);
            }
            {
                var vs       = new VertexShader(lightVertexCode);
                var fs       = new FragmentShader(lightFragmentCode);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add(inPosition, position);
                map.Add(inNormal, normal);
                lightBuilder = new RenderMethodBuilder(provider, map);
            }
            var node = new ShadowMappingNode(model, position, shadowBuilder, lightBuilder);

            node.ModelSize = size;
            node.Initialize();

            return(node);
        }
Ejemplo n.º 20
0
        public static ClearStencilNode Create()
        {
            var model   = new ClearStencilModel();
            var vs      = new VertexShader(vertexCode);
            var fs      = new FragmentShader(fragmentCode);
            var array   = new ShaderArray(vs, fs);
            var map     = new AttributeMap();
            var builder = new RenderMethodBuilder(array, map);
            var node    = new ClearStencilNode(model, builder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 21
0
        public static NodePointNode Create(NodePointModel model)
        {
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add("inPosition", NodePointModel.strPosition);
            var builder = new RenderMethodBuilder(array, map);
            var node    = new NodePointNode(model, builder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Render propeller in modern opengl.
        /// </summary>
        /// <returns></returns>
        public static RectNode Create()
        {
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, RectModel.strPosition);
            var builder = new RenderMethodBuilder(provider, map);
            var node    = new RectNode(new RectModel(), RectModel.strPosition, builder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 23
0
        public static FullScreenNode Create(ITextureSource textureSource)
        {
            var model             = new FullScreenModel();
            var map               = new AttributeMap();
            var vs                = new VertexShader(secondPassVert);
            var fs                = new FragmentShader(secondPassFrag);
            var array             = new ShaderArray(vs, fs);
            var secondPassBuilder = new RenderMethodBuilder(array, map);
            var node              = new FullScreenNode(model, secondPassBuilder);

            node.textureSource = textureSource;
            node.Initialize();

            return(node);
        }
Ejemplo n.º 24
0
        public static ZeroAttributeNode Create()
        {
            var vs       = new VertexShader(vertexShader);// not attribute in vertex shader.
            var fs       = new FragmentShader(fragmentShader);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();// no items in this map.
            var builder  = new RenderMethodBuilder(provider, map, new PointSpriteSwitch());
            var model    = new ZeroAttributeModel(DrawMode.TriangleStrip, 0, 4);
            var node     = new ZeroAttributeNode(model, builder);

            node.ModelSize = new vec3(2.05f, 2.05f, 0.01f);
            node.Initialize();

            return(node);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Render propeller in modern opengl.
        /// </summary>
        /// <returns></returns>
        public static LightPositionNode Create()
        {
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, CubeModel.strPosition);
            var builder = new RenderMethodBuilder(provider, map, new PolygonModeState(PolygonMode.Line), new LineWidthState(3));
            var node    = new LightPositionNode(new CubeModel(), CubeModel.strPosition, builder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 26
0
        public static ParticleNode Create(int particleCount)
        {
            IShaderProgramProvider updateProvider, renderProvider;
            {
                var vs = new VertexShader(updateVert);
                var feedbackVaryings = new string[] { outPosition, outVelocity };
                updateProvider = new ShaderArray(feedbackVaryings, ShaderProgram.BufferMode.Separate, vs);
            }
            {
                var vs = new VertexShader(renderVert);
                var gs = new GeometryShader(renderGeom);
                var fs = new FragmentShader(renderFrag);
                renderProvider = new ShaderArray(vs, gs, fs);
            }
            RenderMethodBuilder updateBuilder, updateBuilder2, renderBuilder, renderBuilder2;
            var blend = new BlendSwitch(BlendEquationMode.Add, BlendSrcFactor.One, BlendDestFactor.One);
            {
                var map = new AttributeMap();
                map.Add(inPosition, ParticleModel.inPosition);
                map.Add(inVelocity, ParticleModel.inVelocity);
                updateBuilder = new RenderMethodBuilder(updateProvider, map);
            }
            {
                var map = new AttributeMap();
                map.Add(inPosition, ParticleModel.inPosition2);
                map.Add(inVelocity, ParticleModel.inVelocity2);
                updateBuilder2 = new RenderMethodBuilder(updateProvider, map);
            }
            {
                var map = new AttributeMap();
                map.Add(inPosition, ParticleModel.inPosition);
                map.Add(inVelocity, ParticleModel.inVelocity);
                renderBuilder = new RenderMethodBuilder(renderProvider, map, blend);
            }
            {
                var map = new AttributeMap();
                map.Add(inPosition, ParticleModel.inPosition2);
                map.Add(inVelocity, ParticleModel.inVelocity2);
                renderBuilder2 = new RenderMethodBuilder(renderProvider, map, blend);
            }

            var model = new ParticleModel(particleCount);
            var node  = new ParticleNode(model, updateBuilder, updateBuilder2, renderBuilder, renderBuilder2);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Creates a <see cref="LightPositionNode"/> which displays and updates light's position.
        /// </summary>
        /// <param name="light"></param>
        /// <param name="initAngle"></param>
        /// <returns></returns>
        public static SphereNode Create()
        {
            var model    = new Sphere(1f, 10, 15);
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, Sphere.strPosition);
            var builder = new RenderMethodBuilder(provider, map, new PolygonModeSwitch(PolygonMode.Line));
            var node    = new SphereNode(model, Sphere.strPosition, builder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="totalBmp"></param>
        /// <returns></returns>
        public static SkyboxNode Create(Bitmap totalBmp)
        {
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, Skybox.strPosition);
            var builder = new RenderMethodBuilder(provider, map, new CullFaceSwitch(CullFaceMode.Front));
            var model   = new Skybox();
            var node    = new SkyboxNode(model, Skybox.strPosition, totalBmp, builder);

            node.Initialize();
            node.Scale = new vec3(9000000, 9000000, 9000000);
            return(node);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// render many cubes in regular way.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static ManyCubesNode0 Create(ManyCubesModel model)
        {
            var map = new AttributeMap();

            map.Add("vPosition", ManyCubesModel.strPosition);
            map.Add("vColor", ManyCubesModel.strColor);
            var vs               = new VertexShader(regularVert);
            var fs               = new FragmentShader(regularFrag);
            var array            = new ShaderArray(vs, fs);
            var firstPassBuilder = new RenderMethodBuilder(array, map);
            var node             = new ManyCubesNode0(model, firstPassBuilder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Render propeller in modern opengl.
        /// </summary>
        /// <param name="direction"></param>
        /// <returns></returns>
        public static LineNode Create(vec3 direction)
        {
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, LineModel.strPosition);
            var lineWidthSwitch = new LineWidthSwitch(10);
            var builder         = new RenderMethodBuilder(provider, map, lineWidthSwitch);
            var node            = new LineNode(new LineModel(direction), builder);

            node.Initialize();

            return(node);
        }