Support Forum       G3D Web Page     
Public Member Functions | Friends | List of all members
G3D::UniversalMaterial::Specification Class Reference

Specification of a material; used for loading. More...

Public Member Functions

 Specification ()
 
 Specification (const Any &any)
 
Construct a UniversalMaterial::Specification from an Any, typically loaded by parsing a file. More...
 
 Specification (const Color4 &lambertian)
 
AlphaFilter alphaFilter () const
 
uint8 flags () const
 
size_t hashCode () const
 
Any inferAmbientOcclusionAtTransparentPixels () const
 
void load (const String &filename)
 Load from a file created by save(). More...
 
bool operator!= (const Specification &s) const
 
bool operator== (const Specification &s) const
 
void removeBump ()
 
void removeEmissive ()
 
void removeGlossy ()
 
void removeLambertian ()
 Makes the surface opaque black. More...
 
void removeTransmissive ()
 
const Samplersampler () const
 
void setAlphaHint (const AlphaFilter &a)
 
void setBump (const String &filename, const BumpMap::Settings &settings=BumpMap::Settings(), float normalMapWhiteHeightInPixels=4.0f, bool invertPrecomputedNormalYAxis=false)
 The image is assumed to be in linear (R) space. More...
 
void setBump (const BumpMap::Specification &bump)
 
void setConstant (const String &name, float c)
 
void setConstant (const String &name, int c)
 
void setConstant (const String &name, bool c)
 
void setCustomShaderPrefix (const String &s)
 
void setEmissive (const Texture::Specification &spec)
 
void setEmissive (const shared_ptr< Texture > &tex)
 
void setEta (float etaTransmit, float etaReflect)
 Set the index of refraction. More...
 
void setExtinction (const Color3 &extinctionTransmit, const Color3 &extinctionReflect)
 
void setFlags (uint8 f)
 
void setGlossy (const Texture::Specification &spec)
 Mirror reflection or glossy reflection. More...
 
void setGlossy (const shared_ptr< Texture > &tex)
 
void setinferAmbientOcclusionAtTransparentPixels (Any b)
 boolean or "auto" More...
 
void setLambertian (const Texture::Specification &spec)
 Filename of Lambertian ("diffuse") term, empty if none. More...
 
void setLambertian (const shared_ptr< Texture > &tex)
 
void setLightMaps (const shared_ptr< Texture > &lightMap)
 Sets the diffuse light map for this surface. More...
 
void setLightMaps (const shared_ptr< Texture > lightMap[3])
 Sets the radiosity normal map for this material specification. More...
 
void setLightMaps (const shared_ptr< UniversalMaterial > &otherMaterial)
 Sets the radiosity normal map for this material specification from the other material. More...
 
void setMirrorHint (MirrorQuality q)
 Defaults to G3D::MirrorQuality::STATIC_PROBE. More...
 
void setRefractionHint (RefractionHint q)
 Defaults to G3D::RefractionHint::DYNAMIC_FLAT. More...
 
void setSampler (const Sampler &sampler)
 
void setTransmissive (const Texture::Specification &spec)
 This is an approximation of attenuation due to extinction while traveling through a translucent material. More...
 
void setTransmissive (const shared_ptr< Texture > &tex)
 
Any toAny () const
 

Friends

class UniversalMaterial
 

Detailed Description

Specification of a material; used for loading.

Can be written to a file or constructed from a series of calls.

The following terminology for photon scattering is used in the G3D::UniversalMaterial::Specification and G3D::UniversalBSDF classes and their documentation:

Constructor & Destructor Documentation

◆ Specification() [1/3]

G3D::UniversalMaterial::Specification::Specification ( )

◆ Specification() [2/3]

G3D::UniversalMaterial::Specification::Specification ( const Any any)


Construct a UniversalMaterial::Specification from an Any, typically loaded by parsing a file.

Some simple examples follow.

All fields as texture maps:

