/  ChuGL Materials

Material

NormalMaterial

TangentMaterial

FlatMaterial

PhongMaterial

LinesMaterial

UVMaterial

PBRMaterial

ChuGL materials wrap and supply parameters to a ChuGL shader, describing the appearance of geometries.

Material

inherits : SG_Component : Object

Chugl material types. Represents uniforms/textures/buffers that are passed into a given shader.

examples

constructors

Material()

Default constructor for Material.

Material(Shader shader)

Create a Material component with the given Shader.

member functions

void uniformFloat4(int location, vec4 uniform_value)

Set a vec4 uniform value at the given location.

vec4 uniformFloat4(int location)

Get a vec4 uniform value at the given location.

void uniformInt(int location, int uniform_value)

Set an int uniform value at the given location.

int uniformInt(int location)

Get an int uniform value at the given location.

void uniformInt2(int location, int x, int y)

Set an vec2 uniform value at the given location.

int[] uniformInt2(int location)

Get an vec2 uniform value at the given location.

void uniformInt3(int location, int x, int y, int z)

Set an vec3 uniform value at the given location.

int[] uniformInt3(int location)

Get an vec3 uniform value at the given location.

void uniformInt4(int location, int x, int y, int z, int w)

Set an vec4 uniform value at the given location.

int[] uniformInt4(int location)

Get an vec4 uniform value at the given location.

void storageBuffer(int location, float[] storageBuffer)

Bind the given array data as a storage buffer at the given location.

void storageBuffer(int location, StorageBuffer storageBuffer)

Bind a storage buffer at the given location.

void sampler(int location, TextureSampler sampler)

Bind a sampler at the given location.

TextureSampler sampler(int location)

Get the sampler at the given location.

void texture(int location, Texture texture)

Bind a texture at the given location.

Texture texture(int location)

Get the texture at the given location.

void storageTexture(int location, Texture texture)

Binds a storage texture at the given location. Defaults to the textures base mip level 0.

Shader shader()

Get the shader of the material.

void shader(Shader shader)

Set the shader of the material.

int cullMode()

Get the cull mode of the material. Material.Cull_None, Material.Cull_Front, or Material.Cull_Back.

void cullMode(int cullMode)

Set the cull mode of the material. valid options: Material.Cull_None, Material.Cull_Front, or Material.Cull_Back.

void topology(int topology)

Set the primitive topology of the material. valid options: Material.Topology_PointList, Material.Topology_LineList, Material.Topology_LineStrip, Material.Topology_TriangleList, or Material.Topology_TriangleStrip.

int topology()

Get the primitive topology of the material. Material.Topology_PointList, Material.Topology_LineList, Material.Topology_LineStrip, Material.Topology_TriangleList, or Material.Topology_TriangleStrip.

int[] activeUniformLocations()

Get list of active uniform locations, i.e. uniform locations that have been set (bind group entry locations)

void uniformFloat(int location, float uniform_value)

Set a float uniform value at the given location.

float uniformFloat(int location)

Get a float uniform value at the given location.

void uniformFloat2(int location, vec2 uniform_value)

Set a vec2 uniform value at the given location.

vec2 uniformFloat2(int location)

Get a vec2 uniform value at the given location.

void uniformFloat3(int location, vec3 uniform_value)

Set a vec3 uniform value at the given location.

vec3 uniformFloat3(int location)

Get a vec3 uniform value at the given location.

static member variables

int Cull_None

No culling.

int Cull_Front

Cull front faces.

int Cull_Back

Cull back faces.

int Topology_PointList

Interpret each vertex as a point.

int Topology_LineList

Interpret each pair of vertices as a line.

int Topology_LineStrip

Each vertex after the first defines a line primitive between it and the previous vertex.

int Topology_TriangleList

Interpret each triplet of vertices as a triangle.

int Topology_TriangleStrip

Each vertex after the first two defines a triangle primitive between it and the previous two vertices.


NormalMaterial

inherits : Material : SG_Component : Object

Visualize normals of a mesh.

constructors

NormalMaterial()

