moltrun 1.7.2

High-performance game engine library with AI capabilities, built on wgpu for modern 3D graphics and physics simulation
Documentation
// 기본 2D 렌더링 셰이더

// Bind Group 0: 텍스처 + 샘플러
@group(0) @binding(0) var t_diffuse: texture_2d<f32>;
@group(0) @binding(1) var s_diffuse: sampler;

struct VertexInput {
    @location(0) position: vec2<f32>,    // 2D 위치
    @location(1) color: vec4<f32>,       // RGBA 색상
    @location(2) tex_coords: vec2<f32>,  // UV 텍스처 좌표
}

struct VertexOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) color: vec4<f32>,
    @location(1) tex_coords: vec2<f32>,  // UV 좌표를 프래그먼트로 전달
}

// Vertex Shader - 정점 변환
@vertex
fn vs_main(input: VertexInput) -> VertexOutput {
    var output: VertexOutput;
    output.position = vec4<f32>(input.position, 0.0, 1.0);
    output.color = input.color;
    output.tex_coords = input.tex_coords;
    return output;
}

// Fragment Shader - 픽셀 색상
@fragment
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
    // 텍스처에서 색상 샘플링
    let tex_color = textureSample(t_diffuse, s_diffuse, input.tex_coords);
    
    // 텍스처 색상과 정점 색상을 곱함 (색상 틴트 효과)
    return tex_color * input.color;
}