# HG changeset patch # User sam # Date 1712982013 -25200 # Node ID b5be4ea07c3cf007ebac65fb7f9d8cccdda4d447 # Parent 7e89c8fe57a8c141afc80ddde9c3a7543d10cfae fix: errors that have now been discovered thanks to last commit :) diff -r 7e89c8fe57a8 -r b5be4ea07c3c semicongine/material.nim --- a/semicongine/material.nim Sat Apr 13 11:09:02 2024 +0700 +++ b/semicongine/material.nim Sat Apr 13 11:20:13 2024 +0700 @@ -55,15 +55,15 @@ proc assertCanRender*(shader: ShaderConfiguration, materialType: MaterialType) = for attr in shader.inputs: if attr.perInstance: - assert materialType.instanceAttributes.contains(attr.name), &"MaterialType '{materialType}' requires instance attribute {attr.name} in order to be renderable with the assigned shader '{shader}'" + assert materialType.instanceAttributes.contains(attr.name), &"MaterialType '{materialType}' requires instance attribute '{attr.name}' in order to be renderable with the assigned shader '{shader}'" else: - assert materialType.vertexAttributes.contains(attr.name), &"MaterialType '{materialType}' requires vertex attribute {attr.name} in order to be renderable with the assigned shader '{shader}'" + assert materialType.vertexAttributes.contains(attr.name), &"MaterialType '{materialType}' requires vertex attribute '{attr.name}' in order to be renderable with the assigned shader '{shader}'" proc `$`*(material: MaterialData): string = var attributes: seq[string] for key, value in material.attributes.pairs: attributes.add &"{key}: {value}" - return &"""Material '{material.name}' | Attributes: [{attributes.join(", ")}]""" + return &"""{material.name}: [{attributes.join(", ")}]""" proc initMaterialData*( theType: MaterialType, @@ -93,10 +93,6 @@ initMaterialData(theType = theType, name = theName, attributes = attributes.toTable) const - EMPTY_MATERIAL* = MaterialType( - name: "empty material", - vertexAttributes: {"position": Vec3F32}.toTable, - ) COLORED_MATERIAL* = MaterialType( name: "single color material", vertexAttributes: {"position": Vec3F32}.toTable, @@ -132,6 +128,11 @@ }.toTable, attributes: {"baseTexture": TextureType, "color": Vec4F32}.toTable ) + EMPTY_MATERIAL* = MaterialType( + name: "empty material", + vertexAttributes: {"position": Vec3F32}.toTable, + instanceAttributes: {TRANSFORM_ATTRIB: Mat4F32}.toTable, + ) EMPTY_SHADER* = createShaderConfiguration( name = "empty shader", inputs = [ diff -r 7e89c8fe57a8 -r b5be4ea07c3c semicongine/panel.nim --- a/semicongine/panel.nim Sat Apr 13 11:09:02 2024 +0700 +++ b/semicongine/panel.nim Sat Apr 13 11:20:13 2024 +0700 @@ -15,7 +15,8 @@ UV_ATTRIB = SHADER_ATTRIB_PREFIX & "uv" PANEL_MATERIAL_TYPE* = MaterialType( name: "default-panel-material-type", - vertexAttributes: {TRANSFORM_ATTRIB: Mat4F32, POSITION_ATTRIB: Vec3F32, UV_ATTRIB: Vec2F32}.toTable, + vertexAttributes: {POSITION_ATTRIB: Vec3F32, UV_ATTRIB: Vec2F32}.toTable, + instanceAttributes: {TRANSFORM_ATTRIB: Mat4F32, MATERIALINDEX_ATTRIBUTE: UInt16}.toTable, attributes: {"panelTexture": TextureType, "color": Vec4F32}.toTable, ) PANEL_SHADER* = createShaderConfiguration( diff -r 7e89c8fe57a8 -r b5be4ea07c3c semicongine/text.nim --- a/semicongine/text.nim Sat Apr 13 11:09:02 2024 +0700 +++ b/semicongine/text.nim Sat Apr 13 11:20:13 2024 +0700 @@ -19,7 +19,8 @@ UV_ATTRIB = SHADER_ATTRIB_PREFIX & "uv" TEXT_MATERIAL_TYPE* = MaterialType( name: "default-text-material-type", - vertexAttributes: {TRANSFORM_ATTRIB: Mat4F32, POSITION_ATTRIB: Vec3F32, UV_ATTRIB: Vec2F32}.toTable, + vertexAttributes: {POSITION_ATTRIB: Vec3F32, UV_ATTRIB: Vec2F32}.toTable, + instanceAttributes: {TRANSFORM_ATTRIB: Mat4F32, MATERIALINDEX_ATTRIBUTE: UInt16}.toTable, attributes: {"fontAtlas": TextureType, "color": Vec4F32}.toTable, ) TEXT_SHADER* = createShaderConfiguration(