UniversalMaterial::Specification {
lambertian = "diffusemap.png";
alphaFilter = BINARY;
// Put smoothness in the alpha channel
glossy = "specmap.png";
transmissive = "transmap.png"; // Simple transmission
emissive = "emitmap.png";
emissive = mul("emitmap.png", 3.0); // various options for emissive
emissive = Color3(0.5);
bump = "bumpmap.png"; // see BumpMap::Specification
// Sophisticated transmission:
// Properties of the back-face side:
etaTransmit = 1.0;
extinctionTransmit = Color3(1,1,1);
flags = 0;
// Properties of the front-face side:
etaReflect = 1.0;
extinctionReflect = Color3(1,1,1);
// Hints and hacks
refractionHint = "DYNAMIC_FLAT";
mirrorHint = "STATIC_PROBE";
// Should transparent pixels guess their AO value from nearby opaque ones?
// This looks good on tree leaves and bad on glass or smoke
sampler = Sampler {
maxMipMap = 4;
};
// Arbitrary fields for use in experiments and prototypes.
// These are bound to macros in shaders and stored in a double. Setting
// a constant to nan() unsets it.
constantTable = {
ANISO = 1;
HEIGHT = 3.7;
ITERATIONS = 1;
};
}

Diffuse yellow (any Color3 automatically coerces to a pure Lambertian surface):

Color3(1,1,0)

Simple diffuse texture (any string coerces to a filename for the Lambertian texture):

"dirt.jpg"

Mirror:

UniversalMaterial::Specification {
lambertian = Color3(0.01);
glossy = Color4(Color3(0.95), 1.0);
}

Red plastic:

UniversalMaterial::Specification {
lambertian = Color3(0.95, 0.2, 0.05);
glossy = Color4(Color3(0.3), 0.5);
}

Green glass:

UniversalMaterial::Specification {
lambertian = Color3(0.01, 0.1, 0.05);
transmissive = Color3(0.01, 0.9, 0.01);
glossy = Color4(Color3(0.4), 1.0);
}

Any component can be a Texture::Specification, Color3/Color4, or table of {texture = ...; constant = ...}.

See also
G3D::RefractionHint,
G3D::MirrorQuality,
G3D::BumpMapSpecification

◆ Specification() [3/3]

G3D::UniversalMaterial::Specification::Specification ( const Color4 lambertian)

Member Function Documentation

◆ alphaFilter()

AlphaFilter G3D::UniversalMaterial::Specification::alphaFilter ( ) const
inline

◆ flags()

uint8 G3D::UniversalMaterial::Specification::flags ( ) const
inline

◆ hashCode()

size_t G3D::UniversalMaterial::Specification::hashCode ( ) const

◆ inferAmbientOcclusionAtTransparentPixels()

Any G3D::UniversalMaterial::Specification::inferAmbientOcclusionAtTransparentPixels ( ) const
inline

◆ load()

void G3D::UniversalMaterial::Specification::load ( const String filename)

Load from a file created by save().

◆ operator!=()

bool G3D::UniversalMaterial::Specification::operator!= ( const Specification s) const
inline

◆ operator==()

bool G3D::UniversalMaterial::Specification::operator== ( const Specification s) const

◆ removeBump()

void G3D::UniversalMaterial::Specification::removeBump ( )

◆ removeEmissive()

void G3D::UniversalMaterial::Specification::removeEmissive ( )

◆ removeGlossy()

void G3D::UniversalMaterial::Specification::removeGlossy ( )

◆ removeLambertian()

void G3D::UniversalMaterial::Specification::removeLambertian ( )

Makes the surface opaque black.

◆ removeTransmissive()

void G3D::UniversalMaterial::Specification::removeTransmissive ( )

◆ sampler()

const Sampler& G3D::UniversalMaterial::Specification::sampler ( ) const
inline

Referenced by setSampler().

◆ setAlphaHint()

void G3D::UniversalMaterial::Specification::setAlphaHint ( const AlphaFilter a)
inline

◆ setBump() [1/2]

void G3D::UniversalMaterial::Specification::setBump ( const String filename,
const BumpMap::Settings settings = BumpMap::Settings(),
float  normalMapWhiteHeightInPixels = 4.0f,
bool  invertPrecomputedNormalYAxis = false 
)

The image is assumed to be in linear (R) space.

Parameters
normalMapWhiteHeightInPixelsWhen loading normal maps, argument used for G3D::GImage::computeNormalMap() whiteHeightInPixels. Default is 2.0f
Deprecated:

◆ setBump() [2/2]

void G3D::UniversalMaterial::Specification::setBump ( const BumpMap::Specification bump)
inline

◆ setConstant() [1/3]

void G3D::UniversalMaterial::Specification::setConstant ( const String name,
float  c 
)
inline

◆ setConstant() [2/3]

void G3D::UniversalMaterial::Specification::setConstant ( const String name,
int  c 
)
inline

