Class material
material
Defined in: material.js.
Constructor Attributes | Constructor Name and Description |
---|---|
material()
Defines how a mesh should be visualized.
|
Field Attributes | Field Name and Description |
---|---|
The ambient color of the material.
|
|
The diffuse color of the material.
|
|
The amount of diffuse light that should be allowed.
|
|
The source logic for the material as a shading program.
|
|
The amount of reflected specular light.
|
|
The specular color of the material
|
|
The amount of specular light that should be allowed.
|
|
Data that depends on the drawing mode.
|
Method Attributes | Method Name and Description |
---|---|
addTexture(slot, image)
Adds a texture to be drawn.
|
|
Iterates all textures to the next texture frame
|
|
setFramebufferSource(Camera)
Sets the given camera as the source framebuffer.
|
Class Detail
material()
Defines how a mesh should be visualized.
Materials are the main way to have advanced graphics control
with customized behavior. With custom or built-in shader objects,
materials provide the data inputs to these programs allowing for dynamic
visuals.
Field Detail
ambient
The ambient color of the material.
diffuse
The diffuse color of the material.
diffuseAmount
The amount of diffuse light that should be allowed.
program
The source logic for the material as a shading program.
This can either be a sandboxe.material.coreProgram or
a shader program object with custom logic.
shininess
The amount of reflected specular light.
specular
The specular color of the material
specularAmount
The amount of specular light that should be allowed.
userData
Data that depends on the drawing mode. In implementations
that support shaders, this can be used as you see fit.
This property should be overwritten to update the user data.
Up to 32 values can be given to the program.
Method Detail
addTexture(slot, image)
Adds a texture to be drawn.
How textures interact with the mesh is dependent on the material attached with
renderMesh.material. If the material is using a sandboxe.material.coreProgram, sandboxe.material.textureSlot.color
will be used as an RGBA texture, sandboxe.material.textureSlot.normal will be used as a lighting normal map,
and sandboxe.material.textureSlot.shiny will be used as a light reflectivity map. For user-made programs using
Shader, the first argument refers to what texture slot you can access the texture from in
the shader programming language. Refer to shader for more info. Note that using textureSlot.color,
.normal, and .shiny are equivalent to calling addTexture() with 0, 1, and 2 respectively as
the texture slot argument.
- Parameters:
- {Number} slot
- The texture slot. See sandboxe.material.textureSlot
- {asset} image
- The image to use a texture. Multiple frames are supported and can be iterated through dynamically.
nextTextureFrame()
Iterates all textures to the next texture frame
setFramebufferSource(Camera)
Sets the given camera as the source framebuffer.
The source framebuffer is an optional input you can specify
to utilize the last known visual of a camera as a texture
source. This can be used in a few different ways. Once its set,
sandboxe.material.corePrograms will map it as another texture binding.
To disable this, simply call setFramebufferSource again with a
default entity. If your material uses a custom shader, the shader can access
if through the Dynacoe_SampleFramebuffer function.
- Parameters:
- {camera} Camera