1 module sbylib.graphics.material.standard.glyph; 2 3 import sbylib.graphics.material.standard.material; 4 import sbylib.graphics.material.standard.renderpass; 5 6 class GlyphMaterial : Material { 7 8 mixin RenderPass!(StandardRenderPass); 9 10 mixin ShaderSource!(ShaderStage.Vertex, q{ 11 #version 450 12 layout (location = 0) in vec2 position; 13 layout (location = 1) in ivec2 uv; 14 layout (location = 0) out vec2 uv2; 15 16 layout (binding = 0) uniform UniformData { 17 mat4 worldMatrix; 18 } uni; 19 20 void main() { 21 gl_Position = uni.worldMatrix * vec4(position, 0, 1); 22 gl_Position.y = -gl_Position.y; 23 uv2 = uv; 24 } 25 }); 26 27 mixin ShaderSource!(ShaderStage.Fragment, q{ 28 #version 450 29 layout (location = 0) in vec2 uv; 30 layout (location = 0) out vec4 fragColor; 31 32 layout (binding = 1) uniform sampler2D tex; 33 34 void main() { 35 fragColor = texture(tex, uv / textureSize(tex,0)).rrrr; 36 } 37 }); 38 39 @vertex struct Vertex { 40 vec2 position; 41 ivec2 uv; 42 } 43 44 immutable CreateInfo i = { 45 rasterization: { 46 depthClampEnable: false, 47 rasterizerDiscardEnable: false, 48 polygonMode: PolygonMode.Fill, 49 cullMode: CullMode.None, 50 frontFace: FrontFace.CounterClockwise, 51 depthBiasEnable: false, 52 depthBiasConstantFactor: 0.0f, 53 depthBiasClamp: 0.0f, 54 depthBiasSlopeFactor: 0.0f, 55 lineWidth: 1.0f, 56 }, 57 multisample: { 58 rasterizationSamples: SampleCount.Count1, 59 sampleShadingEnable: false, 60 alphaToCoverageEnable: false, 61 alphaToOneEnable: false, 62 }, 63 depthStencil: { 64 depthTestEnable: true, 65 depthWriteEnable: true, 66 depthCompareOp: CompareOp.Less, 67 }, 68 colorBlend: { 69 logicOpEnable: false, 70 attachments: [{ 71 blendEnable: false, 72 colorWriteMask: ColorComponent.R 73 | ColorComponent.G 74 | ColorComponent.B 75 | ColorComponent.A, 76 }] 77 } 78 }; 79 mixin Info!i; 80 81 struct VertexUniform { 82 mat4 worldMatrix; 83 } 84 85 @uniform @binding(0) @stage(ShaderStage.Vertex) VertexUniform vertexUniform; 86 @texture @binding(1) @stage(ShaderStage.Fragment) Texture tex; 87 88 mixin MaxObjects!(10); 89 90 mixin Instance; 91 }