fix pass & GL constants Changelog: * (#4762)

* fix material props when using pass switches

* don't rely on WebGLRenderingContext static constants

* skybox precision
This commit is contained in:
Yun Hsiao Wu
2019-07-01 09:31:37 +08:00
committed by Weiliang Wang
parent f92dead173
commit 257f966bd3
21 changed files with 960 additions and 954 deletions
+4 -3
View File
@@ -80,7 +80,7 @@ interface IMaterialInfo {
export class Material extends Asset {
/**
* @zh
* 获取材质资源的实例,您应当不会需要手动调用这个函数。
* 获取材质资源的实例,应当不会需要手动调用这个函数。
*/
public static getInstantiatedMaterial (mat: Material, rndCom: RenderableComponent, inEditor: boolean) {
if (mat._owner === rndCom) {
@@ -365,10 +365,11 @@ export class Material extends Asset {
states: this._states,
});
// handle property values
this._props.length = this._passes.length;
const totalPasses = this._effectAsset.techniques[this._techIdx].passes.length;
this._props.length = totalPasses;
if (keepProps) {
this._passes.forEach((pass, i) => {
let props = this._props[i];
let props = this._props[pass.idxInTech];
if (!props) { props = this._props[i] = {}; }
for (const p of Object.keys(props)) {
const val = props[p];
+2 -3
View File
@@ -45,9 +45,9 @@ export class Skeleton extends Asset {
private _joints: string[] = [];
@property([Mat4])
private _bindposes: Mat4[] | null = null;
private _bindposes: Mat4[] = [];
private _bindTRS: IBindTRS[] | null = null;
private _bindTRS: IBindTRS[] = [];
/**
* 所有关节的绑定姿势矩阵。该数组的长度始终与 `this.joints` 的长度相同。
@@ -58,7 +58,6 @@ export class Skeleton extends Asset {
set bindposes (value) {
this._bindposes = value;
if (!value) { this._bindTRS = null; return; }
this._bindTRS = value.map((m) => {
const position = new Vec3();
const rotation = new Quat();
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -301,7 +301,7 @@ export class AvatarModelComponent extends SkinningModelComponent {
if (!lca) { console.warn('illegal skinning roots'); return; }
// merge joints accordingly
const skeleton = new Skeleton();
skeleton.bindposes = [];
const bindposes: Mat4[] = [];
for (const unit of this._avatarUnits) {
if (!unit || !unit.skeleton || !unit.skinningRoot) { continue; }
const partial = unit.skeleton;
@@ -311,7 +311,7 @@ export class AvatarModelComponent extends SkinningModelComponent {
const idx = skeleton.joints.findIndex((p) => p === path);
if (idx >= 0) { continue; }
skeleton.joints.push(path);
skeleton.bindposes.push(partial.bindposes && partial.bindposes[i] || new Mat4());
bindposes.push(partial.bindposes[i] || new Mat4());
}
}
// sort the array to be more cache-friendly
@@ -321,7 +321,7 @@ export class AvatarModelComponent extends SkinningModelComponent {
return 0;
});
skeleton.joints = skeleton.joints.map((_, idx, arr) => arr[idxMap[idx]]);
skeleton.bindposes = skeleton.bindposes.map((_, idx, arr) => arr[idxMap[idx]]);
skeleton.bindposes = bindposes.map((_, idx, arr) => arr[idxMap[idx]]);
// apply
// @ts-ignore
super.skeleton = skeleton;
@@ -148,8 +148,8 @@ export class BatchedSkinningModelComponent extends SkinningModelComponent {
}
public onLoad () {
this._batchMaterial = this.getSharedMaterial(0);
super.onLoad();
this._batchMaterial = this.getSharedMaterial(0);
this.cook();
}
@@ -217,7 +217,7 @@ export class BatchedSkinningModelComponent extends SkinningModelComponent {
if (!lca) { console.warn('illegal skinning roots'); return; }
// merge joints accordingly
const skeleton = new Skeleton();
skeleton.bindposes = [];
const bindposes: Mat4[] = [];
for (const unit of this.units) {
if (!unit || !unit.skeleton || !unit.skinningRoot) { continue; }
const partial = unit.skeleton;
@@ -227,7 +227,7 @@ export class BatchedSkinningModelComponent extends SkinningModelComponent {
const idx = skeleton.joints.findIndex((p) => p === path);
if (idx >= 0) { continue; }
skeleton.joints.push(path);
skeleton.bindposes.push(partial.bindposes && partial.bindposes[i] || new Mat4());
bindposes.push(partial.bindposes[i] || new Mat4());
}
}
// sort the array to be more cache-friendly
@@ -237,7 +237,7 @@ export class BatchedSkinningModelComponent extends SkinningModelComponent {
return 0;
});
skeleton.joints = skeleton.joints.map((_, idx, arr) => arr[idxMap[idx]]);
skeleton.bindposes = skeleton.bindposes.map((_, idx, arr) => arr[idxMap[idx]]);
skeleton.bindposes = bindposes.map((_, idx, arr) => arr[idxMap[idx]]);
// apply
this.skeleton = skeleton;
}
@@ -162,7 +162,7 @@ export default class ParticleSystemRenderer {
displayOrder: 8,
})
public get particleMaterial () {
return this.particleSystem.getMaterial(0, CC_EDITOR)!;
return this.particleSystem.getMaterial(0);
}
public set particleMaterial (val) {
@@ -177,7 +177,7 @@ export default class ParticleSystemRenderer {
displayOrder: 9,
})
public get trailMaterial () {
return this.particleSystem.getMaterial(1, CC_EDITOR)!;
return this.particleSystem.getMaterial(1)!;
}
public set trailMaterial (val) {
@@ -190,7 +190,7 @@ export default class ParticleSystemRenderer {
private frameTile_velLenScale: Vec4;
private _node_scale: Vec4;
private attrs: any[];
private _vertAttrs: IGFXAttribute[];
private _vertAttrs: IGFXAttribute[] = [];
private particleSystem: any;
private _particles: RecyclePool | null = null;
private _defaultMat: Material | null = null;
+1 -1
View File
@@ -69,7 +69,7 @@ export class RenderableComponent extends Component {
* @zh 返回相对应序号的材质。
* @param {Number} idx - Look for the material list number
*/
public getMaterial (idx: number, inEditor: boolean = false, autoUpdate: boolean = false): Material | null {
public getMaterial (idx: number, inEditor: boolean = CC_EDITOR, autoUpdate: boolean = false): Material | null {
const mat = this._materials[idx];
if (!mat) { return null; }
const instantiated = Material.getInstantiatedMaterial(mat, this, inEditor);
@@ -90,7 +90,7 @@ export class SkinningModelComponent extends ModelComponent {
const device: GFXDevice = cc.director.root && cc.director.root.device;
const joints = this._skeleton && this._skeleton.joints.length || 0;
const type = selectJointsMediumType(device, joints);
const mat = this.getMaterial(index, CC_EDITOR) || this._getBuiltinMaterial();
const mat = this.getMaterial(index) || this._getBuiltinMaterial();
mat.recompileShaders({ CC_USE_SKINNING: type });
super._onMaterialModified(index, mat);
}
+2 -2
View File
@@ -82,7 +82,7 @@ export class UIModelComponent extends UIComponent {
}
const matNum = this._modelComponent.sharedMaterials.length;
for (let i = 0; i < matNum; i++) {
const material = this._modelComponent.getMaterial(i, CC_EDITOR)! as Material;
const material = this._modelComponent.getMaterial(i)! as Material;
if (material == null) {
continue;
}
@@ -105,7 +105,7 @@ export class UIModelComponent extends UIComponent {
}
}
for (let i = 0; i < matNum; i++) {
const material = this._modelComponent.getMaterial(i, CC_EDITOR)!;
const material = this._modelComponent.getMaterial(i);
if (material == null) {
continue;
}
+3 -3
View File
@@ -352,12 +352,12 @@ export class WebGLGFXCommandBuffer extends GFXCommandBuffer {
if (this._curGPUPipelineState) {
const glPrimitive = this._curGPUPipelineState.glPrimitive;
switch (glPrimitive) {
case WebGLRenderingContext.TRIANGLES: {
case 0x0004: { // WebGLRenderingContext.TRIANGLES
this._numTris += inputAssembler.indexCount / 3 * Math.max(inputAssembler.instanceCount, 1);
break;
}
case WebGLRenderingContext.TRIANGLE_STRIP:
case WebGLRenderingContext.TRIANGLE_FAN: {
case 0x0005: // WebGLRenderingContext.TRIANGLE_STRIP
case 0x0006: { // WebGLRenderingContext.TRIANGLE_FAN
this._numTris += (inputAssembler.indexCount - 2) * Math.max(inputAssembler.instanceCount, 1);
break;
}
File diff suppressed because it is too large Load Diff
+14 -16
View File
@@ -223,8 +223,6 @@ export class WebGLGFXDevice extends GFXDevice {
return false;
}
// No errors are thrown using try catch
// Tested through ios baidu browser 4.14.1
if (!this._webGLRC) {
console.error('This device does not support WebGL.');
return false;
@@ -242,18 +240,18 @@ export class WebGLGFXDevice extends GFXDevice {
this._renderer = gl.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL);
this._vendor = gl.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL);
} else {
this._renderer = gl.getParameter(WebGLRenderingContext.RENDERER);
this._vendor = gl.getParameter(WebGLRenderingContext.VENDOR);
this._renderer = gl.getParameter(gl.RENDERER);
this._vendor = gl.getParameter(gl.VENDOR);
}
this._version = gl.getParameter(WebGLRenderingContext.VERSION);
this._maxVertexAttributes = gl.getParameter(WebGLRenderingContext.MAX_VERTEX_ATTRIBS);
this._maxVertexUniformVectors = gl.getParameter(WebGLRenderingContext.MAX_VERTEX_UNIFORM_VECTORS);
this._maxFragmentUniformVectors = gl.getParameter(WebGLRenderingContext.MAX_FRAGMENT_UNIFORM_VECTORS);
this._maxTextureUnits = gl.getParameter(WebGLRenderingContext.MAX_TEXTURE_IMAGE_UNITS);
this._maxVertexTextureUnits = gl.getParameter(WebGLRenderingContext.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
this._depthBits = gl.getParameter(WebGLRenderingContext.DEPTH_BITS);
this._stencilBits = gl.getParameter(WebGLRenderingContext.STENCIL_BITS);
this._version = gl.getParameter(gl.VERSION);
this._maxVertexAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
this._maxVertexUniformVectors = gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS);
this._maxFragmentUniformVectors = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS);
this._maxTextureUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
this._maxVertexTextureUnits = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
this._depthBits = gl.getParameter(gl.DEPTH_BITS);
this._stencilBits = gl.getParameter(gl.STENCIL_BITS);
this._devicePixelRatio = info.devicePixelRatio || 1.0;
this._width = this._canvas.width;
@@ -636,7 +634,7 @@ export class WebGLGFXDevice extends GFXDevice {
const curFBO = this.stateCache.glFramebuffer;
if (this.stateCache.glFramebuffer !== gpuFramebuffer.glFramebuffer) {
gl.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER, gpuFramebuffer.glFramebuffer);
gl.bindFramebuffer(gl.FRAMEBUFFER, gpuFramebuffer.glFramebuffer);
this.stateCache.glFramebuffer = gpuFramebuffer.glFramebuffer;
}
@@ -652,11 +650,11 @@ export class WebGLGFXDevice extends GFXDevice {
const data = view.subarray(buffOffset, buffOffset + memSize);
gl.readPixels(region.texOffset.x, region.texOffset.y, w, h,
WebGLRenderingContext.RGBA, WebGLRenderingContext.UNSIGNED_BYTE, data);
gl.RGBA, gl.UNSIGNED_BYTE, data);
}
if (this.stateCache.glFramebuffer !== curFBO) {
gl.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER, curFBO);
gl.bindFramebuffer(gl.FRAMEBUFFER, curFBO);
this.stateCache.glFramebuffer = curFBO;
}
}
@@ -664,7 +662,7 @@ export class WebGLGFXDevice extends GFXDevice {
public blitFramebuffer (src: GFXFramebuffer, dst: GFXFramebuffer, srcRect: IGFXRect, dstRect: IGFXRect, filter: GFXFilter) {
}
private initStates (gl: WebGLRenderingContext) {
private initStates (gl: gl) {
gl.activeTexture(gl.TEXTURE0);
gl.pixelStorei(gl.PACK_ALIGNMENT, 1);
+6 -6
View File
@@ -106,11 +106,11 @@ export class WebGLGPUFramebuffer {
}
export class WebGLGPUSampler {
public glMinFilter: GLenum = WebGLRenderingContext.NONE;
public glMagFilter: GLenum = WebGLRenderingContext.NONE;
public glWrapS: GLenum = WebGLRenderingContext.NONE;
public glWrapT: GLenum = WebGLRenderingContext.NONE;
public glWrapR: GLenum = WebGLRenderingContext.NONE;
public glMinFilter: GLenum = 0;
public glMagFilter: GLenum = 0;
public glWrapS: GLenum = 0;
public glWrapT: GLenum = 0;
public glWrapR: GLenum = 0;
}
export class WebGLGPUInput {
@@ -187,7 +187,7 @@ export class WebGLGPUPipelineLayout {
export class WebGLGPUPipelineState {
public glPrimitive: GLenum = WebGLRenderingContext.TRIANGLES;
public glPrimitive: GLenum = 0x0004; // WebGLRenderingContext.TRIANGLES;
public gpuShader: WebGLGPUShader | null = null;
public rs: GFXRasterizerState = new GFXRasterizerState();
public dss: GFXDepthStencilState = new GFXDepthStencilState();
+3 -3
View File
@@ -52,9 +52,9 @@ export class WebGLGFXInputAssembler extends GFXInputAssembler {
gpuIndexBuffer = (info.indexBuffer as WebGLGFXBuffer).gpuBuffer;
if (gpuIndexBuffer) {
switch (gpuIndexBuffer.stride) {
case 1: glIndexType = WebGLRenderingContext.UNSIGNED_BYTE; break;
case 2: glIndexType = WebGLRenderingContext.UNSIGNED_SHORT; break;
case 4: glIndexType = WebGLRenderingContext.UNSIGNED_INT; break;
case 1: glIndexType = 0x1401; break; // WebGLRenderingContext.UNSIGNED_BYTE
case 2: glIndexType = 0x1403; break; // WebGLRenderingContext.UNSIGNED_SHORT
case 4: glIndexType = 0x1405; break; // WebGLRenderingContext.UNSIGNED_INT
default: {
console.error('Error index buffer stride.');
}
+14 -14
View File
@@ -7,20 +7,20 @@ import { WebGLGFXRenderPass } from './webgl-render-pass';
import { WebGLGFXShader } from './webgl-shader';
const WebGLPrimitives: GLenum[] = [
WebGLRenderingContext.POINTS,
WebGLRenderingContext.LINES,
WebGLRenderingContext.LINE_STRIP,
WebGLRenderingContext.LINE_LOOP,
WebGLRenderingContext.NONE,
WebGLRenderingContext.NONE,
WebGLRenderingContext.NONE,
WebGLRenderingContext.TRIANGLES,
WebGLRenderingContext.TRIANGLE_STRIP,
WebGLRenderingContext.TRIANGLE_FAN,
WebGLRenderingContext.NONE,
WebGLRenderingContext.NONE,
WebGLRenderingContext.NONE,
WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.POINTS,
0x0001, // WebGLRenderingContext.LINES,
0x0003, // WebGLRenderingContext.LINE_STRIP,
0x0002, // WebGLRenderingContext.LINE_LOOP,
0x0000, // WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.NONE,
0x0004, // WebGLRenderingContext.TRIANGLES,
0x0005, // WebGLRenderingContext.TRIANGLE_STRIP,
0x0006, // WebGLRenderingContext.TRIANGLE_FAN,
0x0000, // WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.NONE,
];
export class WebGLGFXPipelineState extends GFXPipelineState {
+14 -14
View File
@@ -4,10 +4,10 @@ import { GFXSampler, GFXSamplerState, IGFXSamplerInfo } from '../sampler';
import { WebGLGPUSampler } from './webgl-gpu-objects';
const WebGLWraps: GLenum[] = [
WebGLRenderingContext.REPEAT,
WebGLRenderingContext.MIRRORED_REPEAT,
WebGLRenderingContext.CLAMP_TO_EDGE,
WebGLRenderingContext.CLAMP_TO_EDGE,
0x2901, // WebGLRenderingContext.REPEAT,
0x8370, // WebGLRenderingContext.MIRRORED_REPEAT,
0x812F, // WebGLRenderingContext.CLAMP_TO_EDGE,
0x812F, // WebGLRenderingContext.CLAMP_TO_EDGE,
];
export class WebGLGFXSampler extends GFXSampler {
@@ -78,8 +78,8 @@ export class WebGLGFXSampler extends GFXSampler {
this._state.mipLODBias = info.mipLODBias;
}
let glMinFilter = WebGLRenderingContext.NONE;
let glMagFilter = WebGLRenderingContext.NONE;
let glMinFilter = 0;
let glMagFilter = 0;
const minFilter = this._state.minFilter;
const magFilter = this._state.magFilter;
@@ -87,26 +87,26 @@ export class WebGLGFXSampler extends GFXSampler {
if (minFilter === GFXFilter.LINEAR || minFilter === GFXFilter.ANISOTROPIC) {
if (mipFilter === GFXFilter.LINEAR || mipFilter === GFXFilter.ANISOTROPIC) {
glMinFilter = WebGLRenderingContext.LINEAR_MIPMAP_LINEAR;
glMinFilter = 0x2703; // WebGLRenderingContext.LINEAR_MIPMAP_LINEAR;
} else if (mipFilter === GFXFilter.POINT) {
glMinFilter = WebGLRenderingContext.LINEAR_MIPMAP_NEAREST;
glMinFilter = 0x2701; // WebGLRenderingContext.LINEAR_MIPMAP_NEAREST;
} else {
glMinFilter = WebGLRenderingContext.LINEAR;
glMinFilter = 0x2601; // WebGLRenderingContext.LINEAR;
}
} else {
if (mipFilter === GFXFilter.LINEAR || mipFilter === GFXFilter.ANISOTROPIC) {
glMinFilter = WebGLRenderingContext.NEAREST_MIPMAP_LINEAR;
glMinFilter = 0x2702; // WebGLRenderingContext.NEAREST_MIPMAP_LINEAR;
} else if (mipFilter === GFXFilter.POINT) {
glMinFilter = WebGLRenderingContext.NEAREST_MIPMAP_NEAREST;
glMinFilter = 0x2700; // WebGLRenderingContext.NEAREST_MIPMAP_NEAREST;
} else {
glMinFilter = WebGLRenderingContext.NEAREST;
glMinFilter = 0x2600; // WebGLRenderingContext.NEAREST;
}
}
if (magFilter === GFXFilter.LINEAR || magFilter === GFXFilter.ANISOTROPIC) {
glMagFilter = WebGLRenderingContext.LINEAR;
glMagFilter = 0x2601; // WebGLRenderingContext.LINEAR;
} else {
glMagFilter = WebGLRenderingContext.NEAREST;
glMagFilter = 0x2600; // WebGLRenderingContext.NEAREST;
}
const glWrapS = WebGLWraps[this._state.addressU];
File diff suppressed because it is too large Load Diff
+18 -20
View File
@@ -150,8 +150,6 @@ export class WebGL2GFXDevice extends GFXDevice {
return false;
}
// No errors are thrown using try catch
// Tested through ios baidu browser 4.14.1
if (!this._webGL2RC) {
console.error('This device does not support WebGL2.');
return false;
@@ -170,23 +168,23 @@ export class WebGL2GFXDevice extends GFXDevice {
this._renderer = gl.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL);
this._vendor = gl.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL);
} else {
this._renderer = gl.getParameter(WebGL2RenderingContext.RENDERER);
this._vendor = gl.getParameter(WebGL2RenderingContext.VENDOR);
this._renderer = gl.getParameter(gl.RENDERER);
this._vendor = gl.getParameter(gl.VENDOR);
}
this._version = gl.getParameter(WebGL2RenderingContext.VERSION);
this._maxVertexAttributes = gl.getParameter(WebGL2RenderingContext.MAX_VERTEX_ATTRIBS);
this._maxVertexUniformVectors = gl.getParameter(WebGL2RenderingContext.MAX_VERTEX_UNIFORM_VECTORS);
this._maxFragmentUniformVectors = gl.getParameter(WebGL2RenderingContext.MAX_FRAGMENT_UNIFORM_VECTORS);
this._maxTextureUnits = gl.getParameter(WebGL2RenderingContext.MAX_TEXTURE_IMAGE_UNITS);
this._maxVertexTextureUnits = gl.getParameter(WebGL2RenderingContext.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
this._maxUniformBufferBindings = gl.getParameter(WebGL2RenderingContext.MAX_UNIFORM_BUFFER_BINDINGS);
this._maxUniformBlockSize = gl.getParameter(WebGL2RenderingContext.MAX_UNIFORM_BLOCK_SIZE);
this._depthBits = gl.getParameter(WebGL2RenderingContext.DEPTH_BITS);
this._stencilBits = gl.getParameter(WebGL2RenderingContext.STENCIL_BITS);
// let maxVertexUniformBlocks = gl.getParameter(WebGL2RenderingContext.MAX_VERTEX_UNIFORM_BLOCKS);
// let maxFragmentUniformBlocks = gl.getParameter(WebGL2RenderingContext.MAX_FRAGMENT_UNIFORM_BLOCKS);
// let uboOffsetAlignment = gl.getParameter(WebGL2RenderingContext.UNIFORM_BUFFER_OFFSET_ALIGNMENT);
this._version = gl.getParameter(gl.VERSION);
this._maxVertexAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
this._maxVertexUniformVectors = gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS);
this._maxFragmentUniformVectors = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS);
this._maxTextureUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
this._maxVertexTextureUnits = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
this._maxUniformBufferBindings = gl.getParameter(gl.MAX_UNIFORM_BUFFER_BINDINGS);
this._maxUniformBlockSize = gl.getParameter(gl.MAX_UNIFORM_BLOCK_SIZE);
this._depthBits = gl.getParameter(gl.DEPTH_BITS);
this._stencilBits = gl.getParameter(gl.STENCIL_BITS);
// let maxVertexUniformBlocks = gl.getParameter(gl.MAX_VERTEX_UNIFORM_BLOCKS);
// let maxFragmentUniformBlocks = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_BLOCKS);
// let uboOffsetAlignment = gl.getParameter(gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT);
this._devicePixelRatio = info.devicePixelRatio || 1.0;
this._width = this._canvas.width;
@@ -551,7 +549,7 @@ export class WebGL2GFXDevice extends GFXDevice {
const curFBO = this.stateCache.glFramebuffer;
if (this.stateCache.glFramebuffer !== gpuFramebuffer.glFramebuffer) {
gl.bindFramebuffer(WebGL2RenderingContext.FRAMEBUFFER, gpuFramebuffer.glFramebuffer);
gl.bindFramebuffer(gl.FRAMEBUFFER, gpuFramebuffer.glFramebuffer);
this.stateCache.glFramebuffer = gpuFramebuffer.glFramebuffer;
}
@@ -567,11 +565,11 @@ export class WebGL2GFXDevice extends GFXDevice {
const data = view.subarray(buffOffset, buffOffset + memSize);
gl.readPixels(region.texOffset.x, region.texOffset.y, w, h,
WebGL2RenderingContext.RGBA, WebGL2RenderingContext.UNSIGNED_BYTE, data);
gl.RGBA, gl.UNSIGNED_BYTE, data);
}
if (this.stateCache.glFramebuffer !== curFBO) {
gl.bindFramebuffer(WebGL2RenderingContext.FRAMEBUFFER, curFBO);
gl.bindFramebuffer(gl.FRAMEBUFFER, curFBO);
this.stateCache.glFramebuffer = curFBO;
}
}
+3 -3
View File
@@ -52,9 +52,9 @@ export class WebGL2GFXInputAssembler extends GFXInputAssembler {
gpuIndexBuffer = (info.indexBuffer as WebGL2GFXBuffer).gpuBuffer;
if (gpuIndexBuffer) {
switch (gpuIndexBuffer.stride) {
case 1: glIndexType = WebGLRenderingContext.UNSIGNED_BYTE; break;
case 2: glIndexType = WebGLRenderingContext.UNSIGNED_SHORT; break;
case 4: glIndexType = WebGLRenderingContext.UNSIGNED_INT; break;
case 1: glIndexType = 0x1401; break; // WebGLRenderingContext.UNSIGNED_BYTE
case 2: glIndexType = 0x1403; break; // WebGLRenderingContext.UNSIGNED_SHORT
case 4: glIndexType = 0x1405; break; // WebGLRenderingContext.UNSIGNED_INT
default: {
console.error('Illegal index buffer stride.');
}
+14 -14
View File
@@ -7,20 +7,20 @@ import { WebGL2GFXRenderPass } from './webgl2-render-pass';
import { WebGL2GFXShader } from './webgl2-shader';
const WebGLPrimitives: GLenum[] = [
WebGLRenderingContext.POINTS,
WebGLRenderingContext.LINES,
WebGLRenderingContext.LINE_STRIP,
WebGLRenderingContext.LINE_LOOP,
WebGLRenderingContext.NONE,
WebGLRenderingContext.NONE,
WebGLRenderingContext.NONE,
WebGLRenderingContext.TRIANGLES,
WebGLRenderingContext.TRIANGLE_STRIP,
WebGLRenderingContext.TRIANGLE_FAN,
WebGLRenderingContext.NONE,
WebGLRenderingContext.NONE,
WebGLRenderingContext.NONE,
WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.POINTS,
0x0001, // WebGLRenderingContext.LINES,
0x0003, // WebGLRenderingContext.LINE_STRIP,
0x0002, // WebGLRenderingContext.LINE_LOOP,
0x0000, // WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.NONE,
0x0004, // WebGLRenderingContext.TRIANGLES,
0x0005, // WebGLRenderingContext.TRIANGLE_STRIP,
0x0006, // WebGLRenderingContext.TRIANGLE_FAN,
0x0000, // WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.NONE,
0x0000, // WebGLRenderingContext.NONE,
];
export class WebGL2GFXPipelineState extends GFXPipelineState {
+1 -1
View File
@@ -160,7 +160,7 @@ export class SkinningModel extends Model {
if (!super.updateUBOs() || !this._skeleton) { return false; }
const len = this._joints.length;
if (this._skeleton.bindTRS) { // TODO: pre-apply this into animation clip
if (this._skeleton.bindTRS.length) { // TODO: pre-apply this into animation clip
for (let i = 0; i < len; ++i) {
const cur = this._joints[i]; cur.update();
const bindpose = this._skeleton.bindTRS[i];