Packageaway3d.materials.compilation
Classpublic class ShaderCompiler
InheritanceShaderCompiler Inheritance Object
Subclasses LightingShaderCompiler, SuperShaderCompiler

ShaderCompiler is an abstract base class for shader compilers that use modular shader methods to assemble a material. Concrete subclasses are used by the default materials.

See also

away3d.materials.methods.ShadingMethodBase


Public Properties
 PropertyDefined By
  alphaPremultiplied : Boolean
Indicates whether visible textures (or other pixels) used by this material have already been premultiplied.
ShaderCompiler
  animatableAttributes : Vector.<String>
[read-only] The attributes that need to be animated by animators.
ShaderCompiler
  animateUVs : Boolean
Indicate whether UV coordinates need to be animated using the renderable's transformUV matrix.
ShaderCompiler
  animationTargetRegisters : Vector.<String>
[read-only] The target registers for animated properties, written to by the animators.
ShaderCompiler
  cameraPositionIndex : int
[read-only] The index of the vertex constant containing the camera position.
ShaderCompiler
  commonsDataIndex : int
[read-only] The index for the common data register.
ShaderCompiler
  diffuseLightSources : uint
Define which light source types to use for diffuse reflections.
ShaderCompiler
  enableLightFallOff : Boolean
Whether or not to use fallOff and radius properties for lights.
ShaderCompiler
  forceSeperateMVP : Boolean
Indicates whether the screen projection should be calculated by forcing a separate scene matrix and view-projection matrix.
ShaderCompiler
  fragmentCode : String
[read-only] The generated fragment code.
ShaderCompiler
  fragmentLightCode : String
[read-only] The code containing the lighting calculations.
ShaderCompiler
  fragmentPostLightCode : String
[read-only] The code containing the post-lighting calculations.
ShaderCompiler
  lightFragmentConstantIndex : int
[read-only] The first index for the fragment constants containing the light data.
ShaderCompiler
  lightProbeDiffuseIndices : Vector.<uint>
[read-only] Indices for the light probe diffuse textures.
ShaderCompiler
  lightProbeSpecularIndices : Vector.<uint>
[read-only] Indices for the light probe specular textures.
ShaderCompiler
  methodSetup : ShaderMethodSetup
The shader method setup object containing the method configuration and their value objects for the material being compiled.
ShaderCompiler
  needUVAnimation : Boolean
[read-only] Indicates whether the compiled code needs UV animation.
ShaderCompiler
  normalBufferIndex : int
[read-only] The index for the vertex normal attribute stream.
ShaderCompiler
  numDirectionalLights : uint
The amount of directional lights that need to be supported.
ShaderCompiler
  numLightProbes : uint
The amount of light probes that need to be supported.
ShaderCompiler
  numPointLights : uint
The amount of point lights that need to be supported.
ShaderCompiler
  numUsedFragmentConstants : uint
[read-only] The amount of fragment constants used by the material.
ShaderCompiler
  numUsedStreams : uint
[read-only] The amount of vertex attribute streams used by the material.
ShaderCompiler
  numUsedTextures : uint
[read-only] The amount of textures used by the material.
ShaderCompiler
  numUsedVaryings : uint
[read-only] Number of used varyings.
ShaderCompiler
  numUsedVertexConstants : uint
[read-only] The amount of vertex constants used by the material.
ShaderCompiler
  preserveAlpha : Boolean
Indicates whether the output alpha value should remain unchanged compared to the material's original alpha.
ShaderCompiler
  probeWeightsIndex : int
[read-only] The index of the fragment constant containing the weights for the light probes.
ShaderCompiler
  sceneMatrixIndex : int
[read-only] The index of the vertex constant containing the scene matrix.
ShaderCompiler
  sceneNormalMatrixIndex : int
[read-only] The index of the vertex constant containing the uniform scene matrix (the inverse transpose).
ShaderCompiler
  secondaryUVBufferIndex : int
[read-only] The index for the secondary UV vertex attribute stream.
ShaderCompiler
  shadedTarget : String
[read-only] The register name containing the final shaded colour.
ShaderCompiler
  specularLightSources : uint
Define which light source types to use for specular reflections.
ShaderCompiler
  tangentBufferIndex : int
[read-only] The index for the vertex tangent attribute stream.
ShaderCompiler
  usesNormals : Boolean
[read-only] Indicates whether the compiled shader uses normals.
ShaderCompiler
  usingSpecularMethod : Boolean
[read-only] Indicates whether the specular method is used.
ShaderCompiler
  uvBufferIndex : int
[read-only] The index for the UV vertex attribute stream.
ShaderCompiler
  UVSource : String
[read-only] The souce register providing the UV coordinate to animate.
ShaderCompiler
  UVTarget : String
[read-only] The target register to place the animated UV coordinate.
ShaderCompiler
  uvTransformIndex : int
[read-only] The index for the UV transformation matrix vertex constant.
ShaderCompiler
  vertexCode : String
[read-only] The generated vertex code.
ShaderCompiler
Protected Properties
 PropertyDefined By
  _alphaPremultiplied : Boolean
ShaderCompiler
  _animatableAttributes : Vector.<String>
ShaderCompiler
  _animateUVs : Boolean
ShaderCompiler
  _animationTargetRegisters : Vector.<String>
ShaderCompiler
  _cameraPositionIndex : int = -1
ShaderCompiler
  _combinedLightSources : uint
ShaderCompiler
  _dependencyCounter : MethodDependencyCounter
ShaderCompiler
  _diffuseLightSources : uint
ShaderCompiler
  _enableLightFallOff : Boolean
ShaderCompiler
  _forceSeperateMVP : Boolean
ShaderCompiler
  _fragmentCode : String
ShaderCompiler
  _fragmentConstantData : Vector.<Number>
ShaderCompiler
  _fragmentLightCode : String
ShaderCompiler
  _fragmentPostLightCode : String
ShaderCompiler
  _lightFragmentConstantIndex : int = -1
ShaderCompiler
  _lightProbeDiffuseIndices : Vector.<uint>
ShaderCompiler
  _lightProbeSpecularIndices : Vector.<uint>
ShaderCompiler
  _methodSetup : ShaderMethodSetup
ShaderCompiler
  _mipmap : Boolean
ShaderCompiler
  _needUVAnimation : Boolean
ShaderCompiler
  _normalBufferIndex : int = -1
ShaderCompiler
  _numDirectionalLights : uint
ShaderCompiler
  _numLightProbes : uint
ShaderCompiler
  _numLights : int
ShaderCompiler
  _numPointLights : uint
ShaderCompiler
  _numProbeRegisters : Number
ShaderCompiler
  _preserveAlpha : Boolean = true
ShaderCompiler
  _probeWeightsIndex : int = -1
ShaderCompiler
  _profile : String
ShaderCompiler
  _registerCache : ShaderRegisterCache
ShaderCompiler
  _repeat : Boolean
ShaderCompiler
  _sceneMatrixIndex : int = -1
ShaderCompiler
  _sceneNormalMatrixIndex : int = -1
ShaderCompiler
  _secondaryUVBufferIndex : int = -1
ShaderCompiler
  _sharedRegisters : ShaderRegisterData
ShaderCompiler
  _smooth : Boolean
ShaderCompiler
  _specularLightSources : uint
ShaderCompiler
  _tangentBufferIndex : int = -1
ShaderCompiler
  _usingSpecularMethod : Boolean
ShaderCompiler
  _uvBufferIndex : int = -1
ShaderCompiler
  _UVSource : String
ShaderCompiler
  _UVTarget : String
ShaderCompiler
  _uvTransformIndex : int = -1
ShaderCompiler
  _vertexCode : String
ShaderCompiler
  _vertexConstantData : Vector.<Number>
ShaderCompiler
Public Methods
 MethodDefined By
  
ShaderCompiler(profile:String)
Creates a new ShaderCompiler object.
ShaderCompiler
  
compile():void
Compiles the code after all setup on the compiler has finished.
ShaderCompiler
  
dispose():void
Disposes all resources used by the compiler.
ShaderCompiler
  
