# HG changeset patch # User Sam # Date 1685272160 -25200 # Node ID a107d9ef1a1f03ab9f30f486a9f5ca1cb465ba10 # Parent fd1a95f433d1f10e1dd1d8bde0eda93788b1f2f5 add: flat attribute for shader in/outputs diff -r fd1a95f433d1 -r a107d9ef1a1f src/semicongine/core/gpu_data.nim --- a/src/semicongine/core/gpu_data.nim Sun May 28 17:52:03 2023 +0700 +++ b/src/semicongine/core/gpu_data.nim Sun May 28 18:09:20 2023 +0700 @@ -150,6 +150,7 @@ thetype*: DataType arrayCount*: uint32 perInstance*: bool + noInterpolation: bool memoryPerformanceHint*: MemoryPerformanceHint func vertexInputs*(attributes: seq[ShaderAttribute]): seq[ShaderAttribute] = @@ -292,6 +293,7 @@ name: string, perInstance=false, arrayCount=0'u32, + noInterpolation=false, memoryPerformanceHint=PreferFastRead, ): auto = ShaderAttribute( @@ -299,6 +301,7 @@ thetype: getDataType[T](), perInstance: perInstance, arrayCount: arrayCount, + noInterpolation: noInterpolation, memoryPerformanceHint: memoryPerformanceHint, ) @@ -1059,7 +1062,8 @@ var i = 0'u32 for attribute in group: assert attribute.arrayCount == 0, "arrays not supported for shader vertex attributes" - result.add &"layout(location = {i}) in {attribute.thetype.glslType} {attribute.name};" + let flat = if attribute.noInterpolation: "flat " else: "" + result.add &"layout(location = {i}) {flat}in {attribute.thetype.glslType} {attribute.name};" for j in 0 ..< attribute.thetype.numberOfVertexInputAttributeDescriptors: i += attribute.thetype.nLocationSlots @@ -1092,5 +1096,6 @@ var i = 0'u32 for attribute in group: assert attribute.arrayCount == 0, "arrays not supported for outputs" - result.add &"layout(location = {i}) out {attribute.thetype.glslType} {attribute.name};" + let flat = if attribute.noInterpolation: "flat " else: "" + result.add &"layout(location = {i}) {flat}out {attribute.thetype.glslType} {attribute.name};" i += 1 diff -r fd1a95f433d1 -r a107d9ef1a1f src/semicongine/resources/mesh.nim --- a/src/semicongine/resources/mesh.nim Sun May 28 17:52:03 2023 +0700 +++ b/src/semicongine/resources/mesh.nim Sun May 28 18:09:20 2023 +0700 @@ -12,7 +12,13 @@ import ./image -let DEFAULTEXTURE = Texture(image: newImage(1, 1, @[[255'u8, 255'u8, 255'u8, 255'u8]]), sampler: DefaultSampler()) +let DEFAULTSAMPLER = Sampler( + magnification: VK_FILTER_NEAREST, + minification: VK_FILTER_NEAREST, + wrapModeS: VK_SAMPLER_ADDRESS_MODE_REPEAT, + wrapModeT: VK_SAMPLER_ADDRESS_MODE_REPEAT, + ) +let DEFAULTEXTURE = Texture(image: newImage(1, 1, @[[255'u8, 255'u8, 255'u8, 255'u8]]), sampler: DEFAULTSAMPLER) type glTFHeader = object