Visitar URL original
Merge pull request #545 from guycalledfrank/tempnosh · WebGL-HTML5-Repo/engine@0390059 · GitHub
Skip to content

Commit 0390059

Browse files
Merge pull request playcanvas#545 from guycalledfrank/tempnosh
Fix various LM stuff (mostly for android)
2 parents e625bce + 97d648f commit 0390059

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎src/graphics/program-lib/phong.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ pc.programlib.phong = {
185185
if (chunks.extensionVS) {
186186
code += chunks.extensionVS + "\n";
187187
}
188-
188+
189189
code += chunks.baseVS;
190190

191191
// Allow first shadow coords to be computed in VS
@@ -549,6 +549,7 @@ pc.programlib.phong = {
549549
}
550550
}
551551

552+
552553
if (numShadowLights > 0) {
553554
code += chunks.shadowCoordPS + chunks.shadowPS;
554555
if (mainShadowLight>=0) code += chunks.shadowVSPS;

‎src/scene/lightmapper.js‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pc.extend(pc, function () {
1818
if (!node.enabled) return;
1919

2020
var i;
21-
if (node.model && node.model.model) {
21+
if (node.model && node.model.model && node.model.enabled) {
2222
if (allNodes) allNodes.push(node);
2323
if (node.model.data.lightmapped) {
2424
if (nodes) {
@@ -276,9 +276,15 @@ pc.extend(pc, function () {
276276

277277
// Store scene values
278278
var origFog = scene.fog;
279+
var origAmbientR = scene.ambientLight.r;
280+
var origAmbientG = scene.ambientLight.g;
281+
var origAmbientB = scene.ambientLight.b;
279282
var origDrawCalls = scene.drawCalls;
280283

281284
scene.fog = pc.FOG_NONE;
285+
scene.ambientLight.r = 0;
286+
scene.ambientLight.g = 0;
287+
scene.ambientLight.b = 0;
282288

283289
// Create pseudo-camera
284290
if (!lmCamera) {
@@ -343,6 +349,7 @@ pc.extend(pc, function () {
343349
lmMaterial.cull = pc.CULLFACE_NONE;
344350
lmMaterial.forceUv1 = true; // provide data to xformUv1
345351
lmMaterial.update();
352+
lmMaterial.updateShader(device, scene);
346353
}
347354

348355
for(node=0; node<nodes.length; node++) {
@@ -464,6 +471,7 @@ pc.extend(pc, function () {
464471
lmCamera.setRenderTarget(targTmp);
465472

466473
//console.log("Baking light "+lights[i]._node.name + " on model " + nodes[node].name);
474+
467475
this.renderer.render(scene, lmCamera);
468476
stats.renderPasses++;
469477

@@ -550,6 +558,9 @@ pc.extend(pc, function () {
550558
// Roll back scene stuff
551559
scene.drawCalls = origDrawCalls;
552560
scene.fog = origFog;
561+
scene.ambientLight.r = origAmbientR;
562+
scene.ambientLight.g = origAmbientG;
563+
scene.ambientLight.b = origAmbientB;
553564

554565
scene._updateLightStats(); // update statistics
555566

0 commit comments

Comments
 (0)