setConstantDataBuffers(vertexConstantData:Vector.<Number>, fragmentConstantData:Vector.<Number>):void
Sets the constant buffers allocated by the material.
ShaderCompiler
  
setTextureSampling(smooth:Boolean, repeat:Boolean, mipmap:Boolean):void
Sets the default texture sampling properties.
ShaderCompiler
Protected Methods
 MethodDefined By
  
Figure out which named registers are required, and how often.
ShaderCompiler
  
Compile the world-space position.
ShaderCompiler
  
Compile the lighting code.
ShaderCompiler
  
Compiles the code for the methods.
ShaderCompiler
  
Compile the code for the methods.
ShaderCompiler
  
Calculate the normal.
ShaderCompiler
  
Calculate the view direction.
ShaderCompiler
  
Creates the registers to contain the normal data.
ShaderCompiler
  
Prepares the setup for the light code.
ShaderCompiler
  
Reset all the indices to "unused".
ShaderCompiler
  
usesLights():Boolean
Indicates whether the compiled shader uses lights.
ShaderCompiler
  
Indicates whether lights are used for diffuse reflections.
ShaderCompiler
  
Indicates whether lights are used for specular reflections.
ShaderCompiler
  
usesProbes():Boolean
Indicates whether any light probes are used.
ShaderCompiler
  
Indicates whether light probes are being used for diffuse reflections.
ShaderCompiler
  
Indicates whether light probes are being used for specular reflections.
ShaderCompiler
Property Detail
_alphaPremultipliedproperty
protected var _alphaPremultiplied:Boolean

_animatableAttributesproperty 
protected var _animatableAttributes:Vector.<String>

_animateUVsproperty 
protected var _animateUVs:Boolean

_animationTargetRegistersproperty 
protected var _animationTargetRegisters:Vector.<String>

_cameraPositionIndexproperty 
protected var _cameraPositionIndex:int = -1

_combinedLightSourcesproperty 
protected var _combinedLightSources:uint

_dependencyCounterproperty 
protected var _dependencyCounter:MethodDependencyCounter

_diffuseLightSourcesproperty 
protected var _diffuseLightSources:uint

_enableLightFallOffproperty 
protected var _enableLightFallOff:Boolean

_forceSeperateMVPproperty 
protected var _forceSeperateMVP:Boolean

_fragmentCodeproperty 
protected var _fragmentCode:String

_fragmentConstantDataproperty 
protected var _fragmentConstantData:Vector.<Number>

_fragmentLightCodeproperty 
protected var _fragmentLightCode:String

_fragmentPostLightCodeproperty 
protected var _fragmentPostLightCode:String

_lightFragmentConstantIndexproperty 
protected var _lightFragmentConstantIndex:int = -1

_lightProbeDiffuseIndicesproperty 
protected var _lightProbeDiffuseIndices:Vector.<uint>

_lightProbeSpecularIndicesproperty 
protected var _lightProbeSpecularIndices:Vector.<uint>

_methodSetupproperty 
protected var _methodSetup:ShaderMethodSetup

_mipmapproperty 
protected var _mipmap:Boolean

_needUVAnimationproperty 
protected var _needUVAnimation:Boolean

_normalBufferIndexproperty 
protected var _normalBufferIndex:int = -1

_numDirectionalLightsproperty 
protected var _numDirectionalLights:uint

_numLightProbesproperty 
protected var _numLightProbes:uint

_numLightsproperty 
protected var _numLights:int

_numPointLightsproperty 
protected var _numPointLights:uint

_numProbeRegistersproperty 
protected var _numProbeRegisters:Number

_preserveAlphaproperty 
protected var _preserveAlpha:Boolean = true

_probeWeightsIndexproperty 
protected var _probeWeightsIndex:int = -1

_profileproperty 
protected var _profile:String

_registerCacheproperty 
protected var _registerCache:ShaderRegisterCache

_repeatproperty 
protected var _repeat:Boolean

_sceneMatrixIndexproperty 
protected var _sceneMatrixIndex:int = -1

_sceneNormalMatrixIndexproperty 
protected var _sceneNormalMatrixIndex:int = -1

_secondaryUVBufferIndexproperty 
protected var _secondaryUVBufferIndex:int = -1

_sharedRegistersproperty 
protected var _sharedRegisters:ShaderRegisterData

_smoothproperty 
protected var _smooth:Boolean

_specularLightSourcesproperty 
protected var _specularLightSources:uint

_tangentBufferIndexproperty 
protected var _tangentBufferIndex:int = -1

_usingSpecularMethodproperty 
protected var _usingSpecularMethod:Boolean

_uvBufferIndexproperty 
protected var _uvBufferIndex:int = -1

_UVSourceproperty 
protected var _UVSource:String

_UVTargetproperty 
protected var _UVTarget:String

_uvTransformIndexproperty 
protected var _uvTransformIndex:int = -1

_vertexCodeproperty 
protected var _vertexCode:String

_vertexConstantDataproperty 
protected var _vertexConstantData:Vector.<Number>

alphaPremultipliedproperty 
alphaPremultiplied:Boolean

Indicates whether visible textures (or other pixels) used by this material have already been premultiplied.


Implementation
    public function get alphaPremultiplied():Boolean
    public function set alphaPremultiplied(value:Boolean):void
animatableAttributesproperty 
animatableAttributes:Vector.<String>  [read-only]

The attributes that need to be animated by animators.


Implementation
    public function get animatableAttributes():Vector.<String>
animateUVsproperty 
animateUVs:Boolean

Indicate whether UV coordinates need to be animated using the renderable's transformUV matrix.


Implementation
    public function get animateUVs():Boolean
    public function set animateUVs(value:Boolean):void
animationTargetRegistersproperty 
animationTargetRegisters:Vector.<String>  [read-only]

The target registers for animated properties, written to by the animators.


Implementation
    public function get animationTargetRegisters():Vector.<String>
cameraPositionIndexproperty 
cameraPositionIndex:int  [read-only]

The index of the vertex constant containing the camera position.


Implementation
    public function get cameraPositionIndex():int
commonsDataIndexproperty 
commonsDataIndex:int  [read-only]

The index for the common data register.


Implementation
    public function get commonsDataIndex():int
diffuseLightSourcesproperty 
diffuseLightSources:uint

Define which light source types to use for diffuse reflections. This allows choosing between regular lights and/or light probes for diffuse reflections.


Implementation
    public function get diffuseLightSources():uint
    public function set diffuseLightSources(value:uint):void

See also

enableLightFallOffproperty 
enableLightFallOff:Boolean

Whether or not to use fallOff and radius properties for lights. This can be used to improve performance and compatibility for constrained mode.


Implementation
    public function get enableLightFallOff():Boolean
    public function set enableLightFallOff(value:Boolean):void
forceSeperateMVPproperty 
forceSeperateMVP:Boolean

Indicates whether the screen projection should be calculated by forcing a separate scene matrix and view-projection matrix. This is used to prevent rounding errors when using multiple passes with different projection code.


Implementation
    public function get forceSeperateMVP():Boolean
    public function set forceSeperateMVP(value:Boolean):void
fragmentCodeproperty 
fragmentCode:String  [read-only]

The generated fragment code.


Implementation
    public function get fragmentCode():String
fragmentLightCodeproperty 
fragmentLightCode:String  [read-only]

The code containing the lighting calculations.


Implementation
    public function get fragmentLightCode():String
fragmentPostLightCodeproperty 
fragmentPostLightCode:String  [read-only]

The code containing the post-lighting calculations.


Implementation
    public function get fragmentPostLightCode():String
lightFragmentConstantIndexproperty 
lightFragmentConstantIndex:int  [read-only]

The first index for the fragment constants containing the light data.


Implementation
    public function get lightFragmentConstantIndex():int
lightProbeDiffuseIndicesproperty 
lightProbeDiffuseIndices:Vector.<uint>  [read-only]

Indices for the light probe diffuse textures.


Implementation
    public function get lightProbeDiffuseIndices():Vector.<uint>
lightProbeSpecularIndicesproperty 
lightProbeSpecularIndices:Vector.<uint>  [read-only]

Indices for the light probe specular textures.


