![]() |
vkmEngine 1.0.15
A C++ game engine · vkmengine.com
|
A complete PBR material. More...
#include <material_asset.h>
Public Member Functions | |
| bool | layered () const |
| Whether it blends layers, as a terrain's does. | |
| Public Member Functions inherited from Vkm::Engine::Resource | |
| Resource (const Resource &other) | |
Duplicate other's contents and name, but not its identity. | |
| const std::string & | name () const noexcept |
| Serializable identity; non-empty and unique within its type once added. | |
| uint64_t | uid () const noexcept |
| Process-unique id stamped by add(); names the asset, not the slot it sits in. | |
| uint64_t | version () const noexcept |
| Change counter the backend keys GPU re-uploads on; moved by commit(). | |
| bool | isHidden () const noexcept |
| Added by ResourceManager::addPrivate: not user-facing, not saved. | |
| nlohmann::json & | sourceJson () |
| Mutable source JSON, allocating a null document if there is none. | |
| const nlohmann::json & | sourceJson () const |
| Const source JSON; asserts hasSource(), so guard the call with it. | |
Public Attributes | |
| float | alphaCutoff = 0.5f |
| AlphaMask: discard below this albedo alpha (glTF default 0.5) | |
| bool | doubleSided = false |
| Both faces drawn, a back face lit as its own (glTF doubleSided): cloth, leaves, cards. | |
| glm::vec4 | albedo = {1,1,1,1} |
| Base color (RGB) + opacity (A; Transparent type blends on it) | |
| float | metallic = 0.0f |
| float | roughness = 0.5f |
| Surface roughness (0: smooth, 1: rough); GGX alpha = roughness^2. | |
| float | ior = 1.5f |
| float | ao = 1.0f |
| float | normalScale = 1.0f |
| Normal map intensity (0: flat, 1: as authored, >1: exaggerated) | |
| glm::vec3 | emission = {0,0,0} |
| Emissive color (RGB), linear. | |
| float | emissiveStrength = 1.0f |
| HDR multiplier on emission. | |
| float | clearcoat = 0.0f |
| Clearcoat layer strength (0: none, 1: full); attenuates the base layer. | |
| float | clearcoatRoughness = 0.0f |
| Clearcoat lobe roughness (0: smooth, 1: rough) | |
| float | anisotropy = 0.0f |
| Anisotropy strength (0: isotropic, 1: fully anisotropic) | |
| glm::vec3 | anisotropyDirection = {1,0,0} |
| Anisotropy direction (tangent space) | |
| glm::vec3 | sheenColor = {0,0,0} |
| Sheen tint, Charlie lobe (0 = disabled); cloth / velvet. | |
| float | sheenRoughness = 0.3f |
| Sheen lobe roughness. | |
| float | subsurface = 0.0f |
| Subsurface scattering strength; skin / wax / leaves. | |
| glm::vec3 | subsurfaceColor = {1,1,1} |
| Subsurface color tint. | |
| float | transmission = 0.0f |
| Fraction of light refracted instead of diffused (0: opaque, 1: glass) | |
| float | thicknessFactor = 0.0f |
| Volume thickness in metres (0: thin-walled, no absorption) | |
| float | attenuationDistance = 1.0f |
| Path length at which radiance reaches attenuationColor (m) | |
| glm::vec3 | attenuationColor = {1,1,1} |
| Transmittance after one attenuationDistance (white = no tint) | |
| float | heightScale = 0.0f |
| Parallax-occlusion depth scale (0: off; 0.02-0.1 typical) | |
| glm::vec2 | uvScale = {1.0f, 1.0f} |
| float | boxMapping = 0.0f |
| bool | waves = false |
| std::array< MaterialHandle, MAX_LAYERS > | layers {} |
| Materials blended in its place, by layerWeights: what a terrain draws with. | |
| TextureHandle | layerWeights |
| std::array< glm::vec2, MAX_LAYERS > | layerTiling {} |
Static Public Attributes | |
| static constexpr uint32_t | MAX_LAYERS = 4 |
| The most materials a layered one blends (layers). | |
A complete PBR material.
The Disney/glTF principled model; each scalar multiplies its map when one is bound. Fields here and shader support move in lockstep.
| float Vkm::Engine::MaterialAsset::metallic = 0.0f |
Metalness (0: dielectric, 1: metallic)
| float Vkm::Engine::MaterialAsset::ior = 1.5f |
Index of refraction; dielectric F0 = ((ior-1)/(ior+1))^2
| float Vkm::Engine::MaterialAsset::ao = 1.0f |
Ambient occlusion (0: occluded, 1: open): indirect light, and direct light at grazing angles (micro-shadowing)
| glm::vec2 Vkm::Engine::MaterialAsset::uvScale = {1.0f, 1.0f} |
A mesh's maps are read at uv * uvScale + uvOffset: how many times they repeat across its UVs on each axis, and how far they slide - 200 lays a texture two hundred times along a field. A decal, which lays its maps over its box, and an ocean's surface (waves) read neither.
| float Vkm::Engine::MaterialAsset::boxMapping = 0.0f |
Metres one repeat of the maps spans when box-mapped: the uv is read off where a point lies in its object's own frame, at the size the object is drawn, on the face its normal most nearly turns to - so a stretched cube is not a stretched texture, and the texture stays on the object as it moves. 0 reads the mesh's UVs. Made for boxes and faceted meshes: a smooth one shows a seam where its normal turns from one face to the next. Unskinned meshes; a skinned one keeps its UVs.
| bool Vkm::Engine::MaterialAsset::waves = false |
Moved by the scene's Ocean: the surface rides its waves, the maps lie over the water by its detailScale, crests whiten with its foam, and it casts no shadow (see rendering.md, "The ocean"). With no ocean in the scene it draws, and casts, as an ordinary surface.
| std::array<MaterialHandle, MAX_LAYERS> Vkm::Engine::MaterialAsset::layers {} |
Materials blended in its place, by layerWeights: what a terrain draws with.
Each layer's albedo, normal and AO/roughness/metallic maps and factors, read at its own tiling of the mesh's uv, weighted by layerWeights' R, G, B and A at that uv; every other field of this material is unread. Derived, not saved: a terrain makes and owns the material it draws with (TerrainSystem).
| TextureHandle Vkm::Engine::MaterialAsset::layerWeights |
Each layer's share, read at the mesh's uv.
| std::array<glm::vec2, MAX_LAYERS> Vkm::Engine::MaterialAsset::layerTiling {} |
Each layer's repeats across the mesh's uv, read in place of the layer's own uvScale, zero for once: a terrain tiles each layer at its own size in metres.