c3d.shader

the shader module provides a bunch of tools for creating your own custom shaders and also the default shaders so they can be easily integrated

defaultdefault versions of the shaders
fragsome useful fragment shaders
vertexsome useful vertex shaders
defaultSource

default versions of the shaders

vertex(x, y, z, w, properties, scale, rot, pos, per, cam_transform, cam_position, cam_rotation)the default vertex shader
frag(px_info)the default fragment shader
geometry(triangle)the default geometry shader
vertex(x, y, z, w, properties, scale, rot, pos, per, cam_transform, cam_position, cam_rotation)Source

the default vertex shader

Parameters

  1. x number x of the vertex to be transformed by the shader
  2. y number y of the vertex to be transformed by the shader
  3. z number z of the vertex to be transformed by the shader
  4. w number w of the vertex to be transformed by the shader
  5. properties table properties of the object this vertex belongs to
  6. scale table the scale matrix of the object this vertex belongs to
  7. rot table the rotation matrix of the object this vertex belongs to
  8. pos table the translation matrix of the object this vertex belongs to
  9. per table the current perspective matrix present in the scene
  10. cam_transform table the generic transform of the current camera
  11. cam_position table the position transform of the current camera
  12. cam_rotation table the rotation transform of the current camera

Returns

  1. number x of the transformed vertex
  2. number y of the transformed vertex
  3. number z of the transformed vertex
  4. number w of the transformed vertex
frag(px_info)Source

the default fragment shader

Parameters

  1. px_info table the pixels information given from the rasterizer

Returns

  1. number the color to set this pixel to
  2. boolean whether should this pixel be made transparent
geometry(triangle)Source

the default geometry shader

Parameters

  1. triangle table the triangle inputed into the shader

Returns

  1. table the returned triangle from the shader
fragSource

some useful fragment shaders

noise()white noise fragment shader
noise()Source

white noise fragment shader

Returns

  1. number random color (black/white)
vertexSource

some useful vertex shaders

skybox(x, y, z, w, properties, scale, rot, pos, per, cam_transform, cam_position, cam_rotation)makes this object not be affected by its position and camera position.
skybox(x, y, z, w, properties, scale, rot, pos, per, cam_transform, cam_position, cam_rotation)Source

makes this object not be affected by its position and camera position. only rotation. ideal for skyboxes !

Parameters

  1. x number x of the vertex to be transformed by the shader
  2. y number y of the vertex to be transformed by the shader
  3. z number z of the vertex to be transformed by the shader
  4. w number w of the vertex to be transformed by the shader
  5. properties table properties of the object this vertex belongs to
  6. scale table the scale matrix of the object this vertex belongs to
  7. rot table the rotation matrix of the object this vertex belongs to
  8. pos table the translation matrix of the object this vertex belongs to
  9. per table the current perspective matrix present in the scene
  10. cam_transform table the generic transform of the current camera
  11. cam_position table the position transform of the current camera
  12. cam_rotation table the rotation transform of the current camera

Returns

  1. number x of the transformed vertex
  2. number y of the transformed vertex
  3. number z of the transformed vertex
  4. number w of the transformed vertex