public static SurfaceWrapper <T> WithShader <T>(this T surface, ISurfaceShader shader) where T : Surface { if (shader == null) { throw new Exception("Shader not found"); } shader.UseOnSurface(surface); return(new SurfaceWrapper <T>(surface)); }
public SpriteSet(ISurfaceShader shaderProgram, SurfaceSetting[] surfaceSettings) { this.sprites = new Dictionary <string, Sprite <TVertexData> >(); this.surface = new IndexedSurface <TVertexData>(); if (surfaceSettings != null) { this.surface.AddSettings(surfaceSettings); } if (shaderProgram != null) { shaderProgram.UseOnSurface(this.surface); } }
public Layer(ISurfaceShader shader, ISurfaceShader wispShader, CrepuscularRayGeometry rayGeo, string filename, float brightness, int wisps) { this.rayGeo = rayGeo; var texture = new Texture("gfx/" + filename + ".png", true); this.surface = new PostProcessSurface(); this.surface.AddSettings( new TextureUniform("diffuseTexture", texture), new ColorUniform("color", Color.GrayScale((byte)(255 * brightness))) ); shader.UseOnSurface(this.surface); this.wispSurface = new IndexedSurface<UVColorVertexData>(); wispShader.UseOnSurface(this.wispSurface); this.wispGeo = new Sprite2DGeometry(this.wispSurface) { Color = Color.White.WithAlpha() }; this.wisps = Enumerable.Range(0, wisps) .Select(i => new Wisp()).ToList(); }