public static EdgeDetectNode Create() { RenderUnitBuilder compute, render; { var cs = new CSharpGL.ComputeShader(computeShader); var provider = new ShaderArray(cs); var map = new AttributeMap(); compute = new RenderUnitBuilder(provider, map); } { var vs = new VertexShader(vertexCode, inPosition, inUV); 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 RenderUnitBuilder(provider, map); } var node = new EdgeDetectNode(new RectangleModel(), RectangleModel.strPosition, compute, render); node.Initialize(); return(node); }
public static ParticleNode Create() { var blend = new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha); var depthTest = new DepthTestState(false); RenderUnitBuilder defaultBuilder, textureBuilder; { var vs = new VertexShader(vert); var fs = new FragmentShader(frag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); defaultBuilder = new RenderUnitBuilder(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 RenderUnitBuilder(provider, map, blend, depthTest); } var model = new ParticleModel(); var node = new ParticleNode(model, defaultBuilder, textureBuilder); node.Initialize(); return(node); }
/// <summary> /// /// </summary> /// <returns></returns> public static RaycastingNode Create() { var model = new RaycastingModel(); RenderUnitBuilder defaultBuilder, isosurfaceBuilder; { var vs = new VertexShader(defaultVert, "vVertex"); var fs = new FragmentShader(defaultFrag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add("vVertex", RaycastingModel.position); defaultBuilder = new RenderUnitBuilder(provider, map, new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha)); } { var vs = new VertexShader(isourfaceVert, "vVertex"); var fs = new FragmentShader(isosurfaceFrag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add("vVertex", RaycastingModel.position); isosurfaceBuilder = new RenderUnitBuilder(provider, map, new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha)); } var node = new RaycastingNode(model, defaultBuilder, isosurfaceBuilder); node.Initialize(); return(node); }
/// <summary> /// /// </summary> /// <returns></returns> public static SimpleComputeNode Create() { var model = new SimpleCompute(); RenderUnitBuilder reset, compute, render; { var cs = new CSharpGL.ComputeShader(resetCompute); var map = new AttributeMap(); var provider = new ShaderArray(cs); reset = new RenderUnitBuilder(provider, map); } { var cs = new CSharpGL.ComputeShader(computeShader); var map = new AttributeMap(); var provider = new ShaderArray(cs); compute = new RenderUnitBuilder(provider, map); } { var vs = new VertexShader(renderVert, "position"); var fs = new FragmentShader(renderFrag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add("position", SimpleCompute.strPosition); render = new RenderUnitBuilder(provider, map); } var node = new SimpleComputeNode(model, reset, compute, render); node.Initialize(); return(node); }
/// <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) { RenderUnitBuilder shadowBuilder, lightBuilder; { var vs = new VertexShader(shadowVertexCode, inPosition); var provider = new ShaderArray(vs); var map = new AttributeMap(); map.Add(inPosition, position); shadowBuilder = new RenderUnitBuilder(provider, map); } { var vs = new VertexShader(lightVertexCode, inPosition, inNormal); 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 RenderUnitBuilder(provider, map); } var node = new ShadowMappingNode(model, position, shadowBuilder, lightBuilder); node.ModelSize = size; node.Initialize(); return(node); }
public static OITNode Create(IBufferSource model, string position, string normal, vec3 size) { var builders = new RenderUnitBuilder[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 RenderUnitBuilder(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 RenderUnitBuilder(provider, map); } var node = new OITNode(model, position, builders); node.ModelSize = size; node.Initialize(); return(node); }
public static EnvironmentMappingNode Create(Texture skybox, IBufferSource model, string position, string normal) { RenderUnitBuilder reflectBuilder, refractBuilder; { var vs = new VertexShader(vertexCode, inPosition, inNormal); 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 RenderUnitBuilder(provider, map); } { var vs = new VertexShader(vertexCode, inPosition, inNormal); 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 RenderUnitBuilder(provider, map); } var node = new EnvironmentMappingNode(model, Teapot.strPosition, reflectBuilder, refractBuilder); node.skyboxTexture = skybox; node.Initialize(); return(node); }
/// <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 RenderUnitBuilder[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 RenderUnitBuilder(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 RenderUnitBuilder(provider, map); } var node = new NormalNode(model, position, builders); node.ModelSize = size; node.Initialize(); return(node); }
/// <summary> /// /// </summary> /// <returns></returns> public static RaycastNode Create() { var model = new RaycastModel(); RenderUnitBuilder backfaceBuilder, raycastingBuilder; { var vs = new VertexShader(backfaceVert, "position", "boundingBox"); var fs = new FragmentShader(backfaceFrag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add("position", RaycastModel.strposition); map.Add("boundingBox", RaycastModel.strcolor); backfaceBuilder = new RenderUnitBuilder(provider, map, new CullFaceState(CullFaceMode.Front, true)); } { var vs = new VertexShader(raycastingVert, "position", "boundingBox"); var fs = new FragmentShader(raycastingFrag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add("position", RaycastModel.strposition); map.Add("boundingBox", RaycastModel.strcolor); raycastingBuilder = new RenderUnitBuilder(provider, map, new CullFaceState(CullFaceMode.Back, true)); } var node = new RaycastNode(model, RaycastModel.strposition, backfaceBuilder, raycastingBuilder); node.Initialize(); return(node); }
/// <summary> /// Render propeller in modern opengl. /// </summary> /// <returns></returns> public static LightPostionNode Create() { var vs = new VertexShader(vertexCode, inPosition); var fs = new FragmentShader(fragmentCode); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add(inPosition, CubeModel.strPosition); var builder = new RenderUnitBuilder(provider, map, new PolygonModeState(PolygonMode.Line), new LineWidthState(3)); var node = new LightPostionNode(new CubeModel(), CubeModel.strPosition, builder); node.Initialize(); return(node); }
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 RenderUnitBuilder(provider, map, new PointSpriteState()); 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); }
/// <summary> /// /// </summary> /// <param name="totalBmp"></param> /// <returns></returns> public static SkyboxNode Create(Bitmap totalBmp) { var vs = new VertexShader(vertexCode, inPosition); var fs = new FragmentShader(fragmentCode); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add(inPosition, Skybox.strPosition); var builder = new RenderUnitBuilder(provider, map, new CullFaceState(CullFaceMode.Front)); var model = new Skybox(); var node = new SkyboxNode(model, Skybox.strPosition, totalBmp, builder); node.Initialize(); return(node); }
public static ParticleDemoNode Create(int particleCount) { IShaderProgramProvider updateProvider, renderProvider; { var vs = new VertexShader(updateVert, inPosition, inVelocity); var feedbackVaryings = new string[] { outPosition, outVelocity }; updateProvider = new ShaderArray(feedbackVaryings, ShaderProgram.BufferMode.Separate, vs); } { var vs = new VertexShader(renderVert, vposition); var gs = new GeometryShader(renderGeom); var fs = new FragmentShader(renderFrag); renderProvider = new ShaderArray(vs, gs, fs); } RenderUnitBuilder updateBuilder, updateBuilder2, renderBuilder, renderBuilder2; var blend = new BlendState(BlendingSourceFactor.One, BlendingDestinationFactor.One); { var map = new AttributeMap(); map.Add(inPosition, ParticleDemoModel.inPosition); map.Add(inVelocity, ParticleDemoModel.inVelocity); updateBuilder = new RenderUnitBuilder(updateProvider, map); } { var map = new AttributeMap(); map.Add(inPosition, ParticleDemoModel.inPosition2); map.Add(inVelocity, ParticleDemoModel.inVelocity2); updateBuilder2 = new RenderUnitBuilder(updateProvider, map); } { var map = new AttributeMap(); map.Add(vposition, ParticleDemoModel.inPosition); renderBuilder = new RenderUnitBuilder(renderProvider, map, blend); } { var map = new AttributeMap(); map.Add(vposition, ParticleDemoModel.inPosition2); renderBuilder2 = new RenderUnitBuilder(renderProvider, map, blend); } var model = new ParticleDemoModel(particleCount); var node = new ParticleDemoNode(model, updateBuilder, updateBuilder2, renderBuilder, renderBuilder2); node.Initialize(); return(node); }
public static DemoNode Create() { IShaderProgramProvider updateProvider, renderProvider; { var vs = new VertexShader(updateVert, inPosition, inVelocity); var feedbackVaryings = new string[] { outPosition, outVelocity }; updateProvider = new ShaderArray(feedbackVaryings, ShaderProgram.BufferMode.Separate, vs); } { var vs = new VertexShader(renderVert, inPosition); var fs = new FragmentShader(renderFrag); renderProvider = new ShaderArray(vs, fs); } RenderUnitBuilder updateBuilder, updateBuilder2, renderBuilder, renderBuilder2; { var map = new AttributeMap(); map.Add(inPosition, DemoModel.inPosition); map.Add(inVelocity, DemoModel.inVelocity); updateBuilder = new RenderUnitBuilder(updateProvider, map); } { var map = new AttributeMap(); map.Add(inPosition, DemoModel.inPosition2); map.Add(inVelocity, DemoModel.inVelocity2); updateBuilder2 = new RenderUnitBuilder(updateProvider, map); } { var map = new AttributeMap(); map.Add(inPosition, DemoModel.inPosition); map.Add(inVelocity, DemoModel.inVelocity); renderBuilder = new RenderUnitBuilder(renderProvider, map); } { var map = new AttributeMap(); map.Add(inPosition, DemoModel.inPosition2); map.Add(inVelocity, DemoModel.inVelocity2); renderBuilder2 = new RenderUnitBuilder(renderProvider, map); } var model = new DemoModel(); var node = new DemoNode(model, updateBuilder, updateBuilder2, renderBuilder, renderBuilder2); node.Initialize(); return(node); }
// this fragment shader is not needed. // private const string fragmentCode = // @"#version 330 core // //layout(location = 0) out float fragmentdepth; ////out vec4 out_Color; // //void main(void) { // fragmentdepth = gl_FragCoord.z; // //} //"; /// <summary> /// Render teapot to framebuffer in modern opengl. /// </summary> /// <returns></returns> public static DepthTeapotNode Create() { RenderUnitBuilder shadowmapBuilder; { var vs = new VertexShader(vertexCode, inPosition); var provider = new ShaderArray(vs); var map = new AttributeMap(); map.Add(inPosition, Teapot.strPosition); shadowmapBuilder = new RenderUnitBuilder(provider, map); } var model = new Teapot(); var node = new DepthTeapotNode(model, shadowmapBuilder); node.Initialize(); return(node); }
public static GrayFilterNode Create() { var model = new GrayFilterModel(); var vs = new VertexShader(renderVert, "a_vertex", "a_texCoord"); var fs = new FragmentShader(renderFrag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add("a_vertex", GrayFilterModel.position); map.Add("a_texCoord", GrayFilterModel.texCoord); var builder = new RenderUnitBuilder(provider, map); var node = new GrayFilterNode(model, GrayFilterModel.position, builder); node.Initialize(); return(node); }
/// <summary> /// /// </summary> /// <returns></returns> public static TerainNode Create() { var model = new TerainModel(); RenderUnitBuilder defaultBuilder; { var vs = new VertexShader(vert, "vVertex"); var fs = new FragmentShader(frag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); defaultBuilder = new RenderUnitBuilder(provider, map, new PolygonModeState(PolygonMode.Line)); } var node = new TerainNode(model, defaultBuilder); node.Initialize(); return(node); }
/// <summary> /// /// </summary> /// <param name="totalBmp"></param> /// <returns></returns> public static SkyboxNode Create(Bitmap[] bitmaps) { var vs = new VertexShader(vertexCode, inPosition); var fs = new FragmentShader(fragmentCode); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add(inPosition, Skybox.strPosition); var cullface = new CullFaceState(CullFaceMode.Back);// display back faces only. var builder = new RenderUnitBuilder(provider, map, cullface); var model = new Skybox(); var node = new SkyboxNode(model, Skybox.strPosition, bitmaps, builder); node.EnablePicking = TwoFlags.Children;// sky box should not take part in picking. node.Initialize(); return(node); }
public static SimplexNoiseNode Create() { var model = new Sphere(1, 180, 360); RenderUnitBuilder renderBuilder; { var vs = new VertexShader(renderVert, "in_Position"); var fs = new FragmentShader(renderFrag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add("in_Position", Sphere.strPosition); renderBuilder = new RenderUnitBuilder(provider, map); } var node = new SimplexNoiseNode(model, Sphere.strPosition, renderBuilder); node.ModelSize = model.Size; node.Initialize(); return(node); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="position"></param> /// <param name="normal"></param> /// <param name="size"></param> /// <returns></returns> public static DirectionalLightNode Create(CSharpGL.DirectionalLight light, IBufferSource model, string position, string normal, vec3 size) { var vs = new VertexShader(directionalLightVert, vPosition, vNormal); var fs = new FragmentShader(directionalLightFrag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add(vPosition, position); map.Add(vNormal, normal); var builder = new RenderUnitBuilder(provider, map); var node = new DirectionalLightNode(model, position, builder); node.Light = light; node.ModelSize = size; node.Children.Add(new LegacyBoundingBoxNode(size)); node.Initialize(); return(node); }
public static BasicTessellationNode Create(ObjVNF model) { var vs = new VertexShader(renderVert, "Position_VS_in", "TexCoord_VS_in", "Normal_VS_in"); var tc = new TessControlShader(renderTesc); var te = new TessEvaluationShader(renderTese); var fs = new FragmentShader(renderFrag); var provider = new ShaderArray(vs, tc, te, fs); var map = new AttributeMap(); map.Add("Position_VS_in", ObjVNF.strPosition); map.Add("TexCoord_VS_in", ObjVNF.strTexCoord); map.Add("Normal_VS_in", ObjVNF.strNormal); var builder = new RenderUnitBuilder(provider, map); var node = new BasicTessellationNode(model, builder); node.ModelSize = model.GetSize(); node.Initialize(); return(node); }