Commit 31044481 authored by 邱旭's avatar 邱旭

增加shader编译错误打印shader代码

parent b068d4b0
This diff is collapsed.
This diff is collapsed.
...@@ -7488,7 +7488,8 @@ ...@@ -7488,7 +7488,8 @@
gl.shaderSource(shader, src); gl.shaderSource(shader, src);
gl.compileShader(shader); gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
console.log(gl.getShaderInfoLog(shader)); console.error(src);
console.error(gl.getShaderInfoLog(shader));
return null; return null;
} }
return shader; return shader;
...@@ -13908,7 +13909,7 @@ ...@@ -13908,7 +13909,7 @@
*/ */
_this.renderObj = null; _this.renderObj = null;
/** /**
* 相对于stage的可见区域,考虑不对外开放,但是有些地方又有用,比如某点是否在舞台可见区域内viewRect.isPointIn(gp) * 舞台在设备里截取后的可见区域,有些时候知道可见区域是非常重要的,因为这样你就可以根据舞台的可见区域做自适应了。
* @property viewRect * @property viewRect
* @public * @public
* @since 1.0.0 * @since 1.0.0
...@@ -14015,6 +14016,7 @@ ...@@ -14015,6 +14016,7 @@
_this.canvas = canvas; _this.canvas = canvas;
var s = _this; var s = _this;
_this._instanceType = "Stage"; _this._instanceType = "Stage";
Stage._stageList["canvas"] = s;
s.stage = _this; s.stage = _this;
s.name = "stageInstance_" + s.instanceId; s.name = "stageInstance_" + s.instanceId;
s.desWidth = desWidth; s.desWidth = desWidth;
...@@ -14088,6 +14090,17 @@ ...@@ -14088,6 +14090,17 @@
// }, 200) // }, 200)
// } // }
} }
/**
* 直接获取stage的引用,避免总是从Event.ADD_TO_STAGE 事件中去获取stage引用
* @property getStage
* @param {string} stageName
* @return {any}
* @since 2.0.0
*/
Stage.getStage = function (stageName) {
if (stageName === void 0) { stageName = "cusEngine"; }
return Stage._stageList[stageName];
};
Object.defineProperty(Stage.prototype, "bgColor", { Object.defineProperty(Stage.prototype, "bgColor", {
/** /**
* 舞台的背景色,暂时无效,渲染器默认透明背景,且webgl模式下clearColor不会跟着修改,TODO 以后修改 * 舞台的背景色,暂时无效,渲染器默认透明背景,且webgl模式下clearColor不会跟着修改,TODO 以后修改
...@@ -14578,6 +14591,13 @@ ...@@ -14578,6 +14591,13 @@
s._ml = null; s._ml = null;
_super.prototype.destroy.call(this); _super.prototype.destroy.call(this);
}; };
/**
* @property _stageList
* @static
* @type {Object}
* @private
*/
Stage._stageList = {};
return Stage; return Stage;
}(Container)); }(Container));
...@@ -32531,9 +32551,9 @@ ...@@ -32531,9 +32551,9 @@
if (frontVert) if (frontVert)
frontVert += "\n"; frontVert += "\n";
var frontFrag = [ var frontFrag = [
parameters.useNormalMap ? '#extension GL_OES_standard_derivatives : enable' : '',
'precision ' + parameters.precision + ' float;', 'precision ' + parameters.precision + ' float;',
'precision ' + parameters.precision + ' int;', 'precision ' + parameters.precision + ' int;',
parameters.useNormalMap ? '#extension GL_OES_standard_derivatives : enable' : '',
parameters.lightAffect ? '#define USE_LIGHT' : '', parameters.lightAffect ? '#define USE_LIGHT' : '',
parameters.useMap ? '#define USE_MAP' : '', parameters.useMap ? '#define USE_MAP' : '',
parameters.useNormalMap ? '#define USE_NORMAL_MAP' : '', parameters.useNormalMap ? '#define USE_NORMAL_MAP' : '',
...@@ -32953,14 +32973,14 @@ ...@@ -32953,14 +32973,14 @@
" #ifdef USE_MAP", " #ifdef USE_MAP",
" vec4 mapColor = texture2D( uMap, vTextureCoord );", " vec4 mapColor = texture2D( uMap, vTextureCoord );",
" color *= mapColor;", " color *= mapColor;",
" vec2 s = step(vec2(uFrameUvs.x,uFrameUvs.y),vTextureCoord) - step(vec2(uFrameUvs.z,uFrameUvs.w),vTextureCoord);", " vec2 s = step(vec2(uFrameUvs.x, uFrameUvs.y),vTextureCoord) - step(vec2(uFrameUvs.z, uFrameUvs.w), vTextureCoord);",
// " vec2 s = step(vec2(0.6669921875,0.4111328125),vTextureCoord) - step(vec2(0.951171875,0.65625),vTextureCoord);", // " vec2 s = step(vec2(0.6669921875,0.4111328125),vTextureCoord) - step(vec2(0.951171875,0.65625),vTextureCoord);",
" color *= abs(s.x * s.y);", " color *= abs(s.x * s.y);",
" #endif", " #endif",
" vec3 normal = vNormal;", " vec3 normal = vNormal;",
" #ifdef USE_NORMAL_MAP", " #ifdef USE_NORMAL_MAP",
" normal = getNormalFromMap();", " normal = getNormalFromMap();",
" #endif", " #endif",
//计算顶点颜色 //计算顶点颜色
" #ifdef USE_VERTEXCOLOR", " #ifdef USE_VERTEXCOLOR",
" color *= vec4(vColor,1.0);", " color *= vec4(vColor,1.0);",
...@@ -33118,20 +33138,21 @@ ...@@ -33118,20 +33138,21 @@
if (!obj.geometry || !obj.material) if (!obj.geometry || !obj.material)
return; return;
var mat = obj.material; var mat = obj.material;
obj.geometry; var meshes = this.meshes;
//提取渲染对象及材质,分组渲染,怎么考虑同一个geometry只需要处理一次attr, //提取渲染对象及材质,分组渲染,怎么考虑同一个geometry只需要处理一次attr,
//分组按 //分组按
// if (!this.meshes.length) { // if (!this.meshes.length) {
// this.meshes.push(obj); // this.meshes.push(obj);
// } else { // } else {
for (var i = 0; i < this.meshes.length; i++) { var len = meshes.length;
if (this.meshes[i].material == mat) { //没啥软用 for (var i = 0; i < len; i++) {
this.meshes.splice(i, 0, obj); if (meshes[i].material == mat) { //没啥软用
meshes.splice(i, 0, obj);
return; return;
} }
} }
// } // }
this.meshes.push(obj); meshes.push(obj);
}; };
D3Renderer.prototype.flush = function () { D3Renderer.prototype.flush = function () {
//生成一张阴影的深度贴图 //生成一张阴影的深度贴图
...@@ -33169,6 +33190,13 @@ ...@@ -33169,6 +33190,13 @@
//模型矩阵也默认加上 //模型矩阵也默认加上
if (uniforms["uModelMatrix"]) if (uniforms["uModelMatrix"])
uniforms["uModelMatrix"] = mesh._worldMatrix.toArray(); uniforms["uModelMatrix"] = mesh._worldMatrix.toArray();
if (uniforms.uNormalMatrix) {
var modelViewMatrix_1 = tempMatrix4.multiplyMatrices(this.camera.worldMatrixInverse, mesh._worldMatrix);
var normalMatrix_1 = modelViewMatrix_1.invert().transpose();
// var normalMatrix = mesh._worldMatrix.invert().transpose();
uniforms["uNormalMatrix"] = normalMatrix_1.toArray();
// this.setShaderUniform(curShader, "uNormalMatrix", normalMatrix.toArray());
}
//处理所有自定义属性 //处理所有自定义属性
for (var u in cusUniforms) { for (var u in cusUniforms) {
var uniform = cusUniforms[u]; var uniform = cusUniforms[u];
...@@ -39567,6 +39595,10 @@ ...@@ -39567,6 +39595,10 @@
exports.FloatDisplay = FloatDisplay; exports.FloatDisplay = FloatDisplay;
exports.FpsPanel = FpsPanel; exports.FpsPanel = FpsPanel;
exports.FrameAni = FrameAni; exports.FrameAni = FrameAni;
exports.GLBuffer = GLBuffer;
exports.GLFramebuffer = GLFramebuffer;
exports.GLShader = GLShader;
exports.GLTexture = GLTexture;
exports.Geometry = Geometry; exports.Geometry = Geometry;
exports.GlobalLoader = GlobalLoader; exports.GlobalLoader = GlobalLoader;
exports.Graphics = Graphics; exports.Graphics = Graphics;
...@@ -39627,20 +39659,24 @@ ...@@ -39627,20 +39659,24 @@
exports.VERSION = VERSION; exports.VERSION = VERSION;
exports.Vector2 = Vector2; exports.Vector2 = Vector2;
exports.Vector3 = Vector3; exports.Vector3 = Vector3;
exports.VertexArrayObject = VertexArrayObject;
exports.WebglRenderer = WebglRenderer; exports.WebglRenderer = WebglRenderer;
exports.abs = abs; exports.abs = abs;
exports.calculatePlaneIndices = calculatePlaneIndices; exports.calculatePlaneIndices = calculatePlaneIndices;
exports.cancelAnimationFrame = cancelAnimationFrame; exports.cancelAnimationFrame = cancelAnimationFrame;
exports.checkMaxIfStatementsInShader = checkMaxIfStatementsInShader;
exports.clamp = clamp; exports.clamp = clamp;
exports.clearTextureCache = clearTextureCache; exports.clearTextureCache = clearTextureCache;
exports.cos = cos; exports.cos = cos;
exports.countTrailingZeros = countTrailingZeros; exports.countTrailingZeros = countTrailingZeros;
exports.createCanvas = createCanvas; exports.createCanvas = createCanvas;
exports.createContext = createContext;
exports.createImage = createImage; exports.createImage = createImage;
exports.createTextureSheet = createTextureSheet; exports.createTextureSheet = createTextureSheet;
exports.createTexturesByAtlas = createTexturesByAtlas; exports.createTexturesByAtlas = createTexturesByAtlas;
exports.decodeText = decodeText; exports.decodeText = decodeText;
exports.defaultFragmentShader3d = defaultFragmentShader3d; exports.defaultFragmentShader3d = defaultFragmentShader3d;
exports.defaultValue = defaultValue;
exports.defaultVertexShader3d = defaultVertexShader3d; exports.defaultVertexShader3d = defaultVertexShader3d;
exports.deinterleave2 = deinterleave2; exports.deinterleave2 = deinterleave2;
exports.deinterleave3 = deinterleave3; exports.deinterleave3 = deinterleave3;
This diff is collapsed.
...@@ -176,22 +176,3 @@ function checkIntersection( ...@@ -176,22 +176,3 @@ function checkIntersection(
object: object object: object
}; };
} }
//交付分
var a = 5
//时间分每天
var b = 1
//极限时间
var j = 15
//项目基础时间
var i = 4
function aaa(t) {
t -= i
return a + t * b + (t * t) / j * a / i / i;
}
function bbb(t) {
//完整项目按4天
t -= i
return a + t * b + (t * t) / j * a / i / i;
}
\ No newline at end of file
This diff is collapsed.
import { Dict } from "../../2d/utils"; import { Dict, hex2rgb } from "../../2d/utils";
import { HashObject } from "../../2d/HashObject"; import { HashObject } from "../../2d/HashObject";
import { WebglRenderer } from "../../2d/renderers/WebglRenderer"; import { WebglRenderer } from "../../2d/renderers/WebglRenderer";
import { GLShader } from "../../glCore"; import { GLShader } from "../../glCore";
...@@ -44,6 +44,30 @@ export class ShaderMaterial extends HashObject { ...@@ -44,6 +44,30 @@ export class ShaderMaterial extends HashObject {
alpha: 1; alpha: 1;
/**
* 十六进制 hex2rgb ,转成0到1的数组
*/
private _color: number = 0xffffff;
private _colorArr: Float32Array = new Float32Array([1.0, 1.0, 1.0]);
get color() {
return this._color;
}
set color(value: number) {
if (this._color === value) return;
this._color = value;
var arr = hex2rgb(value)
this._colorArr[0] = arr[0];
this._colorArr[1] = arr[1];
this._colorArr[2] = arr[2];
}
//获取
get colorArr() {
return this._colorArr;
}
/** /**
* key就是渲染器唯一id * key就是渲染器唯一id
*/ */
......
...@@ -33,8 +33,11 @@ export * from "./tween"; ...@@ -33,8 +33,11 @@ export * from "./tween";
//3D //3D
export * from "./3d"; export * from "./3d";
// glCore
export * from "./glCore";
//spine //spine
export * from "./spine"; export * from "./spine";
//fps面板,后续可以加入每次drawCall,总绘制对象等等 //fps面板,后续可以加入每次drawCall,总绘制对象等等
export * from "./2d/FpsPanel"; export * from "./2d/FpsPanel";
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment