aFalcon

Members
  • Content count

    388
  • Joined

  • Last visited

  • Days Won

    3

aFalcon last won the day on March 15

aFalcon had the most liked content!

About aFalcon

  • Rank
    Advanced Member

Profile Information

  • Location
    this._collideWithWorld()

Recent Profile Visitors

1,954 profile views
  1. aFalcon

    Explosion scene for a game

    Used this is a great place to start... https://doc.babylonjs.com/snippets/writing2 Adapted to extend range (supernova effect)[loops itself] and added fader fadeout -> cool things. var blueBoom; anmExplodeShader = function(){ BABYLON.Effect.ShadersStore["customVertexShader"]= "\r\n"+ "precision highp float;\r\n"+ "// Attributes\r\n"+ "attribute vec3 position;\r\n"+ "attribute vec3 normal;\r\n"+ "// Uniforms\r\n"+ "uniform mat4 worldViewProjection;\r\n"+ "uniform float time;\r\n"+ "void main(void) {\r\n"+ " vec3 p = position;\r\n"+ " vec3 j = vec3(0., -1.0, 0.);\r\n"+ " p = p + normal * log2(1. + time) * 25.0;\r\n"+ " gl_Position = worldViewProjection * vec4(p, 1.0);\r\n"+ "}\r\n"; BABYLON.Effect.ShadersStore["customFragmentShader"]="\r\n"+ "precision highp float;\r\n"+ "uniform float time;\r\n"+ "uniform float fader;\r\n"+ "void main(void) {\r\n"+ // " gl_FragColor = vec4(1.0,0.0,1.0,1.0);\r\n"+ // " gl_FragColor = vec4(0.2,0.0,1.0,1.0);\r\n"+ " gl_FragColor = vec4(0.2,0.0,1.0,fader);\r\n"+ "}\r\n"; var shaderMaterial = new BABYLON.ShaderMaterial("shader", scene, { vertex: "custom", fragment: "custom", }, { // needAlphaBlending : true, attributes: ["position", "normal", "uv"], uniforms: ["world", "worldView", "worldViewProjection", "view", "projection"], needAlphaBlending: true }); // " gl_FragColor = vec4(1. - log2(1. + time)/100., 1. * log2(1. + time), 0., 1. - log2(1. + time/2.)/log2(1. + 3.95));\r\n"+ shaderMaterial.backFaceCulling = false; blueBoom = BABYLON.MeshBuilder.CreateSphere("blueBoom", {diameter:100}, scene); blueBoom.convertToFlatShadedMesh(); blueBoom.material = shaderMaterial; blueBoom.material.alphaMode = 2; var time = 0.; var fader = 1; scene.registerBeforeRender(function() { if(time<50) { blueBoom.material.setFloat("fader", fader); blueBoom.material.setFloat("time", time); time +=0.1; //fadeout over time if(time > 30){ blueBoom.material.setFloat("fader", fader); fader -=0.01; // blueBoom.material.alpha -= 0.5; // console.log('ALPHA: ',blueBoom.material.alpha) } } else { blueBoom.dispose(); } }); Also rotate the camera to look down into the y axis... pretty cool low poly cartoon explosion effect.
  2. aFalcon

    Performance Optimization tips.

    rudimentary stats... TEST DESCRIPTION: rotating parent with gradual increasing number of children(30,60,90) for each rotation, step-interpolation = 0.02, on a closed-circuit track. BASELINE NO-PERF-OPS 3 CONTROL-TESTS: TIMESTART: START-ANIMATION TIMESTOP: END-ORBIT = 1867 TIMESTART: START-ANIMATION TIMESTOP: END-ORBIT = 4294 TIMESTART: START-ANIMATION TIMESTOP: END-ORBIT = 6724 OP-TEST-1 visibility = 0 3 COMPARISON-TESTS: TIMESTART: START-ANIMATION TIMESTOP: END-ORBIT = 1937 TIMESTOP: END-ORBIT = 4237 TIMESTOP: END-ORBIT = 4679 OP-TEST-1 RESULTS: Within variance, visibility = 0 for hidden mesh, reduces orbit time ~2 seconds on third rotation (HOO-RAY). QUESTION: which is better visibility or setEnabled(false)? Bird should read source code, or... TEST: replace vis =0 to setEnable(false) in the same loops... TIMESTART: START-ANIMATION TIMESTOP: END-ORBIT = 1917 TIMESTOP: END-ORBIT = 4227 TIMESTOP: END-ORBIT = 4778 RESULTS: Interesting - visibility is slightly faster (within variance). Didn't expect that. Bird should read source code. NOTE: couldn't use setElement(false) at parent level because in context need parent to remain visible, and only children hidden. NEXT-STEPS: Not going to do LOD test, sticking with simple visibility op for the moment. Instances not applicable. This is solved. Maybe more PERFOPS later. Hope this helps someone.
  3. aFalcon

    Babylonjs consumes too much memory

    Also in optimization phase and ran across this simultaneously... https://blog.raananweber.com/2015/09/03/scene-optimization-in-babylon-js/ friend @RaananW says crystal clear: So hooray, bird on topic (marks on calendar) : ) Hit jRad with the similar question about a year back, on run-time vertex editing utility.... @BMWPilote Maybe that helps you. Are Instances applicable? https://doc.babylonjs.com/how_to/how_to_use_instances Or LOD?: https://doc.babylonjs.com/how_to/how_to_use_lod https://doc.babylonjs.com/how_to/in-browser_mesh_simplification cheers!
  4. aFalcon

    Performance Optimization tips.

    Ok, Put in TIMESTAMPS ... gotta go. Thanks to who'ever made dude. Here is adapted timestamp utility, to easily measure performance anywhere: //TIMER var timeStamp = 0; var currentTimeStamp = 0; var timeReport = function(testname){ console.log('TIMESTART: '+testname); if(!timeStamp){ timeStamp = new Date().getTime(); } return function (testname) { currentTimeStamp = new Date().getTime(); var timeDelta = currentTimeStamp - timeStamp; console.log('TIMESTOP: '+testname+' = '+timeDelta); timeStamp = null; } } //EXAMPLE-USAGE-. // var debugTimeStop = timeReport('START Time Test'); // debugTimeStop('END Time Test'); Statistics pending...
  5. aFalcon

    Performance Optimization tips.

    Statistics -->great idea<-- Thank you setEnabled(true) insight! TINY-UPDATES: - the code below worked well as first pass rough-in. RESULTS: performance improvement achieved! (ding). - Will try setEnabled... on parents - -> But had interesting PROBLEM: need parent setEnabled(true) AND children setEnabled(false)???<-- anyway... : ) - Hello LOD! too. - Probably date.now all three [hope] (BZ thx). reloadLevel = function(){ for(var i=0; i<edges.length; i++){ edges[i].visibility = 1; } for(var i=0; i<orbs.length; i++){ orbs[i].visibility = 1; } for(var i=0; i<boxes.length; i++){ boxes[i].visibility = 1; } for (var i=0; i<tiles.length; i++){ tiles[i].visibility = 1; } } unloadLevel = function(){ for(var i=0; i<edges.length; i++){ edges[i].visibility = 0; } for(var i=0; i<orbs.length; i++){ orbs[i].visibility = 0; } for(var i=0; i<boxes.length; i++){ boxes[i].visibility = 0; } for (var i=0; i<tiles.length; i++){ tiles[i].visibility = 0; } }
  6. Question about setEnabled(false). Is it better performance than visibility = 0 ? And wondering what is the difference? If 1 mesh is rotating 10 children, and 5 can be hidden - which is more performant: visibility or setEnabled(false); I'll test it.... Lots of reading. Thanks!
  7. let you_guys = 'heros'; Because of this, was able to figure out alpha opacity on a sine wave for a shader-fader. Not perfect, but pretty cool for a rookie. : ) Hope it helps someone. http://www.babylonjs-playground.com/#16UICJ#9
  8. "binary encoded packet"... excellent! And multi-player tip very helpful. Thank you.
  9. aFalcon

    What's next?

    Sounds ambient...
  10. Super cool, and.booking vacation. : ) Curious, about that websocket, babylon node server, (examples or link)... How does that render out?
  11. aFalcon

    What's next?

    HighlightLayer.removeAll() would be really helpful. Because -> glows all the things.
  12. aFalcon

    What's next?

    🏆 The bird likes to learn. Asks boss, says "later".
  13. aFalcon

    What's next?

    Rewritten... animation-configuration-objects can be put in a single array, var anmScript = [anm1, anm2, anm3,...]; ...triggered at run-time. : ) BABYLON.animation(anm1); token animations - give single line animation loops,: BABYLON.animation({attr:'opacity',to:0, from:0, done:fn(){]); And single-line animation loops is what makes ....animation-factories. UPDATED.
  14. aFalcon

    What's next?

    BABYLON.animate( {src:{}, attr:'', from:0, to:10, done:fn(){} } ); //compact single-line interpolation factory syntax. : )
  15. "always bet on js" ...