-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #395 from lirongf/master
修改后期处理流程,增加shaderDataCMDType枚举,动态增加Scene Uniform,修改blur示例
- Loading branch information
Showing
8 changed files
with
273 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/layaAir/laya/d3/core/render/command/SetShaderDataCMD.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { Command } from "./Command"; | ||
import { ShaderData } from "../../../shader/ShaderData" | ||
import { BaseTexture } from "../../../../resource/BaseTexture"; | ||
import { Vector2 } from "../../../math/Vector2"; | ||
import { Vector3 } from "../../../math/Vector3"; | ||
import { Vector4 } from "../../../math/Vector4"; | ||
import { Quaternion } from "../../../math/Quaternion"; | ||
import { Matrix4x4 } from "../../../math/Matrix4x4"; | ||
export enum ShaderDataType{ | ||
Int, | ||
Bool, | ||
Number, | ||
Vector2, | ||
Vector3, | ||
Vector, | ||
Quaternion, | ||
Matrix4x4, | ||
Buffer, | ||
Texture | ||
} | ||
|
||
/** | ||
* @internal | ||
* <code>SetShaderDataTextureCMD</code> 类用于创建设置渲染目标指令。 | ||
*/ | ||
export class SetShaderDataCMD extends Command { | ||
/**@internal */ | ||
private static _pool: any[] = []; | ||
|
||
/**@internal */ | ||
private _shaderData: ShaderData = null; | ||
/**@internal */ | ||
private _nameID: number = 0; | ||
/**@internal */ | ||
private _value: number|BaseTexture|boolean|Vector2|Vector3|Vector4|Float32Array|Quaternion|Matrix4x4 = null; | ||
/**@internal */ | ||
private _dataType:number = -1; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
static create(shaderData: ShaderData, nameID: number, value:any,shaderDataType:ShaderDataType): SetShaderDataCMD { | ||
var cmd: SetShaderDataCMD; | ||
cmd = SetShaderDataCMD._pool.length > 0 ? SetShaderDataCMD._pool.pop() : new SetShaderDataCMD(); | ||
cmd._shaderData = shaderData; | ||
cmd._nameID = nameID; | ||
cmd._value = value; | ||
cmd._dataType = shaderDataType | ||
return cmd; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @override | ||
*/ | ||
run(): void { | ||
switch(this._dataType){ | ||
case ShaderDataType.Int: | ||
this._shaderData.setInt(this._nameID,this._value as number); | ||
break; | ||
case ShaderDataType.Number: | ||
this._shaderData.setNumber(this._nameID,this._value as number); | ||
break; | ||
case ShaderDataType.Bool: | ||
this._shaderData.setBool(this._nameID,this._value as boolean); | ||
break; | ||
case ShaderDataType.Matrix4x4: | ||
this._shaderData.setMatrix4x4(this._nameID,this._value as Matrix4x4); | ||
break; | ||
case ShaderDataType.Quaternion: | ||
this._shaderData.setQuaternion(this._nameID,this._value as Quaternion); | ||
break; | ||
case ShaderDataType.Texture: | ||
this._shaderData.setTexture(this._nameID,this._value as BaseTexture); | ||
break; | ||
case ShaderDataType.Vector: | ||
this._shaderData.setVector(this._nameID,this._value as Vector4); | ||
break; | ||
case ShaderDataType.Vector2: | ||
this._shaderData.setVector2(this._nameID,this._value as Vector2); | ||
break; | ||
case ShaderDataType.Vector3: | ||
this._shaderData.setVector3(this._nameID,this._value as Vector3); | ||
break; | ||
case ShaderDataType.Buffer: | ||
this._shaderData.setBuffer(this._nameID,this._value as Float32Array); | ||
break; | ||
default: | ||
throw "no type shaderValue on this CommendBuffer"; | ||
} | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @override | ||
*/ | ||
recover(): void { | ||
SetShaderDataCMD._pool.push(this); | ||
this._shaderData = null; | ||
this._nameID = 0; | ||
this._value = null; | ||
this._dataType = -1; | ||
} | ||
|
||
} | ||
|
||
|
Oops, something went wrong.