Skip to content

Commit

Permalink
v1.6.0
Browse files Browse the repository at this point in the history
Former-commit-id: 08f7f83
  • Loading branch information
deltakosh committed Nov 5, 2013
1 parent 2329607 commit 1861a49
Show file tree
Hide file tree
Showing 45 changed files with 622 additions and 242 deletions.
4 changes: 4 additions & 0 deletions Babylon/Materials/textures/babylon.texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
BABYLON.Texture.prototype = Object.create(BABYLON.BaseTexture.prototype);

// Constants
BABYLON.Texture.NEAREST_SAMPLINGMODE = 1;
BABYLON.Texture.BILINEAR_SAMPLINGMODE = 2;
BABYLON.Texture.TRILINEAR_SAMPLINGMODE = 3;

BABYLON.Texture.EXPLICIT_MODE = 0;
BABYLON.Texture.SPHERICAL_MODE = 1;
BABYLON.Texture.PLANAR_MODE = 2;
Expand Down
4 changes: 2 additions & 2 deletions Babylon/PostProcess/babylon.blackAndWhitePostProcess.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var BABYLON = BABYLON || {};

(function () {
BABYLON.BlackAndWhitePostProcess = function (name, ratio, camera) {
BABYLON.PostProcess.call(this, name, "blackAndWhite", null, null, ratio, camera);
BABYLON.BlackAndWhitePostProcess = function (name, ratio, camera, samplingMode) {
BABYLON.PostProcess.call(this, name, "blackAndWhite", null, null, ratio, camera, samplingMode);
};

BABYLON.BlackAndWhitePostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
Expand Down
9 changes: 7 additions & 2 deletions Babylon/PostProcess/babylon.blurPostProcess.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
var BABYLON = BABYLON || {};

(function () {
BABYLON.BlurPostProcess = function (name, direction, blurWidth, ratio, camera) {
BABYLON.PostProcess.call(this, name, "blur", ["screenSize", "direction", "blurWidth"], null, ratio, camera);
BABYLON.BlurPostProcess = function (name, direction, blurWidth, ratio, camera, samplingMode) {

if (samplingMode === undefined) {
samplingMode = BABYLON.Texture.BILINEAR_SAMPLINGMODE;
}

BABYLON.PostProcess.call(this, name, "blur", ["screenSize", "direction", "blurWidth"], null, ratio, camera, samplingMode);

this.direction = direction;
this.blurWidth = blurWidth;
Expand Down
16 changes: 16 additions & 0 deletions Babylon/PostProcess/babylon.convolutionPostProcess.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var BABYLON = BABYLON || {};

(function () {
BABYLON.ConvolutionPostProcess = function (name, kernelMatrix, ratio, camera, samplingMode) {
BABYLON.PostProcess.call(this, name, "convolution", ["kernelMatrix"], null, ratio, camera, samplingMode);

this.kernelMatrix = kernelMatrix;
var that = this;
this.onApply = function (effect) {
effect.setMatrix("kernelMatrix", that.kernelMatrix);
};
};

BABYLON.ConvolutionPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);

})();
20 changes: 10 additions & 10 deletions Babylon/PostProcess/babylon.fxaaPostProcess.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var BABYLON = BABYLON || {};

(function () {
BABYLON.FxaaPostProcess = function (name, ratio, camera) {
BABYLON.PostProcess.call(this, name, "fxaa", ["texelSize"], null, ratio, camera);
};

BABYLON.FxaaPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
var BABYLON = BABYLON || {};

(function () {
BABYLON.FxaaPostProcess = function (name, ratio, camera, samplingMode) {
BABYLON.PostProcess.call(this, name, "fxaa", ["texelSize"], null, ratio, camera, samplingMode);
};

BABYLON.FxaaPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
BABYLON.FxaaPostProcess.prototype.onSizeChanged = function () {
this.texelWidth = 1.0 / this.width;
this.texelHeight = 1.0 / this.height;
};
};
BABYLON.FxaaPostProcess.prototype.onApply = function (effect) {
effect.setFloat2("texelSize", this.texelWidth, this.texelHeight);
};
};
})();
4 changes: 2 additions & 2 deletions Babylon/PostProcess/babylon.passPostProcess.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var BABYLON = BABYLON || {};

(function () {
BABYLON.PassPostProcess = function (name, ratio, camera) {
BABYLON.PostProcess.call(this, name, "pass", null, null, ratio, camera);
BABYLON.PassPostProcess = function (name, ratio, camera, samplingMode) {
BABYLON.PostProcess.call(this, name, "pass", null, null, ratio, camera, samplingMode);
};

BABYLON.PassPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
Expand Down
136 changes: 69 additions & 67 deletions Babylon/PostProcess/babylon.postProcess.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
var BABYLON = BABYLON || {};

(function () {
BABYLON.PostProcess = function (name, fragmentUrl, parameters, samplers, ratio, camera, samplingMode) {
this.name = name;
this._camera = camera;
this._scene = camera.getScene();
camera.postProcesses.push(this);
this._engine = this._scene.getEngine();
this._renderRatio = ratio;
this.width = -1;
this.height = -1;
this.renderTargetSamplingMode = samplingMode ? samplingMode : BABYLON.TextureSamplingModes.NEAREST;

samplers = samplers || [];
samplers.push("textureSampler");

this._effect = this._engine.createEffect({ vertex: "postprocess", fragment: fragmentUrl },
["position"],
parameters || [],
samplers, "");
};

// Methods
BABYLON.PostProcess.prototype.onApply = null;
BABYLON.PostProcess.prototype._onDispose = null;
BABYLON.PostProcess.prototype.onSizeChanged = null;
BABYLON.PostProcess.prototype.activate = function () {
var desiredWidth = this._engine._renderingCanvas.width * this._renderRatio;
var desiredHeight = this._engine._renderingCanvas.height * this._renderRatio;
var BABYLON = BABYLON || {};

(function () {
BABYLON.PostProcess = function (name, fragmentUrl, parameters, samplers, ratio, camera, samplingMode) {
this.name = name;
this._camera = camera;
this._scene = camera.getScene();
camera.postProcesses.push(this);
this._engine = this._scene.getEngine();
this._renderRatio = ratio;
this.width = -1;
this.height = -1;
this.renderTargetSamplingMode = samplingMode ? samplingMode : BABYLON.Texture.NEAREST_SAMPLINGMODE;

samplers = samplers || [];
samplers.push("textureSampler");

this._effect = this._engine.createEffect({ vertex: "postprocess", fragment: fragmentUrl },
["position"],
parameters || [],
samplers, "");
};

// Methods
BABYLON.PostProcess.prototype.onApply = null;
BABYLON.PostProcess.prototype._onDispose = null;
BABYLON.PostProcess.prototype.onSizeChanged = null;
BABYLON.PostProcess.prototype.activate = function () {
var desiredWidth = this._engine._renderingCanvas.width * this._renderRatio;
var desiredHeight = this._engine._renderingCanvas.height * this._renderRatio;
if (this.width !== desiredWidth || this.height !== desiredHeight) {
if (this._texture) {
this._engine._releaseTexture(this._texture);
Expand All @@ -39,45 +39,47 @@
if (this.onSizeChanged) {
this.onSizeChanged();
}
}
this._engine.bindFramebuffer(this._texture);
};

BABYLON.PostProcess.prototype.apply = function () {
// Check
if (!this._effect.isReady())
return null;

// Render
this._engine.enableEffect(this._effect);
this._engine.setState(false);
this._engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);

// Texture
this._effect._bindTexture("textureSampler", this._texture);

// Parameters
if (this.onApply) {
this.onApply(this._effect);
}

return this._effect;
};

BABYLON.PostProcess.prototype.dispose = function () {
if (this._onDispose) {
this._onDispose();
}
}
this._engine.bindFramebuffer(this._texture);
};

BABYLON.PostProcess.prototype.apply = function () {
// Check
if (!this._effect.isReady())
return null;

// States
this._engine.enableEffect(this._effect);
this._engine.setState(false);
this._engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
this._engine.setDepthBuffer(false);
this._engine.setDepthWrite(false);

// Texture
this._effect._bindTexture("textureSampler", this._texture);

// Parameters
if (this.onApply) {
this.onApply(this._effect);
}

return this._effect;
};

BABYLON.PostProcess.prototype.dispose = function () {
if (this._onDispose) {
this._onDispose();
}
if (this._texture) {
this._engine._releaseTexture(this._texture);
this._texture = null;
}

var index = this._camera.postProcesses.indexOf(this);
this._camera.postProcesses.splice(index, 1);
this._texture = null;
}

var index = this._camera.postProcesses.indexOf(this);
this._camera.postProcesses.splice(index, 1);
if (index == 0 && this._camera.postProcesses.length > 0) {
this._camera.postProcesses[0].width = -1; // invalidate frameBuffer to hint the postprocess to create a depth buffer
}
};

}
};

})();
9 changes: 3 additions & 6 deletions Babylon/PostProcess/babylon.postProcessManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,13 @@
if (effect) {
// VBOs
engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect);
// some effect activation have a side effect of putting depthBuffer / dephWrite on
// so we force it off at each post process pass
engine.setDepthBuffer(false);
engine.setDepthWrite(false);

// Draw order
engine.draw(true, 0, 6);
}
}
// reenable depth buffer


// Restore depth buffer
engine.setDepthBuffer(true);
engine.setDepthWrite(true);
};
Expand Down
4 changes: 2 additions & 2 deletions Babylon/PostProcess/babylon.refractionPostProcess.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var BABYLON = BABYLON || {};

(function () {
BABYLON.RefractionPostProcess = function (name, refractionTextureUrl, color, depth, colorLevel, ratio, camera) {
BABYLON.PostProcess.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], ratio, camera);
BABYLON.RefractionPostProcess = function (name, refractionTextureUrl, color, depth, colorLevel, ratio, camera, samplingMode) {
BABYLON.PostProcess.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], ratio, camera, samplingMode);

this.color = color;
this.depth = depth;
Expand Down
17 changes: 17 additions & 0 deletions Babylon/Shaders/convolution.fragment.fx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifdef GL_ES
precision mediump float;
#endif

// Samplers
varying vec2 vUV;
uniform sampler2D textureSampler;

uniform mat4 kernelMatrix;

void main(void)
{
vec3 baseColor = texture2D(textureSampler, vUV).rgb;
vec3 updatedColor = (kernelMatrix * vec4(baseColor, 1.0)).rgb;

gl_FragColor = vec4(updatedColor, 1.0);
}
2 changes: 1 addition & 1 deletion Babylon/Shaders/fxaa.fragment.fx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define FXAA_REDUCE_MIN (1.0/128.0)
#define FXAA_REDUCE_MUL (1.0/8.0)
#define FXAA_SPAN_MAX 8.0
//#define texelSize vec2(1.0/1600, 1.0/900)

varying vec2 vUV;
uniform sampler2D textureSampler;
uniform vec2 texelSize;
Expand Down
14 changes: 4 additions & 10 deletions Babylon/babylon.engine.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
var BABYLON = BABYLON || {};

(function () {
BABYLON.TextureSamplingModes = {
NEAREST : 1,
BILINEAR: 2,
TRILINEAR: 3,
DEFAULT : 3
};
BABYLON.Engine = function (canvas, antialias) {
this._renderingCanvas = canvas;

Expand Down Expand Up @@ -719,7 +713,7 @@
// in the same way, generateDepthBuffer is defaulted to true
var generateMipMaps = false;
var generateDepthBuffer = true;
var samplingMode = BABYLON.TextureSamplingModes.DEFAULT;
var samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
if (options !== undefined) {
generateMipMaps = options.generateMipMaps === undefined ? options : options.generateMipmaps;
generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
Expand All @@ -738,14 +732,14 @@
var height = size.height || size;
var magFilter = gl.NEAREST;
var minFilter = gl.NEAREST;
if (samplingMode === BABYLON.TextureSamplingModes.BILINEAR) {
if (samplingMode === BABYLON.Texture.BILINEAR_SAMPLINGMODE) {
magFilter = gl.LINEAR;
if (generateMipMaps) {
minFilter = gl.LINEAR_MIPMAP_NEAREST;
} else {
minFilter = gl.LINEAR;
}
} else if (samplingMode === BABYLON.TextureSamplingModes.TRILINEAR) {
} else if (samplingMode === BABYLON.Texture.TRILINEAR_SAMPLINGMODE) {
magFilter = gl.LINEAR;
if (generateMipMaps) {
minFilter = gl.LINEAR_MIPMAP_LINEAR;
Expand Down Expand Up @@ -888,7 +882,7 @@
this._gl.bindTexture(this._gl.TEXTURE_CUBE_MAP, null);
this._activeTexturesCache[channel] = null;
}
// hmm vilain leak !

var index = this._loadedTexturesCache.indexOf(texture);
if (index !== -1) {
this._loadedTexturesCache.splice(index, 1);
Expand Down
2 changes: 1 addition & 1 deletion Babylon/jscompaktor.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
JSKompactor.exe /i:"Babylon/Tools/babylon.math.js,Babylon/Tools/babylon.tools.js,Babylon/babylon.engine.js,Babylon/babylon.node.js,Babylon/Culling/babylon.boundingSphere.js,Babylon/Culling/babylon.boundingBox.js,Babylon/Culling/babylon.boundingInfo.js,Babylon/Lights/babylon.light.js,Babylon/Lights/babylon.pointLight.js,Babylon/Lights/babylon.spotlight.js,Babylon/Lights/babylon.directionalLight.js,Babylon/Lights//Shadows/babylon.shadowGenerator.js,Babylon/Lights/babylon.hemisphericLight.js,Babylon/Collisions/babylon.collider.js,Babylon/Cameras/babylon.camera.js,Babylon/Cameras/babylon.freeCamera.js,Babylon/Cameras/babylon.touchCamera.js,Babylon/Cameras/babylon.deviceOrientationCamera.js,Babylon/Cameras/babylon.arcRotateCamera.js,Babylon/babylon.scene.js,Babylon/Mesh/babylon.vertexBuffer.js,Babylon/Mesh/babylon.mesh.js,Babylon/Mesh/babylon.subMesh.js,Babylon/Materials/textures/babylon.baseTexture.js,Babylon/Rendering/babylon.renderingGroup.js,Babylon/Rendering/babylon.renderingManager.js,Babylon/Materials/textures/babylon.texture.js,Babylon/Materials/textures/babylon.cubeTexture.js,Babylon/Materials/textures/babylon.renderTargetTexture.js,Babylon/Materials/textures/babylon.mirrorTexture.js,Babylon/Materials/textures/babylon.dynamicTexture.js,Babylon/Materials/textures/babylon.videoTexture.js,Babylon/Materials/babylon.effect.js,Babylon/Materials/babylon.material.js,Babylon/Materials/babylon.standardMaterial.js,Babylon/Materials/babylon.multiMaterial.js,Babylon/Tools/babylon.database.js,Babylon/Tools/babylon.sceneLoader.js,Babylon/Sprites/babylon.spriteManager.js,Babylon/Sprites/babylon.sprite.js,Babylon/Layer/babylon.layer.js,Babylon/Particles/babylon.particle.js,Babylon/Particles/babylon.particleSystem.js,Babylon/Animations/babylon.animation.js,Babylon/Animations/babylon.animatable.js,Babylon/Culling/Octrees/babylon.octree.js,Babylon/Culling/Octrees/babylon.octreeBlock.js,Babylon/Bones/babylon.bone.js,Babylon/Bones/babylon.skeleton.js,Babylon/PostProcess/babylon.postProcess.js,Babylon/PostProcess/babylon.postProcessManager.js,Babylon/PostProcess/babylon.passPostProcess.js,Babylon/PostProcess/babylon.blurPostProcess.js,Babylon/PostProcess/babylon.fxaaPostProcess.js,Babylon/PostProcess/babylon.refractionPostProcess.js,Babylon/PostProcess/babylon.blackAndWhitePostProcess.js" /o:"..\babylon.js" /w:".." /s:"Babylon/Shaders"
JSKompactor.exe /i:"Babylon/Tools/babylon.math.js,Babylon/Tools/babylon.tools.js,Babylon/babylon.engine.js,Babylon/babylon.node.js,Babylon/Culling/babylon.boundingSphere.js,Babylon/Culling/babylon.boundingBox.js,Babylon/Culling/babylon.boundingInfo.js,Babylon/Lights/babylon.light.js,Babylon/Lights/babylon.pointLight.js,Babylon/Lights/babylon.spotlight.js,Babylon/Lights/babylon.directionalLight.js,Babylon/Lights//Shadows/babylon.shadowGenerator.js,Babylon/Lights/babylon.hemisphericLight.js,Babylon/Collisions/babylon.collider.js,Babylon/Cameras/babylon.camera.js,Babylon/Cameras/babylon.freeCamera.js,Babylon/Cameras/babylon.touchCamera.js,Babylon/Cameras/babylon.deviceOrientationCamera.js,Babylon/Cameras/babylon.arcRotateCamera.js,Babylon/babylon.scene.js,Babylon/Mesh/babylon.vertexBuffer.js,Babylon/Mesh/babylon.mesh.js,Babylon/Mesh/babylon.subMesh.js,Babylon/Materials/textures/babylon.baseTexture.js,Babylon/Rendering/babylon.renderingGroup.js,Babylon/Rendering/babylon.renderingManager.js,Babylon/Materials/textures/babylon.texture.js,Babylon/Materials/textures/babylon.cubeTexture.js,Babylon/Materials/textures/babylon.renderTargetTexture.js,Babylon/Materials/textures/babylon.mirrorTexture.js,Babylon/Materials/textures/babylon.dynamicTexture.js,Babylon/Materials/textures/babylon.videoTexture.js,Babylon/Materials/babylon.effect.js,Babylon/Materials/babylon.material.js,Babylon/Materials/babylon.standardMaterial.js,Babylon/Materials/babylon.multiMaterial.js,Babylon/Tools/babylon.database.js,Babylon/Tools/babylon.sceneLoader.js,Babylon/Sprites/babylon.spriteManager.js,Babylon/Sprites/babylon.sprite.js,Babylon/Layer/babylon.layer.js,Babylon/Particles/babylon.particle.js,Babylon/Particles/babylon.particleSystem.js,Babylon/Animations/babylon.animation.js,Babylon/Animations/babylon.animatable.js,Babylon/Culling/Octrees/babylon.octree.js,Babylon/Culling/Octrees/babylon.octreeBlock.js,Babylon/Bones/babylon.bone.js,Babylon/Bones/babylon.skeleton.js,Babylon/PostProcess/babylon.postProcess.js,Babylon/PostProcess/babylon.postProcessManager.js,Babylon/PostProcess/babylon.passPostProcess.js,Babylon/PostProcess/babylon.blurPostProcess.js,Babylon/PostProcess/babylon.fxaaPostProcess.js,Babylon/PostProcess/babylon.refractionPostProcess.js,Babylon/PostProcess/babylon.blackAndWhitePostProcess.js,Babylon/PostProcess/babylon.convolutionPostProcess.js" /o:"..\babylon.js" /w:".." /s:"Babylon/Shaders"
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ def export_camera(object, scene, file_handler):
Export_babylon.write_bool(file_handler, "checkCollisions", object.data.checkCollisions)
Export_babylon.write_bool(file_handler, "applyGravity", object.data.applyGravity)
Export_babylon.write_array3(file_handler, "ellipsoid", object.data.ellipsoid)

locAnim = False
coma = False

if object.animation_data:
if object.animation_data.action:
file_handler.write(",\"animations\":[")
for fcurve in object.animation_data.action.fcurves:
if fcurve.data_path == "location" and locAnim == False:
Export_babylon.export_animation(object, scene, file_handler, "location", "position", coma, 1)
locAnim = coma = True
file_handler.write("]")
#Set Animations
Export_babylon.write_bool(file_handler, "autoAnimate", True)
Export_babylon.write_int(file_handler, "autoAnimateFrom", 0)
Export_babylon.write_int(file_handler, "autoAnimateTo", bpy.context.scene.frame_end - bpy.context.scene.frame_start + 1)
Export_babylon.write_bool(file_handler, "autoAnimateLoop", True)

file_handler.write("}")

def export_light(object, scene, file_handler):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public void GenerateBabylonFile(string file, string outputFile, bool skinned)
var services = new ServiceContainer();

// Create a graphics device

services.AddService<IGraphicsDeviceService>(GraphicsDeviceService.singletonInstance);
var form = new Form();

services.AddService<IGraphicsDeviceService>(BabylonExport.Core.Exporters.FBX.GraphicsDeviceService.AddRef(form.Handle, 1, 1));

var contentBuilder = new ContentBuilder();
var contentManager = new ContentManager(services, contentBuilder.OutputDirectory);
Expand Down
Loading

0 comments on commit 1861a49

Please sign in to comment.