package renderer import "core:log" import "core:fmt" MATERIAL_MAX_TEXTURES :: 32 Material :: struct { // TODO: SS - 'Name'? shader_program: ^Shader_Program, textures: [MATERIAL_MAX_TEXTURES]^Texture, texture_count: u8, uniforms: []Uniform, casts_shadow: bool, uv_scale: [2]f32, // TODO: SS - Move? } create_material :: proc(program: ^Shader_Program, textures: []^Texture, uniforms: []Uniform, casts_shadow: bool) -> (Material, bool) { m: Material m.shader_program = program for t, i in textures { if t == nil { log.warnf("Found nil texture at index %v in when creating material.", i) continue } if m.texture_count >= MATERIAL_MAX_TEXTURES { log.warnf("Too many textures passed when creating material. Max is %v.", MATERIAL_MAX_TEXTURES) break } m.textures[m.texture_count] = t m.texture_count += 1 } if m.texture_count == 0 { log.warn("No textures passed when creating material.") // TODO: SS - Should we return false here? } m.uniforms = uniforms m.casts_shadow = casts_shadow m.uv_scale = { 1.0, 1.0 } // NOTE: SS - Hardcoded. return m, true }