PointLight name changed to LightSource.

This commit is contained in:
Zemledelec 2016-06-23 22:41:33 +03:00
parent 4fc2a84e20
commit 2ed4682ef6
16 changed files with 265 additions and 265 deletions

View File

@ -2,7 +2,7 @@ goog.provide('og.control.Sun');
goog.require('og.inheritance');
goog.require('og.control.BaseControl');
goog.require('og.light.PointLight');
goog.require('og.light.LightSource');
goog.require('og.astro.earth');
goog.require('og.math.Quaternion');
@ -32,7 +32,7 @@ og.control.Sun = function (options) {
/**
* Light source.
* @public
* @type {og.light.PointLight}
* @type {og.light.LightSource}
*/
this.sunlight = null;
@ -61,7 +61,7 @@ og.control.Sun.prototype.oninit = function () {
this.planet.lightEnabled = true;
//sunlight initialization
this.sunlight = new og.light.PointLight();
this.sunlight = new og.light.LightSource();
this.sunlight.setAmbient(new og.math.Vector3(0.15, 0.15, 0.25));
this.sunlight.setDiffuse(new og.math.Vector3(0.9, 0.9, 0.8));
this.sunlight.setSpecular(new og.math.Vector3(0.1, 0.1, 0.06));

170
src/og/light/lightSource.js Normal file
View File

@ -0,0 +1,170 @@
goog.provide('og.light.LightSource');
goog.require('og.math.Vector3');
og.light.LightSource = function (name, position, ambient, diffuse, specular, shininess, directional) {
this._name = name || ("p" + og.light.LightSource._counter++);
this._renderNode = null;
this._position = position || new og.math.Vector3();
this.directional = true;// = directional || false;
this._ambient = ambient || new og.math.Vector3();
this._diffuse = diffuse || new og.math.Vector3(0.8, 0.8, 0.8);
this._specular = specular || new og.math.Vector3(0.18, 0.18, 0.18);
this._shininess = shininess || 3.3;
this._active = true;
this._tempAmbient = ambient ? ambient.clone() : new og.math.Vector3();
this._tempDiffuse = diffuse ? diffuse.clone() : new og.math.Vector3();
this._tempSpecular = specular ? specular.clone() : new og.math.Vector3();
this._tempShininess = shininess || 1.0;
};
og.light.LightSource._counter = 0;
og.light.LightSource.prototype.clone = function () {
};
og.light.LightSource.prototype.setActive = function (active) {
if (active && !this._active) {
var rn = this._renderNode;
if (rn) {
var index = rn._lightsNames.indexOf(this._name);
this._shininess = rn._lightsParamsf[index] = this._tempShininess;
if (index != -1) {
index *= 9;
this._ambient.x = rn._lightsParamsv[index] = this._tempAmbient.x;
this._ambient.y = rn._lightsParamsv[index + 1] = this._tempAmbient.y;
this._ambient.z = rn._lightsParamsv[index + 2] = this._tempAmbient.z;
this._diffuse.x = rn._lightsParamsv[index + 3] = this._tempDiffuse.x;
this._diffuse.y = rn._lightsParamsv[index + 4] = this._tempDiffuse.y;
this._diffuse.z = rn._lightsParamsv[index + 5] = this._tempDiffuse.z;
this._specular.x = rn._lightsParamsv[index + 6] = this._tempSpecular.x;
this._specular.y = rn._lightsParamsv[index + 7] = this._tempSpecular.y;
this._specular.z = rn._lightsParamsv[index + 8] = this._tempSpecular.z;
}
}
this._active = true;
} else if (!active && this._active) {
this._tempAmbient = this._ambient.clone();
this._tempDiffuse = this._diffuse.clone();
this._tempSpecular = this._specular.clone();
this._tempShininess = this._shininess;
this.setBlack();
this._active = false;
}
return this.active;
};
og.light.LightSource.prototype.isActive = function () {
return this._active;
};
og.light.LightSource.prototype.setPosition = function (position) {
this._position.x = position.x;
this._position.y = position.y;
this._position.z = position.z;
return this;
};
og.light.LightSource.prototype.setAmbient = function (rgb) {
this._ambient = rgb;
var rn = this._renderNode;
if (rn) {
var index = 9 * rn._lightsNames.indexOf(this._name);
if (index != -1) {
rn._lightsParamsv[index] = rgb.x;
rn._lightsParamsv[index + 1] = rgb.y;
rn._lightsParamsv[index + 2] = rgb.z;
}
}
return this;
};
og.light.LightSource.prototype.setDiffuse = function (rgb) {
this._diffuse = rgb;
var rn = this._renderNode;
if (rn) {
var index = 9 * rn._lightsNames.indexOf(this._name);
if (index != -1) {
rn._lightsParamsv[index + 3] = rgb.x;
rn._lightsParamsv[index + 4] = rgb.y;
rn._lightsParamsv[index + 5] = rgb.z;
}
}
return this;
};
og.light.LightSource.prototype.setSpecular = function (rgb) {
this._specular = rgb;
var rn = this._renderNode;
if (rn) {
var index = 9 * rn._lightsNames.indexOf(this._name);
if (index != -1) {
rn._lightsParamsv[index + 6] = rgb.x;
rn._lightsParamsv[index + 7] = rgb.y;
rn._lightsParamsv[index + 8] = rgb.z;
}
}
return this;
};
og.light.LightSource.prototype.setShininess = function (shininess) {
this._shininess = shininess;
var rn = this._renderNode;
if (rn) {
var index = rn._lightsNames.indexOf(this._name);
if (index != -1) {
rn._lightsParamsf[index] = shininess;
}
}
return this;
};
og.light.LightSource.prototype.setBlack = function () {
this._ambient.clear();
this._diffuse.clear();
this._specular.clear();
this._shininess = 0;
var rn = this._renderNode;
if (rn) {
var index = 9 * rn._lightsNames.indexOf(this._name);
if (index != -1) {
rn._lightsParamsv[index] = rn._lightsParamsv[index + 1] = rn._lightsParamsv[index + 2] =
rn._lightsParamsv[index + 3] = rn._lightsParamsv[index + 4] = rn._lightsParamsv[index + 5] =
rn._lightsParamsv[index + 6] = rn._lightsParamsv[index + 7] = rn._lightsParamsv[index + 8] = 0;
}
}
return this;
};
og.light.LightSource.prototype.addTo = function (renderNode) {
this._renderNode = renderNode;
renderNode._lights.push(this);
renderNode._lightsNames.push(this._name);
renderNode._lightsParamsf.push(this._shininess);
renderNode._lightsParamsv.push.apply(renderNode._lightsParamsv, this._ambient.toVec());
renderNode._lightsParamsv.push.apply(renderNode._lightsParamsv, this._diffuse.toVec());
renderNode._lightsParamsv.push.apply(renderNode._lightsParamsv, this._specular.toVec());
return this;
};
og.light.LightSource.prototype.remove = function () {
var rn = this.renderNode;
if (rn) {
var li = rn.getLightById(this._name);
if (li != -1) {
rn._lights.splice(li, 1);
rn._lightsNames.splice(li, 1);
rn._lightsParamsf.splice(li, 1);
rn._lightsParamsv.splice(li, 9);//3*3
}
}
this._renderNode = null;
};

View File

@ -1,170 +0,0 @@
goog.provide('og.light.PointLight');
goog.require('og.math.Vector3');
og.light.PointLight = function (name, position, ambient, diffuse, specular, shininess, directional) {
this._name = name || ("p" + og.light.PointLight._counter++);
this._renderNode = null;
this._position = position || new og.math.Vector3();
this.directional = true;// = directional || false;
this._ambient = ambient || new og.math.Vector3();
this._diffuse = diffuse || new og.math.Vector3(0.8, 0.8, 0.8);
this._specular = specular || new og.math.Vector3(0.18, 0.18, 0.18);
this._shininess = shininess || 3.3;
this._active = true;
this._tempAmbient = ambient ? ambient.clone() : new og.math.Vector3();
this._tempDiffuse = diffuse ? diffuse.clone() : new og.math.Vector3();
this._tempSpecular = specular ? specular.clone() : new og.math.Vector3();
this._tempShininess = shininess || 1.0;
};
og.light.PointLight._counter = 0;
og.light.PointLight.prototype.clone = function () {
};
og.light.PointLight.prototype.setActive = function (active) {
if (active && !this._active) {
var rn = this._renderNode;
if (rn) {
var index = rn._pointLightsNames.indexOf(this._name);
this._shininess = rn._pointLightsParamsf[index] = this._tempShininess;
if (index != -1) {
index *= 9;
this._ambient.x = rn._pointLightsParamsv[index] = this._tempAmbient.x;
this._ambient.y = rn._pointLightsParamsv[index + 1] = this._tempAmbient.y;
this._ambient.z = rn._pointLightsParamsv[index + 2] = this._tempAmbient.z;
this._diffuse.x = rn._pointLightsParamsv[index + 3] = this._tempDiffuse.x;
this._diffuse.y = rn._pointLightsParamsv[index + 4] = this._tempDiffuse.y;
this._diffuse.z = rn._pointLightsParamsv[index + 5] = this._tempDiffuse.z;
this._specular.x = rn._pointLightsParamsv[index + 6] = this._tempSpecular.x;
this._specular.y = rn._pointLightsParamsv[index + 7] = this._tempSpecular.y;
this._specular.z = rn._pointLightsParamsv[index + 8] = this._tempSpecular.z;
}
}
this._active = true;
} else if (!active && this._active) {
this._tempAmbient = this._ambient.clone();
this._tempDiffuse = this._diffuse.clone();
this._tempSpecular = this._specular.clone();
this._tempShininess = this._shininess;
this.setBlack();
this._active = false;
}
return this.active;
};
og.light.PointLight.prototype.isActive = function () {
return this._active;
};
og.light.PointLight.prototype.setPosition = function (position) {
this._position.x = position.x;
this._position.y = position.y;
this._position.z = position.z;
return this;
};
og.light.PointLight.prototype.setAmbient = function (rgb) {
this._ambient = rgb;
var rn = this._renderNode;
if (rn) {
var index = 9 * rn._pointLightsNames.indexOf(this._name);
if (index != -1) {
rn._pointLightsParamsv[index] = rgb.x;
rn._pointLightsParamsv[index + 1] = rgb.y;
rn._pointLightsParamsv[index + 2] = rgb.z;
}
}
return this;
};
og.light.PointLight.prototype.setDiffuse = function (rgb) {
this._diffuse = rgb;
var rn = this._renderNode;
if (rn) {
var index = 9 * rn._pointLightsNames.indexOf(this._name);
if (index != -1) {
rn._pointLightsParamsv[index + 3] = rgb.x;
rn._pointLightsParamsv[index + 4] = rgb.y;
rn._pointLightsParamsv[index + 5] = rgb.z;
}
}
return this;
};
og.light.PointLight.prototype.setSpecular = function (rgb) {
this._specular = rgb;
var rn = this._renderNode;
if (rn) {
var index = 9 * rn._pointLightsNames.indexOf(this._name);
if (index != -1) {
rn._pointLightsParamsv[index + 6] = rgb.x;
rn._pointLightsParamsv[index + 7] = rgb.y;
rn._pointLightsParamsv[index + 8] = rgb.z;
}
}
return this;
};
og.light.PointLight.prototype.setShininess = function (shininess) {
this._shininess = shininess;
var rn = this._renderNode;
if (rn) {
var index = rn._pointLightsNames.indexOf(this._name);
if (index != -1) {
rn._pointLightsParamsf[index] = shininess;
}
}
return this;
};
og.light.PointLight.prototype.setBlack = function () {
this._ambient.clear();
this._diffuse.clear();
this._specular.clear();
this._shininess = 0;
var rn = this._renderNode;
if (rn) {
var index = 9 * rn._pointLightsNames.indexOf(this._name);
if (index != -1) {
rn._pointLightsParamsv[index] = rn._pointLightsParamsv[index + 1] = rn._pointLightsParamsv[index + 2] =
rn._pointLightsParamsv[index + 3] = rn._pointLightsParamsv[index + 4] = rn._pointLightsParamsv[index + 5] =
rn._pointLightsParamsv[index + 6] = rn._pointLightsParamsv[index + 7] = rn._pointLightsParamsv[index + 8] = 0;
}
}
return this;
};
og.light.PointLight.prototype.addTo = function (renderNode) {
this._renderNode = renderNode;
renderNode._pointLights.push(this);
renderNode._pointLightsNames.push(this._name);
renderNode._pointLightsParamsf.push(this._shininess);
renderNode._pointLightsParamsv.push.apply(renderNode._pointLightsParamsv, this._ambient.toVec());
renderNode._pointLightsParamsv.push.apply(renderNode._pointLightsParamsv, this._diffuse.toVec());
renderNode._pointLightsParamsv.push.apply(renderNode._pointLightsParamsv, this._specular.toVec());
return this;
};
og.light.PointLight.prototype.remove = function () {
var rn = this.renderNode;
if (rn) {
var li = rn.getLightById(this._name);
if (li != -1) {
rn._pointLights.splice(li, 1);
rn._pointLightsNames.splice(li, 1);
rn._pointLightsParamsf.splice(li, 1);
rn._pointLightsParamsv.splice(li, 9);//3*3
}
}
this._renderNode = null;
};

View File

@ -30,7 +30,7 @@ goog.require('og.webgl.Framebuffer');
goog.require('og.mercator');
goog.require('og.proj.EPSG4326');
goog.require('og.ImageCanvas');
goog.require('og.light.PointLight');
goog.require('og.light.LightSource');
goog.require('og.planetSegment.NormalMapCreatorQueue');
goog.require('og.GeoImage');
goog.require('og.planetSegment.GeoImageTileCreatorQueue');
@ -801,9 +801,9 @@ og.node.Planet.prototype._drawOverlays = function () {
sh = h.shaderPrograms.overlays_wl._program,
shu = sh.uniforms;
gl.uniform4fv(shu.pointLightsPositions._pName, this._pointLightsTransformedPositions);
gl.uniform3fv(shu.pointLightsParamsv._pName, this._pointLightsParamsv);
gl.uniform1fv(shu.pointLightsParamsf._pName, this._pointLightsParamsf);
gl.uniform4fv(shu.lightsPositions._pName, this._lightsTransformedPositions);
gl.uniform3fv(shu.lightsParamsv._pName, this._lightsParamsv);
gl.uniform1fv(shu.lightsParamsf._pName, this._lightsParamsf);
gl.uniformMatrix3fv(shu.normalMatrix._pName, false, renderer.activeCamera._normalMatrix._m);
gl.uniformMatrix4fv(shu.viewMatrix._pName, false, renderer.activeCamera._viewMatrix._m);
@ -865,9 +865,9 @@ og.node.Planet.prototype._drawSingle = function () {
sh = h.shaderPrograms.single_wl._program,
shu = sh.uniforms;
gl.uniform4fv(shu.pointLightsPositions._pName, this._pointLightsTransformedPositions);
gl.uniform3fv(shu.pointLightsParamsv._pName, this._pointLightsParamsv);
gl.uniform1fv(shu.pointLightsParamsf._pName, this._pointLightsParamsf);
gl.uniform4fv(shu.lightsPositions._pName, this._lightsTransformedPositions);
gl.uniform3fv(shu.lightsParamsv._pName, this._lightsParamsv);
gl.uniform1fv(shu.lightsParamsf._pName, this._lightsParamsf);
gl.uniformMatrix3fv(shu.normalMatrix._pName, false, renderer.activeCamera._normalMatrix._m);
gl.uniformMatrix4fv(shu.viewMatrix._pName, false, renderer.activeCamera._viewMatrix._m);

View File

@ -138,9 +138,9 @@ og.node.PlanetAtmosphere.prototype._drawOverlays = function () {
sh = h.shaderPrograms.overlaysAtmosphere_wl._program,
shu = sh.uniforms;
gl.uniform4fv(shu.pointLightsPositions._pName, this._pointLightsTransformedPositions);
gl.uniform3fv(shu.pointLightsParamsv._pName, this._pointLightsParamsv);
gl.uniform1fv(shu.pointLightsParamsf._pName, this._pointLightsParamsf);
gl.uniform4fv(shu.lightsPositions._pName, this._lightsTransformedPositions);
gl.uniform3fv(shu.lightsParamsv._pName, this._lightsParamsv);
gl.uniform1fv(shu.lightsParamsf._pName, this._lightsParamsf);
gl.uniformMatrix3fv(shu.normalMatrix._pName, false, renderer.activeCamera._normalMatrix._m);
gl.uniformMatrix4fv(shu.viewMatrix._pName, false, renderer.activeCamera._viewMatrix._m);
@ -220,9 +220,9 @@ og.node.PlanetAtmosphere.prototype._drawSingle = function () {
sh = h.shaderPrograms.singleAtmosphere_wl._program,
shu = sh.uniforms;
gl.uniform4fv(shu.pointLightsPositions._pName, this._pointLightsTransformedPositions);
gl.uniform3fv(shu.pointLightsParamsv._pName, this._pointLightsParamsv);
gl.uniform1fv(shu.pointLightsParamsf._pName, this._pointLightsParamsf);
gl.uniform4fv(shu.lightsPositions._pName, this._lightsTransformedPositions);
gl.uniform3fv(shu.lightsParamsv._pName, this._lightsParamsv);
gl.uniform1fv(shu.lightsParamsf._pName, this._lightsParamsf);
gl.uniformMatrix3fv(shu.normalMatrix._pName, false, renderer.activeCamera._normalMatrix._m);
gl.uniformMatrix4fv(shu.viewMatrix._pName, false, renderer.activeCamera._viewMatrix._m);

View File

@ -57,13 +57,13 @@ og.node.RenderNode = function (name) {
/**
* Point light array.
* @private
* @type {Array.<og.light.PointLight>}
* @type {Array.<og.light.LightSource>}
*/
this._pointLights = [];
this._pointLightsTransformedPositions = [];
this._pointLightsParamsv = [];
this._pointLightsParamsf = [];
this._pointLightsNames = [];
this._lights = [];
this._lightsTransformedPositions = [];
this._lightsParamsv = [];
this._lightsParamsf = [];
this._lightsNames = [];
/**
* Entity collection array.
@ -138,7 +138,7 @@ og.node.RenderNode.prototype.removeEntityCollection = function (entityCollection
/**
* Adds point light source.
* @public
* @param {og.light.PointLight} light - Point light source.
* @param {og.light.LightSource} light - Light source.
* @returns {og.node.RenderNode}
*/
og.node.RenderNode.prototype.addLight = function (light) {
@ -150,17 +150,17 @@ og.node.RenderNode.prototype.addLight = function (light) {
* Gets light object by its name.
* @public
* @param {string} name - Point light name.
* @returns {og.light.PointLight}
* @returns {og.light.LightSource}
*/
og.node.RenderNode.prototype.getLightByName = function (name) {
var li = this._pointLightsNames.indexOf(name);
return this._pointLights[li];
var li = this._lightsNames.indexOf(name);
return this._lights[li];
};
/**
* Removes light source.
* @public
* @param {og.light.PointLight} light - Point light object.
* @param {og.light.LightSource} light - Light source object.
*/
og.node.RenderNode.prototype.removeLight = function (light) {
light.remove();
@ -255,19 +255,19 @@ og.node.RenderNode.prototype.setDrawMode = function (mode) {
*/
og.node.RenderNode.prototype.transformLights = function () {
var r = this.renderer;
for (var i = 0; i < this._pointLights.length; i++) {
for (var i = 0; i < this._lights.length; i++) {
var ii = i * 4;
var tp;
if (this._pointLights[i].directional) {
tp = r.activeCamera._normalMatrix.mulVec(this._pointLights[i]._position);
this._pointLightsTransformedPositions[ii + 3] = 0;
if (this._lights[i].directional) {
tp = r.activeCamera._normalMatrix.mulVec(this._lights[i]._position);
this._lightsTransformedPositions[ii + 3] = 0;
} else {
tp = r.activeCamera._viewMatrix.mulVec3(this._pointLights[i]._position);
this._pointLightsTransformedPositions[ii + 3] = 1;
tp = r.activeCamera._viewMatrix.mulVec3(this._lights[i]._position);
this._lightsTransformedPositions[ii + 3] = 1;
}
this._pointLightsTransformedPositions[ii] = tp.x;
this._pointLightsTransformedPositions[ii + 1] = tp.y;
this._pointLightsTransformedPositions[ii + 2] = tp.z;
this._lightsTransformedPositions[ii] = tp.x;
this._lightsTransformedPositions[ii + 1] = tp.y;
this._lightsTransformedPositions[ii + 2] = tp.z;
}
};

View File

@ -22,7 +22,7 @@ goog.addDependency('../../../og/src/og/control/mouseNavigation.js', ['og.control
goog.addDependency('../../../og/src/og/control/showFps.js', ['og.control.ShowFps'], ['og.control.BaseControl', 'og.inheritance'], false);
goog.addDependency('../../../og/src/og/control/simpleNavigation.js', ['og.control.SimpleNavigation'], ['og.control.BaseControl', 'og.inheritance', 'og.input'], false);
goog.addDependency('../../../og/src/og/control/spinNavigation.js', ['og.SpinNavigation'], ['og.bv.Sphere', 'og.control.BaseControl', 'og.inheritance', 'og.math', 'og.math.Matrix4', 'og.math.Quaternion', 'og.math.Ray', 'og.math.Vector3'], false);
goog.addDependency('../../../og/src/og/control/sun.js', ['og.control.Sun'], ['og.astro.earth', 'og.control.BaseControl', 'og.inheritance', 'og.light.PointLight', 'og.math.Quaternion'], false);
goog.addDependency('../../../og/src/og/control/sun.js', ['og.control.Sun'], ['og.astro.earth', 'og.control.BaseControl', 'og.inheritance', 'og.light.LightSource', 'og.math.Quaternion'], false);
goog.addDependency('../../../og/src/og/control/toggleWireframe.js', ['og.control.ToggleWireframe'], ['og.inheritance', 'og.input', 'og.webgl'], false);
goog.addDependency('../../../og/src/og/control/touchNavigation.js', ['og.control.TouchNavigation'], ['og.bv.Sphere', 'og.control.BaseControl', 'og.inheritance', 'og.math', 'og.math.Matrix4', 'og.math.Pixel', 'og.math.Quaternion', 'og.math.Ray', 'og.math.Vector3'], false);
goog.addDependency('../../../og/src/og/control/zoomControl.js', ['og.control.ZoomControl'], ['og.control.BaseControl', 'og.control.MouseNavigation', 'og.inheritance'], false);
@ -54,7 +54,7 @@ goog.addDependency('../../../og/src/og/layer/layer.js', ['og.layer', 'og.layer.L
goog.addDependency('../../../og/src/og/layer/vector.js', ['og.layer.Vector'], ['og.Entity', 'og.EntityCollection', 'og.LonLat', 'og.QueueArray', 'og.inheritance', 'og.math', 'og.quadTree', 'og.quadTree.EntityCollectionQuadNode'], false);
goog.addDependency('../../../og/src/og/layer/wms.js', ['og.layer.WMS'], ['og.inheritance', 'og.layer.XYZ'], false);
goog.addDependency('../../../og/src/og/layer/xyz.js', ['og.layer.XYZ'], ['og.inheritance', 'og.layer.Layer', 'og.proj.EPSG3857', 'og.quadTree', 'og.utils'], false);
goog.addDependency('../../../og/src/og/light/pointLight.js', ['og.light.PointLight'], ['og.math.Vector3'], false);
goog.addDependency('../../../og/src/og/light/lightSource.js', ['og.light.LightSource'], ['og.math.Vector3'], false);
goog.addDependency('../../../og/src/og/lonlat.js', ['og.LonLat'], ['og.mercator'], false);
goog.addDependency('../../../og/src/og/math/coder.js', ['og.math.coder'], ['og.math', 'og.math.Vector4'], false);
goog.addDependency('../../../og/src/og/math/math.js', ['og.math'], [], false);
@ -69,7 +69,7 @@ goog.addDependency('../../../og/src/og/math/vector4.js', ['og.math.Vector4'], ['
goog.addDependency('../../../og/src/og/mercator.js', ['og.mercator'], [], false);
goog.addDependency('../../../og/src/og/node/axes.js', ['og.node.Axes'], ['og.inheritance', 'og.node.RenderNode'], false);
goog.addDependency('../../../og/src/og/node/node.js', ['og.node.Node'], [], false);
goog.addDependency('../../../og/src/og/node/planet.js', ['og.node.Planet'], ['og.Extent', 'og.GeoImage', 'og.ImageCanvas', 'og.LonLat', 'og.PlanetCamera', 'og.PlanetSegmentHelper', 'og.bv.Sphere', 'og.inheritance', 'og.layer', 'og.light.PointLight', 'og.math', 'og.math.Matrix4', 'og.math.Ray', 'og.math.Vector2', 'og.math.Vector3', 'og.math.coder', 'og.mercator', 'og.node.RenderNode', 'og.planetSegment', 'og.planetSegment.GeoImageTileCreatorQueue', 'og.planetSegment.NormalMapCreatorQueue', 'og.planetSegment.Segment', 'og.planetSegment.SegmentWGS84', 'og.proj.EPSG4326', 'og.quadTree', 'og.quadTree.QuadNode', 'og.shaderProgram.heightPicking', 'og.shaderProgram.overlays_nl', 'og.shaderProgram.overlays_wl', 'og.shaderProgram.single_nl', 'og.shaderProgram.single_wl', 'og.webgl', 'og.webgl.Framebuffer'], false);
goog.addDependency('../../../og/src/og/node/planet.js', ['og.node.Planet'], ['og.Extent', 'og.GeoImage', 'og.ImageCanvas', 'og.LonLat', 'og.PlanetCamera', 'og.PlanetSegmentHelper', 'og.bv.Sphere', 'og.inheritance', 'og.layer', 'og.light.LightSource', 'og.math', 'og.math.Matrix4', 'og.math.Ray', 'og.math.Vector2', 'og.math.Vector3', 'og.math.coder', 'og.mercator', 'og.node.RenderNode', 'og.planetSegment', 'og.planetSegment.GeoImageTileCreatorQueue', 'og.planetSegment.NormalMapCreatorQueue', 'og.planetSegment.Segment', 'og.planetSegment.SegmentWGS84', 'og.proj.EPSG4326', 'og.quadTree', 'og.quadTree.QuadNode', 'og.shaderProgram.heightPicking', 'og.shaderProgram.overlays_nl', 'og.shaderProgram.overlays_wl', 'og.shaderProgram.single_nl', 'og.shaderProgram.single_wl', 'og.webgl', 'og.webgl.Framebuffer'], false);
goog.addDependency('../../../og/src/og/node/planetAtmosphere.js', ['og.node.PlanetAtmosphere'], ['og.inheritance', 'og.shaderProgram.atmosphereSpace', 'og.shaderProgram.overlaysAtmosphere_wl', 'og.shaderProgram.overlays_nl', 'og.shaderProgram.singleAtmosphere_wl', 'og.shaderProgram.single_nl', 'og.shape.Icosphere'], false);
goog.addDependency('../../../og/src/og/node/renderNode.js', ['og.node.RenderNode'], ['og.Events', 'og.inheritance', 'og.math.Matrix4', 'og.math.Vector3', 'og.node.Node', 'og.utils.FontAtlas', 'og.utils.TextureAtlas', 'og.webgl'], false);
goog.addDependency('../../../og/src/og/node/skyBox.js', ['og.node.SkyBox'], ['og.inheritance', 'og.node.RenderNode', 'og.shaderProgram.skybox'], false);

View File

@ -39,9 +39,9 @@ og.shaderProgram.overlays_wl = function () {
texBiasArr: { type: og.shaderProgram.types.VEC3 },
tcolorArr: { type: og.shaderProgram.types.VEC4 },
numTex: { type: og.shaderProgram.types.INT },
pointLightsPositions: { type: og.shaderProgram.types.VEC3 },
pointLightsParamsv: { type: og.shaderProgram.types.VEC3 },
pointLightsParamsf: { type: og.shaderProgram.types.FLOAT },
lightsPositions: { type: og.shaderProgram.types.VEC3 },
lightsParamsv: { type: og.shaderProgram.types.VEC3 },
lightsParamsf: { type: og.shaderProgram.types.FLOAT },
uGeoImage: { type: og.shaderProgram.types.SAMPLER2D },
geoImageTexBias: { type: og.shaderProgram.types.VEC3 },
uGlobalTextureCoord: { type: og.shaderProgram.types.VEC4 },
@ -69,9 +69,9 @@ og.shaderProgram.overlaysAtmosphere_wl = function () {
texBiasArr: { type: og.shaderProgram.types.VEC3 },
tcolorArr: { type: og.shaderProgram.types.VEC4 },
numTex: { type: og.shaderProgram.types.INT },
pointLightsPositions: { type: og.shaderProgram.types.VEC3 },
pointLightsParamsv: { type: og.shaderProgram.types.VEC3 },
pointLightsParamsf: { type: og.shaderProgram.types.FLOAT },
lightsPositions: { type: og.shaderProgram.types.VEC3 },
lightsParamsv: { type: og.shaderProgram.types.VEC3 },
lightsParamsf: { type: og.shaderProgram.types.FLOAT },
uGeoImage: { type: og.shaderProgram.types.SAMPLER2D },
geoImageTexBias: { type: og.shaderProgram.types.VEC3 },
uGlobalTextureCoord: { type: og.shaderProgram.types.VEC4 },
@ -93,9 +93,9 @@ og.shaderProgram.overlaysAtmosphere_wl = function () {
fScaleDepth: { type: og.shaderProgram.types.FLOAT },
fScaleOverScaleDepth: { type: og.shaderProgram.types.FLOAT },
pointLightsPositions: { type: og.shaderProgram.types.VEC4 },
pointLightsParamsv: { type: og.shaderProgram.types.VEC3 },
pointLightsParamsf: { type: og.shaderProgram.types.FLOAT }
lightsPositions: { type: og.shaderProgram.types.VEC4 },
lightsParamsv: { type: og.shaderProgram.types.VEC3 },
lightsParamsf: { type: og.shaderProgram.types.FLOAT }
},
attributes: {
aVertexPosition: { type: og.shaderProgram.types.VEC3, enableArray: true },

View File

@ -14,9 +14,9 @@ og.shaderProgram.shape_wl = function () {
modelMatrix: { type: og.shaderProgram.types.MAT4 },
normalMatrix: { type: og.shaderProgram.types.MAT4 },
pointLightsPositions: { type: og.shaderProgram.types.VEC4 },
pointLightsParamsv: { type: og.shaderProgram.types.VEC3 },
pointLightsParamsf: { type: og.shaderProgram.types.FLOAT },
lightsPositions: { type: og.shaderProgram.types.VEC4 },
lightsParamsv: { type: og.shaderProgram.types.VEC3 },
lightsParamsf: { type: og.shaderProgram.types.FLOAT },
uColor: { type: og.shaderProgram.types.VEC4 },
uSampler: { type: og.shaderProgram.types.SAMPLER2D }

View File

@ -39,9 +39,9 @@ og.shaderProgram.single_wl = function () {
uGlobalTextureCoord: { type: og.shaderProgram.types.VEC4 },
uNightImage: { type: og.shaderProgram.types.SAMPLER2D },
uSpecularImage: { type: og.shaderProgram.types.SAMPLER2D },
pointLightsPositions: { type: og.shaderProgram.types.VEC4 },
pointLightsParamsv: { type: og.shaderProgram.types.VEC3 },
pointLightsParamsf: { type: og.shaderProgram.types.FLOAT }
lightsPositions: { type: og.shaderProgram.types.VEC4 },
lightsParamsv: { type: og.shaderProgram.types.VEC3 },
lightsParamsf: { type: og.shaderProgram.types.FLOAT }
},
attributes: {
aVertexPosition: { type: og.shaderProgram.types.VEC3, enableArray: true },
@ -83,9 +83,9 @@ og.shaderProgram.singleAtmosphere_wl = function () {
fScaleDepth: { type: og.shaderProgram.types.FLOAT },
fScaleOverScaleDepth: { type: og.shaderProgram.types.FLOAT },
pointLightsPositions: { type: og.shaderProgram.types.VEC4 },
pointLightsParamsv: { type: og.shaderProgram.types.VEC3 },
pointLightsParamsf: { type: og.shaderProgram.types.FLOAT }
lightsPositions: { type: og.shaderProgram.types.VEC4 },
lightsParamsv: { type: og.shaderProgram.types.VEC3 },
lightsParamsf: { type: og.shaderProgram.types.FLOAT }
},
attributes: {
aVertexPosition: { type: og.shaderProgram.types.VEC3, enableArray: true },

View File

@ -2,9 +2,9 @@ precision highp float;
#define MAX_POINT_LIGHTS 1
uniform vec3 pointLightsPositions[MAX_POINT_LIGHTS];
uniform vec3 pointLightsParamsv[MAX_POINT_LIGHTS * 3];
uniform float pointLightsParamsf[MAX_POINT_LIGHTS];
uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
uniform vec3 lightsParamsv[MAX_POINT_LIGHTS * 3];
uniform float lightsParamsf[MAX_POINT_LIGHTS];
#define MAX_TEX 4
@ -29,7 +29,7 @@ void main(void)
vec4 nm = texture2D(uNormalMap, vTextureCoord.zw);
vec3 normal = normalize(v_NMatrix * ((nm.xyz - 0.5) * 2.0));
vec3 lightDirection = normalize(pointLightsPositions[0] - vPosition.xyz);
vec3 lightDirection = normalize(lightsPositions[0] - vPosition.xyz);
//float distance = length(dir);
//float attenuation = 1.0/(1.0+0.1*distance+0.01*distance*distance);
vec3 eyeDirection = normalize(-vPosition.xyz);
@ -37,11 +37,11 @@ void main(void)
vec4 nightImageColor = texture2D( uNightImage, vGlobalTextureCoord.st );
float shininess = texture2D( uSpecularImage, vGlobalTextureCoord.st ).r * 255.0;
float specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), pointLightsParamsf[0]);
float specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), lightsParamsf[0]);
float diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
vec3 spec = pointLightsParamsv[2] * specularLightWeighting * shininess;
vec3 lightWeighting = pointLightsParamsv[0] + pointLightsParamsv[1] * diffuseLightWeighting + spec;
vec3 spec = lightsParamsv[2] * specularLightWeighting * shininess;
vec3 lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + spec;
vec3 night = 10.0 * vec3(0.58, 0.48, 0.25) * (0.3 - diffuseLightWeighting) * nightImageColor.rgb;

View File

@ -2,9 +2,9 @@ precision highp float;
#define MAX_POINT_LIGHTS 1
uniform vec4 pointLightsPositions[MAX_POINT_LIGHTS];
uniform vec3 pointLightsParamsv[MAX_POINT_LIGHTS * 3];
uniform float pointLightsParamsf[MAX_POINT_LIGHTS];
uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
uniform vec3 lightsParamsv[MAX_POINT_LIGHTS * 3];
uniform float lightsParamsf[MAX_POINT_LIGHTS];
#define MAX_TEX 4
@ -29,7 +29,7 @@ void main(void)
vec4 nm = texture2D(uNormalMap, vTextureCoord.zw);
vec3 normal = normalize(v_NMatrix * ((nm.xyz - 0.5) * 2.0));
vec3 lightDirection = normalize(pointLightsPositions[0].xyz - vPosition.xyz * pointLightsPositions[0].w);
vec3 lightDirection = normalize(lightsPositions[0].xyz - vPosition.xyz * lightsPositions[0].w);
//float distance = length(dir);
//float attenuation = 1.0/(1.0+0.1*distance+0.01*distance*distance);
vec3 eyeDirection = normalize(-vPosition.xyz);
@ -37,11 +37,11 @@ void main(void)
vec4 nightImageColor = texture2D( uNightImage, vGlobalTextureCoord.st );
float shininess = texture2D( uSpecularImage, vGlobalTextureCoord.st ).r * 255.0;
float specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), pointLightsParamsf[0]);
float specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), lightsParamsf[0]);
float diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
vec3 spec = pointLightsParamsv[2] * specularLightWeighting * shininess;
vec3 lightWeighting = pointLightsParamsv[0] + pointLightsParamsv[1] * diffuseLightWeighting + spec;
vec3 spec = lightsParamsv[2] * specularLightWeighting * shininess;
vec3 lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + spec;
vec3 night = 10.0 * vec3(0.58, 0.48, 0.25) * (0.3 - diffuseLightWeighting) * nightImageColor.rgb;

View File

@ -9,10 +9,10 @@ uniform sampler2D uSampler;
#define MAX_POINT_LIGHTS 1
uniform int pointLightsQuantity;
uniform vec4 pointLightsPositions[MAX_POINT_LIGHTS];
uniform vec3 pointLightsParamsv[MAX_POINT_LIGHTS * 3];
uniform float pointLightsParamsf[MAX_POINT_LIGHTS];
uniform int lightsQuantity;
uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
uniform vec3 lightsParamsv[MAX_POINT_LIGHTS * 3];
uniform float lightsParamsf[MAX_POINT_LIGHTS];
void main(void) {
@ -26,15 +26,15 @@ void main(void) {
//i=0
lightDirection = normalize(pointLightsPositions[0].xyz - vPosition.xyz * pointLightsPositions[0].w);
lightDirection = normalize(lightsPositions[0].xyz - vPosition.xyz * lightsPositions[0].w);
//float distance = length(dir);
//float attenuation = 1.0/(1.0+0.1*distance+0.01*distance*distance);
normal = normalize(vNormal);
eyeDirection = normalize(-vPosition.xyz);
reflectionDirection = reflect(-lightDirection, normal);
specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), pointLightsParamsf[0]);
specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), lightsParamsf[0]);
diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
lightWeighting = pointLightsParamsv[0] + pointLightsParamsv[1] * diffuseLightWeighting + pointLightsParamsv[2] * specularLightWeighting;
lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + lightsParamsv[2] * specularLightWeighting;
vec4 cc = texture2D( uSampler, vTextureCoord.st );
//cc.a = 0.5 + length(cc.rgb);

View File

@ -5,9 +5,9 @@ uniform sampler2D uNormalMap;
#define MAX_POINT_LIGHTS 1
uniform vec4 pointLightsPositions[MAX_POINT_LIGHTS];
uniform vec3 pointLightsParamsv[MAX_POINT_LIGHTS * 3];
uniform float pointLightsParamsf[MAX_POINT_LIGHTS];
uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
uniform vec3 lightsParamsv[MAX_POINT_LIGHTS * 3];
uniform float lightsParamsf[MAX_POINT_LIGHTS];
uniform mat3 normalMatrix;
uniform sampler2D uGeoImage;
uniform sampler2D uNightImage;
@ -24,7 +24,7 @@ void main(void) {
vec3 normal = normalize(normalMatrix * ((texture2D(uNormalMap, vTextureCoord.zw).rgb - 0.5) * 2.0));
vec3 lightDirection = normalize(pointLightsPositions[0].xyz - vPosition.xyz * pointLightsPositions[0].w);
vec3 lightDirection = normalize(lightsPositions[0].xyz - vPosition.xyz * lightsPositions[0].w);
vec3 eyeDirection = normalize(-vPosition.xyz);
vec3 reflectionDirection = reflect(-lightDirection, normal);
@ -34,10 +34,10 @@ void main(void) {
vec4 nightImageColor = texture2D( uNightImage, vGlobalTextureCoord.st );
float shininess = texture2D( uSpecularImage, vGlobalTextureCoord.st ).r * 255.0;
float specularLightWeighting = pow( max( dot(reflectionDirection, eyeDirection), 0.0), pointLightsParamsf[0]);
float specularLightWeighting = pow( max( dot(reflectionDirection, eyeDirection), 0.0), lightsParamsf[0]);
float diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
vec3 spec = pointLightsParamsv[2] * specularLightWeighting * shininess;
vec3 lightWeighting = pointLightsParamsv[0] + pointLightsParamsv[1] * diffuseLightWeighting * c0 + spec;
vec3 spec = lightsParamsv[2] * specularLightWeighting * shininess;
vec3 lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting * c0 + spec;
vec3 night = 10.0 * vec3(0.58, 0.48, 0.25) * (0.31 - length(c0)) * nightImageColor.rgb;

View File

@ -5,9 +5,9 @@ uniform sampler2D uNormalMap;
#define MAX_POINT_LIGHTS 1
uniform vec4 pointLightsPositions[MAX_POINT_LIGHTS];
uniform vec3 pointLightsParamsv[MAX_POINT_LIGHTS * 3];
uniform float pointLightsParamsf[MAX_POINT_LIGHTS];
uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
uniform vec3 lightsParamsv[MAX_POINT_LIGHTS * 3];
uniform float lightsParamsf[MAX_POINT_LIGHTS];
uniform mat3 normalMatrix;
uniform sampler2D uGeoImage;
uniform sampler2D uNightImage;
@ -22,7 +22,7 @@ void main(void) {
vec3 normal = normalize(normalMatrix * ((texture2D(uNormalMap, vTextureCoord.zw).rgb - 0.5) * 2.0));
vec3 lightDirection = normalize(pointLightsPositions[0].xyz - vPosition.xyz*pointLightsPositions[0].w);
vec3 lightDirection = normalize(lightsPositions[0].xyz - vPosition.xyz*lightsPositions[0].w);
//float distance = length(dir);
//float attenuation = 1.0/(1.0+0.1*distance+0.01*distance*distance);
vec3 eyeDirection = normalize(-vPosition.xyz);
@ -34,10 +34,10 @@ void main(void) {
float shininess = texture2D( uSpecularImage, vGlobalTextureCoord.st ).r * 255.0;
float specularLightWeighting = pow( max( dot(reflectionDirection, eyeDirection), 0.0), pointLightsParamsf[0]);
float specularLightWeighting = pow( max( dot(reflectionDirection, eyeDirection), 0.0), lightsParamsf[0]);
float diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
vec3 spec = pointLightsParamsv[2] * specularLightWeighting * shininess;
vec3 lightWeighting = pointLightsParamsv[0] + pointLightsParamsv[1] * diffuseLightWeighting + spec;
vec3 spec = lightsParamsv[2] * specularLightWeighting * shininess;
vec3 lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + spec;
vec3 night = 10.0 * vec3(0.58, 0.48, 0.25) * (0.3 - diffuseLightWeighting) * nightImageColor.rgb;

View File

@ -187,9 +187,9 @@ og.shape.BaseShape.prototype.draw = function () {
sh.activate();
gl.uniform4fv(shu.pointLightsPositions._pName, rn._pointLightsTransformedPositions);
gl.uniform3fv(shu.pointLightsParamsv._pName, rn._pointLightsParamsv);
gl.uniform1fv(shu.pointLightsParamsf._pName, rn._pointLightsParamsf);
gl.uniform4fv(shu.lightsPositions._pName, rn._lightsTransformedPositions);
gl.uniform3fv(shu.lightsParamsv._pName, rn._lightsParamsv);
gl.uniform1fv(shu.lightsParamsf._pName, rn._lightsParamsf);
gl.uniformMatrix4fv(shu.projectionMatrix._pName, false, r.activeCamera._projectionMatrix._m);
gl.uniformMatrix4fv(shu.viewMatrix._pName, false, r.activeCamera._viewMatrix._m);
gl.uniformMatrix3fv(shu.normalMatrix._pName, false, r.activeCamera._normalMatrix._m);