Implementation
    public function get lightProbeSpecularIndices():Vector.<uint>
methodSetupproperty 
methodSetup:ShaderMethodSetup

The shader method setup object containing the method configuration and their value objects for the material being compiled.


Implementation
    public function get methodSetup():ShaderMethodSetup
    public function set methodSetup(value:ShaderMethodSetup):void
needUVAnimationproperty 
needUVAnimation:Boolean  [read-only]

Indicates whether the compiled code needs UV animation.


Implementation
    public function get needUVAnimation():Boolean
normalBufferIndexproperty 
normalBufferIndex:int  [read-only]

The index for the vertex normal attribute stream.


Implementation
    public function get normalBufferIndex():int
numDirectionalLightsproperty 
numDirectionalLights:uint

The amount of directional lights that need to be supported.


Implementation
    public function get numDirectionalLights():uint
    public function set numDirectionalLights(value:uint):void
numLightProbesproperty 
numLightProbes:uint

The amount of light probes that need to be supported.


Implementation
    public function get numLightProbes():uint
    public function set numLightProbes(value:uint):void
numPointLightsproperty 
numPointLights:uint

The amount of point lights that need to be supported.


Implementation
    public function get numPointLights():uint
    public function set numPointLights(value:uint):void
numUsedFragmentConstantsproperty 
numUsedFragmentConstants:uint  [read-only]

The amount of fragment constants used by the material. Any animation code to be added can append its vertex constant data after this.


Implementation
    public function get numUsedFragmentConstants():uint
numUsedStreamsproperty 
numUsedStreams:uint  [read-only]

The amount of vertex attribute streams used by the material. Any animation code to be added can add its streams after this. Also used to automatically disable attribute slots on pass deactivation.


Implementation
    public function get numUsedStreams():uint
numUsedTexturesproperty 
numUsedTextures:uint  [read-only]

The amount of textures used by the material. Used to automatically disable texture slots on pass deactivation.


Implementation
    public function get numUsedTextures():uint
numUsedVaryingsproperty 
numUsedVaryings:uint  [read-only]

Number of used varyings. Any animation code to be added can add its used varyings after this.


Implementation
    public function get numUsedVaryings():uint
numUsedVertexConstantsproperty 
numUsedVertexConstants:uint  [read-only]

The amount of vertex constants used by the material. Any animation code to be added can append its vertex constant data after this.


Implementation
    public function get numUsedVertexConstants():uint
preserveAlphaproperty 
preserveAlpha:Boolean

Indicates whether the output alpha value should remain unchanged compared to the material's original alpha.


Implementation
    public function get preserveAlpha():Boolean
    public function set preserveAlpha(value:Boolean):void
probeWeightsIndexproperty 
probeWeightsIndex:int  [read-only]

The index of the fragment constant containing the weights for the light probes.


Implementation
    public function get probeWeightsIndex():int
sceneMatrixIndexproperty 
sceneMatrixIndex:int  [read-only]

The index of the vertex constant containing the scene matrix.


Implementation
    public function get sceneMatrixIndex():int
sceneNormalMatrixIndexproperty 
sceneNormalMatrixIndex:int  [read-only]

The index of the vertex constant containing the uniform scene matrix (the inverse transpose).


Implementation
    public function get sceneNormalMatrixIndex():int
secondaryUVBufferIndexproperty 
secondaryUVBufferIndex:int  [read-only]

The index for the secondary UV vertex attribute stream.


Implementation
    public function get secondaryUVBufferIndex():int
shadedTargetproperty 
shadedTarget:String  [read-only]

The register name containing the final shaded colour.


Implementation
    public function get shadedTarget():String
specularLightSourcesproperty 
specularLightSources:uint

Define which light source types to use for specular reflections. This allows choosing between regular lights and/or light probes for specular reflections.


Implementation
    public function get specularLightSources():uint
    public function set specularLightSources(value:uint):void

See also

tangentBufferIndexproperty 
tangentBufferIndex:int  [read-only]

The index for the vertex tangent attribute stream.


Implementation
    public function get tangentBufferIndex():int
