Most visited

Recently visited

Material.LightingModel

public static final enum Material.LightingModel
extends Enum<Material.LightingModel>

java.lang.Object
   ↳ java.lang.Enum<com.viro.core.Material.LightingModel>
     ↳ com.viro.core.Material.LightingModel


LightingModel defines a formula for combining a material’s diffuse, specular, and other properties with the Lights in the Scene, and the point of view, to create the color of each rendered pixel.

Summary

Enum values

Material.LightingModel  BLINN

The Blinn-Phong approximation of real-world reflectance. 

Material.LightingModel  CONSTANT

The diffuse color (or texture) entirely determines the color of the surface. 

Material.LightingModel  LAMBERT

Lambert’s Law of diffuse reflectance determines the color of the surface. 

Material.LightingModel  PHONG

The Phong approximation of real-world reflectance. 

Material.LightingModel  PHYSICALLY_BASED

Physically-based shading, or PBR, is a set of algorithms that more accurately render environments while simplifying the modeling process for artists. 

Public methods

static Material.LightingModel valueOf(String name)
static final LightingModel[] values()

Enum values

BLINN

Material.LightingModel BLINN

The Blinn-Phong approximation of real-world reflectance. This is similar to Phong, but uses a different formula for the specular contribution.

specularLight = pow(max(0, dot(H, N)), shininess)

where H is the vector halfway between the light vector L and the eye vector E, and shininess is the value of the material's shininess property.

CONSTANT

Material.LightingModel CONSTANT

The diffuse color (or texture) entirely determines the color of the surface. Lights are not taken into consideration. color = diffuseMaterial

LAMBERT

Material.LightingModel LAMBERT

Lambert’s Law of diffuse reflectance determines the color of the surface. The diffuse color (or texture) and the angle of incidence between each Light and the surface determines the color of each pixel. The formula is as follows:

color = (∑ambientLight + ∑diffuseLight) * diffuseMaterial

∑ambientLight: the sum of all ambient lights in the scene, as contributed by ViroAmbientLight objects

∑diffuseLight: the sum of each non-ambient light's diffuse contribution. Each light's contribution is defined as follows

diffuseLight = max(0, dot(N, L))

where N is the surface normal vector at the point being shaded, and L is the normalized vector from the point being shaded to the light source.

PHONG

Material.LightingModel PHONG

The Phong approximation of real-world reflectance. This formula adds a specular contribution to the calculation, taking the point of view of the user into account.

color = (∑ambientLight + ∑diffuseLight) * diffuseMaterial + ∑specularLight * specularTexture

∑specularLight: the sum of each non-ambient light's specular contribution. Each light's specular contribution is defined as follows

specularLight = pow(max(0, dot(R, E)), shininess)

where E is the normalized vector from the point being shaded to the viewer, R is the reflection of the light vector L across the normal vector N, and shininess is the value of the material's shininess property.

PHYSICALLY_BASED

Material.LightingModel PHYSICALLY_BASED

Physically-based shading, or PBR, is a set of algorithms that more accurately render environments while simplifying the modeling process for artists. Use this LightingModel to render with PBR. PBR should be combined with HDR rendering for best results: you can enable HDR via setHDREnabled(boolean). In addition, PBR must itself be enabled via setPBREnabled(boolean).

PBR relies on the following properties when rendering:

  • The diffuse or albedo texture defines the base color of the material. This can be set by setDiffuseTexture(Texture)
  • The metalness value or texture defines how "metallic" the surface is, which influences the degree to which light refracts and reflects off the surface, the sharpness of the reflections, and more. This can be set by setMetalnessMap(Texture), or, if a uniform value is preferred, setMetalness(float).
  • The roughness value or texture defines the roughness of the microfacets on the surface. The rougher a surface is, the more light will scatter along completely different directions, resulting in larger and more muted specular reflections. Smoother surfaces, meanwhile, exhibit a sharper specular reflection as light rays are more likely to reflect in a uniform direction. Roughness can be set by setRoughnessMap(Texture), or, if a uniform value is preferred, setRoughness(float)
  • The ambient occlusion value or texture approximates how exposed the surface is to ambient lighting. This has no effect on direct lights (it does not result in clear shadows) but it darkens enclosed and sheltered areas. These textures are typically authored using modeling tools along with roughness and metalness. Ambient occlusion can be set by setAmbientOcclusionMap(Texture).
  • The lighting environment is a Texture (typically an HDR equirectangular image) that acts as a global light source, illuminating surfaces with diffuse and specular ambient light. We treat each pixel in the lighting environment as a light emitter, thereby capturing the environment's global lighting and general feel. This gives objects a sense of belonging to their environment. For this reason it is common to use the scene's background texture as the lighting environment, but this is not necessary. To set the lighting environment use setLightingEnvironment(Texture).

PBR rendering also takes into account normal maps to add more surface detail. However, PBR will ignore some properties used by the basic lighting models. Specifically, the specular texture (setSpecularTexture(Texture) and the shininess property (setShininess(float) are ignored when rendering physically-based surfaces.

Public methods

valueOf

Material.LightingModel valueOf (String name)

Parameters
name String

Returns
Material.LightingModel

values

LightingModel[] values ()

Returns
LightingModel[]

Hooray!