Default constructor for NormalMaterial.

member functions

void worldspaceNormals(int use_worldspace_normals)

Set whether to use worldspace normals. If false, visualizes normals in local object space.

int worldspaceNormals()

Get whether to use worldspace normals. If false, visualizes normals in local object space.


TangentMaterial

inherits : Material : SG_Component : Object

Visualize tangents of a mesh.

constructors

TangentMaterial()

Default constructor for TangentMaterial.

member functions

void worldspaceTangents(int use_worldspace_tangents)

Set whether to use worldspace tangents. If false, visualizes tangents in local object space.

int worldspaceTangents()

Get whether to use worldspace tangents. If false, visualizes tangents in local object space.


FlatMaterial

inherits : Material : SG_Component : Object

Simple flat-shaded material (not affected by lighting).

examples

constructors

FlatMaterial()

Default constructor for FlatMaterial.

member functions

TextureSampler sampler()

Get the sampler of the material.

vec3 color()

Get the color of the material.

void color(vec3 color)

Set material color uniform as an rgb. Alpha set to 1.0.

void sampler(TextureSampler sampler)

Set the sampler of the material.

Texture colorMap()

Get the color map of the material.

void colorMap(Texture colorMap)

Set the color map of the material.

void offset(vec2 offset)

Set the texture sampler offset of the material. Default (0, 0). Useful for scrolling textures or sampling a subregion of a texture atlas. E.g. An offset of (0.5, 0.5) will begin sampling from the center of the texture.

vec2 offset()

Get the texture sampler offset of the material.

void scale(vec2 scale)

Set the texture sampler scale of the material. Default (1, 1). Useful for scaling textures or sampling a subregion of a texture atlas. E.g. A scale of (0.5, 0.5) will sample 1/4 of the texture.

vec2 scale()

Get the texture sampler scale of the material.


PhongMaterial

inherits : Material : SG_Component : Object

Phong specular shading model.

examples

constructors

PhongMaterial()

Default constructor for PhongMaterial.

member functions

Texture colorMap()

Get the diffuse texture of the material.

vec3 specular()

Get the specular color of the material.

void specular(vec3 specular)

Set the specular color of the material.

vec3 color()

Get the diffuse color of the material.

void color(vec3 diffuse)

Set the diffuse color of the material.

float shine()

Get the log shininess exponent.

void shine(float shine)

Set the log shininess exponent. default 5.

vec3 emission()

Get the emission color of the material.

void emission(vec3 emission)

Set the emission color of the material. Default black.

float normalFactor()

Get the normal factor of the material. Scales effect of normal map. Default 1.0.

void normalFactor(float normalFactor)

Set the normal factor of the material. Scales effect of normal map.

float aoFactor()

Get the ambient occlusion factor of the material. Default 1.0.

void aoFactor(float aoFactor)

Set the ambient occlusion factor of the material. Default 1.0. 0 disables AO. Set between 0 and 1.

void colorMap(Texture albedoTexture)

Set the diffuse texture of the material.

Texture specularMap()

Get the specular texture of the material.

void specularMap(Texture specularTexture)

Set the specular texture of the material.

Texture aoMap()

Get the ambient occlusion texture of the material.

void aoMap(Texture aoTexture)

Set the ambient occlusion texture of the material.

Texture emissiveMap()

Get the emissive texture of the material.

void emissiveMap(Texture emissiveTexture)

Set the emissive texture of the material.

Texture normalMap()

Get the normal texture of the material.

void normalMap(Texture normalTexture)

Set the normal texture of the material.

int envmapMethod()

Get the environment map sampling method. One of PhongMaterial.EnvmapMethod_None, PhongMaterial.EnvmapMethod_Reflect, PhongMaterial.EnvmapMethod_Refract. Set the environment map via GScene.envMap(Texture). Default EnvmapMethod_Reflect.

void envmapMethod(int envmapMethod)

Set the environment map sampling method. One of PhongMaterial.EnvmapMethod_None, PhongMaterial.EnvmapMethod_Reflect, PhongMaterial.EnvmapMethod_Refract. Default EnvmapMethod_Reflect.

