# HG changeset patch # User Sam # Date 1691859305 -25200 # Node ID e656c0aad09301e620552f9f3ca4102d6ece36e3 # Parent 9efc258df2088c8fe8338f79ceea300fb465f411 fix: test not running with temporary new material system diff -r 9efc258df208 -r e656c0aad093 tests/test_mesh.nim --- a/tests/test_mesh.nim Sat Aug 12 23:54:28 2023 +0700 +++ b/tests/test_mesh.nim Sat Aug 12 23:55:05 2023 +0700 @@ -1,3 +1,5 @@ +import std/sequtils +import std/tables import semicongine proc main() = @@ -20,14 +22,14 @@ const vertexInput = @[ attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), - attr[uint8]("material", memoryPerformanceHint=PreferFastRead), + attr[uint16]("materialIndex", memoryPerformanceHint=PreferFastRead), attr[Vec2f]("texcoord_0", memoryPerformanceHint=PreferFastRead), attr[Mat4]("transform", memoryPerformanceHint=PreferFastWrite, perInstance=true), ] intermediate = @[ attr[Vec4f]("vertexColor"), attr[Vec2f]("colorTexCoord"), - attr[uint8]("materialId", noInterpolation=true) + attr[uint16]("materialIndexOut", noInterpolation=true) ] fragOutput = @[attr[Vec4f]("color")] uniforms = @[ @@ -44,20 +46,22 @@ samplers=samplers, vertexCode=""" gl_Position = vec4(position, 1.0) * (transform * Uniforms.view * Uniforms.projection); -vertexColor = Uniforms.baseColorFactor[material]; +vertexColor = Uniforms.baseColorFactor[materialIndex]; colorTexCoord = texcoord_0; -materialId = material; +materialIndexOut = materialIndex; """, fragmentCode=""" -vec4 col[4] = vec4[4](vec4(1, 0, 0, 1), vec4(0, 1, 0, 1), vec4(0, 0, 1, 1), vec4(1, 1, 1, 1)); -color = texture(baseColorTexture[materialId], colorTexCoord) * vertexColor; +// vec4 col[4] = vec4[4](vec4(1, 0, 0, 1), vec4(0, 1, 0, 1), vec4(0, 0, 1, 1), vec4(1, 1, 1, 1)); +color = texture(baseColorTexture[materialIndexOut], colorTexCoord) * vertexColor; """ ) engine.setRenderer(engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode, clearColor=newVec4f(0, 0, 0, 1))) for scene in scenes.mitems: - engine.addScene(scene, vertexInput, samplers, transformAttribute="transform", materialIndexAttribute="") + engine.addScene(scene, vertexInput, samplers) scene.addShaderGlobal("projection", Unit4) scene.addShaderGlobal("view", Unit4) + let baseColors = scene.materials.map(proc(i: Material): Vec4f = getValue[Vec4f](i[].constants["baseColorFactor"])) + scene.addShaderGlobalArray("baseColorFactor", baseColors) var size = 1'f32 elevation = 0'f32