Using the realistic material

REDsdk provides an all-purpose, realistic material. This material is energetically equilibrated and fully customizable. Using that material, you should be able to reproduce the look & feel of almost every material in nature.

The default realistic material

Creating a realistic material

Call RED::IMaterial::SetupRealisticMaterial to setup a realistic material from an existing material object. The creation of a material occurs using RED::IResourceManager::CreateMaterial.

Realistic materials can also be created Using REDsdk's material editor. In this case, materials are saved to .red files and can be reloaded like any other material. See Loading a material from library for details on these operations.

The realistic material shading model

The realistic material shading model uses several basic inputs, that are summarized below:

InputDescriptionSample
DiffusionThis is the diffuse color / texture information of the material, used in a Lambertian equation.
TransmissionThis is the transmission color / texture information of the material. The transmission has precedence over the diffusion term for the calculation of energy preservation.
ReflectionThis is the reflection color / texture information of the material. The reflection has precedence over the diffusion and transparency terms for the calculation of energy preservation.

These three inputs are all involved in the energy preservation rule which is enforced by the realistic material shading model: the sum of the diffusion + reflection + transmission terms is always lower than or equal to 1.0. This is summarized below:

reflect' = reflect // reflection color is the dominant color and we left it unmodified
transmission' = (white - reflect') * transmission
diffuse' = (white - reflect' - transmission') * diffuse

This means that a realistic material with a reflection color set to white is totally opaque and reflective, even if any of the other components is not black.

Then, these inputs can be modified using special parameters:

InputDescriptionSample
FresnelThe fresnel option is a very powerful term that is used to modulate the amount of reflection emitted by the material based on the angle of the viewing direction with the surface. This must be turned on for all glasses materials.
Anisotropic reflectanceThis is an extra anisotropic term that can be set to specify anisotropic reflections in the realistic material. Two anisotropy values (anisotropy in U and anisotropy in V) can be set, or texture with at least two channels (red and green) can be set instead, to define a per-pixel anisotropic information. Anisotropy values are in [0.0f, 1.0f]. The larger the value the wider the reflection angle.
Anisotropy orientationThis term defines the orientation of the anisotropy. Either a single angular value or a texture with at least one channel (red) defines the value of the rotation angle to apply to the basis used to define the reflectance of the material. Angles are expressed in radians. The read texture value is multiplied by 2*PI to map the usual [0.0,1.0] range to [0.0,2*PI].
Transmission glossinessThis term defines the glossiness value of the material. A single glossiness value or a texture with at least one channel (red) can be used to define the per-pixel transmission glossiness of the material. Glossiness values are in [0.0f,1.0f]. The larger the value the wider the transmission glossiness cone.
Transmission scatteringThis is an extra absorption term that can be specified for the material transmission. It uses an out-scattering color and an out-scattering scale used to specifiy the amount of energy being absorbed along the path of a ray for each unit length crossed in the model media volume. This is related to Volumetric effects.
Reflection fogThis is fade-out term that can be specified for reflections. At a certain distance, the color of the reflection becomes equal to the specified reflection fog color, and any other visible reflection is lost.

Finally, the realistic material also features surface modifiers, that are detailed below:

InputDescriptionSample
Bump mapThe bump map of the realistic material affects the surface normal of the geometry at the shaded fragment.
Displacement mapThe displacement map of the realistic material modifies the surface of the geometry that uses it. See Displacement for details on displacement mapping.

Diffusion

The diffusion model used is Lambertian, meaning that the incoming light is diffused uniformly in every outgoing direction (i.e. in the whole hemisphere around the surface hit point). It is controlled giving one color (constant over the surface or by texel using a texture). A light that illuminates a surface produces a more visible lighting if it's aligned with the surface normal.

Note:

According to the previously detailed energy preservation rule, the object may appear of another color than the diffuse one if reflection and / or transmission are used.

Reflection

In our realistic material, reflections have greater weight than two others shading components. First, the user has to choose between two different behaviors (see the figure below):

Fresnel reflections (on the left) compared to uniform ones (on the right); in the Fresnel case, note how the reflection fades off as the angle between the eye vector and the surface normal decreases