◆ setConstant() [3/3]

void G3D::UniversalMaterial::Specification::setConstant ( const String name,
bool  c 
)
inline

◆ setCustomShaderPrefix()

void G3D::UniversalMaterial::Specification::setCustomShaderPrefix ( const String s)
inline

◆ setEmissive() [1/2]

void G3D::UniversalMaterial::Specification::setEmissive ( const Texture::Specification spec)

◆ setEmissive() [2/2]

void G3D::UniversalMaterial::Specification::setEmissive ( const shared_ptr< Texture > &  tex)

◆ setEta()

void G3D::UniversalMaterial::Specification::setEta ( float  etaTransmit,
float  etaReflect 
)

Set the index of refraction.

Not used unless transmissive is non-zero.

◆ setExtinction()

void G3D::UniversalMaterial::Specification::setExtinction ( const Color3 extinctionTransmit,
const Color3 extinctionReflect 
)
inline

◆ setFlags()

void G3D::UniversalMaterial::Specification::setFlags ( uint8  f)
inline

◆ setGlossy() [1/2]

void G3D::UniversalMaterial::Specification::setGlossy ( const Texture::Specification spec)

Mirror reflection or glossy reflection.

This actually specifies the $F_0$ term, which is the minimum reflectivity of the surface. At glancing angles it will increase towards white.

The alpha channel specifies the smoothness of the surface on [0, 1]. Smoother materials have sharp, bright highlights. Setting this to zero disables glossy reflection.

◆ setGlossy() [2/2]

void G3D::UniversalMaterial::Specification::setGlossy ( const shared_ptr< Texture > &  tex)

◆ setinferAmbientOcclusionAtTransparentPixels()

void G3D::UniversalMaterial::Specification::setinferAmbientOcclusionAtTransparentPixels ( Any  b)
inline

boolean or "auto"

◆ setLambertian() [1/2]

void G3D::UniversalMaterial::Specification::setLambertian ( const Texture::Specification spec)

Filename of Lambertian ("diffuse") term, empty if none.

The alpha channel is a mask that will be applied to all maps for coverage. That is, alpha = 0 indicates holes in the surface. Alpha is for partial coverage. Do not use alpha for transparency; set transmissiveFilename instead.

The image file is assumed to be in the sRGB color space. The constant is multiplied in "linear" space, after sRGB->RGB conversion.

◆ setLambertian() [2/2]

void G3D::UniversalMaterial::Specification::setLambertian ( const shared_ptr< Texture > &  tex)

◆ setLightMaps() [1/3]

void G3D::UniversalMaterial::Specification::setLightMaps ( const shared_ptr< Texture > &  lightMap)

Sets the diffuse light map for this surface.

Pass shared_ptr<Texture>() to erase an existing light map.

◆ setLightMaps() [2/3]

void G3D::UniversalMaterial::Specification::setLightMaps ( const shared_ptr< Texture lightMap[3])

Sets the radiosity normal map for this material specification.

◆ setLightMaps() [3/3]

void G3D::UniversalMaterial::Specification::setLightMaps ( const shared_ptr< UniversalMaterial > &  otherMaterial)

Sets the radiosity normal map for this material specification from the other material.

◆ setMirrorHint()

void G3D::UniversalMaterial::Specification::setMirrorHint ( MirrorQuality  q)
inline

◆ setRefractionHint()

void G3D::UniversalMaterial::Specification::setRefractionHint ( RefractionHint  q)
inline

◆ setSampler()

void G3D::UniversalMaterial::Specification::setSampler ( const Sampler sampler)
inline

◆ setTransmissive() [1/2]

void G3D::UniversalMaterial::Specification::setTransmissive ( const Texture::Specification spec)

This is an approximation of attenuation due to extinction while traveling through a translucent material.

Note that no real material is transmissive without also being at least slightly glossy.

The image file is assumed to be in the sRGB color space. The constant is multiplied in "linear" space, after sRGB->RGB conversion.

◆ setTransmissive() [2/2]

void G3D::UniversalMaterial::Specification::setTransmissive ( const shared_ptr< Texture > &  tex)

◆ toAny()

Any G3D::UniversalMaterial::Specification::toAny ( ) const

Friends And Related Function Documentation

◆ UniversalMaterial

friend class UniversalMaterial
friend

documentation generated on Wed Nov 24 2021 08:02:01 using doxygen 1.8.15