float refractionRatio()

Get the refraction ratio of the material. Only used when envmapMethod is PhongMaterial.EnvmapMethod_Refract. Default 0.5.

void refractionRatio(float ratio)

Set the refraction ratio of the material. Only used when envmapMethod is PhongMaterial.EnvmapMethod_Refract. Default 1.0.

int envmapBlend()

Get the blend mode of the environment map. One of PhongMaterial.EnvmapBlend_None, PhongMaterial.EnvmapBlend_Mix, PhongMaterial.EnvmapBlend_Add, PhongMaterial.EnvmapBlend_Multiply. Default EnvmapBlend_None.

void envmapBlend(int blendMode)

Set the blend mode of the environment map. One of PhongMaterial.EnvmapBlend_None, PhongMaterial.EnvmapBlend_Mix, PhongMaterial.EnvmapBlend_Add, PhongMaterial.EnvmapBlend_Multiply. Set to EnvmapBlend_None to disable environment lighting.

float envmapIntensity()

Get the intensity of the environment map lighting. Default 1.0.

void envmapIntensity(float intensity)

Set the intensity of the environment map lighting. Default 1.0.

static member variables

int EnvmapMethod_None

No environment map sampling.

int EnvmapMethod_Reflection

Sample the environment map via reflection (like chrome or a mirror)

int EnvmapMethod_Refraction

Sample the environment map via refraction (like glass or water)

int EnvmapBlend_None

No environment map blending.

int EnvmapBlend_Add

Add the environment map color to the material color.

int EnvmapBlend_Multiply

Multiply the environment map color with the material color.

int EnvmapBlend_Mix

Linearly mix the environment map color with the material color. An intensity of 0.0 will show only the material color, 1.0 will show only the environment map color.


LinesMaterial

inherits : Material : SG_Component : Object

2D line material. You probably don't need to instantiate this directly. Use GLines instead.

constructors

LinesMaterial()

Default constructor for LinesMaterial.

member functions

float width()

Get the thickness of the lines in the material.

void width(float thickness)

Set the thickness of the lines in the material.

vec3 color()

Get the line color.

void color(vec3 color)

Set the line color.


UVMaterial

inherits : Material : SG_Component : Object

Visualize UV coordinates of a mesh.

constructors

UVMaterial()

Default constructor for UVMaterial.


PBRMaterial

inherits : Material : SG_Component : Object

No description available

examples

constructors

PBRMaterial()

Default constructor for PBRMaterial.

member functions

Texture colorMap()

Get the albedo texture of the material.

float normalFactor()

Get the normal factor of the material. Scales effect of normal map. Default 1.0.

float aoFactor()

Get the ambient occlusion factor of the material. Default 1.0.

Texture aoMap()

Get the ambient occlusion texture of the material.

Texture emissiveMap()

Get the emissive texture of the material.

Texture normalMap()

Get the normal texture of the material.

vec3 color()

Get the albedo color of the material.

void color(vec3 albedo)

Set the albedo color of the material.

vec3 emissive()

Get the emissive color of the material.

void emissive(vec3 emissive)

Set the emissive color of the material.

float metallic()

Get the metallic factor of the material.

void metallic(float metallic)

No description available

float roughness()

Get the roughness factor of the material.

void roughness(float roughness)

Set the roughness factor of the material.

void normalFactor(float normalFactor)

Set the normal factor of the material. Scales effect of normal map. Default 1.0.

void aoFactor(float aoFactor)

Set the ambient occlusion factor of the material. Default 1.0.

void colorMap(Texture albedoTexture)

Set the albedo texture of the material.

void normalMap(Texture normalTexture)

Set the normal texture of the material.

void aoMap(Texture aoTexture)

Set the ambient occlusion texture of the material.

Texture mrMap()

Get the metallic-roughness texture of the material.

void mrMap(Texture mrTexture)

Set the metallic-roughness texture of the material.

void emissiveMap(Texture emissiveTexture)

Set the emissive texture of the material.