pub const TEXT_WGSL: &str = "// Copyright 2025 eraflo\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nstruct Globals {\n view_proj: mat4x4<f32>,\n};\n\n@group(0) @binding(0)\nvar<uniform> globals: Globals;\n\n@group(1) @binding(0)\nvar t_diffuse: texture_2d<f32>;\n@group(1) @binding(1)\nvar s_diffuse: sampler;\n\nstruct VertexInput {\n @location(0) position: vec2<f32>,\n @location(1) uv: vec2<f32>,\n @location(2) color: vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) clip_position: vec4<f32>,\n @location(0) uv: vec2<f32>,\n @location(1) color: vec4<f32>,\n};\n\n@vertex\nfn vs_main(model: VertexInput) -> VertexOutput {\n var out: VertexOutput;\n out.clip_position = globals.view_proj * vec4<f32>(model.position, 0.0, 1.0);\n out.uv = model.uv;\n out.color = model.color;\n return out;\n}\n\n@fragment\nfn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {\n // We assume the atlas is an R8 format texture (alpha)\n let alpha = textureSample(t_diffuse, s_diffuse, in.uv).r;\n if (alpha <= 0.0) {\n discard;\n }\n return vec4<f32>(in.color.rgb, in.color.a * alpha);\n}\n";Expand description
Shader for text rendering. Consumed by
khora_infra::StandardTextRenderer::new as a raw String.