Nazara Engine
0.4
A fast, complete, cross-platform API designed for game development
|
Graphics class that represents a material. More...
Public Member Functions | |
Material () | |
Constructs a Material object with default states. More... | |
Material (const MaterialPipeline *pipeline) | |
Constructs a Material object using a MaterialPipeline. More... | |
Material (const MaterialPipelineInfo &pipelineInfo) | |
Constructs a Material object using a MaterialPipelineInfo. More... | |
Material (const String &pipelineName) | |
Constructs a Material object using a MaterialPipeline name. More... | |
Material (const Material &material) | |
Constructs a Material object by assignation. More... | |
~Material () | |
Destructs the object and calls OnMaterialRelease. More... | |
void | Apply (const MaterialPipeline::Instance &instance) const |
Applies shader to the material. More... | |
void | BuildFromParameters (const ParameterList &matData, const MaterialParams &matParams=MaterialParams()) |
Builds the material from a parameter list. More... | |
void | Configure (const MaterialPipeline *pipeline) |
Reset material pipeline state. More... | |
void | Configure (const MaterialPipelineInfo &pipelineInfo) |
Reset material pipeline state. More... | |
bool | Configure (const String &pipelineName) |
Reset material pipeline state. More... | |
void | EnableAlphaTest (bool alphaTest) |
Enable/Disable alpha test for this material. More... | |
void | EnableBlending (bool blending) |
Enable/Disable blending for this material. More... | |
void | EnableColorWrite (bool colorWrite) |
Enable/Disable color writing for this material. More... | |
void | EnableDepthBuffer (bool depthBuffer) |
Enable/Disable depth buffer for this material. More... | |
void | EnableDepthSorting (bool depthSorting) |
Enable/Disable depth sorting for this material. More... | |
void | EnableDepthWrite (bool depthWrite) |
Enable/Disable depth writing for this material. More... | |
void | EnableFaceCulling (bool faceCulling) |
Enable/Disable face culling for this material. More... | |
void | EnableReflectionMapping (bool reflection) |
Enable/Disable reflection mapping for this material. More... | |
void | EnableScissorTest (bool scissorTest) |
Enable/Disable scissor test for this material. More... | |
void | EnableShadowCasting (bool castShadows) |
Enable/Disable shadow casting for this material. More... | |
void | EnableShadowReceive (bool receiveShadows) |
Enable/Disable shadow receiving for this material. More... | |
void | EnableStencilTest (bool stencilTest) |
Enable/Disable stencil test for this material. More... | |
void | EnsurePipelineUpdate () const |
Ensures the pipeline gets updated. More... | |
const TextureRef & | GetAlphaMap () const |
Gets the alpha map. More... | |
float | GetAlphaThreshold () const |
Gets the alpha test threshold. More... | |
Color | GetAmbientColor () const |
Gets the ambient color. More... | |
RendererComparison | GetDepthFunc () const |
Gets the function to compare depth. More... | |
const MaterialRef & | GetDepthMaterial () const |
Gets the depth material. More... | |
Color | GetDiffuseColor () const |
Gets the diffuse color. More... | |
const TextureRef & | GetDiffuseMap () const |
Gets the diffuse map. More... | |
TextureSampler & | GetDiffuseSampler () |
Gets the diffuse sampler. More... | |
const TextureSampler & | GetDiffuseSampler () const |
Gets the diffuse sampler. More... | |
BlendFunc | GetDstBlend () const |
Gets the dst in blend. More... | |
const TextureRef & | GetEmissiveMap () const |
Gets the emissive map. More... | |
FaceSide | GetFaceCulling () const |
Gets the face culling. More... | |
FaceFilling | GetFaceFilling () const |
Gets the face filling. More... | |
const TextureRef & | GetHeightMap () const |
Gets the height map. More... | |
float | GetLineWidth () const |
Gets the line width of this material. More... | |
const TextureRef & | GetNormalMap () const |
Gets the normal map. More... | |
const MaterialPipeline * | GetPipeline () const |
Gets the render states. More... | |
const MaterialPipelineInfo & | GetPipelineInfo () const |
Gets the pipeline informations. More... | |
float | GetPointSize () const |
Gets the point size of this material. More... | |
ReflectionMode | GetReflectionMode () const |
Gets the reflection mode of the material. More... | |
const UberShader * | GetShader () const |
Gets the über-shader used by this material. More... | |
float | GetShininess () const |
Gets the shininess. More... | |
Color | GetSpecularColor () const |
Gets the specular color. More... | |
const TextureRef & | GetSpecularMap () const |
Gets the specular map. More... | |
TextureSampler & | GetSpecularSampler () |
Gets the specular sampler. More... | |
const TextureSampler & | GetSpecularSampler () const |
Gets the specular sampler. More... | |
BlendFunc | GetSrcBlend () const |
Gets the src in blend. More... | |
bool | HasAlphaMap () const |
Checks whether this material has an alpha map. More... | |
bool | HasDepthMaterial () const |
Checks whether this material has a depth material. More... | |
bool | HasDiffuseMap () const |
Checks whether this material has a diffuse map. More... | |
bool | HasEmissiveMap () const |
Checks whether this material has a emissive map. More... | |
bool | HasHeightMap () const |
Checks whether this material has a height map. More... | |
bool | HasNormalMap () const |
Checks whether this material has a normal map. More... | |
bool | HasSpecularMap () const |
Checks whether this material has a specular map. More... | |
bool | IsAlphaTestEnabled () const |
Checks whether this material has alpha test enabled. More... | |
bool | IsBlendingEnabled () const |
Checks whether this material has blending enabled. More... | |
bool | IsColorWriteEnabled () const |
Checks whether this material has color write enabled. More... | |
bool | IsDepthBufferEnabled () const |
Checks whether this material has depth buffer enabled. More... | |
bool | IsDepthSortingEnabled () const |
Checks whether this material has depth sorting enabled. More... | |
bool | IsDepthWriteEnabled () const |
Checks whether this material has depth writing enabled. More... | |
bool | IsFaceCullingEnabled () const |
Checks whether this material has face culling enabled. More... | |
bool | IsReflectionMappingEnabled () const |
Checks whether this material has reflection mapping enabled. More... | |
bool | IsScissorTestEnabled () const |
Checks whether this material has scissor test enabled. More... | |
bool | IsStencilTestEnabled () const |
Checks whether this material has stencil test enabled. More... | |
bool | IsShadowCastingEnabled () const |
Checks whether this material cast shadow. More... | |
bool | IsShadowReceiveEnabled () const |
Checks whether this material receive shadow. More... | |
bool | LoadFromFile (const String &filePath, const MaterialParams ¶ms=MaterialParams()) |
Loads the material from file. More... | |
bool | LoadFromMemory (const void *data, std::size_t size, const MaterialParams ¶ms=MaterialParams()) |
Loads the material from memory. More... | |
bool | LoadFromStream (Stream &stream, const MaterialParams ¶ms=MaterialParams()) |
Loads the material from stream. More... | |
void | Reset () |
Resets the material, cleans everything. More... | |
void | SaveToParameters (ParameterList *matData) |
Builds a ParameterList with material data. More... | |
bool | SetAlphaMap (const String &textureName) |
Sets the alpha map by name. More... | |
void | SetAlphaMap (TextureRef alphaMap) |
Sets the alpha map with a reference to a texture. More... | |
void | SetAlphaThreshold (float alphaThreshold) |
Sets the alpha threshold. More... | |
void | SetAmbientColor (const Color &ambient) |
Sets the color for ambient. More... | |
void | SetDepthFunc (RendererComparison depthFunc) |
Sets the depth functor. More... | |
void | SetDepthMaterial (MaterialRef depthMaterial) |
Sets the depth material. More... | |
void | SetDiffuseColor (const Color &diffuse) |
Sets the color for diffuse. More... | |
bool | SetDiffuseMap (const String &textureName) |
Sets the diffuse map by name. More... | |
void | SetDiffuseMap (TextureRef diffuseMap) |
Sets the diffuse map with a reference to a texture. More... | |
void | SetDiffuseSampler (const TextureSampler &sampler) |
Sets the diffuse sampler. More... | |
void | SetDstBlend (BlendFunc func) |
Sets the dst in blend. More... | |
bool | SetEmissiveMap (const String &textureName) |
Sets the emissive map by name. More... | |
void | SetEmissiveMap (TextureRef textureName) |
Sets the emissive map with a reference to a texture. More... | |
void | SetFaceCulling (FaceSide faceSide) |
Sets the face culling. More... | |
void | SetFaceFilling (FaceFilling filling) |
Sets the face filling. More... | |
bool | SetHeightMap (const String &textureName) |
Sets the height map by path or name. More... | |
void | SetHeightMap (TextureRef textureName) |
Sets the height map with a reference to a texture. More... | |
void | SetLineWidth (float lineWidth) |
Sets the line width for this material. More... | |
bool | SetNormalMap (const String &textureName) |
Sets the normal map by path or name. More... | |
void | SetNormalMap (TextureRef textureName) |
Sets the normal map with a reference to a texture. More... | |
void | SetPointSize (float pointSize) |
Sets the point size for this material. More... | |
void | SetReflectionMode (ReflectionMode reflectionMode) |
Changes reflection mode of the material. More... | |
void | SetShader (UberShaderConstRef uberShader) |
Sets the shader with a constant reference to a ubershader. More... | |
bool | SetShader (const String &uberShaderName) |
Sets the shader by name. More... | |
void | SetShininess (float shininess) |
Sets the shininess of the material. More... | |
void | SetSpecularColor (const Color &specular) |
Sets the color for specular. More... | |
bool | SetSpecularMap (const String &textureName) |
Sets the specular map by name. More... | |
void | SetSpecularMap (TextureRef specularMap) |
Sets the specular map with a reference to a texture. More... | |
void | SetSpecularSampler (const TextureSampler &sampler) |
Sets the specular sampler. More... | |
void | SetSrcBlend (BlendFunc func) |
Sets the src in blend. More... | |
Material & | operator= (const Material &material) |
Sets the current material with the content of the other one. More... | |
NazaraSignal (OnMaterialReflectionModeChange, const Material *, ReflectionMode) | |
NazaraSignal (OnMaterialRelease, const Material *) | |
NazaraSignal (OnMaterialReset, const Material *) | |
Public Member Functions inherited from Nz::RefCounted | |
RefCounted (bool persistent=true) | |
Constructs a RefCounted object with a persistance aspect. More... | |
RefCounted (const RefCounted &)=delete | |
RefCounted (RefCounted &&)=default | |
virtual | ~RefCounted () |
Destructs the object. More... | |
void | AddReference () const |
Adds a reference to the object. | |
unsigned int | GetReferenceCount () const |
Gets the number of references to the object. More... | |
bool | IsPersistent () const |
Checks whether the object is persistent. More... | |
bool | RemoveReference () const |
Removes a reference to the object. More... | |
bool | SetPersistent (bool persistent=true, bool checkReferenceCount=false) |
Sets the persistence of the object. More... | |
RefCounted & | operator= (const RefCounted &)=delete |
RefCounted & | operator= (RefCounted &&)=default |
Public Member Functions inherited from Nz::Resource | |
Resource (const Resource &)=default | |
Resource (Resource &&) noexcept=default | |
const String & | GetFilePath () const |
Gets the file path associated with the resource. More... | |
void | SetFilePath (const String &filePath) |
Sets the file path associated with the resource. More... | |
Resource & | operator= (const Resource &)=default |
Resource & | operator= (Resource &&) noexcept=default |
Static Public Member Functions | |
static MaterialRef | GetDefault () |
Gets the default material. More... | |
static int | GetTextureUnit (TextureMap textureMap) |
template<typename... Args> | |
static MaterialRef | New (Args &&... args) |
Creates a new material from the arguments. More... | |
Friends | |
class | Graphics |
Graphics class that represents a material.
|
inline |
Constructs a Material object using a MaterialPipeline.
Calls Configure with the pipeline parameter
|
inline |
|
inline |
Constructs a Material object using a MaterialPipeline name.
Calls Configure with the pipelineName parameter
|
inline |
|
inline |
Destructs the object and calls OnMaterialRelease.
void Nz::Material::Apply | ( | const MaterialPipeline::Instance & | instance | ) | const |
Applies shader to the material.
instance | Pipeline instance to update |
textureUnit | Unit for the texture GL_TEXTURE"i" |
lastUsedUnit | Optional argument to get the last texture unit |
void Nz::Material::BuildFromParameters | ( | const ParameterList & | matData, |
const MaterialParams & | matParams = MaterialParams() |
||
) |
Builds the material from a parameter list.
matData | Data information for the material |
matParams | Additional parameters for the material |
|
inline |
Reset material pipeline state.
Sets the material pipeline
|
inline |
Reset material pipeline state.
Sets the material pipeline using pipeline info
|
inline |
Reset material pipeline state.
Sets the material pipeline using a name to lookup in the MaterialPipelineLibrary
|
inline |
Enable/Disable alpha test for this material.
When enabled, all objects using this material will be rendered using alpha testing, rejecting pixels if their alpha component is under a defined threshold. This allows some kind of transparency with a much cheaper cost as it doesn't prevent any optimization (as deferred rendering or batching).
alphaTest | Defines if this material will use alpha testing |
|
inline |
Enable/Disable blending for this material.
When enabled, all objects using this material will be rendered using blending, obeying the dstBlend and srcBlend parameters This is useful with translucent objects, but will reduces performance as it prevents some optimizations (as deferred rendering)
blending | Defines if this material will use blending |
|
inline |
Enable/Disable color writing for this material.
colorWrite | Defines if this material will use color writing |
|
inline |
Enable/Disable depth buffer for this material.
When enabled, all objects using this material will be rendered using a depth buffer, if the RenderTarget has one. This will enable Depth Test, preventing further fragments to render on top of closer ones.
This parameter is required for depth writing.
In order to enable depth writing without enabling depth test, set the depth comparison function to RendererComparison_Never
depthBuffer | Defines if this material will use depth buffer |
|
inline |
Enable/Disable depth sorting for this material.
When enabled, all objects using this material will be rendered far from near This is useful with translucent objects, but will reduces performance as it breaks batching
depthSorting | Defines if this material will use depth sorting |
|
inline |
Enable/Disable depth writing for this material.
When enabled, and if depth buffer is enabled and present, all fragments generated with this material will write to the depth buffer if they pass depth test.
This is usually disabled with translucent objects, as depth test is wanted to prevent them from rendering on top of opaque objects but not depth writing (which could make other translucent fragments to fail depth test)
depthBuffer | Defines if this material will use depth write |
|
inline |
Enable/Disable face culling for this material.
When enabled, the material prevents front and/or back faces from rendering. This is commonly used as an optimization to prevent processing of hidden faces by the rendering device.
Use SetFaceCulling to control which side will be eliminated.
faceCulling | Defines if this material will use face culling |
|
inline |
Enable/Disable reflection mapping for this material.
When enabled, the material will render reflections from the object environment according to the reflection mode. Whether or not this is expensive depends of the reflection mode and size.
Please note this is only a hint for the render technique, and reflections can be forcefully enabled or disabled depending on the material shader.
Use SetReflectionMode and SetReflectionSize to control reflection quality.
reflection | Defines if this material should use reflection mapping |
|
inline |
Enable/Disable scissor test for this material.
When enabled, the material prevents fragments out of the scissor box to be rendered. This can be useful with GUI, where widgets must not be rendered outside of their parent rendering area.
scissorTest | Defines if this material will use scissor test |
|
inline |
Enable/Disable shadow casting for this material.
When enabled, all objects using this material will be allowed to cast shadows upon any objects using a material with shadow receiving enabled. The depth material replaces this one when rendering shadows.
castShadows | Defines if this material will be allowed to cast shadows |
|
inline |
Enable/Disable shadow receiving for this material.
When enabled, all objects using this material will be allowed to be casted shadows upon themselves Disabling this can be helpful to prevent some rendering artifacts (especially with translucent objects)
receiveShadows | Defines if this material will be able to receive shadows |
|
inline |
Enable/Disable stencil test for this material.
When enabled, all fragments must pass the stencil test to be rendered.
scissorTest | Defines if this material will use stencil test |
|
inline |
Ensures the pipeline gets updated.
When the pipeline gets invalidated, it's not updated until required (per example by calling GetPipeline). Using this function forces the pipeline update, making GetPipeline thread-safe as long as the pipeline does not get invalidated.
|
inline |
|
inline |
Gets the alpha test threshold.
|
inline |
|
inlinestatic |
Gets the default material.
|
inline |
Gets the function to compare depth.
|
inline |
Gets the depth material.
|
inline |
|
inline |
|
inline |
Gets the diffuse sampler.
|
inline |
Gets the diffuse sampler.
|
inline |
|
inline |
|
inline |
|
inline |
Gets the face filling.
|
inline |
Gets the height map.
|
inline |
Gets the line width of this material.
|
inline |
Gets the normal map.
|
inline |
Gets the render states.
|
inline |
Gets the pipeline informations.
|
inline |
Gets the point size of this material.
|
inline |
|
inline |
Gets the über-shader used by this material.
|
inline |
Gets the shininess.
|
inline |
Gets the specular color.
|
inline |
Gets the specular map.
|
inline |
Gets the specular sampler.
|
inline |
Gets the specular sampler.
|
inline |
Gets the src in blend.
|
inline |
Checks whether this material has an alpha map.
|
inline |
Checks whether this material has a depth material.
|
inline |
Checks whether this material has a diffuse map.
|
inline |
Checks whether this material has a emissive map.
|
inline |
Checks whether this material has a height map.
|
inline |
Checks whether this material has a normal map.
|
inline |
Checks whether this material has a specular map.
|
inline |
Checks whether this material has alpha test enabled.
|
inline |
Checks whether this material has blending enabled.
|
inline |
Checks whether this material has color write enabled.
|
inline |
Checks whether this material has depth buffer enabled.
|
inline |
Checks whether this material has depth sorting enabled.
|
inline |
Checks whether this material has depth writing enabled.
|
inline |
Checks whether this material has face culling enabled.
|
inline |
Checks whether this material has reflection mapping enabled.
|
inline |
Checks whether this material has scissor test enabled.
|
inline |
Checks whether this material cast shadow.
|
inline |
Checks whether this material receive shadow.
|
inline |
Checks whether this material has stencil test enabled.
|
inline |
Loads the material from file.
filePath | Path to the file |
params | Parameters for the material |
|
inline |
Loads the material from memory.
data | Raw memory |
size | Size of the memory |
params | Parameters for the material |
|
inline |
Loads the material from stream.
stream | Stream to the material |
params | Parameters for the material |
|
static |
Creates a new material from the arguments.
args | Arguments for the material |
Sets the current material with the content of the other one.
material | The other Material |
void Nz::Material::Reset | ( | ) |
Resets the material, cleans everything.
void Nz::Material::SaveToParameters | ( | ParameterList * | matData | ) |
Builds a ParameterList with material data.
matData | Destination parameter list which will receive material data |
|
inline |
Sets the alpha map by name.
textureName | Named texture |
|
inline |
Sets the alpha map with a reference to a texture.
alphaMap | Texture |
|
inline |
Sets the alpha threshold.
alphaThreshold | Threshold for the alpha |
|
inline |
Sets the color for ambient.
ambient | Color for ambient |
|
inline |
Sets the depth functor.
depthFunc |
|
inline |
|
inline |
Sets the color for diffuse.
diffuse | Color for diffuse |
|
inline |
Sets the diffuse map by name.
textureName | Named texture |
|
inline |
Sets the diffuse map with a reference to a texture.
diffuseMap | Texture |
|
inline |
Sets the diffuse sampler.
sampler | Diffuse sample |
|
inline |
Sets the dst in blend.
func | Function for dst blending |
|
inline |
Sets the emissive map by name.
textureName | Named texture |
|
inline |
Sets the emissive map with a reference to a texture.
emissiveMap | Texture |
|
inline |
Sets the face culling.
faceSide | Face to cull |
|
inline |
Sets the face filling.
filling | Face to fill |
|
inline |
Sets the height map by path or name.
textureName | Named texture |
|
inline |
Sets the height map with a reference to a texture.
heightMap | Texture |
|
inline |
Sets the line width for this material.
This parameter is used when rendering lines, to define the width (in pixels) the line will take on the framebuffer
lineWidth | Width of the line |
|
inline |
Sets the normal map by path or name.
textureName | Named texture |
|
inline |
Sets the normal map with a reference to a texture.
normalMap | Texture |
|
inline |
Sets the point size for this material.
This parameter is used when rendering points, to define the size (in pixels) the point will take on the framebuffer
pointSize | Size of the point |
|
inline |
Changes reflection mode of the material.
When reflections are enable, the material will render reflections from the object environment according to the reflection mode. This function does change the reflection mode used by the material.
Skyboxes reflections are the cheapest but are static and thus can't reflect other objects. Probes reflections are cheap, depending on probes reflection mode, but require regular probe finding from objects using it. Real-time reflections are expensive but provide the most accurate reflection map (and can reflect other objects around).
reflectionMode | The new reflection mode this material should use |
|
inline |
Sets the shader with a constant reference to a ubershader.
uberShader | Uber shader to apply |
|
inline |
Sets the shader by name.
uberShaderName | Named shader |
|
inline |
Sets the shininess of the material.
shininess | Value of the shininess |
|
inline |
Sets the color for specular.
specular | Color |
|
inline |
Sets the specular map by name.
textureName | Named texture |
|
inline |
Sets the specular map with a reference to a texture.
specularMap | Texture |
|
inline |
|
inline |
Sets the src in blend.
func | Function for src blending |