Skip to content

Commit

Permalink
speed up
Browse files Browse the repository at this point in the history
  • Loading branch information
ZIWEI authored and ZIWEI committed Dec 11, 2015
1 parent ef92066 commit 53515be
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 27 deletions.
59 changes: 32 additions & 27 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -701,40 +701,45 @@
sphereMesh.visible = (cfg_ui.getRigid() == 0);

if ((!cfg_ui.getPause()) || guiStep) {

simulationShader.setTimer(cfg_ui.getTimeStep());

if (count > 20 && !isWebGL2) simulationShader.setStart(0);

timer += 1;

// Ugly hack to make the particle mesh always draw last
scene.remove(mesh); scene.add(mesh);

if (isWebGL2) {
if (count % 2 === 0) {
gpgpu.pass(simulationShader, vbo_pos2, vbo_pos, cfg_ui, usrControl);
mesh.geometry = vbo_pos2;
var ii = cfg_ui.getSpeedUp();
while(ii>0){
ii--;
simulationShader.setTimer(cfg_ui.getTimeStep());

if (count > 20 && !isWebGL2) simulationShader.setStart(0);

timer += 1;

// Ugly hack to make the particle mesh always draw last
scene.remove(mesh); scene.add(mesh);

if (isWebGL2) {
if (count % 2 === 0) {
gpgpu.pass(simulationShader, vbo_pos2, vbo_pos, cfg_ui, usrControl);
mesh.geometry = vbo_pos2;
} else {
gpgpu.pass(simulationShader, vbo_pos, vbo_pos2, cfg_ui, usrControl);
mesh.geometry = vbo_pos;
}
} else {
gpgpu.pass(simulationShader, vbo_pos, vbo_pos2, cfg_ui, usrControl);
mesh.geometry = vbo_pos;
simulationShader.setPositionsTexture(rtTexturePos);
if (count < 15)
gpgpu.initVel(simulationShader);
gpgpu.pass(simulationShader, rtTexturePos2, cfg_ui, usrControl);
material.uniforms.map.value = rtTexturePos;
var a = rtTexturePos;
rtTexturePos = rtTexturePos2;
rtTexturePos2 = a;
}
} else {
simulationShader.setPositionsTexture(rtTexturePos);
if (count < 15)
gpgpu.initVel(simulationShader);
gpgpu.pass(simulationShader, rtTexturePos2, cfg_ui, usrControl);
material.uniforms.map.value = rtTexturePos;
var a = rtTexturePos;
rtTexturePos = rtTexturePos2;
rtTexturePos2 = a;
count++;
guiStep = !guiStep;
}
count++;
guiStep = !guiStep;
}

camControl.update();

renderer.render(scene, camera);

stats.end();
}

Expand Down
7 changes: 7 additions & 0 deletions js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var UI_cfg = function () {

var controls = {
gui: null,
"Speed Up": 1,
"Render": 0,
"Material":0,

Expand Down Expand Up @@ -125,6 +126,11 @@ var UI_cfg = function () {
this.setPause = function (value) {
controls['pause'] = value;
}

this.getSpeedUp = function () {
return controls['Speed Up'];
}

this.init = function () {
//cfg = new Cfg();

Expand Down Expand Up @@ -177,6 +183,7 @@ var UI_cfg = function () {
Action_Folder.add(controls, "start");
Action_Folder.add(controls, "pause");
Action_Folder.add(controls, "step");
Action_Folder.add(controls, "Speed Up").step(1);

Action_Folder.open();

Expand Down

0 comments on commit 53515be

Please sign in to comment.