UNPKG

@awayjs/renderer

Version:
325 lines 9.99 kB
import { Matrix3D, IAssetClass, IAbstractionClass, IAsset, IAbstraction } from '@awayjs/core'; import { ContextGLProfile, ContextGLCompareMode, ProgramData, Stage, ShaderRegisterCache, ShaderRegisterData } from '@awayjs/stage'; import { _Render_RenderableBase } from './_Render_RenderableBase'; import { _Render_ElementsBase } from './_Render_ElementsBase'; import { AnimationRegisterData } from './AnimationRegisterData'; import { _Render_MaterialBase } from './_Render_MaterialBase'; import { _Stage_ElementsBase } from './_Stage_ElementsBase'; import { View } from '@awayjs/view'; import { IPass } from './IPass'; import { IShaderBase } from './IShaderBase'; /** * ShaderBase keeps track of the number of dependencies for "named registers" used across a pass. * Named registers are that are not necessarily limited to a single method. They are created by the compiler and * passed on to methods. The compiler uses the results to reserve usages through RegisterPool, which can be removed * each time a method has been compiled into the shader. * * @see RegisterPool.addUsage */ export declare class ShaderBase implements IShaderBase { private static _store; private static _abstractionClassPool; private _renderElements; private _renderMaterial; private _view; private _pass; _stage: Stage; private _programData; private _blendFactor; private _blendEquation; private _invalidProgram; private _animationVertexCode; private _animationFragmentCode; private _numUsedVertexConstants; private _numUsedFragmentConstants; private _numUsedStreams; private _numUsedTextures; private _usesAnimation; protected _sharedRegisters: ShaderRegisterData; protected _registerCache: ShaderRegisterCache; protected _vertexCode: string; protected _fragmentCode: string; protected _postAnimationFragmentCode: string; get view(): View; get stage(): Stage; get pass(): IPass; get renderMaterial(): _Render_MaterialBase; get programData(): ProgramData; usesBlending: boolean; useImageRect: boolean; usesCurves: boolean; /** * */ activeElements: _Stage_ElementsBase; /** * The depth compare mode used to render the renderables using this material. * * @see away.stagegl.ContextGLCompareMode */ depthCompareMode: ContextGLCompareMode; /** * Indicate whether the shader should write to the depth buffer or not. Ignored when blending is enabled. */ writeDepth: boolean; profile: ContextGLProfile; get usesAnimation(): boolean; set usesAnimation(value: boolean); private _defaultCulling; _pInverseSceneMatrix: Float32Array; animationRegisterData: AnimationRegisterData; get numUsedVertexConstants(): number; get numUsedFragmentConstants(): number; /** * The amount of used vertex streams in the vertex code. * Used by the animation code generation to know from which index on streams are available. */ get numUsedStreams(): number; /** * */ get numUsedTextures(): number; numLights: number; usesPremultipliedAlpha: boolean; useBothSides: boolean; usesUVTransform: boolean; usesColorTransform: boolean; alphaThreshold: number; ambientR: number; ambientG: number; ambientB: number; /** * */ usesCommonData: boolean; /** * Indicates whether the pass requires any fragment animation code. */ usesFragmentAnimation: boolean; /** * The amount of dependencies on the projected position. */ projectionDependencies: number; /** * The amount of dependencies on the normal vector. */ normalDependencies: number; /** * The amount of dependencies on the vertex color. */ colorDependencies: number; /** * The amount of dependencies on the view direction. */ viewDirDependencies: number; /** * The amount of dependencies on the primary UV coordinates. */ uvDependencies: number; /** * The amount of dependencies on the secondary UV coordinates. */ secondaryUVDependencies: number; /** * The amount of dependencies on the global position. This can be 0 while hasGlobalPosDependencies is true when * the global position is used as a temporary value (fe to calculate the view direction) */ globalPosDependencies: number; /** * The amount of tangent vector dependencies (fragment shader). */ tangentDependencies: number; /** * */ outputsColors: boolean; /** * Indicates whether or not normals are output. */ outputsNormals: boolean; /** * Indicates whether or not normal calculations are output in tangent space. */ outputsTangentNormals: boolean; /** * Indicates whether or not normal calculations are * expected in tangent space. This is only the case if no world-space * dependencies exist and normals are being output. */ usesTangentSpace: boolean; /** * Indicates whether there are any dependencies on the world-space position vector. */ usesGlobalPosFragment: boolean; /** * Indicates whether there are any dependencies on the local position vector. */ usesPositionFragment: boolean; vertexConstantData: Float32Array; fragmentConstantData: Float32Array; viewMatrix: Matrix3D; sceneMatrix: Matrix3D; sceneNormalMatrix: Matrix3D; /** * The index for the common data register. */ commonsDataIndex: number; /** * The index for the curve vertex attribute stream. */ curvesIndex: number; /** * The index for the UV vertex attribute stream. */ uvIndex: number; /** * The index for the secondary UV vertex attribute stream. */ secondaryUVIndex: number; /** * The index for the vertex normal attribute stream. */ normalIndex: number; /** * The index for the color attribute stream. */ colorBufferIndex: number; /** * The index for the vertex tangent attribute stream. */ tangentIndex: number; /** * */ skyboxScaleIndex: number; /** * */ scenePositionIndex: number; /** * The index of the vertex constant containing the view matrix. */ viewMatrixIndex: number; /** * The index of the vertex constant containing the scene matrix. */ sceneMatrixIndex: number; /** * The index of the vertex constant containing the uniform scene matrix (the inverse transpose). */ sceneNormalMatrixIndex: number; /** * The index of the vertex constant containing the camera position. */ cameraPositionIndex: number; /** * The index for the UV transformation matrix vertex constant. */ uvMatrixIndex: number; /** * The index for the color transform fragment constant. */ colorTransformIndex: number; /** * */ jointIndexIndex: number; /** * */ jointWeightIndex: number; /** * */ imageIndices: Array<number>; readonly id: number; /** * Creates a new MethodCompilerVO object. */ constructor(renderElements: _Render_ElementsBase, renderMaterial: _Render_MaterialBase, pass: IPass, stage: Stage); requestAbstraction(asset: IAsset): IAbstraction; storeAbstraction(abstraction: IAbstraction): void; /** * * @param imageObjectClass */ static registerAbstraction(abstractionClass: IAbstractionClass, assetClass: IAssetClass): void; _includeDependencies(): void; /** * Clears dependency counts for all registers. Called when recompiling a pass. */ reset(): void; /** * The blend mode to use when drawing this renderable. The following blend modes are supported: * <ul> * <li>BlendMode.NORMAL: No blending, unless the material inherently needs it</li> * <li>BlendMode.LAYER: Force blending. * This will draw the object the same as NORMAL, but without writing depth writes.</li> * <li>BlendMode.MULTIPLY</li> * <li>BlendMode.ADD</li> * <li>BlendMode.ALPHA</li> * </ul> */ setBlendMode(value: string): void; /** * @inheritDoc */ _activate(): void; /** * @inheritDoc */ _deactivate(): void; /** * * * @param renderable * @param stage * @param camera */ _setRenderState(renderState: _Render_RenderableBase): void; invalidateProgram(): void; dispose(): void; private _updateProgram; /** * Reset all the indices to "unused". */ protected _initRegisterIndices(): void; /** * Compile the code for the methods. */ protected _compileDependencies(): void; /** * Initializes the unchanging constant data for this shader object. */ protected _initConstantData(): void; private _compileColorCode; private _compileGlobalPositionCode; private _compilePositionCode; private _compileCurvesCode; /** * Calculate the transformed colours */ private _compileColorTransformCode; /** * Calculate the (possibly animated) UV coordinates. */ private _compileUVCode; /** * Provide the secondary UV coordinates. */ private _compileSecondaryUVCode; /** * Calculate the view direction. */ private _compileViewDirCode; /** * Calculate the normal. */ private _compileNormalCode; private _compileAnimationCode; setVertexConst(index: number, x?: number, y?: number, z?: number, w?: number): void; setVertexConstFromArray(index: number, data: Float32Array): void; setVertexConstFromMatrix(index: number, matrix: Matrix3D): void; setFragmentConst(index: number, x?: number, y?: number, z?: number, w?: number): void; } //# sourceMappingURL=ShaderBase.d.ts.map