# HG changeset patch # User sam # Date 1713202599 -25200 # Node ID 443e8090614c6844456cd663dd41e258deb16ff4 # Parent 6261baf559637e9109e26cad9f26add718f1e6c7 fix: some mesh attributes will be handled automatically, ignore them when doing mesh-material-shader compatability-check diff -r 6261baf55963 -r 443e8090614c semicongine/material.nim --- a/semicongine/material.nim Mon Apr 15 22:33:24 2024 +0700 +++ b/semicongine/material.nim Tue Apr 16 00:36:39 2024 +0700 @@ -55,6 +55,8 @@ proc assertCanRender*(shader: ShaderConfiguration, materialType: MaterialType) = for attr in shader.inputs: if attr.perInstance: + if attr.name in [TRANSFORM_ATTRIB, MATERIALINDEX_ATTRIBUTE]: + continue 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[attr.name] == attr.theType, &"Instance attribute '{attr.name}' of MaterialType '{materialType}' is of type {materialType.instanceAttributes[attr.name]} but assigned shader '{shader}' declares type '{attr.theType}'" else: diff -r 6261baf55963 -r 443e8090614c semicongine/mesh.nim --- a/semicongine/mesh.nim Mon Apr 15 22:33:24 2024 +0700 +++ b/semicongine/mesh.nim Tue Apr 16 00:36:39 2024 +0700 @@ -50,6 +50,8 @@ else: assert false, &"Mesh '{mesh.name}' is missing required vertex attribute '{name}: {theType}' for {material.theType}" for name, theType in material.theType.instanceAttributes: + if name in [TRANSFORM_ATTRIB, MATERIALINDEX_ATTRIBUTE]: + continue if mesh.instanceData.contains(name): assert mesh.instanceData[name].theType == theType, &"{material.theType} expected instance attribute '{name}' to be '{theType}' but it is {mesh.instanceData[name].theType}" else: diff -r 6261baf55963 -r 443e8090614c semicongine/renderer.nim --- a/semicongine/renderer.nim Mon Apr 15 22:33:24 2024 +0700 +++ b/semicongine/renderer.nim Tue Apr 16 00:36:39 2024 +0700 @@ -155,6 +155,7 @@ # find all material data and group it by material type for mesh in scene.meshes: + assert mesh.material != nil, "Mesh {mesh} has no material assigned" if not scenedata.materials.contains(mesh.material.theType): scenedata.materials[mesh.material.theType] = @[] if not scenedata.materials[mesh.material.theType].contains(mesh.material): @@ -167,7 +168,7 @@ if not (MATERIALINDEX_ATTRIBUTE in mesh[].attributes): mesh[].initInstanceAttribute(MATERIALINDEX_ATTRIBUTE, uint16(scenedata.materials[mesh.material.theType].find(mesh.material))) - renderer.checkSceneIntegrity(scene) + # renderer.checkSceneIntegrity(scene) # create index buffer if necessary var indicesBufferSize = 0'u64