Skip to content

Commit

Permalink
add lightmapMode scene setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksims committed Aug 5, 2016
1 parent d145aac commit c52a0e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/framework/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ pc.extend(pc, function () {
},

_firstBake: function() {
this.lightmapper.bake();
this.lightmapper.bake(null, this.scene.lightmapMode);
},

/**
Expand Down
5 changes: 2 additions & 3 deletions src/graphics/program-lib/chunks/biasRcvPlane.frag
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ vec2 computeReceiverPlaneDepthBias(vec3 texCoordDX, vec3 texCoordDY) {
}

float getShadowBias(float resolution, float maxBias) {
vec3 shadowPosDX = dFdx(dShadowCoord) + vec3(0.00001);
vec3 shadowPosDY = dFdy(dShadowCoord) + vec3(0.00001);
vec3 shadowPosDX = dFdx(dShadowCoord);
vec3 shadowPosDY = dFdy(dShadowCoord);
vec2 texelSize = vec2(1.0 / resolution);

vec2 receiverPlaneDepthBias = computeReceiverPlaneDepthBias(shadowPosDX, shadowPosDY);
float fractionalSamplingError = 2.0 * dot(vec2(texelSize), abs(receiverPlaneDepthBias));

return -min(fractionalSamplingError, maxBias);
}

8 changes: 8 additions & 0 deletions src/scene/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ pc.extend(pc, function () {
* Only valid for prefiltered cubemap skyboxes.
* @property {Number} lightmapSizeMultiplier Lightmap resolution multiplier
* @property {Number} lightmapMaxResolution Maximum lightmap resolution
* @property {Number} lightmapMode Baking mode, with possible values:
* <ul>
* <li>pc.BAKE_COLOR: single color lightmap
* <li>pc.BAKE_COLORDIR: single color lightmap + dominant light direction (used for bump/specular)
* </ul>
* Only lights with bakeDir=true will be used for generating the dominant light direction.
*/
var Scene = function Scene() {
this.root = null;
Expand Down Expand Up @@ -295,6 +301,7 @@ pc.extend(pc, function () {

this.lightmapSizeMultiplier = 1;
this.lightmapMaxResolution = 2048;
this.lightmapMode = pc.BAKE_COLORDIR;

this._stats = {
meshInstances: 0,
Expand Down Expand Up @@ -490,6 +497,7 @@ pc.extend(pc, function () {
this.toneMapping = settings.render.tonemapping;
this.lightmapSizeMultiplier = settings.render.lightmapSizeMultiplier;
this.lightmapMaxResolution = settings.render.lightmapMaxResolution;
this.lightmapMode = settings.render.lightmapMode;
this.exposure = settings.render.exposure;
this.skyboxIntensity = settings.render.skyboxIntensity===undefined? 1 : settings.render.skyboxIntensity;
this.skyboxMip = settings.render.skyboxMip===undefined? 0 : settings.render.skyboxMip;
Expand Down

0 comments on commit c52a0e7

Please sign in to comment.