Whatever the model you choose, reflections can be made glossy and / or anisotropic. The glossiness is a measure of the dispersion of the reflection rays around the perfectly specular reflection vector. It can be seen as the half-angle of the cone subtended by the reflection vector where reflection samples are taken. The more the angle increases the more the reflections are blurry (and will require samples to avoid too much noise; see figure below).

The sphere on the left is less glossy than the one on the right.

The anisotropy defines the shape of the reflections. Anisotropic materials reflect light according to the surface orientation (see figure below). It means that a local surface coordinate system is needed to handle oriented reflections. The basis used is the one given by the normal and the tangent vectors to the surface (see RED::IMeshShape::BuildTangents).

The sphere on the left is isotropic as the one on the right is anisotropic. Notice how reflections are vertically distorted in the anisotropic case

Transmission

Every realistic material has its own index of refraction (IOR; see the Table of common IOR (Table of common indices of refraction) for a list of known material IOR). When transparent, the material IOR is used to deviate light rays when they travel through the volume (see figure below).

The same realistic material with two different IOR values (1.02 on the left and 1.1 on the right)

As for reflections, refractions can be glossy to simulate a wide range of materials:

The same realistic material with (on the right) or without (on the left) refraction glossiness

GPU rendering

The rendering of the realistic material on the GPU is quite slow due to the complexity of the parameters it handles. Most parameters are properly supported on the GPU except the transmission glossiness texture and the reflection glossiness texture that are both ignored if the material is rendered using a GPU.

Real-time vs. photo-realistic configurations

The realistic material can be created for real-time rendering needs or for photo-realistic rendering needs, or for both needs, when using RED::IMaterial::SetupRealisticMaterial. The real-time version of the realistic material will use environmental mapping techniques instead of true ray-traced reflections. It'll also use refraction effects instead of true refractions, to ensure it can be rendered at real-time rates.

Realistic material properties

A realistic material is setup with a built-in material controller linked with it. Here is the full list of the realistic material properties. Each time a property name uses the '+' term, this means that the two strings indicated by #define statements must be concatenated.

Properties names are listed below:

PropertyTypeRangeDescription
Diffuse component
RED_MATCTRL_DIFFUSE_COLORColorn/aColor used for diffusion
RED_MATCTRL_DIFFUSE_TEXTURETexturen/aTexture used for diffusion
RED_MATCTRL_DIFFUSE_MATRIX + RED_MATCTRL_UVMATRIX_UOFFSETFloat]-inf,+inf[Diffuse texture translation along the u axis
RED_MATCTRL_DIFFUSE_MATRIX + RED_MATCTRL_UVMATRIX_VOFFSETFloat]-inf,+inf[Diffuse texture translation along the v axis
RED_MATCTRL_DIFFUSE_MATRIX + RED_MATCTRL_UVMATRIX_USCALEFloat]-inf,+inf[Diffuse texture repetition along the u axis
RED_MATCTRL_DIFFUSE_MATRIX + RED_MATCTRL_UVMATRIX_VSCALEFloat]-inf,+inf[Diffuse texture repetition along the v axis
RED_MATCTRL_DIFFUSE_MATRIX + RED_MATCTRL_UVMATRIX_UVROTATIONFloat]-inf,+inf[Diffuse texture rotation along the normal to the surface
RED_MATCTRL_DIFFUSE_CHANNELInteger[0, 15]Mesh input channel for diffuse texture uv coordinates
Transmission component
RED_MATCTRL_TRANSMISSION_COLORColorn/aColor used for transmission
RED_MATCTRL_TRANSMISSION_TEXTURETexturen/aTexture used for transmission
RED_MATCTRL_TRANSMISSION_MATRIX + RED_MATCTRL_UVMATRIX_UOFFSETFloat]-inf,+inf[Transmission texture translation along the u axis
RED_MATCTRL_TRANSMISSION_MATRIX + RED_MATCTRL_UVMATRIX_VOFFSETFloat]-inf,+inf[Transmission texture translation along the v axis
RED_MATCTRL_TRANSMISSION_MATRIX + RED_MATCTRL_UVMATRIX_USCALEFloat]-inf,+inf[Transmission texture repetition along the u axis
RED_MATCTRL_TRANSMISSION_MATRIX + RED_MATCTRL_UVMATRIX_VSCALEFloat]-inf,+inf[Transmission texture repetition along the v axis
RED_MATCTRL_TRANSMISSION_MATRIX + RED_MATCTRL_UVMATRIX_UVROTATIONFloat]-inf,+inf[Transmission texture rotation along the normal to the surface
RED_MATCTRL_TRANSMISSION_CHANNELInteger[0, 15]Mesh input channel for transmission texture uv coordinates
Transmission glossiness component
RED_MATCTRL_TRANSMISSION_GLOSSINESS_ANGLEFloat[0.0f,+inf[Transmission glossiness angle
RED_MATCTRL_TRANSMISSION_GLOSSINESS_TEXTURETexturen/aTexture used for transmission glossiness. The first channel of the texture is used.
RED_MATCTRL_TRANSMISSION_GLOSSINESS_MATRIX + RED_MATCTRL_UVMATRIX_UOFFSETFloat]-inf,+inf[Transmission texture translation along the u axis
RED_MATCTRL_TRANSMISSION_GLOSSINESS_MATRIX + RED_MATCTRL_UVMATRIX_VOFFSETFloat]-inf,+inf[Transmission texture translation along the v axis
RED_MATCTRL_TRANSMISSION_GLOSSINESS_MATRIX + RED_MATCTRL_UVMATRIX_USCALEFloat]-inf,+inf[Transmission texture repetition along the u axis
RED_MATCTRL_TRANSMISSION_GLOSSINESS_MATRIX + RED_MATCTRL_UVMATRIX_VSCALEFloat]-inf,+inf[Transmission texture repetition along the v axis
RED_MATCTRL_TRANSMISSION_GLOSSINESS_MATRIX + RED_MATCTRL_UVMATRIX_UVROTATIONFloat]-inf,+inf[Transmission texture rotation along the normal to the surface
RED_MATCTRL_TRANSMISSION_GLOSSINESS_CHANNELInteger[0, 15]Mesh input channel for transmission glossiness texture uv coordinates
Bump component
RED_MATCTRL_BUMP_TEXTURETexturen/aTexture used for bump
RED_MATCTRL_BUMP_MATRIX + RED_MATCTRL_UVMATRIX_UOFFSETFloat]-inf,+inf[Bump texture translation along the u axis
RED_MATCTRL_BUMP_MATRIX + RED_MATCTRL_UVMATRIX_VOFFSETFloat]-inf,+inf[Bump texture translation along the v axis
RED_MATCTRL_BUMP_MATRIX + RED_MATCTRL_UVMATRIX_USCALEFloat]-inf,+inf[Bump texture repetition along the u axis
RED_MATCTRL_BUMP_MATRIX + RED_MATCTRL_UVMATRIX_VSCALEFloat]-inf,+inf[Bump texture repetition along the v axis
RED_MATCTRL_BUMP_MATRIX + RED_MATCTRL_UVMATRIX_UVROTATIONFloat]-inf,+inf[Bump texture rotation along the normal to the surface
RED_MATCTRL_BUMP_CHANNELInteger[0, 15]Mesh input channel for bump texture uv coordinates
RED_MATCTRL_TANGENTS_CHANNELInteger[0, 15]Mesh input channel for tangent vectors definition
Environment component (real-time realistic materials)
RED_MATCTRL_ENVIRONMENT_TEXTURETexturen/aTexture used for environment mapping
RED_MATCTRL_ENVIRONMENT_MATRIX + RED_MATCTRL_UVMATRIX_UOFFSETFloat]-inf,+inf[Environment texture translation along the u axis
RED_MATCTRL_ENVIRONMENT_MATRIX + RED_MATCTRL_UVMATRIX_VOFFSETFloat]-inf,+inf[Environment texture translation along the v axis
RED_MATCTRL_ENVIRONMENT_MATRIX + RED_MATCTRL_UVMATRIX_USCALEFloat]-inf,+inf[Environment texture repetition along the u axis
RED_MATCTRL_ENVIRONMENT_MATRIX + RED_MATCTRL_UVMATRIX_VSCALEFloat]-inf,+inf[Environment texture repetition along the v axis
RED_MATCTRL_ENVIRONMENT_MATRIX + RED_MATCTRL_UVMATRIX_UVROTATIONFloat]-inf,+inf[Environment texture rotation along the normal to the surface
RED_MATCTRL_ENVIRONMENT_AUTOBoolean[false, true]Toggle automatic environment maps (generated using RED::RenderShaderParameter::REF_AUTO_CUBE_MAP)
RED_MATCTRL_ENVIRONMENT_BACKBoolean[false, true]Toggle background environment maps (from RED::IViewpointRenderList::SetBackgroundImages)
Reflection component
RED_MATCTRL_REFLECTION_COLORColorn/aColor used for reflection
RED_MATCTRL_REFLECTION_TEXTURETexturen/aTexture used for reflection
RED_MATCTRL_REFLECTION_MATRIX + RED_MATCTRL_UVMATRIX_UOFFSETFloat]-inf,+inf[Reflection texture translation along the u axis
RED_MATCTRL_REFLECTION_MATRIX + RED_MATCTRL_UVMATRIX_VOFFSETFloat]-inf,+inf[Reflection texture translation along the v axis
RED_MATCTRL_REFLECTION_MATRIX + RED_MATCTRL_UVMATRIX_USCALEFloat]-inf,+inf[Reflection texture repetition along the u axis
RED_MATCTRL_REFLECTION_MATRIX + RED_MATCTRL_UVMATRIX_VSCALEFloat]-inf,+inf[Reflection texture repetition along the v axis
RED_MATCTRL_REFLECTION_MATRIX + RED_MATCTRL_UVMATRIX_UVROTATIONFloat]-inf,+inf[Reflection texture rotation along the normal to the surface
RED_MATCTRL_REFLECTION_CHANNELInteger[0, 15]Mesh input channel for reflection texture uv coordinates
Anisotropy component
RED_MATCTRL_ANISOTROPY_UFloat[0.0f,+inf[Anisotropy along the U axis of the local (tangent, binormal, normal) basis at the shaded fragment
RED_MATCTRL_ANISOTROPY_VFloat[0.0f,+inf[Anisotropy along the V axis of the local (tangent, binormal, normal) basis at the shaded fragment
RED_MATCTRL_ANISOTROPY_TEXTURETexturen/aTexture used for the reflection anisotropy
RED_MATCTRL_ANISOTROPY_MATRIX + RED_MATCTRL_UVMATRIX_UOFFSETFloat]-inf,+inf[Anisotropy texture translation along the u axis
RED_MATCTRL_ANISOTROPY_MATRIX + RED_MATCTRL_UVMATRIX_VOFFSETFloat]-inf,+inf[Anisotropy texture translation along the v axis
RED_MATCTRL_ANISOTROPY_MATRIX + RED_MATCTRL_UVMATRIX_USCALEFloat]-inf,+inf[Anisotropy texture repetition along the u axis
RED_MATCTRL_ANISOTROPY_MATRIX + RED_MATCTRL_UVMATRIX_VSCALEFloat]-inf,+inf[Anisotropy texture repetition along the v axis
RED_MATCTRL_ANISOTROPY_MATRIX + RED_MATCTRL_UVMATRIX_UVROTATIONFloat]-inf,+inf[Anisotropy texture rotation along the normal to the surface
RED_MATCTRL_ANISOTROPY_CHANNELInteger[0, 15]Mesh input channel for anisotropy texture uv coordinates
Anisotropy rotation component
RED_MATCTRL_ANISOTROPY_ROTATIONFloat]-inf,+inf[Anisotropy rotation angle around the normal axis of the local (tangent, binormal, normal) basis at the shaded fragment
RED_MATCTRL_ANISOTROPY_ROTATION_TEXTURETexturen/aTexture used for the rotation of the anisotropy
RED_MATCTRL_ANISOTROPY_ROTATION_MATRIX + RED_MATCTRL_UVMATRIX_UOFFSETFloat]-inf,+inf[Anisotropy rotation texture translation along the u axis
RED_MATCTRL_ANISOTROPY_ROTATION_MATRIX + RED_MATCTRL_UVMATRIX_VOFFSETFloat]-inf,+inf[Anisotropy rotation texture translation along the v axis
RED_MATCTRL_ANISOTROPY_ROTATION_MATRIX + RED_MATCTRL_UVMATRIX_USCALEFloat]-inf,+inf[Anisotropy rotation texture repetition along the u axis
RED_MATCTRL_ANISOTROPY_ROTATION_MATRIX + RED_MATCTRL_UVMATRIX_VSCALEFloat]-inf,+inf[Anisotropy rotation texture repetition along the v axis
RED_MATCTRL_ANISOTROPY_ROTATION_MATRIX + RED_MATCTRL_UVMATRIX_UVROTATIONFloat]-inf,+inf[Anisotropy rotation texture rotation along the normal to the surface
RED_MATCTRL_ANISOTROPY_ROTATION_CHANNELInteger[0, 15]Mesh input channel for anisotropy rotation texture uv coordinates
Displacement component
RED_MATCTRL_DISPLACEMENT_HEIGHTFloat]0.0f,+inf[Height amplitude of the surface displacement, in model units
RED_MATCTRL_DISPLACEMENT_OFFSETFloat]-inf,+inf[Offset applied to the height ampliture of the surface displacement, in model units
RED_MATCTRL_DISPLACEMENT_TEXTURETexturen/aDisplacement map texture
RED_MATCTRL_DISPLACEMENT_MATRIX + RED_MATCTRL_UVMATRIX_UOFFSETFloat]-inf,+inf[Displacement texture translation along the u axis
RED_MATCTRL_DISPLACEMENT_MATRIX + RED_MATCTRL_UVMATRIX_VOFFSETFloat]-inf,+inf[Displacement texture translation along the v axis
RED_MATCTRL_DISPLACEMENT_MATRIX + RED_MATCTRL_UVMATRIX_USCALEFloat]-inf,+inf[Displacement texture repetition along the u axis
RED_MATCTRL_DISPLACEMENT_MATRIX + RED_MATCTRL_UVMATRIX_VSCALEFloat]-inf,+inf[Displacement texture repetition along the v axis
RED_MATCTRL_DISPLACEMENT_MATRIX + RED_MATCTRL_UVMATRIX_UVROTATIONFloat]-inf,+inf[Displacement texture rotation along the normal to the surface
RED_MATCTRL_DISPLACEMENT_CHANNELInteger[0, 15]Mesh input channel for displacement texture uv coordinates
Miscellaneous properties
RED_MATCTRL_DOUBLESIDEDBoolean[false,true]Is the material double sided?
RED_MATCTRL_FRESNELBoolean[false,true]Is the material using a Fresnel reflectance model?
RED_MATCTRL_IORFloat]0.0f,+inf[Index Of Refraction (IOR) of the material
RED_MATCTRL_TRANSMISSION_SCATTERING_COLORColorn/aColor used for the material transmission scattering
RED_MATCTRL_TRANSMISSION_SCATTERING_SCALEFloat]0.0f,+inf[Model unit scaling applied to the transmission scattering distance
RED_MATCTRL_CAUSTICS_REFLECTIVEBoolean[false,true]Is the material emitting reflective caustics?
RED_MATCTRL_CAUSTICS_REFRACTIVEBoolean[false,true]Is the material emitting refractive caustics?

Table of common indices of refraction

MaterialIOR
Acetone1.36
Air1.0
Alcohol1.33
Chromium Oxide2.7
Copper Oxyde2.7
Crystal2.0
Diamond2.42
Emerald1.57
Ethyl Alcohol1.36
Glass1.5
Glass, Crown1.52
Glass, Heaviest Flint1.89
Glass, Heavy Flint1.65
Glass, Light Flint1.57
Glass, Zinc Crown1.52
Ice1.31
Iodine Crystal3.34
Lapis Lazuli1.61
Polystyrene1.55
Pyrex1.47
Quartz1.6
Quartz, Fused1.46
Ruby1.77
Sapphire1.77
Silicon4.01
Topaz1.61
Water1.33