From 2e27981e356218ea12a08a42fa6b8f9f42714fb3 Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Mon, 22 Apr 2019 14:51:07 +0800 Subject: [PATCH] misc fix (#4269) --- cocos/3d/assets/effect-asset.ts | 2 +- cocos/3d/builtin/effects.js | 20 +++++++++---------- .../framework/directional-light-component.ts | 7 ------- .../3d/framework/skinning-model-component.ts | 14 +++++++------ cocos/3d/geom-utils/aabb.ts | 5 +++-- cocos/renderer/scene/model.ts | 3 ++- cocos/renderer/scene/render-scene.ts | 1 + cocos/scene-graph/node.ts | 2 +- package.json | 1 - 9 files changed, 26 insertions(+), 29 deletions(-) diff --git a/cocos/3d/assets/effect-asset.ts b/cocos/3d/assets/effect-asset.ts index 2be59b4fe3..6a05136268 100644 --- a/cocos/3d/assets/effect-asset.ts +++ b/cocos/3d/assets/effect-asset.ts @@ -6,7 +6,7 @@ import { RenderPassStage } from '../../pipeline/define'; import { programLib } from '../../renderer/core/program-lib'; export interface IPropertyInfo { - type: number; // auto-extracted if not specified + type: number; // auto-extracted value?: number[] | string; sampler?: number[]; } diff --git a/cocos/3d/builtin/effects.js b/cocos/3d/builtin/effects.js index 916e92190c..6ba12043c1 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}, "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":{"type":"color"}}}}]} + {"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":{"value":"grey", "type":28}, "mainTiling_Offset":{"value":[1, 1, 0, 0], "type":16}, "frameTile_velLenScale":{"value":[1, 1, 0, 0], "type":16}, "tintColor":{"value":[0.5, 0.5, 0.5, 0.5], "inspector":{"type":"color"}, "type":16}}}]} ], "shaders": [ { @@ -45,7 +45,7 @@ export default [ { "name": "builtin-skybox", "techniques": [ - {"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"}}}]} + {"passes":[{"rasterizerState":{"cullMode":0}, "program":"builtin-skybox|sky-vs:vert|sky-fs:frag", "priority":245, "depthStencilState":{"depthTest":true, "depthWrite":false}, "properties":{"cubeMap":{"value":"default-cube", "type":31}}}]} ], "shaders": [ { @@ -75,7 +75,7 @@ export default [ { "name": "builtin-sprite", "techniques": [ - {"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"}}}]} + {"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":{"value":"white", "type":28}}}]} ], "shaders": [ { @@ -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":16, "value":[1, 1, 1, 1], "inspector":{"type":"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":{"type":"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}]}, "phase":"planarShadow", "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"}]} + {"name":"opaque", "passes":[{"program":"builtin-standard|standard-vs:vert|standard-fs:frag", "properties":{"tilingOffset":{"value":[1, 1, 0, 0], "type":16}, "albedo":{"value":[1, 1, 1, 1], "inspector":{"type":"color"}, "type":16}, "albedoScale":{"value":[1, 1, 1, 0], "type":16}, "pbrParams":{"value":[0.8, 0.6, 0, 1], "type":16}, "pbrScale":{"value":[1, 1, 1, 1], "type":16}, "emissive":{"value":[1, 1, 1, 1], "inspector":{"type":"color"}, "type":16}, "emissiveScale":{"value":[1, 1, 1, 1], "type":16}, "albedoMap":{"value":"grey", "type":28}, "normalMap":{"value":"normal", "type":28}, "pbrMap":{"value":"grey", "type":28}, "emissiveMap":{"value":"grey", "type":28}, "envMap":{"value":"default-cube", "type":31}}}, {"customizations":["bounds-merge-shadow"], "blendState":{"targets":[{"blend":true, "blendSrc":2, "blendDst":4, "blendDstAlpha":4}]}, "phase":"planarShadow", "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": [ { @@ -182,7 +182,7 @@ export default [ { "name": "builtin-unlit", "techniques": [ - {"name":"opaque", "passes":[{"program":"builtin-unlit|unlit-vs:vert|unlit-fs:frag", "properties":{"color":{"type":16, "value":[1, 1, 1, 1], "inspector":{"type":"color"}}, "tilingOffset":{"type":16, "value":[1, 1, 0, 0]}, "mainTexture":{"type":28, "value":"grey"}}}]} + {"name":"opaque", "passes":[{"program":"builtin-unlit|unlit-vs:vert|unlit-fs:frag", "properties":{"color":{"value":[1, 1, 1, 1], "inspector":{"type":"color"}, "type":16}, "tilingOffset":{"value":[1, 1, 0, 0], "type":16}, "mainTexture":{"value":"grey", "type":28}}}]} ], "shaders": [ { @@ -223,7 +223,7 @@ export default [ { "name": "pipeline/smaa", "techniques": [ - {"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]}}}]} + {"name":"smaa", "passes":[{"program":"pipeline/smaa|smaa-edge-vs:vert|smaa-edge-fs:frag", "depthStencilState":{"depthTest":false, "depthWrite":false}, "properties":{"u_texSampler":{"sampler":[2, 2, null, 2, 2], "type":28}}}, {"program":"pipeline/smaa|smaa-blend-vs:vert|smaa-blend-fs:frag", "depthStencilState":{"depthTest":false, "depthWrite":false}, "properties":{"u_edgeTexSampler":{"sampler":[2, 2, null, 2, 2], "type":28}, "u_areaTexSampler":{"sampler":[2, 2, null, 2, 2], "type":28}, "u_searchTexSampler":{"sampler":[1, 1, null, 2, 2], "type":28}}}]} ], "shaders": [ { @@ -273,19 +273,19 @@ export default [ { "name": "pipeline/tonemap", "techniques": [ - {"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]}}}]} + {"name":"tonemap", "passes":[{"program":"pipeline/tonemap|tonemap-vs:vert|tonemap-fs:frag", "depthStencilState":{"depthTest":false, "depthWrite":false}, "properties":{"u_texSampler":{"sampler":[2, 2, null, 2, 2], "type":28}, "u_blendTexSampler":{"sampler":[2, 2, null, 2, 2], "type":28}}}]} ], "shaders": [ { "name": "pipeline/tonemap|tonemap-vs:vert|tonemap-fs:frag", - "hash": 1212847014, + "hash": 1542908367, "glsl3": { "vert": `\nprecision highp float;\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\nuniform CCGlobal {\n vec4 cc_time; \n vec4 cc_screenSize; \n vec4 cc_screenScale; \n vec4 cc_nativeSize; \n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos; \n vec4 cc_exposure; \n vec4 cc_mainLitDir; \n vec4 cc_mainLitColor; \n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_uv;\nout vec4 v_offset;\nvec4 vert () {\n vec4 pos = vec4(a_position, 0, 1);\n v_uv = a_texCoord * cc_screenScale.xy;\n v_offset = v_uv.xyxy + cc_nativeSize.zwzw * vec4(1.0, 0.0, 0.0, -1.0);\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n`, - "frag": `\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time; \n vec4 cc_screenSize; \n vec4 cc_screenScale; \n vec4 cc_nativeSize; \n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos; \n vec4 cc_exposure; \n vec4 cc_mainLitDir; \n vec4 cc_mainLitColor; \n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n \n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n \n}\nvec3 ACESToneMap(vec3 color) {\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nin vec2 v_uv;\nin vec4 v_offset;\nuniform sampler2D u_texSampler;\nuniform sampler2D u_blendTexSampler;\nvec3 ToLDR(vec3 color) {\n#if CC_USE_HDR\n color *= cc_exposure.x * 1024.0;\n color = ACESToneMap(color);\n color = LinearToSRGB(color);\n#else\n color = SRGBToLinear(color);\n color = ACESToneMap(color);\n color = LinearToSRGB(color);\n#endif\n return color;\n}\nvec4 frag () {\n#if CC_USE_SMAA\n \n vec4 a;\n a.rb = texture(u_blendTexSampler, v_uv).rb; \n a.g = texture(u_blendTexSampler, v_offset.zw).g; \n a.a = texture(u_blendTexSampler, v_offset.xy).a; \n if (dot(a, vec4(1.0)) < 1e-5) {\n vec4 o = texture(u_texSampler, v_uv);\n o.rgb = ToLDR(o.rgb);\n return o;\n } else {\n vec2 offset;\n offset.x = a.a > a.b ? a.a : -a.b;\n offset.y = a.g > a.r ? -a.g : a.r;\n if (abs(offset.x) > abs(offset.y)) {\n offset.y = 0.0;\n } else {\n offset.x = 0.0;\n }\n vec4 C = texture(u_texSampler, v_uv);\n C.rgb = ToLDR(C.rgb);\n vec2 uv = v_uv + sign(offset) * cc_nativeSize.zw;\n vec4 Cop = texture(u_texSampler, uv);\n Cop.rgb = ToLDR(Cop.rgb);\n float s = abs(offset.x) > abs(offset.y) ? abs(offset.x) : abs(offset.y);\n C.rgb = pow(C.rgb, vec3(2.2));\n Cop.rgb = pow(Cop.rgb, vec3(2.2));\n vec4 mixed = mix(C, Cop, s);\n mixed.rgb = pow(mixed.rgb, vec3(1.0 / 2.2));\n return mixed;\n }\n#else \n vec4 o = texture(u_texSampler, v_uv);\n \n o.rgb = ToLDR(o.rgb);\n return o;\n#endif\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }\n` + "frag": `\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time; \n vec4 cc_screenSize; \n vec4 cc_screenScale; \n vec4 cc_nativeSize; \n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos; \n vec4 cc_exposure; \n vec4 cc_mainLitDir; \n vec4 cc_mainLitColor; \n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n \n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n \n}\nvec3 ACESToneMap(vec3 color) {\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nin vec2 v_uv;\nin vec4 v_offset;\nuniform sampler2D u_texSampler;\nuniform sampler2D u_blendTexSampler;\nvec3 ToLDR(vec3 color) {\n#if CC_USE_HDR\n color *= cc_exposure.x * 1024.0;\n color = ACESToneMap(color);\n color = LinearToSRGB(color);\n#else\n color = SRGBToLinear(color);\n color = ACESToneMap(color);\n color = LinearToSRGB(color);\n#endif\n return color;\n}\nvec4 frag () {\n#if CC_USE_SMAA\n \n vec4 a;\n a.rb = texture(u_blendTexSampler, v_uv).rb; \n a.g = texture(u_blendTexSampler, v_offset.zw).g; \n a.a = texture(u_blendTexSampler, v_offset.xy).a; \n if (dot(a, vec4(1.0)) < 1e-5) {\n vec4 o = texture(u_texSampler, v_uv);\n o.rgb = ToLDR(o.rgb);\n return o;\n } else {\n vec2 offset;\n offset.x = a.a > a.b ? a.a : -a.b;\n offset.y = a.g > a.r ? -a.g : a.r;\n if (abs(offset.x) > abs(offset.y)) {\n offset.y = 0.0;\n } else {\n offset.x = 0.0;\n }\n vec4 C = texture(u_texSampler, v_uv);\n C.rgb = ToLDR(C.rgb);\n vec2 uv = v_uv + sign(offset) * cc_nativeSize.zw;\n vec4 Cop = texture(u_texSampler, uv);\n Cop.rgb = ToLDR(Cop.rgb);\n float s = abs(offset.x) > abs(offset.y) ? abs(offset.x) : abs(offset.y);\n C.rgb = pow(C.rgb, vec3(2.2));\n Cop.rgb = pow(Cop.rgb, vec3(2.2));\n vec4 mixed = mix(C, Cop, s);\n mixed.rgb = pow(mixed.rgb, vec3(1.0 / 2.2));\n return mixed;\n }\n#else\n vec4 o = texture(u_texSampler, v_uv);\n \n o.rgb = ToLDR(o.rgb);\n return o;\n#endif\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }\n` }, "glsl1": { "vert": `\nprecision highp float;\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\nuniform vec4 cc_time;\nuniform vec4 cc_screenSize;\nuniform vec4 cc_screenScale;\nuniform vec4 cc_nativeSize;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewInv;\nuniform mat4 cc_matProj;\nuniform mat4 cc_matProjInv;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matViewProjInv;\nuniform vec4 cc_cameraPos;\nuniform vec4 cc_exposure;\nuniform vec4 cc_mainLitDir;\nuniform vec4 cc_mainLitColor;\nuniform vec4 cc_ambientSky;\nuniform vec4 cc_ambientGround;\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_uv;\nvarying vec4 v_offset;\nvec4 vert () {\n vec4 pos = vec4(a_position, 0, 1);\n v_uv = a_texCoord * cc_screenScale.xy;\n v_offset = v_uv.xyxy + cc_nativeSize.zwzw * vec4(1.0, 0.0, 0.0, -1.0);\n return pos;\n}\nvoid main() { gl_Position = vert(); }\n`, - "frag": `\nprecision highp float;\nuniform vec4 cc_time;\nuniform vec4 cc_screenSize;\nuniform vec4 cc_screenScale;\nuniform vec4 cc_nativeSize;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewInv;\nuniform mat4 cc_matProj;\nuniform mat4 cc_matProjInv;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matViewProjInv;\nuniform vec4 cc_cameraPos;\nuniform vec4 cc_exposure;\nuniform vec4 cc_mainLitDir;\nuniform vec4 cc_mainLitColor;\nuniform vec4 cc_ambientSky;\nuniform vec4 cc_ambientGround;\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n \n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n \n}\nvec3 ACESToneMap(vec3 color) {\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvarying vec2 v_uv;\nvarying vec4 v_offset;\nuniform sampler2D u_texSampler;\nuniform sampler2D u_blendTexSampler;\nvec3 ToLDR(vec3 color) {\n#if CC_USE_HDR\n color *= cc_exposure.x * 1024.0;\n color = ACESToneMap(color);\n color = LinearToSRGB(color);\n#else\n color = SRGBToLinear(color);\n color = ACESToneMap(color);\n color = LinearToSRGB(color);\n#endif\n return color;\n}\nvec4 frag () {\n#if CC_USE_SMAA\n \n vec4 a;\n a.rb = texture2D(u_blendTexSampler, v_uv).rb; \n a.g = texture2D(u_blendTexSampler, v_offset.zw).g; \n a.a = texture2D(u_blendTexSampler, v_offset.xy).a; \n if (dot(a, vec4(1.0)) < 1e-5) {\n vec4 o = texture2D(u_texSampler, v_uv);\n o.rgb = ToLDR(o.rgb);\n return o;\n } else {\n vec2 offset;\n offset.x = a.a > a.b ? a.a : -a.b;\n offset.y = a.g > a.r ? -a.g : a.r;\n if (abs(offset.x) > abs(offset.y)) {\n offset.y = 0.0;\n } else {\n offset.x = 0.0;\n }\n vec4 C = texture2D(u_texSampler, v_uv);\n C.rgb = ToLDR(C.rgb);\n vec2 uv = v_uv + sign(offset) * cc_nativeSize.zw;\n vec4 Cop = texture2D(u_texSampler, uv);\n Cop.rgb = ToLDR(Cop.rgb);\n float s = abs(offset.x) > abs(offset.y) ? abs(offset.x) : abs(offset.y);\n C.rgb = pow(C.rgb, vec3(2.2));\n Cop.rgb = pow(Cop.rgb, vec3(2.2));\n vec4 mixed = mix(C, Cop, s);\n mixed.rgb = pow(mixed.rgb, vec3(1.0 / 2.2));\n return mixed;\n }\n#else \n vec4 o = texture2D(u_texSampler, v_uv);\n \n o.rgb = ToLDR(o.rgb);\n return o;\n#endif\n}\nvoid main() { gl_FragColor = frag(); }\n` + "frag": `\nprecision highp float;\nuniform vec4 cc_time;\nuniform vec4 cc_screenSize;\nuniform vec4 cc_screenScale;\nuniform vec4 cc_nativeSize;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewInv;\nuniform mat4 cc_matProj;\nuniform mat4 cc_matProjInv;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matViewProjInv;\nuniform vec4 cc_cameraPos;\nuniform vec4 cc_exposure;\nuniform vec4 cc_mainLitDir;\nuniform vec4 cc_mainLitColor;\nuniform vec4 cc_ambientSky;\nuniform vec4 cc_ambientGround;\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\nvec3 SRGBToLinear(vec3 gamma)\n{\n return pow(gamma, vec3(2.2));\n \n}\nvec3 LinearToSRGB(vec3 linear)\n{\n return pow(linear, vec3(0.454545));\n \n}\nvec3 ACESToneMap(vec3 color) {\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvarying vec2 v_uv;\nvarying vec4 v_offset;\nuniform sampler2D u_texSampler;\nuniform sampler2D u_blendTexSampler;\nvec3 ToLDR(vec3 color) {\n#if CC_USE_HDR\n color *= cc_exposure.x * 1024.0;\n color = ACESToneMap(color);\n color = LinearToSRGB(color);\n#else\n color = SRGBToLinear(color);\n color = ACESToneMap(color);\n color = LinearToSRGB(color);\n#endif\n return color;\n}\nvec4 frag () {\n#if CC_USE_SMAA\n \n vec4 a;\n a.rb = texture2D(u_blendTexSampler, v_uv).rb; \n a.g = texture2D(u_blendTexSampler, v_offset.zw).g; \n a.a = texture2D(u_blendTexSampler, v_offset.xy).a; \n if (dot(a, vec4(1.0)) < 1e-5) {\n vec4 o = texture2D(u_texSampler, v_uv);\n o.rgb = ToLDR(o.rgb);\n return o;\n } else {\n vec2 offset;\n offset.x = a.a > a.b ? a.a : -a.b;\n offset.y = a.g > a.r ? -a.g : a.r;\n if (abs(offset.x) > abs(offset.y)) {\n offset.y = 0.0;\n } else {\n offset.x = 0.0;\n }\n vec4 C = texture2D(u_texSampler, v_uv);\n C.rgb = ToLDR(C.rgb);\n vec2 uv = v_uv + sign(offset) * cc_nativeSize.zw;\n vec4 Cop = texture2D(u_texSampler, uv);\n Cop.rgb = ToLDR(Cop.rgb);\n float s = abs(offset.x) > abs(offset.y) ? abs(offset.x) : abs(offset.y);\n C.rgb = pow(C.rgb, vec3(2.2));\n Cop.rgb = pow(Cop.rgb, vec3(2.2));\n vec4 mixed = mix(C, Cop, s);\n mixed.rgb = pow(mixed.rgb, vec3(1.0 / 2.2));\n return mixed;\n }\n#else\n vec4 o = texture2D(u_texSampler, v_uv);\n \n o.rgb = ToLDR(o.rgb);\n return o;\n#endif\n}\nvoid main() { gl_FragColor = frag(); }\n` }, "builtins": {"globals":{"blocks":["CCGlobal"], "samplers":[]}, "locals":{"blocks":[], "samplers":[]}}, "defines": [ diff --git a/cocos/3d/framework/directional-light-component.ts b/cocos/3d/framework/directional-light-component.ts index b2e7e3a65a..7b35d9d8a6 100644 --- a/cocos/3d/framework/directional-light-component.ts +++ b/cocos/3d/framework/directional-light-component.ts @@ -53,13 +53,6 @@ export class DirectionalLightComponent extends LightComponent { if (this._light) { this._light.illuminance = this._illuminance; } } - public onLoad () { - if (!this._enabled) { - if (!this.node.scene) { return; } - this._getRenderScene().mainLight.enabled = false; - } - } - protected _createLight (scene?: RenderScene) { if (!this.node.scene) { return; } if (!scene) { scene = this._getRenderScene(); } diff --git a/cocos/3d/framework/skinning-model-component.ts b/cocos/3d/framework/skinning-model-component.ts index 8d20075807..751daf0859 100644 --- a/cocos/3d/framework/skinning-model-component.ts +++ b/cocos/3d/framework/skinning-model-component.ts @@ -211,12 +211,14 @@ export class SkinningModelComponent extends ModelComponent { protected _onMaterialModified (index: number, material: Material) { const device = _getGlobalDevice()!; const kind = selectStorageKind(device); - const mat = this.getMaterial(index, CC_EDITOR)!; - mat.recompileShaders({ - CC_USE_SKINNING: true, - CC_USE_JOINTS_TEXTURE: kind === JointStorageKind.textureRGBA32F || kind === JointStorageKind.textureRGBA8, - CC_USE_JOINTS_TEXTURE_RGBA8888: kind === JointStorageKind.textureRGBA8, - }); + const mat = this.getMaterial(index, CC_EDITOR); + if (mat) { + mat.recompileShaders({ + CC_USE_SKINNING: true, + CC_USE_JOINTS_TEXTURE: kind === JointStorageKind.textureRGBA32F || kind === JointStorageKind.textureRGBA8, + CC_USE_JOINTS_TEXTURE_RGBA8888: kind === JointStorageKind.textureRGBA8, + }); + } super._onMaterialModified(index, mat); } diff --git a/cocos/3d/geom-utils/aabb.ts b/cocos/3d/geom-utils/aabb.ts index 05578a0301..d490d64626 100644 --- a/cocos/3d/geom-utils/aabb.ts +++ b/cocos/3d/geom-utils/aabb.ts @@ -15,6 +15,7 @@ const transform_extent_m4 = (out: vec3, extent: vec3, m4: mat4) => { vec3.transformMat3(out, extent, _m3_tmp); }; +// tslint:disable-next-line: class-name export default class aabb { get type () { @@ -123,7 +124,7 @@ export default class aabb { * @param {vec3} minPos * @param {vec3} maxPos */ - public getBoundary (minPos, maxPos) { + public getBoundary (minPos: vec3, maxPos: vec3) { vec3.sub(minPos, this.center, this.halfExtents); vec3.add(maxPos, this.center, this.halfExtents); } @@ -133,7 +134,7 @@ export default class aabb { * @param m - the transform matrix * @param out - the target shape */ - public transform (m, out?: aabb) { + public transform (m, pos, rot, scale, out) { if (!out) { out = this; } vec3.transformMat4(out.center, this.center, m); transform_extent_m4(out.halfExtents, this.halfExtents, m); diff --git a/cocos/renderer/scene/model.ts b/cocos/renderer/scene/model.ts index 5a75af580c..babd7792ae 100644 --- a/cocos/renderer/scene/model.ts +++ b/cocos/renderer/scene/model.ts @@ -181,7 +181,8 @@ export class Model { if (!this._node.hasChanged) { return; } this._node.updateWorldTransformFull(); if (!this._modelBounds) { return; } - this._modelBounds.transform(this._node._mat, this._worldBounds!); + this._modelBounds.transform(this._node._mat, this._node._pos, + this._node._rot, this._node._scale, this._worldBounds!); } public _resetUBOUpdateFlag () { diff --git a/cocos/renderer/scene/render-scene.ts b/cocos/renderer/scene/render-scene.ts index e971996165..94e8e91e05 100644 --- a/cocos/renderer/scene/render-scene.ts +++ b/cocos/renderer/scene/render-scene.ts @@ -100,6 +100,7 @@ export class RenderScene { this._defaultMainLightNode = new Node('Main Light'); this._mainLight = new DirectionalLight(this, 'Main Light', this._defaultMainLightNode); this._mainLight.illuminance = Ambient.SUN_ILLUM; + this._mainLight.enabled = false; // disabled by default this._ambient = new Ambient(this); this._skybox = new Skybox(this); this._planarShadow = new PlanarShadow(this); diff --git a/cocos/scene-graph/node.ts b/cocos/scene-graph/node.ts index d0b792194a..fc947fd894 100644 --- a/cocos/scene-graph/node.ts +++ b/cocos/scene-graph/node.ts @@ -191,7 +191,7 @@ class Node extends BaseNode { vec3.copy(this._pos, this._lpos); quat.copy(this._rot, this._lrot); vec3.copy(this._scale, this._lscale); - this._dirty = this._hasChanged = true; + this._eulerDirty = this._dirty = this._hasChanged = true; for (const child of this._children) { child._onBatchCreated(); } diff --git a/package.json b/package.json index 0b5fc458b2..1f4b96eaa1 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "build:dev": "node ./rollup/out/build-engine-cli.js --sourcemap --platform=any --destination=./bin/cocos-3d.dev.js", "build:min": "uglifyjs ./bin/cocos-3d.dev.js --mangle --source-map -o ./bin/cocos-3d.min.js", "build-rollup": "tsc --build rollup/tsconfig.json", - "dev": "rollup -w -c ./rollup/config.js", "postinstall": "npm run build-rollup", "buildDocs": "node ./scripts/build-docs" },