Get the default shader used with lights, materials, and textures.
You can call baseMaterialShader().modify()
and change any of the following hooks:
Hook | Description |
---|
void beforeVertex
| Called at the start of the vertex shader. |
Vertex getObjectInputs
| Update the vertex data of the model being drawn before any positioning has been applied. It takes in a Vertex struct, which includes: vec3 position , the position of the vertexvec3 normal , the direction facing out of the surfacevec2 texCoord , the texture coordinates associeted with the vertexvec4 color , the per-vertex color The struct can be modified and returned.
|
Vertex getWorldInputs
| Update the vertex data of the model being drawn after transformations such as translate() and scale() have been applied, but before the camera has been applied. It takes in a Vertex struct like, in the getObjectInputs hook above, that can be modified and returned. |
Vertex getCameraInputs
| Update the vertex data of the model being drawn as they appear relative to the camera. It takes in a Vertex struct like, in the getObjectInputs hook above, that can be modified and returned. |
void afterVertex
| Called at the end of the vertex shader. |
void beforeFragment
| Called at the start of the fragment shader. |
Inputs getPixelInputs
| Update the per-pixel inputs of the material. It takes in an Inputs struct, which includes: vec3 normal , the direction pointing out of the surfacevec2 texCoord , a vector where x and y are between 0 and 1 describing the spot on a texture the pixel is mapped to, as a fraction of the texture sizevec3 ambientLight , the ambient light color on the vertexvec4 color , the base material color of the pixelvec3 ambientMaterial , the color of the pixel when affected by ambient lightvec3 specularMaterial , the color of the pixel when reflecting specular highlightsvec3 emissiveMaterial , the light color emitted by the pixelfloat shininess , a number representing how sharp specular reflections should be, from 1 to infinityfloat metalness , a number representing how mirrorlike the material should be, between 0 and 1 The struct can be modified and returned.
|
vec4 combineColors
| Take in a ColorComponents struct containing all the different components of light, and combining them into a single final color. The struct contains: vec3 baseColor , the base color of the pixelfloat opacity , the opacity between 0 and 1 that it should be drawn atvec3 ambientColor , the color of the pixel when affected by ambient lightvec3 specularColor , the color of the pixel when affected by specular reflectionsvec3 diffuse , the amount of diffused light hitting the pixelvec3 ambient , the amount of ambient light hitting the pixelvec3 specular , the amount of specular reflection hitting the pixelvec3 emissive , the amount of light emitted by the pixel
|
vec4 getFinalColor
| Update the final color after mixing. It takes in a vec4 color and must return a modified version. |
void afterFragment
| Called at the end of the fragment shader. |
Most of the time, you will need to write your hooks in GLSL ES version 300. If you are using WebGL 1 instead of 2, write your hooks in GLSL ES 100 instead.
Call baseMaterialShader().inspectHooks()
to see all the possible hooks and their default implementations.