simplex3d.engine.graphics.pluggable

ShaderDeclaration

sealed abstract class ShaderDeclaration extends AnyRef

ShaderPrototype defines a DSL to assist with writing shaders and and linking them together.

Glsl version is inferred based on profile. For Glsl 1.2 non-suqare matrices are re-mapped to square matrices.

Function dependencies are declared with use() declaration.

Uniform values must be specified inside a uniform{} block using the declare() directive. Glsl qualifiers can be chained using qualify() statement. For example: declare[Vec2]("texCoords").qualify("smooth")

Unsized arrays are allowed only in uniform blocks, their size will be automatically resolved to a size of the corresponding BindingSeq.

All dependent variables should be defined inside attribute{} or in{} blocks using declare(). Only VertexShaders are allowed to have attribute{} blocks. Other shaders must use named in{} block and must prefix the variables with the block name in the source code.

Each shader can link with the next stage using an out{} block. In this case shader must also declare main(). Multiple main declarations are allowed within the same program. Alternatively, a shader with main() declaration can share a named set of values using main(){ out{} }. Only one out{} block is allowed per shader, either stage interface out{} or main{ out{} }. Fragment shaders cannot define interface out{}. Shared pre-computed values within the same stage can be requested within main(){ in{} } blocks.

Arrays in in{} and out{} blocks must be sized either to a literal value or to a size of some uniform array. If a uniform array is defined in the shader scope, its size can be accessed using injected variable of the form: se_sizeOf_${StructType}_${ArrayName} or simply se_sizeOf_${ArrayName} when array is declared at the top level.

If a shader does not provide a main(), then it must define a function(){}. Functions can be used within the same stage. Functions can have multiple in{} blocks, but cannot have any out{} blocks.

Additional shader sources can be attached using src() declarations. They will be inserted into the shader code before main() or function() in the order they appear.

A path that resolves to enumeration and a condition on the result can be specified to control shader selection using enums.

Samplers are extracted from structs by the texture manager and then injected at the top level in the shader. This is done to allow property-to-UBO mapping in the future. As a consequence, texture names have to be unique not just inside the parent Struct, but among all the Structs, and all the top-level declarations in Material and Environment.

Texture dimensions can be accessed by declaring integer verctor "se_dimsOf_textureName", for example: declare[Vec2i]("se_dimsOf_myTexture")

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ShaderDeclaration
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ShaderDeclaration(shaderType: Shader.Value)

Type Members

  1. final class Declaration extends AnyRef

    Attributes
    protected

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. final def attributes(block: ⇒ Unit): Unit

    "Only a vertex shader can declare an attributes block.

    "Only a vertex shader can declare an attributes block."

    Attributes
    protected
  8. final def bind[B <: Accessible with Binding](name: String, binding: Value[B])(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[B]): Unit

    Attributes
    protected
  9. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  10. final def condition(path: String)(f: (AnyRef) ⇒ Boolean): Unit

    Attributes
    protected
  11. val debugging: ShaderDebugging

    Attributes
    protected
  12. final def declare[B <: Binding](name: String)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[B]): Declaration

    Attributes
    protected
  13. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  15. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  16. final def function(signature: String)(body: String): Unit

    A shader must either defined main(){} or function(){} (but not both)

    A shader must either defined main(){} or function(){} (but not both)

    Attributes
    protected
  17. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  18. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  19. final def in(name: String)(block: ⇒ Unit): Unit

    Vertex shader cannot have any input blocks (use attributes block instead).

    Vertex shader cannot have any input blocks (use attributes block instead).

    Attributes
    protected
  20. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  21. final def main(name: String)(block: ⇒ Unit)(body: String): Unit

    A shader must either defined main(){} or function(){} (but not both).

    A shader must either defined main(){} or function(){} (but not both).

    Attributes
    protected
  22. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  23. final def notify(): Unit

    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  25. final def out(name: String)(block: ⇒ Unit): Unit

    If a shader defines one or more output blocks it must define main(){}.

    If a shader defines one or more output blocks it must define main(){}. Fragment shaders are allowed to have main(){} without an output block.

    Attributes
    protected
  26. val shaderType: Shader.Value

  27. final def src(src: String): Unit

    Attributes
    protected
  28. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  29. def toPrototype(profile: Profile.Value): ShaderPrototype

  30. def toString(): String

    Definition Classes
    AnyRef → Any
  31. final def uniform(block: ⇒ Unit): Unit

    All uniforms must be declared in the same block.

    All uniforms must be declared in the same block. Engine structs may be translated to GLSl uniform blocks depending on the implementation.

    Attributes
    protected
  32. final def use(functionSignature: String): Unit

    Attributes
    protected
  33. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  34. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  35. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any

Ungrouped