Module luminance::backend::shader[][src]

Expand description

Shader backend interface.

This interface defines the low-level API shaders must implement to be usable.

Shader support is quite complex and requires several concepts to be implemented by the backend. The first one is the concept of « shader stage ». A shader stage represents a single logic of shader processing. Oftentimes, backends support at least two of them:

  • Vertex shader, which is run for all vertices.
  • Fragment shader, which is run for all fragments rasterized by the backend.

Other backends support optional backend stages, such as:

  • Geometry shader, which is run for every primitive (point, lines, triangles, etc.).
  • Tessellation shaders, run to tessellate the vertex stream.
  • Compute shaders, special kind of shaders used to compute non-image related data on the backend using the shader pipeline.

Then, the concept of a « shader program », which agregates shader stages into a single entity after a process of « linking » the various shader stages. A shader program is a pipeline resource, so it will be used inside a graphics pipeline to shade a scene. At the higher level, shader programs are typed with different type variables that don’t leak in the backend, but some have meaning, which is a good transition to the next concept: uniforms. In this backend, uniforms are user-defined structures that can only be built by backend-specific ways. This is why another trait must be implement do perform all the lookups and uniforms construction.

Finally, some traits exist to provide more features, such as ShaderData to support shader data operations.

Traits

Shader support.

Shader data backend.

Backend support for uniforms.