diff --git a/src/graphics/shader.rs b/src/graphics/shader.rs index 93a6244b..70dcf8b6 100644 --- a/src/graphics/shader.rs +++ b/src/graphics/shader.rs @@ -12,15 +12,41 @@ use crate::Context; pub use crate::graphics::opengl::UniformValue; /// The default vertex shader. +/// +/// The source code for this shader is available in [`src/resources/shader.vert`](https://github.com/17cupsofcoffee/tetra/blob/master/src/resources/shader.vert). pub static DEFAULT_VERTEX_SHADER: &str = include_str!("../resources/shader.vert"); /// The default fragment shader. +/// +/// The source code for this shader is available in [`src/resources/shader.vert`](https://github.com/17cupsofcoffee/tetra/blob/master/src/resources/shader.frag). pub static DEFAULT_FRAGMENT_SHADER: &str = include_str!("../resources/shader.frag"); /// A shader program, consisting of a vertex shader and a fragment shader. /// /// This type acts as a lightweight handle to the associated graphics hardware data, /// and so can be cloned with little overhead. +/// +/// # Vertex Shaders +/// +/// Vertex shaders take in data via three attributes: +/// +/// * `a_position` - A `vec2` representing the position of the vertex in world space. +/// * `a_uv` - A `vec2` representing the texture co-ordinates that are associated with the vertex. +/// * `a_color` - A `vec4` representing a color to multiply the output by. +/// +/// # Fragment Shaders +/// +/// Fragment shaders have a single `vec4` output called `o_color` - this should be set to the desired output color for the +/// fragment. +/// +/// # Uniforms +/// +/// By default, the shader is provided with two uniform variables: +/// +/// * `u_projection` - A `mat4` which can be used to translate world space co-ordinates into screen space. +/// * `u_texture` - A `sampler2D` which can be used to access color data from the currently active texture. +/// +/// You can also set data into your own uniform variables via the `set_uniform` method. #[derive(Debug, Clone, PartialEq)] pub struct Shader { pub(crate) handle: Rc,