figureone
    Preparing search index...

    Interface OBJ_VertexShader

    Options used to compose vertex shader source code.

    Shader source code can be automatically composed for different vertex dimension (2D vs 3D), coloring and lighting options.

    Composed source code uses specific attribute, uniform and varying names. Attributes will need to be defined by the user in the attributes property of OBJ_GenericGL.

    Attributes:

    • vec2 a_vertex: used to define vertex positions when dimension = 2.
    • vec4 a_vertex: used to define vertex positions when dimension = 3 - Note, for this case an attribute size of only 3 is needed as the fourth coordinate (w in the homogenous coordinate system) is automatically filled with a 1.
    • vec4 a_color: used to define the color of a vertex when color = 'vertex'
    • vec2 a_texcoord: used to define the texture coordinates to map the vertex to when color = 'texture'
    • vec3 a_normal: used to define the normal vector for a vertex used when light = 'point' or light = 'directional'

    Uniforms will be defined and updated by FigureOne based on the color and transform of the primitive, and the scene being used to draw the primitive. Thus, the uniform variables listed below for are for informational purposes only.

    Uniforms:

    • mat4 u_worldViewProjectionMatrix: transfomration matrix that cascades projection, camera position, and any additional transformation of the shape
    • float u_z: define a specific z for all vertices when dimension = 2
    • u_worldInverseTranspose: transpose of inverse world matrix needed for to correctly transform normal vectors. Used when light = 'point' or light = 'directional'
    • vec3 u_lightWorldPosition: defines the position of a point source light used when light = 'point'
    • mat4 u_worldMatrix: defines the world matrix transform that orients the point source light relative to the shape used when light = 'point'.

    Varyings are passed from the vertex shader to the fragement shader. They are listed here in case the user wants to customize one shader, while relying on composition for the other. All varying expected by the composed shader will need to be defined in the custom shader.

    • vec2 v_texcoord: pass texture coordinates to fragment shader used when color = 'texture'
    • vec4 v_color: pass vertex specific color to fragment shader used when color = 'vertex'
    • vec3 v_normal: pass normals (transformed with u_worldInverseTranspose) to fragment shader used when light = 'directional' or light = 'point'
    • vec3 v_vertexToLight: pass vector between point source light and vertex to fragment shader used when light = 'point'