material resource

 Function Name  Parameter  Return  Explain
getDiffuse None color  
setDiffuse color None  
getAmbient None color  
setAmbient color None  
getSpecular None color  
setSpecular color None  
getEmissive None color  
setEmissive color None  
getPower None number  
setPower number None  
getShadeMode None number Retrieves the shade mode of the material.

Return Values

SHADEMODE_FLAT : flat
SHADEMODE_GOURAUD : gouraud
SHADEMODE_PHONG : phone ( Not supported )

setShadeMode number None  
getTexture number layer (0~7) number   
setTexture number layer (0~7), texture None  
getD3DEffect None string Retrieves the D3D effect file name. If no effect file set in material, return nil;
setD3DEffect string None Set D3D effect file.
findValidTechnique [string technique] string Searches for the next valid technique starting at the technique specified. If technique is absent, starting from the first technique. Return the name of valid technique; If failed, return nil. See Remark 1.
getTechnique None string Retrieves the name of the current technique; if failed, return nil.
setTechnique string technique boolean Sets the active technique (the default active technique is the first valid technique in shader text); if failed, return nil.
validateEffect None boolean Validates the D3D effect (for the active technique)
If no effect file set in material, return nil; otherwise return a boolean indicates the shader whether valid in current device.
getTexturePlay None textureplay  
setTexturePlay textureplay None  
getShadowSource None material  Retrieves the Shadow Source Material
setShadowSource material None  Sets the  Shadow Source Material
getShadowDest None material  Retrieves the Shadow Dest Material
setShadowDest material None  Sets the  Shadow Dest Material
getShadowDepth None material  Retrieves the Depth Material
setShadowDepth material None  Sets the  Depth Material
getFactor None number  x, y, z, w  Retrieves the factors
setFactor number  x, y, z, w None  Sets the factors
 

These group functions are normally used with vertex/pixel shader:

getEffectBool string name bool Retrieves the value of a bool variable in shader text.

Parameters

name : variable name

setEffectBool string name   bool None Sets the value of a bool variable in shader text.
getEffectDword string name dword Retrieves the value of a dword variable in shader text.
setEffectDword string name   dword None Sets the value of a dword variable in shader text.
getEffectFloat string name number  Retrieves the value of a float variable in shader text.
setEffectFloat string name   number  None Sets the value of a float variable in shader text.
getEffectVector string name vec4 Retrieves the value of a vector variable in shader text.
setEffectVector string name   vec4 None Sets the value of a vector variable in shader text.
getEffectMatrix string name matrix Retrieves the value of a matrix variable in shader text.
setEffectMatrix string name   matrix None Sets the value of a matrix variable in shader text.
getEffectString string name string Retrieves the value of a string variable in shader text.
setEffectString string name   string None Sets the value of a string variable in shader text.
setEffectTexture string name   number  None Sets the value of a texture variable in shader text.

 

Styles List

MATERS_SPECULAR  --specular
MATERS_CAUSTIC  --caustic
MATERS_TRANSPARENCE  --transparence
MATERS_NORECEIVESHADOW  --no receive shadow

Remark 1:

Use the findValidTechnique and validateEffect functions in the OnRestoreDevice function of User Script File is a good practice. While use them in other place, we have found these functions do not always get correct result when running on some graphic devices.