Panda3D
|
Defines the way an object appears in the presence of lighting. More...
#include <pandadoc.hpp>
Public Member Functions | |
__init__ (const Material copy) | |
__init__ (str name) | |
clearAmbient () | |
Removes the explicit ambient color from the material. More... | |
clearBaseColor () | |
Removes the explicit base_color color from the material. More... | |
clearDiffuse () | |
Removes the explicit diffuse color from the material. More... | |
clearEmission () | |
Removes the explicit emission color from the material. More... | |
clearMetallic () | |
Removes the explicit metallic setting from the material. More... | |
clearSpecular () | |
Removes the explicit specular color from the material. More... | |
int | compareTo (const Material other) |
Returns a number less than zero if this material sorts before the other one, greater than zero if it sorts after, or zero if they are equivalent. More... | |
const LColor | getAmbient () |
Returns the ambient color setting, if it has been set. More... | |
const LColor | getBaseColor () |
Returns the base_color color setting, if it has been set. More... | |
const LColor | getDiffuse () |
Returns the diffuse color setting, if it has been set. More... | |
const LColor | getEmission () |
Returns the emission color setting, if it has been set. More... | |
bool | getLocal () |
Returns the local viewer flag. More... | |
float | getMetallic () |
Returns the metallic setting, if it has been set. More... | |
float | getRefractiveIndex () |
Returns the index of refraction, or 1 if none has been set for this material. More... | |
float | getRoughness () |
Returns the roughness previously specified by set_roughness. More... | |
float | getShininess () |
Returns the shininess exponent of the material. More... | |
const LColor | getSpecular () |
Returns the specular color setting, if it has been set. More... | |
bool | getTwoside () |
Returns the state of the two-sided lighting flag. More... | |
bool | hasAmbient () |
Returns true if the ambient color has been explicitly set for this material, false otherwise. More... | |
bool | hasBaseColor () |
Returns true if the base color has been explicitly set for this material, false otherwise. More... | |
bool | hasDiffuse () |
Returns true if the diffuse color has been explicitly set for this material, false otherwise. More... | |
bool | hasEmission () |
Returns true if the emission color has been explicitly set for this material, false otherwise. More... | |
bool | hasMetallic () |
Returns true if the metallic has been explicitly set for this material, false otherwise. More... | |
bool | hasRefractiveIndex () |
Returns true if a refractive index has explicitly been specified for this material. More... | |
bool | hasRoughness () |
Returns true if the roughness has been explicitly set for this material, false otherwise. More... | |
bool | hasSpecular () |
Returns true if the specular color has been explicitly set for this material, false otherwise. More... | |
bool | isAttribLocked () |
bool | operator!= (const Material other) |
bool | operator< (const Material other) |
Material | operator= (const Material copy) |
bool | operator== (const Material other) |
output (Ostream out) | |
setAmbient (const LColor color) | |
Specifies the ambient color setting of the material. More... | |
setAttribLock () | |
setBaseColor (const LColor color) | |
Specifies the base color of the material. More... | |
setDiffuse (const LColor color) | |
Specifies the diffuse color setting of the material. More... | |
setEmission (const LColor color) | |
Specifies the emission color setting of the material. More... | |
setLocal (bool local) | |
Sets the local viewer flag. More... | |
setMetallic (float metallic) | |
Sets the metallic setting of the material, which is is used for physically- based rendering models. More... | |
setRefractiveIndex (float refractive_index) | |
Sets the index of refraction of the material, which is used to determine the specular color in absence of an explicit specular color assignment. More... | |
setRoughness (float roughness) | |
Sets the roughness exponent of the material, where 0 is completely shiny (infinite shininess), and 1 is a completely dull object (0 shininess). More... | |
setShininess (float shininess) | |
Sets the shininess exponent of the material. More... | |
setSpecular (const LColor color) | |
Specifies the specular color setting of the material. More... | |
setTwoside (bool twoside) | |
Set this true to enable two-sided lighting. More... | |
write (Ostream out, int indent) | |
![]() | |
object | __reduce__ () |
object | __reduce_persist__ (object pickler) |
VectorUchar | encodeToBamStream () |
Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. More... | |
bool | encodeToBamStream (VectorUchar data, BamWriter writer) |
Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More... | |
fillin (DatagramIterator scan, BamReader manager) | |
This internal function is intended to be called by each class's make_from_bam() method to read in all of the relevant data from the BamFile for the new object. More... | |
UpdateSeq | getBamModified () |
Returns the current bam_modified counter. More... | |
markBamModified () | |
Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More... | |
![]() | |
TypeHandle | getType () |
int | getTypeIndex () |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
bool | isExactType (TypeHandle handle) |
Returns true if the current object is the indicated type exactly. More... | |
bool | isOfType (TypeHandle handle) |
Returns true if the current object is or derives from the indicated type. More... | |
![]() | |
int | getRefCount () |
Returns the current reference count. More... | |
ref () | |
Explicitly increments the reference count. More... | |
bool | testRefCountIntegrity () |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | testRefCountNonzero () |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
bool | unref () |
Explicitly decrements the reference count. More... | |
![]() | |
__init__ (const Namable) | |
__init__ (str initial_name) | |
clearName () | |
Resets the Namable's name to empty. More... | |
str | getName () |
bool | hasName () |
Returns true if the Namable has a nonempty name set, false if the name is empty. More... | |
output (Ostream out) | |
Outputs the Namable. More... | |
setName (str name) | |
Static Public Member Functions | |
static TypeHandle | getClassType () |
static Material | getDefault () |
Returns the default material. More... | |
![]() | |
static TypedWritableReferenceCount | decodeFromBamStream (VectorUchar data, BamReader reader) |
Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on those bytes. More... | |
static TypeHandle | getClassType () |
![]() | |
static TypeHandle | getClassType () |
![]() | |
static TypeHandle | getClassType () |
![]() | |
static TypeHandle | getClassType () |
![]() | |
static TypeHandle | getClassType () |
Public Attributes | |
const LColor | ambient |
Returns the ambient color setting, if it has been set. More... | |
const LColor | base_color |
Returns the base_color color setting, if it has been set. More... | |
const LColor | diffuse |
Returns the diffuse color setting, if it has been set. More... | |
const LColor | emission |
Returns the emission color setting, if it has been set. More... | |
bool | local |
Returns the local viewer flag. More... | |
float | metallic |
Returns the metallic setting, if it has been set. More... | |
float | refractive_index |
Returns the index of refraction, or 1 if none has been set for this material. More... | |
float | roughness |
Returns the roughness previously specified by set_roughness. More... | |
float | shininess |
Returns the shininess exponent of the material. More... | |
const LColor | specular |
Returns the specular color setting, if it has been set. More... | |
bool | twoside |
Returns the state of the two-sided lighting flag. More... | |
![]() | |
TypeHandle | type |
Returns the TypeHandle representing this object's type. More... | |
![]() | |
int | ref_count |
The current reference count. More... | |
![]() | |
const String | name |
Defines the way an object appears in the presence of lighting.
A material is only necessary if lighting is to be enabled; otherwise, the material isn't used.
There are two workflows that are supported: the "classic" workflow of providing separate ambient, diffuse and specular colors, and the "metalness" workflow, in which a base color is specified along with a "metallic" value that indicates whether the material is a metal or a dielectric.
The size of the specular highlight can be specified by either specifying the specular exponent (shininess) or by specifying a roughness value that in perceptually linear in the range of 0-1.
__init__ | ( | const Material | copy | ) |
__init__ | ( | str | name | ) |
clearAmbient | ( | ) |
Removes the explicit ambient color from the material.
clearBaseColor | ( | ) |
Removes the explicit base_color color from the material.
clearDiffuse | ( | ) |
Removes the explicit diffuse color from the material.
clearEmission | ( | ) |
Removes the explicit emission color from the material.
clearMetallic | ( | ) |
Removes the explicit metallic setting from the material.
clearSpecular | ( | ) |
Removes the explicit specular color from the material.
int compareTo | ( | const Material | other | ) |
Returns a number less than zero if this material sorts before the other one, greater than zero if it sorts after, or zero if they are equivalent.
The sorting order is arbitrary and largely meaningless, except to differentiate different materials.
const LColor getAmbient | ( | ) |
Returns the ambient color setting, if it has been set.
Returns (0,0,0,0) if the ambient color has not been set.
const LColor getBaseColor | ( | ) |
Returns the base_color color setting, if it has been set.
If neither the base color nor the metallic have been set, this returns the diffuse color.
|
static |
|
static |
Returns the default material.
const LColor getDiffuse | ( | ) |
Returns the diffuse color setting, if it has been set.
Returns (1,1,1,1) if the diffuse color has not been set.
const LColor getEmission | ( | ) |
Returns the emission color setting, if it has been set.
Returns (0,0,0,0) if the emission color has not been set.
bool getLocal | ( | ) |
Returns the local viewer flag.
Set set_local().
float getMetallic | ( | ) |
Returns the metallic setting, if it has been set.
Returns 0 if it has not been set.
float getRefractiveIndex | ( | ) |
Returns the index of refraction, or 1 if none has been set for this material.
float getRoughness | ( | ) |
Returns the roughness previously specified by set_roughness.
If none was previously set, this value is computed from the shininess value.
float getShininess | ( | ) |
Returns the shininess exponent of the material.
const LColor getSpecular | ( | ) |
Returns the specular color setting, if it has been set.
Returns (0,0,0,0) if the specular color has not been set.
bool getTwoside | ( | ) |
Returns the state of the two-sided lighting flag.
See set_twoside().
bool hasAmbient | ( | ) |
Returns true if the ambient color has been explicitly set for this material, false otherwise.
bool hasBaseColor | ( | ) |
Returns true if the base color has been explicitly set for this material, false otherwise.
bool hasDiffuse | ( | ) |
Returns true if the diffuse color has been explicitly set for this material, false otherwise.
bool hasEmission | ( | ) |
Returns true if the emission color has been explicitly set for this material, false otherwise.
bool hasMetallic | ( | ) |
Returns true if the metallic has been explicitly set for this material, false otherwise.
bool hasRefractiveIndex | ( | ) |
Returns true if a refractive index has explicitly been specified for this material.
bool hasRoughness | ( | ) |
Returns true if the roughness has been explicitly set for this material, false otherwise.
bool hasSpecular | ( | ) |
Returns true if the specular color has been explicitly set for this material, false otherwise.
bool isAttribLocked | ( | ) |
bool operator!= | ( | const Material | other | ) |
bool operator< | ( | const Material | other | ) |
bool operator== | ( | const Material | other | ) |
output | ( | Ostream | out | ) |
setAmbient | ( | const LColor | color | ) |
Specifies the ambient color setting of the material.
This will be the multiplied by any ambient lights in effect on the material to set its base color.
This is the color of the object as it appears in the absence of direct light.
If this is not set, the object color will be used.
setAttribLock | ( | ) |
setBaseColor | ( | const LColor | color | ) |
Specifies the base color of the material.
In conjunction with set_metallic, this is an alternate way to specify the color of a material. For dielectrics, this will determine the value of the diffuse color, and for metals, this will determine the value of the specular color.
Setting this will clear an explicit specular, diffuse or ambient color assignment.
If this is not set, the object color will be used.
setDiffuse | ( | const LColor | color | ) |
Specifies the diffuse color setting of the material.
This will be multiplied by any lights in effect on the material to get the color in the parts of the object illuminated by the lights.
This is the primary color of an object; the color of the object as it appears in direct light, in the absence of highlights.
If this is not set, the object color will be used.
setEmission | ( | const LColor | color | ) |
Specifies the emission color setting of the material.
This is the color of the object as it appears in the absence of any light whatsover, including ambient light. It is as if the object is glowing by this color (although of course it will not illuminate neighboring objects).
If this is not set, the object will not glow by its own light and will only appear visible in the presence of one or more lights.
setLocal | ( | bool | local | ) |
Sets the local viewer flag.
Set this true to enable camera-relative specular highlights, or false to use orthogonal specular highlights. The default value is true. Applications that use orthogonal projection should specify false.
setMetallic | ( | float | metallic | ) |
Sets the metallic setting of the material, which is is used for physically- based rendering models.
This is usually 0 for dielectric materials and 1 for metals. It really does not make sense to set this to a value other than 0 or 1, but it is nonetheless a float for compatibility with tools that allow setting this to values other than 0 or 1.
setRefractiveIndex | ( | float | refractive_index | ) |
Sets the index of refraction of the material, which is used to determine the specular color in absence of an explicit specular color assignment.
This is usually 1.5 for dielectric materials. It is not very useful for metals, since they cannot be described as easily with a single number.
Should be 1 or higher. The default is 1.
setRoughness | ( | float | roughness | ) |
Sets the roughness exponent of the material, where 0 is completely shiny (infinite shininess), and 1 is a completely dull object (0 shininess).
This is a different, more perceptually intuitive way of controlling the size of the specular spot, and more commonly used in physically-based rendering.
Setting a roughness recalculates the shininess value.
setShininess | ( | float | shininess | ) |
Sets the shininess exponent of the material.
This controls the size of the specular highlight spot. In general, larger number produce a smaller specular highlight, which makes the object appear shinier. Smaller numbers produce a larger highlight, which makes the object appear less shiny.
This is usually in the range 0..128.
Setting a shininess value removes any previous roughness assignment.
setSpecular | ( | const LColor | color | ) |
Specifies the specular color setting of the material.
This will be multiplied by any lights in effect on the material to compute the color of specular highlights on the object.
This is the highlight color of an object: the color of small highlight reflections.
If this is not set, the specular color is taken from the index of refraction, which is 1 by default (meaning no specular reflections are generated).
setTwoside | ( | bool | twoside | ) |
Set this true to enable two-sided lighting.
When two-sided lighting is on, both sides of a polygon will be lit by this material. The default is for two-sided lighting to be off, in which case only the front surface is lit.
write | ( | Ostream | out, |
int | indent | ||
) |
const LColor ambient |
Returns the ambient color setting, if it has been set.
Returns (0,0,0,0) if the ambient color has not been set.
const LColor base_color |
Returns the base_color color setting, if it has been set.
If neither the base color nor the metallic have been set, this returns the diffuse color.
const LColor diffuse |
Returns the diffuse color setting, if it has been set.
Returns (1,1,1,1) if the diffuse color has not been set.
const LColor emission |
Returns the emission color setting, if it has been set.
Returns (0,0,0,0) if the emission color has not been set.
bool local |
Returns the local viewer flag.
Set set_local().
float metallic |
Returns the metallic setting, if it has been set.
Returns 0 if it has not been set.
float refractive_index |
Returns the index of refraction, or 1 if none has been set for this material.
float roughness |
Returns the roughness previously specified by set_roughness.
If none was previously set, this value is computed from the shininess value.
float shininess |
Returns the shininess exponent of the material.
const LColor specular |
Returns the specular color setting, if it has been set.
Returns (0,0,0,0) if the specular color has not been set.
bool twoside |
Returns the state of the two-sided lighting flag.
See set_twoside().