usesNormalsproperty 
usesNormals:Boolean  [read-only]

Indicates whether the compiled shader uses normals.


Implementation
    public function get usesNormals():Boolean
usingSpecularMethodproperty 
usingSpecularMethod:Boolean  [read-only]

Indicates whether the specular method is used.


Implementation
    public function get usingSpecularMethod():Boolean
uvBufferIndexproperty 
uvBufferIndex:int  [read-only]

The index for the UV vertex attribute stream.


Implementation
    public function get uvBufferIndex():int
UVSourceproperty 
UVSource:String  [read-only]

The souce register providing the UV coordinate to animate.


Implementation
    public function get UVSource():String
UVTargetproperty 
UVTarget:String  [read-only]

The target register to place the animated UV coordinate.


Implementation
    public function get UVTarget():String
uvTransformIndexproperty 
uvTransformIndex:int  [read-only]

The index for the UV transformation matrix vertex constant.


Implementation
    public function get uvTransformIndex():int
vertexCodeproperty 
vertexCode:String  [read-only]

The generated vertex code.


Implementation
    public function get vertexCode():String
Constructor Detail
ShaderCompiler()Constructor
public function ShaderCompiler(profile:String)

Creates a new ShaderCompiler object.

Parameters
profile:String — The compatibility profile of the renderer.
Method Detail
calculateDependencies()method
protected function calculateDependencies():void

Figure out which named registers are required, and how often.

compile()method 
public function compile():void

Compiles the code after all setup on the compiler has finished.

compileGlobalPositionCode()method 
protected function compileGlobalPositionCode():void

Compile the world-space position.

compileLightingCode()method 
protected function compileLightingCode():void

Compile the lighting code.

compileMethods()method 
protected function compileMethods():void

Compiles the code for the methods.

compileMethodsCode()method 
protected function compileMethodsCode():void

Compile the code for the methods.

compileNormalCode()method 
protected function compileNormalCode():void

Calculate the normal.

compileViewDirCode()method 
protected function compileViewDirCode():void

Calculate the view direction.

createNormalRegisters()method 
protected function createNormalRegisters():void

Creates the registers to contain the normal data.

dispose()method 
public function dispose():void

Disposes all resources used by the compiler.

initLightData()method 
protected function initLightData():void

Prepares the setup for the light code.

initRegisterIndices()method 
protected function initRegisterIndices():void

Reset all the indices to "unused".

setConstantDataBuffers()method 
public function setConstantDataBuffers(vertexConstantData:Vector.<Number>, fragmentConstantData:Vector.<Number>):void

Sets the constant buffers allocated by the material. This allows setting constant data during compilation.

Parameters

vertexConstantData:Vector.<Number> — The vertex constant data buffer.
 
fragmentConstantData:Vector.<Number> — The fragment constant data buffer.

setTextureSampling()method 
public function setTextureSampling(smooth:Boolean, repeat:Boolean, mipmap:Boolean):void

Sets the default texture sampling properties.

Parameters

smooth:Boolean — Indicates whether the texture should be filtered when sampled. Defaults to true.
 
repeat:Boolean — Indicates whether the texture should be tiled when sampled. Defaults to true.
 
mipmap:Boolean — Indicates whether or not any used textures should use mipmapping. Defaults to true.

usesLights()method 
protected function usesLights():Boolean

Indicates whether the compiled shader uses lights.

Returns
Boolean
usesLightsForDiffuse()method 
protected function usesLightsForDiffuse():Boolean

Indicates whether lights are used for diffuse reflections.

Returns
Boolean
usesLightsForSpecular()method 
protected function usesLightsForSpecular():Boolean

Indicates whether lights are used for specular reflections.

Returns
Boolean
usesProbes()method 
protected function usesProbes():Boolean

Indicates whether any light probes are used.

Returns
Boolean
usesProbesForDiffuse()method 
protected function usesProbesForDiffuse():Boolean

Indicates whether light probes are being used for diffuse reflections.

Returns
Boolean
usesProbesForSpecular()method 
protected function usesProbesForSpecular():Boolean

Indicates whether light probes are being used for specular reflections.

Returns
Boolean