import { Matrix } from "../math/matrix" ; import { Vector2 } from "../math/vector2" ; import { Vector4 } from "../math/vector4" ; import { Color } from "./color" ; import { Vertex } from "./vertex" ; export interface VertexInput { viewProject : Matrix ; } export interface FragmentInput { x : number ; y : number ; color ? : Color ; varyingVec2Dict ? : { [ k ] : Vector2 ; } ; varyingVec4Dict ? : { [ k ] : Vector4 ; } ; } export interface IShaderProgram { vertexShading ( vertex , input ) : Vector4 ; fragmentShading ( context ) : Color ; } export class ShaderVarying { public static NORMAL = "normal" ; public static UV = "uv" ; public static EYE = "eye" ; public static WORLD_POS = "world_pos" ; } export default class Shader { protected program : IShaderProgram ; protected vertexInput : VertexInput ; public constructor ( program ) { this . program = program ; this . vertexInput = { viewProject : null } ; } public setViewProject ( vp ) { this . vertexInput . viewProject = vp ; } public vertexShading ( vertex ) { return this . program . vertexShading ( vertex , this . vertexInput ) ; } public fragmentShading ( input ) { return this . program . fragmentShading ( input ) ; } }