public Chart2DSpriteContainer(SpriteSet<UVColorVertexData> sprites, FontGeometry fontGeo, VertexSurface<FastChart2DBarVertex> fastBarSurface = null) { this.line = (Sprite2DGeometry)sprites["line"].Geometry; this.point = (Sprite2DGeometry)sprites["point"].Geometry; this.surface = sprites.Surface; this.quadUV = sprites["quad"].Geometry.UV; this.font = fontGeo; this.ThinLineWidth = 0.015f; this.ThickLineWidth = 0.03f; this.SmallPointSize = 0.03f; this.LargePointSize = 0.1f; this.Color = Color.DeepPink; if (fastBarSurface != null) { this.fastBarSurface = fastBarSurface; this.fastBarSurface.AddSettings(sprites.Surface.Settings); this.fastBarSurface.AddSettings( new Vector2Uniform("uv01", this.quadUV.TopLeft), new Vector2Uniform("uv11", this.quadUV.TopRight), new Vector2Uniform("uv00", this.quadUV.BottomLeft), new Vector2Uniform("uv10", this.quadUV.BottomRight) ); } }
private void writeVertices <TVertexOut>( VertexSurface <TVertexOut> surface, Func <TVertex, TVertexOut> transform = null ) where TVertexOut : struct, IVertexData { ushort vOffset; var vertexArray = surface .WriteVerticesDirectly(this.vertices.Length, out vOffset); if (vOffset != 0) { throw new Exception("Expected vertex offset to be zero."); } if (transform == null) { this.vertices.CopyTo(vertexArray, 0); } else { for (int i = 0; i < this.vertices.Length; i++) { vertexArray[i] = transform(this.vertices[i]); } } }
public Chart2DSpriteContainer(SpriteSet <UVColorVertexData> sprites, FontGeometry fontGeo, VertexSurface <FastChart2DBarVertex> fastBarSurface = null) { this.line = (Sprite2DGeometry)sprites["line"].Geometry; this.point = (Sprite2DGeometry)sprites["point"].Geometry; this.surface = sprites.Surface; this.quadUV = sprites["quad"].Geometry.UV; this.font = fontGeo; this.ThinLineWidth = 0.015f; this.ThickLineWidth = 0.03f; this.SmallPointSize = 0.03f; this.LargePointSize = 0.1f; this.Color = Color.DeepPink; if (fastBarSurface != null) { this.fastBarSurface = fastBarSurface; this.fastBarSurface.AddSettings(sprites.Surface.Settings); this.fastBarSurface.AddSettings( new Vector2Uniform("uv01", this.quadUV.TopLeft), new Vector2Uniform("uv11", this.quadUV.TopRight), new Vector2Uniform("uv00", this.quadUV.BottomLeft), new Vector2Uniform("uv10", this.quadUV.BottomRight) ); } }
/// <summary> /// Constructor. /// </summary> public BoundsRenderer(Entity entity, Mesh mesh) : base(entity, mesh, new VertexSurface()) { m_surface = Surface as VertexSurface; ShaderProgram = ShaderManager.SHADER_UNLIT; BlendMode = BlendMode.Alpha; }
/// <summary> /// Converts the mesh into a renderable surface as a point cloud. Only vertices and no triangles are included. /// </summary> /// <param name="transform">A function to apply to all the vertices.</param> public VertexSurface <TVertexOut> ToPointCloudSurface <TVertexOut>( Func <TVertex, TVertexOut> transform = null ) where TVertexOut : struct, IVertexData { var surface = new VertexSurface <TVertexOut>(); this.writeVertices(surface, transform); return(surface); }
protected override void OnLoad(EventArgs e) { this.shaderMan = new ShaderManager(); var shaderLoader = ShaderFileLoader.CreateDefault("shaders"); // load all shaders var shaders = shaderLoader.Load("").ToList(); this.shaderMan.Add(shaders); var layerShader = this.shaderMan.MakeShaderProgram() .WithVertexShader("copy").WithFragmentShader("copy") .As("layer"); var copyShader = this.shaderMan.MakeShaderProgram() .WithVertexShader("post").WithFragmentShader("copy") .As("copypost"); var wispShader = this.shaderMan.MakeShaderProgram() .WithVertexShader("wisp").WithFragmentShader("wisp") .As("wisp"); var rayShader = this.shaderMan.MakeShaderProgram() .WithVertexShader("crepuscularrays") .WithGeometryShader("crepuscularrays") .WithFragmentShader("crepuscularrays") .As("crepuscularrays"); this.renderTexture = new Texture(1, 1); this.renderTexture.SetParameters(TextureMinFilter.Linear, TextureMagFilter.Linear, TextureWrapMode.ClampToBorder, TextureWrapMode.ClampToBorder); this.renderTarget = new RenderTarget(this.renderTexture); var renderTextureUniform = new TextureUniform("diffuseTexture", this.renderTexture); this.copyToScreen = new PostProcessSurface(); this.copyToScreen.AddSettings(renderTextureUniform, new ColorUniform("color", Color.White)); copyShader.UseOnSurface(this.copyToScreen); this.raySurface = new VertexSurface<CrepuscularRayVertex>(PrimitiveType.Points); this.raySurface.AddSettings(renderTextureUniform); rayShader.UseOnSurface(this.raySurface); var rayGeo = new CrepuscularRayGeometry(this.raySurface); const int layerCount = 4; const float maxBrightness = 0.03f; const float brightnessStep = maxBrightness / layerCount; this.layers = Enumerable.Range(0, layerCount).Reverse() .Select(i => new Layer(layerShader, wispShader, rayGeo, "layer" + i, GameMath.Sqrt(brightnessStep * i), i * i * 5)) .ToList(); InputManager.Initialize(this.Mouse); }
public CrepuscularRayGeometry(VertexSurface<CrepuscularRayVertex> surface) { this.surface = surface; }