public void Bind(ShaderProgram program) { if (this.DiffuseMap != null) { if (this.SpecularMap != null) { this.uniform = new MaterialUniform("material", this.DiffuseMap, this.SpecularMap, this.Shininess, this.AmbientColor, this.Transparency); } else { this.uniform = new MaterialUniform("material", this.DiffuseMap, this.SpecularColor, this.Shininess, this.AmbientColor, this.Transparency); } } else { if (this.SpecularMap != null) { this.uniform = new MaterialUniform("material", this.DiffuseColor, this.SpecularMap, this.Shininess, this.AmbientColor, this.Transparency); } else { this.uniform = new MaterialUniform("material", this.DiffuseColor, this.SpecularColor, this.Shininess, this.AmbientColor, this.Transparency); } } this.uniform.Set(program); }
public RenderHandle(Window win, GlProgram program) { Window = win ?? throw new ArgumentNullException(nameof(win)); Program = program; _uModel = program.GetUniform(UNIFORM_MODEL); _uView = program.GetUniform(UNIFORM_VIEW); _uProjection = program.GetUniform(UNIFORM_PROJECTION); _uShade = program.GetUniform(UNIFORM_SHADE); _uMaterial = new MaterialUniform(program.GetUniform($"{UNIFORM_MATERIAL}.ambient"), program.GetUniform($"{UNIFORM_MATERIAL}.diffusion"), program.GetUniform($"{UNIFORM_MATERIAL}.color")); _uLightCount = program.GetUniform(UNIFORM_LIGHT_COUNT); for (uint i = 0; i < LIGHT_LIMIT; i++) { _uLight[i] = new LightUniform(program.GetUniform($"{UNIFORM_LIGHT}[{i}].position"), program.GetUniform($"{UNIFORM_LIGHT}[{i}].color"), program.GetUniform($"{UNIFORM_LIGHT}[{i}].intensity")); } _uModel.EnsureType(new ShaderElementType(PrimitiveTypes.Matrix, 4)); _uView.EnsureType(new ShaderElementType(PrimitiveTypes.Matrix, 4)); _uProjection.EnsureType(new ShaderElementType(PrimitiveTypes.Matrix, 4)); _uShade.EnsureType(new ShaderElementType(PrimitiveTypes.Bool, 1)); }