changeset 999:b5be4ea07c3c

fix: errors that have now been discovered thanks to last commit :)
author sam <sam@basx.dev>
date Sat, 13 Apr 2024 11:20:13 +0700
parents 7e89c8fe57a8
children fca1f61c0afc
files semicongine/material.nim semicongine/panel.nim semicongine/text.nim
diffstat 3 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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 = [
--- 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(
--- 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(