re-org en App
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
# Shaders Directory
|
||||
|
||||
## Overview
|
||||
|
||||
Contains WGSL shader source files used by the PipelineCache module. These are loaded at runtime from disk when referenced by their registered ID in PipelineCache.register_shader(). If a file is missing, PipelineCache falls back to the embedded BASIC_SHADER constant defined in utils::conf.
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| **basic_shader.wgsl** | Default vertex/fragment shader pair (vs_main / fs_main entry points) with position, normal, UV, and color attributes matching the Vertex struct layout. |
|
||||
|
||||
## Shader Contract
|
||||
|
||||
The WGSL shader must define:
|
||||
|
||||
- `@vertex fn vs_main() -> @builtin(position) vec4<f32>` — vertex entry point
|
||||
- `@fragment fn fs_main() -> @location(0) vec4<f32>` — fragment entry point writing RGBA output
|
||||
- Vertex input attributes matching the 56-byte stride of resources::Vertex:
|
||||
- `@location(0)` → position `[f32; 3]` (offset 0)
|
||||
- `@location(1)` → normal `[f32; 3]` (offset 12)
|
||||
- `@location(2)` → uv `[f32; 2]` (offset 24)
|
||||
- `@location(3)` → color `[f32; 4]` (offset 32)
|
||||
@@ -0,0 +1,24 @@
|
||||
//! # Basic Shader Module
|
||||
struct VertexInput {
|
||||
@location(0) position: vec3<f32>,
|
||||
@location(1) uv: vec2<f32>,
|
||||
@location(2) color: vec3<f32>,
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
@builtin(position) clip_position: vec4<f32>,
|
||||
@location(0) color: vec3<f32>,
|
||||
};
|
||||
|
||||
@vertex
|
||||
fn vs_main(model: VertexInput) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
out.clip_position = vec4<f32>(model.position, 1.0);
|
||||
out.color = model.color; // On transmet la couleur au fragment shader
|
||||
return out;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(in.color, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user