From 4cf879618fdad600563fb4ea3d958f5c40840781 Mon Sep 17 00:00:00 2001 From: Mr F Date: Sun, 31 May 2015 17:03:57 +0300 Subject: [PATCH 1/3] sort additivealpha --- src/scene/scene_forwardrenderer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scene/scene_forwardrenderer.js b/src/scene/scene_forwardrenderer.js index f4a99120926..3a47124095e 100644 --- a/src/scene/scene_forwardrenderer.js +++ b/src/scene/scene_forwardrenderer.js @@ -561,6 +561,7 @@ pc.extend(pc, function () { this.culled = []; var meshPos; var visible; + var btype; // Calculate the distance of transparent meshes from the camera // and cull too @@ -586,7 +587,10 @@ pc.extend(pc, function () { } if (visible) { - if ((meshInstance.material.blendType === pc.BLEND_NORMAL) || (meshInstance.material.blendType === pc.BLEND_PREMULTIPLIED)) { + btype = meshInstance.material.blendType; + if (btype === pc.BLEND_NORMAL + || btype === pc.BLEND_PREMULTIPLIED + || btype === pc.BLEND_ADDITIVEALPHA) { // alpha sort if (! meshPos) meshPos = meshInstance.aabb.center; var tempx = meshPos.x - camPos.x; From 9699c723a82bfd764e7392942979dc5fa4b1c5a4 Mon Sep 17 00:00:00 2001 From: Mr F Date: Sun, 31 May 2015 17:14:10 +0300 Subject: [PATCH 2/3] fix alpha sort --- src/scene/scene_forwardrenderer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/scene/scene_forwardrenderer.js b/src/scene/scene_forwardrenderer.js index 3a47124095e..1f9cf4966ee 100644 --- a/src/scene/scene_forwardrenderer.js +++ b/src/scene/scene_forwardrenderer.js @@ -569,6 +569,7 @@ pc.extend(pc, function () { for (i = 0; i < drawCallsCount; i++) { drawCall = drawCalls[i]; visible = true; + meshPos = null; if (!drawCall.command) { if (drawCall._hidden) continue; // use _hidden property to quickly hide/show meshInstances meshInstance = drawCall; @@ -592,7 +593,7 @@ pc.extend(pc, function () { || btype === pc.BLEND_PREMULTIPLIED || btype === pc.BLEND_ADDITIVEALPHA) { // alpha sort - if (! meshPos) meshPos = meshInstance.aabb.center; + if (!meshPos) meshPos = meshInstance.aabb.center; var tempx = meshPos.x - camPos.x; var tempy = meshPos.y - camPos.y; var tempz = meshPos.z - camPos.z; From 0225f6be0a4d52883a7077aa0ce6d1a884961534 Mon Sep 17 00:00:00 2001 From: Mr F Date: Sun, 31 May 2015 17:15:10 +0300 Subject: [PATCH 3/3] actually don't sort additivealpha --- src/scene/scene_forwardrenderer.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/scene/scene_forwardrenderer.js b/src/scene/scene_forwardrenderer.js index 1f9cf4966ee..bc45b558efd 100644 --- a/src/scene/scene_forwardrenderer.js +++ b/src/scene/scene_forwardrenderer.js @@ -590,8 +590,7 @@ pc.extend(pc, function () { if (visible) { btype = meshInstance.material.blendType; if (btype === pc.BLEND_NORMAL - || btype === pc.BLEND_PREMULTIPLIED - || btype === pc.BLEND_ADDITIVEALPHA) { + || btype === pc.BLEND_PREMULTIPLIED) { // alpha sort if (!meshPos) meshPos = meshInstance.aabb.center; var tempx = meshPos.x - camPos.x;