diff --git a/cocos/3d/assets/effect-asset.ts b/cocos/3d/assets/effect-asset.ts index 1accdbacab..6a9d52a14e 100644 --- a/cocos/3d/assets/effect-asset.ts +++ b/cocos/3d/assets/effect-asset.ts @@ -8,7 +8,6 @@ import { programLib } from '../../renderer/core/program-lib'; export interface IPropertyInfo { type: number; // auto-extracted if not specified value?: number[] | string; - displayName?: string; sampler?: number[]; } export interface IPassStates { diff --git a/cocos/3d/assets/material.ts b/cocos/3d/assets/material.ts index 2e0df70b3e..3d61ee00e8 100644 --- a/cocos/3d/assets/material.ts +++ b/cocos/3d/assets/material.ts @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ import { Asset } from '../../assets/asset'; +import { TextureBase } from '../../assets/texture-base'; import { ccclass, property } from '../../core/data/class-decorator'; import { murmurhash2_32_gc } from '../../core/utils/murmurhash2_gc'; import { GFXBindingType } from '../../gfx/define'; @@ -247,10 +248,10 @@ export class Material extends Asset { const binding = Pass.getBindingFromHandle(handle); if (val instanceof GFXTextureView) { pass.bindTextureView(binding, val); - } else { - const textureView = val.getGFXTextureView(); + } else if (val instanceof TextureBase) { + const textureView: GFXTextureView | null = val.getGFXTextureView(); if (!textureView || !textureView.texture.width || !textureView.texture.height) { - console.warn('texture asset incomplete!'); return false; + console.warn(`material '${this._uuid}' received incomplete texture asset '${val._uuid}'`); return false; } pass.bindTextureView(binding, textureView); pass.bindSampler(binding, samplerLib.getSampler(cc.game._gfxDevice, val.getGFXSamplerInfo())); diff --git a/cocos/3d/builtin/effects.js b/cocos/3d/builtin/effects.js index 1b0e642136..99250560d0 100644 --- a/cocos/3d/builtin/effects.js +++ b/cocos/3d/builtin/effects.js @@ -3,7 +3,7 @@ export default [ { "name": "builtin-particle", "techniques": [ - {"name":"add", "passes":[{"rasterizerState":{"cullMode":0}, "depthStencilState":{"depthTest":true, "depthWrite":false}, "blendState":{"targets":[{"blend":true, "blendSrc":2, "blendDst":1, "blendSrcAlpha":2, "blendDstAlpha":1}]}, "program":"builtin-particle|particle-vs-legacy:lpvs_main|tinted-fs:add", "properties":{"mainTexture":{"type":29, "value":"grey"}, "mainTiling_Offset":{"type":16, "value":[1, 1, 0, 0]}, "frameTile_velLenScale":{"type":16, "value":[1, 1, 0, 0]}, "tintColor":{"type":17, "value":[0.5, 0.5, 0.5, 0.5]}}}]} + {"name":"add", "passes":[{"rasterizerState":{"cullMode":0}, "blendState":{"targets":[{"blend":true, "blendSrc":2, "blendDst":1, "blendSrcAlpha":2, "blendDstAlpha":1}]}, "program":"builtin-particle|particle-vs-legacy:lpvs_main|tinted-fs:add", "depthStencilState":{"depthTest":true, "depthWrite":false}, "properties":{"mainTexture":{"type":28, "value":"grey"}, "mainTiling_Offset":{"type":16, "value":[1, 1, 0, 0]}, "frameTile_velLenScale":{"type":16, "value":[1, 1, 0, 0]}, "tintColor":{"type":16, "value":[0.5, 0.5, 0.5, 0.5], "inspector":{"picker":"color"}}}}]} ], "shaders": [ { @@ -36,7 +36,7 @@ export default [ ]} ], "samplers": [ - {"name":"mainTexture", "type":29, "count":1, "defines":[], "binding":2} + {"name":"mainTexture", "type":28, "count":1, "defines":[], "binding":2} ], "dependencies": {} } @@ -45,7 +45,7 @@ export default [ { "name": "builtin-skybox", "techniques": [ - {"passes":[{"rasterizerState":{"cullMode":0}, "depthStencilState":{"depthTest":true, "depthWrite":false}, "program":"builtin-skybox|sky-vs:vert|sky-fs:frag", "properties":{"cubeMap":{"type":32, "value":"default-cube"}}, "priority":10}]} + {"passes":[{"rasterizerState":{"cullMode":0}, "program":"builtin-skybox|sky-vs:vert|sky-fs:frag", "priority":245, "depthStencilState":{"depthTest":true, "depthWrite":false}, "properties":{"cubeMap":{"type":31, "value":"default-cube"}}}]} ], "shaders": [ { @@ -66,7 +66,7 @@ export default [ ], "blocks": [], "samplers": [ - {"name":"cubeMap", "type":32, "count":1, "defines":[], "binding":0} + {"name":"cubeMap", "type":31, "count":1, "defines":[], "binding":0} ], "dependencies": {} } @@ -75,7 +75,7 @@ export default [ { "name": "builtin-sprite", "techniques": [ - {"passes":[{"depthStencilState":{"depthTest":true, "depthWrite":false}, "blendState":{"targets":[{"blend":true, "blendSrc":2, "blendDst":4, "blendDstAlpha":4}]}, "rasterizerState":{"cullMode":0}, "program":"builtin-sprite|sprite-vs:vert|sprite-fs:frag", "properties":{"mainTexture":{"type":29, "value":"white"}}, "priority":244}]} + {"passes":[{"blendState":{"targets":[{"blend":true, "blendSrc":2, "blendDst":4, "blendDstAlpha":4}]}, "rasterizerState":{"cullMode":0}, "program":"builtin-sprite|sprite-vs:vert|sprite-fs:frag", "priority":244, "depthStencilState":{"depthTest":true, "depthWrite":false}, "properties":{"mainTexture":{"type":28, "value":"white"}}}]} ], "shaders": [ { @@ -96,7 +96,7 @@ export default [ ], "blocks": [], "samplers": [ - {"name":"mainTexture", "type":29, "count":1, "defines":["USE_TEXTURE"], "binding":0} + {"name":"mainTexture", "type":28, "count":1, "defines":["USE_TEXTURE"], "binding":0} ], "dependencies": {} } @@ -105,7 +105,7 @@ export default [ { "name": "builtin-standard", "techniques": [ - {"name":"opaque", "passes":[{"program":"builtin-standard|standard-vs:vert|standard-fs:frag", "properties":{"tilingOffset":{"type":16, "value":[1, 1, 0, 0]}, "albedo":{"type":17, "value":[1, 1, 1, 1]}, "albedoScale":{"type":16, "value":[1, 1, 1, 0]}, "pbrParams":{"type":16, "value":[0.8, 0.6, 0, 1]}, "pbrScale":{"type":16, "value":[1, 1, 1, 1]}, "emissive":{"type":17, "value":[1, 1, 1, 1]}, "emissiveScale":{"type":16, "value":[1, 1, 1, 1]}, "albedoMap":{"type":29, "value":"grey"}, "normalMap":{"type":29, "value":"normal"}, "pbrMap":{"type":29, "value":"grey"}, "emissiveMap":{"type":29, "value":"grey"}, "envMap":{"type":32, "value":"default-cube"}}}, {"customizations":["bounds-merge-shadow"], "depthStencilState":{"depthTest":true, "depthWrite":false, "stencilTestFront":true, "stencilFuncFront":4, "stencilPassOpFront":3}, "blendState":{"targets":[{"blend":true, "blendSrc":2, "blendDst":4, "blendDstAlpha":4}]}, "program":"builtin-standard|planar-shadow-vs:vert|planar-shadow-fs:frag", "switch":"USE_PLANAR_SHADOW"}]} + {"name":"opaque", "passes":[{"program":"builtin-standard|standard-vs:vert|standard-fs:frag", "properties":{"tilingOffset":{"type":16, "value":[1, 1, 0, 0]}, "albedo":{"type":16, "value":[1, 1, 1, 1], "inspector":{"picker":"color"}}, "albedoScale":{"type":16, "value":[1, 1, 1, 0]}, "pbrParams":{"type":16, "value":[0.8, 0.6, 0, 1]}, "pbrScale":{"type":16, "value":[1, 1, 1, 1]}, "emissive":{"type":16, "value":[1, 1, 1, 1], "inspector":{"picker":"color"}}, "emissiveScale":{"type":16, "value":[1, 1, 1, 1]}, "albedoMap":{"type":28, "value":"grey"}, "normalMap":{"type":28, "value":"normal"}, "pbrMap":{"type":28, "value":"grey"}, "emissiveMap":{"type":28, "value":"grey"}, "envMap":{"type":31, "value":"default-cube"}}}, {"customizations":["bounds-merge-shadow"], "blendState":{"targets":[{"blend":true, "blendSrc":2, "blendDst":4, "blendDstAlpha":4}]}, "program":"builtin-standard|planar-shadow-vs:vert|planar-shadow-fs:frag", "depthStencilState":{"depthTest":true, "depthWrite":false, "stencilTestFront":true, "stencilFuncFront":5, "stencilPassOpFront":2, "stencilWriteMaskBack":128, "stencilWriteMaskFront":128, "stencilReadMaskBack":128, "stencilReadMaskFront":128, "stencilRefBack":128, "stencilRefFront":128}, "switch":"USE_PLANAR_SHADOW"}]} ], "shaders": [ { @@ -146,11 +146,11 @@ export default [ ]} ], "samplers": [ - {"name":"albedoMap", "type":29, "count":1, "defines":["USE_ALBEDO_MAP"], "binding":1}, - {"name":"normalMap", "type":29, "count":1, "defines":["USE_NORMAL_MAP"], "binding":2}, - {"name":"pbrMap", "type":29, "count":1, "defines":["USE_PBR_MAP"], "binding":3}, - {"name":"emissiveMap", "type":29, "count":1, "defines":["USE_EMISSIVE_MAP"], "binding":4}, - {"name":"envMap", "type":32, "count":1, "defines":["USE_IBL"], "binding":5} + {"name":"albedoMap", "type":28, "count":1, "defines":["USE_ALBEDO_MAP"], "binding":1}, + {"name":"normalMap", "type":28, "count":1, "defines":["USE_NORMAL_MAP"], "binding":2}, + {"name":"pbrMap", "type":28, "count":1, "defines":["USE_PBR_MAP"], "binding":3}, + {"name":"emissiveMap", "type":28, "count":1, "defines":["USE_EMISSIVE_MAP"], "binding":4}, + {"name":"envMap", "type":31, "count":1, "defines":["USE_IBL"], "binding":5} ], "dependencies": {} }, @@ -180,7 +180,7 @@ export default [ { "name": "builtin-unlit", "techniques": [ - {"name":"opaque", "passes":[{"program":"builtin-unlit|unlit-vs:vert|unlit-fs:frag", "properties":{"color":{"type":17, "value":[1, 1, 1, 1]}, "tilingOffset":{"type":16, "value":[1, 1, 0, 0]}, "mainTexture":{"type":29, "value":"grey"}}}]} + {"name":"opaque", "passes":[{"program":"builtin-unlit|unlit-vs:vert|unlit-fs:frag", "properties":{"color":{"type":16, "value":[1, 1, 1, 1], "inspector":{"picker":"color"}}, "tilingOffset":{"type":16, "value":[1, 1, 0, 0]}, "mainTexture":{"type":28, "value":"grey"}}}]} ], "shaders": [ { @@ -211,7 +211,7 @@ export default [ ]} ], "samplers": [ - {"name":"mainTexture", "type":29, "count":1, "defines":["USE_TEXTURE"], "binding":2} + {"name":"mainTexture", "type":28, "count":1, "defines":["USE_TEXTURE"], "binding":2} ], "dependencies": {} } @@ -220,7 +220,7 @@ export default [ { "name": "pipeline/smaa", "techniques": [ - {"name":"smaa", "passes":[{"depthStencilState":{"depthTest":false, "depthWrite":false}, "program":"pipeline/smaa|smaa-edge-vs:vert|smaa-edge-fs:frag", "properties":{"u_texSampler":{"type":29, "sampler":[2, 2, null, 2, 2]}}}, {"depthStencilState":{"depthTest":false, "depthWrite":false}, "program":"pipeline/smaa|smaa-blend-vs:vert|smaa-blend-fs:frag", "properties":{"u_edgeTexSampler":{"type":29, "sampler":[2, 2, null, 2, 2]}, "u_areaTexSampler":{"type":29, "sampler":[2, 2, null, 2, 2]}, "u_searchTexSampler":{"type":29, "sampler":[1, 1, null, 2, 2]}}}]} + {"name":"smaa", "passes":[{"program":"pipeline/smaa|smaa-edge-vs:vert|smaa-edge-fs:frag", "depthStencilState":{"depthTest":false, "depthWrite":false}, "properties":{"u_texSampler":{"type":28, "sampler":[2, 2, null, 2, 2]}}}, {"program":"pipeline/smaa|smaa-blend-vs:vert|smaa-blend-fs:frag", "depthStencilState":{"depthTest":false, "depthWrite":false}, "properties":{"u_edgeTexSampler":{"type":28, "sampler":[2, 2, null, 2, 2]}, "u_areaTexSampler":{"type":28, "sampler":[2, 2, null, 2, 2]}, "u_searchTexSampler":{"type":28, "sampler":[1, 1, null, 2, 2]}}}]} ], "shaders": [ { @@ -240,7 +240,7 @@ export default [ ], "blocks": [], "samplers": [ - {"name":"u_texSampler", "type":29, "count":1, "defines":[], "binding":0} + {"name":"u_texSampler", "type":28, "count":1, "defines":[], "binding":0} ], "dependencies": {} }, @@ -259,9 +259,9 @@ export default [ "defines": [], "blocks": [], "samplers": [ - {"name":"u_edgeTexSampler", "type":29, "count":1, "defines":[], "binding":0}, - {"name":"u_areaTexSampler", "type":29, "count":1, "defines":[], "binding":1}, - {"name":"u_searchTexSampler", "type":29, "count":1, "defines":[], "binding":2} + {"name":"u_edgeTexSampler", "type":28, "count":1, "defines":[], "binding":0}, + {"name":"u_areaTexSampler", "type":28, "count":1, "defines":[], "binding":1}, + {"name":"u_searchTexSampler", "type":28, "count":1, "defines":[], "binding":2} ], "dependencies": {} } @@ -270,7 +270,7 @@ export default [ { "name": "pipeline/tonemap", "techniques": [ - {"name":"tonemap", "passes":[{"depthStencilState":{"depthTest":false, "depthWrite":false}, "program":"pipeline/tonemap|tonemap-vs:vert|tonemap-fs:frag", "properties":{"u_texSampler":{"type":29, "sampler":[2, 2, null, 2, 2]}, "u_blendTexSampler":{"type":29, "sampler":[2, 2, null, 2, 2]}}}]} + {"name":"tonemap", "passes":[{"program":"pipeline/tonemap|tonemap-vs:vert|tonemap-fs:frag", "depthStencilState":{"depthTest":false, "depthWrite":false}, "properties":{"u_texSampler":{"type":28, "sampler":[2, 2, null, 2, 2]}, "u_blendTexSampler":{"type":28, "sampler":[2, 2, null, 2, 2]}}}]} ], "shaders": [ { @@ -291,8 +291,8 @@ export default [ ], "blocks": [], "samplers": [ - {"name":"u_texSampler", "type":29, "count":1, "defines":[], "binding":0}, - {"name":"u_blendTexSampler", "type":29, "count":1, "defines":[], "binding":1} + {"name":"u_texSampler", "type":28, "count":1, "defines":[], "binding":0}, + {"name":"u_blendTexSampler", "type":28, "count":1, "defines":[], "binding":1} ], "dependencies": {} } diff --git a/cocos/3d/framework/particle/animator/color-overtime.ts b/cocos/3d/framework/particle/animator/color-overtime.ts index 261113eef4..02cc54fe69 100644 --- a/cocos/3d/framework/particle/animator/color-overtime.ts +++ b/cocos/3d/framework/particle/animator/color-overtime.ts @@ -24,7 +24,7 @@ export default class ColorOvertimeModule { public animate (particle: Particle) { if (this.enable) { - color4.multiply(particle.color, particle.startColor01, this.color.evaluate(1.0 - particle.remainingLifetime / particle.startLifetime, pseudoRandom(particle.randomSeed + COLOR_OVERTIME_RAND_OFFSET))); + particle.startColor.mul(this.color.evaluate(1.0 - particle.remainingLifetime / particle.startLifetime, pseudoRandom(particle.randomSeed + COLOR_OVERTIME_RAND_OFFSET)), particle.color); } } } diff --git a/cocos/3d/framework/particle/particle-system-component.ts b/cocos/3d/framework/particle/particle-system-component.ts index 1e2735d97c..938970b252 100644 --- a/cocos/3d/framework/particle/particle-system-component.ts +++ b/cocos/3d/framework/particle/particle-system-component.ts @@ -364,7 +364,6 @@ export class ParticleSystemComponent extends Component { // apply startColor. particle.startColor.set(this.startColor.evaluate(this._time / this.duration, rand)); - particle.startColor.to01(particle.startColor01); particle.color.set(particle.startColor); // apply startLifetime. diff --git a/cocos/3d/framework/particle/particle.ts b/cocos/3d/framework/particle/particle.ts index a9ef803f23..a99e5b442a 100644 --- a/cocos/3d/framework/particle/particle.ts +++ b/cocos/3d/framework/particle/particle.ts @@ -14,7 +14,6 @@ export default class Particle { public startSize: vec3; public size: vec3; public startColor: Color; - public startColor01: color4; public color = cc.Color.WHITE; public randomSeed: number; // uint public remainingLifetime: number; @@ -35,7 +34,6 @@ export default class Particle { this.startSize = vec3.create(0, 0, 0); this.size = vec3.create(0, 0, 0); this.startColor = cc.Color.WHITE; - this.startColor01 = color4.create(); this.color = cc.Color.WHITE; this.randomSeed = 0; // uint this.remainingLifetime = 0.0; diff --git a/cocos/3d/geom-utils/octree.ts b/cocos/3d/geom-utils/octree.ts index acf00c2cbc..4cf7e70b3b 100644 --- a/cocos/3d/geom-utils/octree.ts +++ b/cocos/3d/geom-utils/octree.ts @@ -43,7 +43,7 @@ class OctreeBlock { if (this.entries.length >= this.capacity && this.depth < this.maxDepth) { this.blocks = Octree.createBlocks(this.minPos, this.maxPos, this.entries, this.capacity, this.depth, this.maxDepth, this._getBoundingShape); - this.entries = null; + this.entries.reset(); } } } diff --git a/cocos/3d/ui/assembler/sprite/tiled.ts b/cocos/3d/ui/assembler/sprite/tiled.ts index e344cd10e9..b3fcddef34 100644 --- a/cocos/3d/ui/assembler/sprite/tiled.ts +++ b/cocos/3d/ui/assembler/sprite/tiled.ts @@ -25,12 +25,11 @@ // const dynamicAtlasManager = require('../../../utils/dynamic-atlas/manager'); import { Mat4, Vec3 } from '../../../../core/value-types'; -import { color4, vec3 } from '../../../../core/vmath/index'; +import { vec3 } from '../../../../core/vmath/index'; import { RenderData } from '../../../../renderer/ui/renderData'; import { UI } from '../../../../renderer/ui/ui'; import { SpriteComponent } from '../../components/sprite-component'; import { UIRenderComponent } from '../../components/ui-render-component'; -import { MeshBuffer } from '../../mesh-buffer'; import { IAssembler } from '../assembler'; const matrix = new Mat4(); @@ -39,7 +38,6 @@ const vec3_temps: Vec3[] = []; for (let i = 0; i < 4; i++) { vec3_temps.push(new Vec3()); } -const color_temp = color4.create(); const _tempVertexOffset = 6; const _tempUvOffset = 3; @@ -110,8 +108,7 @@ export const tilled: IAssembler = { const buffer = renderer.currBufferBatch!; const node = sprite.node; - // const color = sprite.color; - sprite.color.to01(color_temp); + const color = sprite.color; const renderData = sprite.renderData; const datas = renderData!.datas; @@ -215,10 +212,10 @@ export const tilled: IAssembler = { vbuf![vertexOffsetV + offset3] = vbuf![vertexOffsetV + offset2]; } - vbuf![vertexOffset + colorOffset] = color_temp.r; - vbuf![vertexOffset + colorOffset + offset1] = color_temp.g; - vbuf![vertexOffset + colorOffset + offset2] = color_temp.b; - vbuf![vertexOffset + colorOffset + offset3] = color_temp.a; + vbuf![vertexOffset + colorOffset] = color.x; + vbuf![vertexOffset + colorOffset + offset1] = color.y; + vbuf![vertexOffset + colorOffset + offset2] = color.z; + vbuf![vertexOffset + colorOffset + offset3] = color.w; // TODO: addColor // color // uintbuf[vertexOffset + colorOffset] = color; diff --git a/cocos/3d/ui/assembler/utils.ts b/cocos/3d/ui/assembler/utils.ts index be536cfd45..a51a7f0efc 100644 --- a/cocos/3d/ui/assembler/utils.ts +++ b/cocos/3d/ui/assembler/utils.ts @@ -8,7 +8,6 @@ import { MeshBuffer } from '../mesh-buffer'; const vec3_temp = vec3.create(); const _worldMatrix = new Mat4(); -const _tempColor = new Color(); export function fillVertices (node: Node, buffer: MeshBuffer, renderData: RenderData, color: Color) { const data = renderData.datas; @@ -88,7 +87,6 @@ export function fillVertices3D (node: Node, renderer: UI, renderData: RenderData const datas = renderData.datas; let buffer = renderer.currBufferBatch!; let vertexOffset = buffer.byteOffset >> 2; - color.to01(_tempColor); let vertexCount = renderData.vertexCount; let indiceOffset = buffer!.indiceOffset; @@ -200,7 +198,6 @@ export function fillVerticesWithoutCalc3D (node: Node, renderer: UI, renderData: const datas = renderData.datas; let buffer = renderer.currBufferBatch!; let vertexOffset = buffer.byteOffset >> 2; - color.to01(_tempColor); // buffer let vertexCount = renderData.vertexCount; diff --git a/cocos/core/value-types/color.ts b/cocos/core/value-types/color.ts index 1bf3f6b196..bb2c54bbc0 100644 --- a/cocos/core/value-types/color.ts +++ b/cocos/core/value-types/color.ts @@ -28,6 +28,8 @@ import CCClass from '../data/class'; import { color4 } from '../vmath'; import { ValueType } from './value-type'; +const to_float = 1 / 255; + /** * !#en * Representation of RGBA colors. @@ -300,7 +302,7 @@ export default class Color extends ValueType { (this.r | 0 ) + ',' + (this.g | 0 ) + ',' + (this.b | 0 ) + ',' + - (this.a / 255).toFixed(2) + ')' + (this.a * to_float).toFixed(2) + ')' ; } else if ( opt === 'rgb' ) { return 'rgb(' + @@ -478,9 +480,9 @@ export default class Color extends ValueType { * color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1}; */ public toHSV () { - const r = this.r / 255; - const g = this.g / 255; - const b = this.b / 255; + const r = this.r * to_float; + const g = this.g * to_float; + const b = this.b * to_float; const hsv = { h: 0, s: 0, v: 0 }; const max = Math.max(r, g, b); const min = Math.min(r, g, b); @@ -502,25 +504,41 @@ export default class Color extends ValueType { return hsv; } - public set (color: Color) { - if (color._val) { - this._val = color._val; + public set (c: Color) { + if (c._val) { + this._val = c._val; } else { - this.r = color.r; - this.g = color.g; - this.b = color.b; - this.a = color.a; + this._val = ((c.a << 24) >>> 0) + (c.b << 16) + (c.g << 8) + c.r; } } - public to01 (out?: color4) { - out = out || color4.create(); - out.r = this.r / 255; - out.g = this.g / 255; - out.b = this.b / 255; - out.a = this.a / 255; - return out; + public mulSelf (c: Color) { + const r = ((this._val & 0x000000ff) * c.r) >> 8; + const g = ((this._val & 0x0000ff00) * c.g) >> 8; + const b = ((this._val & 0x00ff0000) * c.b) >> 8; + const a = ((this._val & 0xff000000) >> 8) * c.a; + this._val = (a & 0xff000000) | (b & 0x00ff0000) | (g & 0x0000ff00) | (r & 0x000000ff); + return this; } + + public mul (c: Color, out?: Color) { + out = out || new Color(); + const r = ((out._val & 0x000000ff) * c.r) >> 8; + const g = ((out._val & 0x0000ff00) * c.g) >> 8; + const b = ((out._val & 0x00ff0000) * c.b) >> 8; + const a = ((out._val & 0xff000000) >> 8) * c.a; + out._val = (a & 0xff000000) | (b & 0x00ff0000) | (g & 0x0000ff00) | (r & 0x000000ff); + return out; + } + + get x () { return this.r * to_float; } + set x (val) { this.r = val * 255; } + get y () { return this.g * to_float; } + set y (val) { this.g = val * 255; } + get z () { return this.b * to_float; } + set z (val) { this.b = val * 255; } + get w () { return this.a * to_float; } + set w (val) { this.a = val * 255; } } CCClass.fastDefine('cc.Color', Color, {r: 0, g: 0, b: 0, a: 255}); diff --git a/cocos/gfx/define.ts b/cocos/gfx/define.ts index 65367162bd..11b2766967 100644 --- a/cocos/gfx/define.ts +++ b/cocos/gfx/define.ts @@ -105,7 +105,6 @@ export enum GFXType { FLOAT2, FLOAT3, FLOAT4, - COLOR4, MAT2, MAT2X3, MAT2X4, diff --git a/cocos/gfx/webgl/webgl-commands.ts b/cocos/gfx/webgl/webgl-commands.ts index 24e82de6aa..d1b620949b 100644 --- a/cocos/gfx/webgl/webgl-commands.ts +++ b/cocos/gfx/webgl/webgl-commands.ts @@ -262,7 +262,6 @@ function GFXTypeToWebGLType (type: GFXType): GLenum { case GFXType.FLOAT2: return WebGLRenderingContext.FLOAT_VEC2; case GFXType.FLOAT3: return WebGLRenderingContext.FLOAT_VEC3; case GFXType.FLOAT4: return WebGLRenderingContext.FLOAT_VEC4; - case GFXType.COLOR4: return WebGLRenderingContext.FLOAT_VEC4; case GFXType.MAT2: return WebGLRenderingContext.FLOAT_MAT2; case GFXType.MAT3: return WebGLRenderingContext.FLOAT_MAT3; case GFXType.MAT4: return WebGLRenderingContext.FLOAT_MAT4; diff --git a/cocos/gfx/webgl2/webgl2-commands.ts b/cocos/gfx/webgl2/webgl2-commands.ts index 6b47793b90..f1737da981 100644 --- a/cocos/gfx/webgl2/webgl2-commands.ts +++ b/cocos/gfx/webgl2/webgl2-commands.ts @@ -357,7 +357,6 @@ function GFXTypeToWebGLType (type: GFXType): GLenum { case GFXType.FLOAT2: return WebGL2RenderingContext.FLOAT_VEC2; case GFXType.FLOAT3: return WebGL2RenderingContext.FLOAT_VEC3; case GFXType.FLOAT4: return WebGL2RenderingContext.FLOAT_VEC4; - case GFXType.COLOR4: return WebGL2RenderingContext.FLOAT_VEC4; case GFXType.MAT2: return WebGL2RenderingContext.FLOAT_MAT2; case GFXType.MAT2X3: return WebGL2RenderingContext.FLOAT_MAT2x3; case GFXType.MAT2X4: return WebGL2RenderingContext.FLOAT_MAT2x4; diff --git a/cocos/pipeline/render-queue.ts b/cocos/pipeline/render-queue.ts index aaa55813fd..95d1c5b165 100644 --- a/cocos/pipeline/render-queue.ts +++ b/cocos/pipeline/render-queue.ts @@ -33,7 +33,7 @@ export class RenderQueue { return a.depth - b.depth; } } else { - return b.hash - a.hash; // the bigger the priority, the earlier + return a.hash - b.hash; } }; @@ -46,7 +46,7 @@ export class RenderQueue { return b.depth - a.depth; } } else { - return b.hash - a.hash; // the bigger the priority, the earlier + return a.hash - b.hash; } }; @@ -79,13 +79,13 @@ export class RenderQueue { const isTransparent = pso.blendState.targets[0].blend; if (!isTransparent) { - const hash = (0 << 30) | (pass.priority << 16) | (subModel.priority << 8) | (len - p); + const hash = (0 << 30) | (pass.priority << 16) | (subModel.priority << 8) | p; this.opaques.push({ hash, depth, shaderId: pso.shader.id, subModel, cmdBuff: subModel.commandBuffers[p]}); } else { - const hash = (1 << 30) | (pass.priority << 16) | (subModel.priority << 8) | (len - p); + const hash = (1 << 30) | (pass.priority << 16) | (subModel.priority << 8) | p; this.transparents.push({ hash, depth, shaderId: pso.shader.id, diff --git a/cocos/renderer/core/pass.ts b/cocos/renderer/core/pass.ts index eb92168dd0..0383cdb6a3 100644 --- a/cocos/renderer/core/pass.ts +++ b/cocos/renderer/core/pass.ts @@ -3,7 +3,7 @@ import { IPassInfo, IPassStates, IShaderInfo } from '../../3d/assets/effect-asset'; import { builtinResMgr } from '../../3d/builtin'; import { TextureBase } from '../../assets/texture-base'; -import { color4, mat2, mat3, mat4, vec2, vec3, vec4 } from '../../core/vmath'; +import { mat2, mat3, mat4, vec2, vec3, vec4 } from '../../core/vmath'; import { GFXBindingLayout, IGFXBinding } from '../../gfx/binding-layout'; import { GFXBuffer } from '../../gfx/buffer'; import { GFXBindingType, GFXBufferUsageBit, GFXDynamicState, @@ -39,7 +39,6 @@ const _type2fn = { [GFXType.FLOAT2]: (a: Float32Array, v: any, idx: number = 0) => vec2.array(a, v, idx * 2), [GFXType.FLOAT3]: (a: Float32Array, v: any, idx: number = 0) => vec3.array(a, v, idx * 3), [GFXType.FLOAT4]: (a: Float32Array, v: any, idx: number = 0) => vec4.array(a, v, idx * 4), - [GFXType.COLOR4]: (a: Float32Array, v: any, idx: number = 0) => color4.array(a, v, idx * 4), [GFXType.MAT2]: (a: Float32Array, v: any, idx: number = 0) => mat2.array(a, v, idx * 4), [GFXType.MAT3]: (a: Float32Array, v: any, idx: number = 0) => mat3.array(a, v, idx * 9), [GFXType.MAT4]: (a: Float32Array, v: any, idx: number = 0) => mat4.array(a, v, idx * 16), @@ -54,7 +53,6 @@ const _type2default = { [GFXType.FLOAT2]: [0, 0], [GFXType.FLOAT3]: [0, 0, 0], [GFXType.FLOAT4]: [0, 0, 0, 0], - [GFXType.COLOR4]: [0, 0, 0, 1], [GFXType.MAT2]: [1, 0, 0, 1], [GFXType.MAT3]: [1, 0, 0, 0, 1, 0, 0, 0, 1], [GFXType.MAT4]: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], diff --git a/cocos/renderer/core/sampler-lib.ts b/cocos/renderer/core/sampler-lib.ts index ce83aab033..a57778b35a 100644 --- a/cocos/renderer/core/sampler-lib.ts +++ b/cocos/renderer/core/sampler-lib.ts @@ -29,7 +29,7 @@ const defaultInfo = [ GFXAddress.WRAP, 16, GFXComparisonFunc.NEVER, - 0, 1000, 0, + 0, 0, 0, 0, 0, 0, 0, ];