Packagesandy.materials.attributes
Classpublic final class PhongAttributes
InheritancePhongAttributes Inheritance ALightAttributes

Realize a Phong shading on a material.

In true Phong shading, normals are supposed to be interpolated across the surface; here scaled normal projections are interpolated in the light map space. The downside of this method is that in case of low poly models interpolation results are inaccurate - in this case you can improve the result using GouraudAttributes for ambient and diffuse, and then this attribute for specular reflection.



Public Properties
 PropertyDefined by
 Inheritedambient : Number
Ambient reflection factor.
ALightAttributes
 Inheriteddiffuse : Number
Diffuse reflection factor.
ALightAttributes
 Inheritedflags : uint
Flags for the attribute.
ALightAttributes
 Inheritedgloss : Number
Specular exponent.
ALightAttributes
  onlySpecular : Boolean = false
Flag for rendering mode.
PhongAttributes
 Inheritedspecular : Number
Specular reflection factor.
ALightAttributes
  spherize : Number = 0
Non-zero value adds sphere normals to actual normals for light rendering.
PhongAttributes
  useBright : Boolean
Flag for lightening mode.
PhongAttributes
Public Methods
 MethodDefined by
  
PhongAttributes(p_bBright:Boolean = false, p_nAmbient:Number = 0.0, p_nQuality:int = 15, p_nSamples:int = 4)
Create the PhongAttributes object.
PhongAttributes
  
computeLightMap(p_oLight:Light3D, p_nQuality:int = 4, p_nSamples:int = 4):void
Compute the light map.
PhongAttributes
 Inherited
draw(p_oGraphics:Graphics, p_oPolygon:Polygon, p_oMaterial:Material, p_oScene:Scene3D):void
Draws light on shape.
ALightAttributes
 Inherited
drawOnSprite(p_oSprite:Sprite2D, p_oMaterial:Material, p_oScene:Scene3D):void
Draws light on sprite.
ALightAttributes
Property detail
onlySpecularproperty
public var onlySpecular:Boolean = false

Flag for rendering mode.

If true, only specular highlight is rendered, when useBright is also true.
If false (the default) ambient and diffuse reflections will also be rendered.

spherizeproperty 
public var spherize:Number = 0

Non-zero value adds sphere normals to actual normals for light rendering. Use this with flat surfaces or cylinders.

useBrightproperty 
useBright:Boolean  [read-write]

Flag for lightening mode.

If true (the default), the lit objects use full light range from black to white.
If false they just range from black to their normal appearance; additionally, current implementation does not render specular reflection in this case.

Implementation
    public function get useBright():Boolean
    public function set useBright(value:Boolean):void
Constructor detail
PhongAttributes()constructor
public function PhongAttributes(p_bBright:Boolean = false, p_nAmbient:Number = 0.0, p_nQuality:int = 15, p_nSamples:int = 4)

Create the PhongAttributes object.

Parameters
p_bBright:Boolean (default = false) — The brightness (value for useBright).
 
p_nAmbient:Number (default = 0.0) — The ambient light value. A value between 0 and 1 is expected.
 
p_nQuality:int (default = 15) — Quality of light response approximation. A value between 2 and 15 is expected.
 
p_nSamples:int (default = 4) — A number of calculated samples per anchor. Positive value is expected.
Method detail
computeLightMap()method
public function computeLightMap(p_oLight:Light3D, p_nQuality:int = 4, p_nSamples:int = 4):void

Compute the light map.

Normally you should not need to call this function, as it is done for you automatically when it is needed. You might call it to compute light map in advance, though.

Parameters
p_oLight:Light3D — Light3D object to make the light map for.
 
p_nQuality:int (default = 4) — Quality of light response approximation. A value between 2 and 15 is expected (Flash radial gradient is used internally light map, thus we can only roughly approximate exact lighting).
 
p_nSamples:int (default = 4) — A number of calculated samples per anchor. Positive value is expected (greater values will produce a little bit more accurate interpolation with non-equally spaced anchors).

See also