• Content count

  • Joined

  • Last visited

  • Days Won


Everything posted by Pryme8

  1. Grid Material Offset

    Is there a way to offset the grid material? Like move it a half unit in the x? example:
  2. Grid Material Offset

    Ill take a look at the github, Im sure its not a hard addition and I am sitting idle at work right now so might as well try to get a commit in. release/materialsLibrary/babylon.gridMaterial.d.ts release/materialsLibrary/babylon.gridMaterial.js Are the only two files I can find on it, Where is the ts file that has the shader information in it? NM found it... And I have no clue how to edit it... Like ts is putting me off from ever contributing, this sucks because I can "read" it but am clueless still on how to modify it, it looks off and my brain is wired to hard for vanilla js. I can edit the shader no problem but the ts part is just not something I am able to mess with. God I wish we were still using javascript...
  3. interface html

    Just use basic HTML for a menu like this. And yes you can fire what ever events from HTML/Javascript to your scene just make sure your scope is correct.
  4. Nasimi The Shader Guru

    Some of the CYOS examples dont come up anymore... not sure why. Make sure your textures you are using are in fact "tileable" and it should work! also, Im not sure if this is the one I had working or not but: BABYLON.Effect.ShadersStore["teriableBasicVertexShader"]= "precision highp float;\r\n"+ "// Attributes\r\n"+ "attribute vec3 position;\r\n"+ "attribute vec3 normal;\r\n"+ "attribute vec2 uv;\r\n"+ "// Uniforms\r\n"+ "uniform mat4 world;\r\n"+ "uniform mat4 worldViewProjection;\r\n"+ "// Varying\r\n"+ "varying vec3 vPositionW;\r\n"+ "varying vec3 vNormalW;\r\n"+ "varying vec2 vUV;\r\n"+ "void main(void) {\r\n"+ " vec4 outPosition = worldViewProjection * vec4(position, 1.0);\r\n"+ " gl_Position = outPosition;\r\n"+ " \r\n"+ " vPositionW = vec3(world * vec4(position, 1.0));\r\n"+ " vNormalW = normalize(vec3(world * vec4(normal, 0.0)));\r\n"+ " \r\n"+ " vUV = uv;\r\n"+ "}\r\n"; BABYLON.Effect.ShadersStore["teriableBasicFragmentShader"]= "precision highp float;\r\n"+ "// Lights\r\n"+ "varying vec3 vPositionW;\r\n"+ "varying vec3 vNormalW;\r\n"+ "varying vec2 vUV;\r\n"+ "// Refs\r\n"+ "uniform sampler2D textureBank;\r\n"+ "const vec3 up = vec3(0.0,1.0,0.0);\r\n"+ "float rangeV(float v, float x, float y){\r\n"+ " return 1.0-max(0.0 , min(1.0 , (v - y)/(y - x)));\r\n"+ "}\r\n"+ "//\r\n"+ "float snoise(vec2 co)\r\n"+ "{\r\n"+ " return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\r\n"+ "}\r\n"+ "void main(void) {\r\n"+ " vec2 r[4];//RANGES\r\n"+ " r[0] = vec2(-50.0,-30.0);\r\n"+ " r[1] = vec2(-30.0,10.0);\r\n"+ " r[2] = vec2(10.0,45.0);\r\n"+ " r[3] = vec2(45.0,50.0);\r\n"+ " vec2 aR[4];\r\n"+ " aR[0] = vec2(0.0,0.35);\r\n"+ " aR[1] = vec2(0.35,0.5);\r\n"+ " aR[2] = vec2(0.5,0.98);\r\n"+ " aR[3] = vec2(0.98,1.0);\r\n"+ " \r\n"+ " float angle = max(0., dot(vNormalW, up));//ANGLE 0:1\r\n"+ " float el = vPositionW.y; //ELEVATION\r\n"+ " /*vec3 color;\r\n"+ " if(angle >= 0.0 && angle <= 0.35 ){\r\n"+ " color = vec3(angle,1.,1.); //BASE COLOR\r\n"+ " }else if(angle > 0.35 && angle <= 0.5 ){\r\n"+ " color = vec3(1.0,angle,1.); //BASE COLOR\r\n"+ " }else if(angle == 1.0){\r\n"+ " color = vec3(0.0,0.0,0.0); //BASE COLOR\r\n"+ " }else{\r\n"+ " color = vec3(1.0,1.0,angle); //BASE COLOR\r\n"+ " }*/\r\n"+ " vec3 color = vec3(1.0,1.0,1.0); //BASE COLOR\r\n"+ " vec3 rc[4]; //RANGE COLORS\r\n"+ " rc[0] = vec3(0.4,0.4,0.2);\r\n"+ " rc[1] = vec3(0.8,0.8,0.3);\r\n"+ " rc[2] = vec3(0.4,0.8,0.4);\r\n"+ " rc[3] = vec3(0.8,0.8,0.9);\r\n"+ " vec3 ac[16]; //ANGLE COLORS\r\n"+ " //ZONE 1:\r\n"+ " ac[0] = vec3(0.2,0.2,0.0);\r\n"+ " ac[1] = vec3(0.4,0.4,0.2);\r\n"+ " ac[2] = vec3(0.5,0.5,0.2);\r\n"+ " ac[3] = vec3(-0.8,-0.8,-0.6);\r\n"+ " //ZONE 2:\r\n"+ " ac[4] = vec3(0.0,0.4,0.4);\r\n"+ " ac[5] = vec3(0.6,0.6,0.6);\r\n"+ " ac[6] = vec3(-0.3,0.0,0.3);\r\n"+ " ac[7] = vec3(-0.2,-0.2,0.0);\r\n"+ " //ZONE 3:\r\n"+ " ac[8] = vec3(0.0,0.4,0.0);\r\n"+ " ac[9] = vec3(-0.2,-0.2,0.0);\r\n"+ " ac[10] = vec3(0.0,0.6,0.6);\r\n"+ " ac[11] = vec3(0.0,-0.8,0.0);\r\n"+ " //ZONE 4:\r\n"+ " ac[12] = vec3(-0.5,-0.5,-0.5);\r\n"+ " ac[13] = vec3(-1.0,0.6,0.0);\r\n"+ " ac[14] = vec3(-1.0,0.0,0.0);\r\n"+ " ac[15] = vec3(0.2,-0.6,-0.6);\r\n"+ " \r\n"+ " float ap[4]; //Angle Blend PERCENTAGE\r\n"+ " ap[0] = rangeV(angle, aR[0].x, aR[0].y);\r\n"+ " ap[1] = rangeV(angle, aR[1].x, aR[1].y);\r\n"+ " ap[2] = rangeV(angle, aR[2].x, aR[2].y);\r\n"+ " ap[3] = rangeV(angle, aR[3].x, aR[3].y);\r\n"+ " \r\n"+ " //Mix into BaseColor for Zones;\r\n"+ " //Zone 1:\r\n"+ " rc[0] = normalize(rc[0]-(ac[0]*(ap[0]*0.5)));\r\n"+ " rc[0] = normalize(rc[0]-(ac[1]*(ap[1]*0.5)));\r\n"+ " rc[0] = normalize(rc[0]-(ac[2]*(ap[2]*0.5)));\r\n"+ " rc[0] = normalize( rc[0]-(ac[3]*(ap[3]*0.5)));\r\n"+ " //Zone 2:\r\n"+ " rc[1] = normalize(rc[1]-(ac[4]*(ap[0]*0.5)));\r\n"+ " rc[1] = normalize(rc[1]-(ac[5]*(ap[1]*0.5)));\r\n"+ " rc[1] = normalize(rc[1]-(ac[6]*(ap[2]*0.5)));\r\n"+ " rc[1] = normalize( rc[1]-(ac[7]*(ap[3]*0.5)));\r\n"+ " //Zone 3:\r\n"+ " rc[2] = normalize(rc[2]-(ac[8]*(ap[0]*0.5)));\r\n"+ " rc[2] = normalize(rc[2]-(ac[9]*(ap[1]*0.5)));\r\n"+ " rc[2] = normalize(rc[2]-(ac[10]*(ap[2]*0.5)));\r\n"+ " rc[2] = normalize( rc[2]-(ac[11]*(ap[3]*0.5)));\r\n"+ " //Zone 4:\r\n"+ " rc[3] = normalize(rc[3]-(ac[12]*(ap[0]*0.5)));\r\n"+ " rc[3] = normalize(rc[3]-(ac[13]*(ap[1]*0.5)));\r\n"+ " rc[3] = normalize(rc[3]-(ac[14]*(ap[2]*0.5)));\r\n"+ " rc[3] = normalize( rc[3]-(ac[15]*(ap[3]*0.5)));\r\n"+ " \r\n"+ " float rp[4]; //RANGE BLEND PERCENTAGE\r\n"+ " rp[0] = rangeV(el, r[0].x, r[0].y);\r\n"+ " rp[1] = rangeV(el, r[1].x, r[1].y);\r\n"+ " rp[2] = rangeV(el, r[2].x, r[2].y);\r\n"+ " rp[3] = rangeV(el, r[3].x, r[3].y);\r\n"+ " \r\n"+ " //Slight Blending nouse... this could be better...\r\n"+ " if(rp[0]<=0.25){\r\n"+ " rp[0]*=snoise(vPositionW.xz);\r\n"+ " }\r\n"+ " if(rp[1]<=0.25){\r\n"+ " rp[1]*=snoise(vPositionW.xz);\r\n"+ " }\r\n"+ " if(rp[2]<=0.25){\r\n"+ " rp[2]*=snoise(vPositionW.xz);\r\n"+ " }\r\n"+ " if(rp[3]<=0.25){\r\n"+ " rp[3]*=snoise(vPositionW.xz);\r\n"+ " }\r\n"+ " \r\n"+ " \r\n"+ " //RANGE COLOR MIX\r\n"+ " color = mix(color, rc[3], rp[3]);\r\n"+ " color = mix(color, rc[2], rp[2]);\r\n"+ " color = mix(color, rc[1], rp[1]);\r\n"+ " color = mix(color, rc[0], rp[0]);\r\n"+ " \r\n"+ " vec3 vLightPosition = vec3(-2,100,5);\r\n"+ " // Light\r\n"+ " vec3 lightVectorW = normalize(vLightPosition - vPositionW);\r\n"+ " // diffuse\r\n"+ " float ndl = max(0., dot(vNormalW, lightVectorW));\r\n"+ " color*=ndl;\r\n"+ " \r\n"+ " gl_FragColor = vec4(color, 1.);\r\n"+ "}\r\n"; var textureBank = new Array(); var textureLocations = [ //ZONE 1: "./textures/Beach_Rocks.jpg",//BASE "./textures/Sand_2.jpg",//Angle Zone 1 "./textures/Sand_2.jpg",//Angle Zone 2 "./textures/Sand_1.jpg",//Angle Zone 3 "./textures/Rocks_2.jpg",//Angle Zone 4 ]; $.each(textureLocations, function(i,e){ textureBank.push(new BABYLON.Texture(e, scene)); textureBank[i].wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE; textureBank[i].wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE; }); teriableBasic = new BABYLON.ShaderMaterial("teriableBasic", scene, { vertex: "teriableBasic", fragment: "teriableBasic", }, { attributes: ["position", "normal", "uv"], uniforms: ["world", "worldView", "worldViewProjection", "view", "projection"] }); teriableBasic.setTexture("textureBank", textureBank); Now that I look at that though, I think that's the basic color one... Ill have to go dig up the one that uses the texture atlas. @MackeyK24, I get off early today like around 130ish send me a message or something to remind me to dig the real one up I'm a space cadet.
  5. Physics Movement

    why not just add a collision listener to the player body? player.body.addEventListener("collide",function(e){ console.log("Collided with:",e.body); console.log("Contact:",; }); can we not add this event to the cannon bodies anymore?
  6. Physics Movement

    I wonder if I can dig up my old PG that shows the difference between force and impulse. It was like 2 years ago almost now though so not sure how to track it down.
  7. Physics Movement the part about the difference in == and === is important.
  8. Canvas and CSS properties

    wont setEnabled work on sprites as well? or like set the colors alpha to 0?
  9. this is more the behavior I expected and if I increase the tilt it makes it drop to the other side on the ridge... interesting!
  10. Physics Movement

    I have not gotten to get home yet, but I will peep it for sure tonight! Ive made a 1st/3rd person player controller for BJS before and the scripts on my work rig at home so I need to reference that. Here is a cheep way to collide two mass 0 objects also (but its really kind of hacky and wont work in most situations) @MackeyK24m Has a really old school one I did, nothing like the new one but its what I used as my model. Its really rudimentary but might get you in the correct direction (no pun intended), if doing the Demo id hold ctrl until you hit the ground or its kinda hard to get a bearing of where you are.
  11. Physics Movement

    Not sure, never tested that! good question though... I'm pretty sure the collision event still fires though. Ill do a PG and test before I need to eat my words though. ANNND it does not... that's odd I figured the collision would still fire... hmmm y'all got me thinking now... This worked back when you constructed the impostors like : setPhysicsState(BABYLON.PhysicsImpostor.SphereImpostor, { mass: 0.0, friction: 0.0001, restitution: 0.0}); So now I need to do some research because I was under the impression the event would still fire it just would not have any responses, but alas that is not the case. Maybe it has something to do with using broadphase vs narrow? I have not looked at this in like over a year so I really dont remember off the top of my head, Id have to be back at the house looking at script.
  12. Water Fluid Simulation

    sexy, I like this effect a ton! good job.
  13. Creation of ground

    Why not just use a square and an alpha texture?
  14. I extended the ground plane to see what the results where after they get off your "sticks" and for sure the one on the ridge behaves differently.
  15. Physics Movement

    var forward = scene.activeCamera.getTarget().subtract(scene.activeCamera.position).normalize(); forward.y = 0; var right = BABYLON.Vector3.Cross(forward, scene.activeCamera.upVector).normalize(); right.y = 0; var move = (forward.scale(f_speed)).subtract((right.scale(s_speed))).subtract(scene.activeCamera.upVector.scale(u_speed)); player_box.body.velocity.x = move.x; player_box.body.velocity.z = move.z; player_box.body.velocity.y = move.y; Hope some of this helps.
  16. Recalculate mesh shading Take a look at the second sphere. Its because your position calculations are off after the scaling. read the section on "Baking Transform"
  17. Physics Movement

    how are you calculating your forward vector? are you taking position from origin into account? Tell you what, when I get home today Ill watch your video and help out. I prolly already have a solution for you that you can adapt.
  18. Recalculate mesh shading the normals do not get scaled... maybe its in the shader?
  19. Recalculate mesh shading

    Why are you scaling the normals? I've always thought they should just be a 1 unit vector, why all the extra calculations?
  20. hmmm, you would think friction would apply differently due to surface contact area but I don't know if any of the physics engines take this into account (I dont think they do)
  21. Physics Movement

    yall are tripping, setting the mass to 0 does not get rid of collision events, it just makes it "static" which does not mean you cant not affect it with your own calculations... I have posted physics controllers that use this method and have proven it to work so..... Im out of this conversation though then if that's the reaction people are having... way to not listen to the person who has deployed this in a production product before though. player_box.body.collisionResponse = 0; player_box.body.addEventListener("collide", function(e){ player_box.body.grounded = true; player_box.body.collisionResponse = 1; }); scene.registerBeforeRender(function(){ //console.log(player_box.position); if(player_box.body.collisionResponse){ player_box.body.grounded = true; player_box.body.velocity.y = 0; }else{ player_box.body.grounded = false; } if(player_box.body.grounded || gravity.y == 0){ if(keys.w){ if(player.speed.f < settings.speeds.normal.f){ player.speed.f += settings.accel; }else{ player.speed.f = settings.speeds.normal.f; } }else if(keys.s){ if(player.speed.f > settings.speeds.normal.b){ player.speed.f -= settings.accel; }else{ player.speed.f = settings.speeds.normal.b; } } if(keys.a){ if(player.speed.s > settings.speeds.normal.s*-1){ player.speed.s -= settings.accel; }else{ player.speed.s = settings.speeds.normal.s*-1; } } if(keys.d ){ if(player.speed.s < settings.speeds.normal.s){ player.speed.s += settings.accel; }else{ player.speed.s = settings.speeds.normal.s; } } if({ if(gravity.y != 0 && player_box.body.grounded){ player_box.body.collisionResponse = 0; var jumpVector = v3(0,6.5,0); player_box.applyImpulse(jumpVector, player_box.position); }else{ if(player.speed.u < -2){ player.speed.u -= settings.accel; }else{ player.speed.u = -2; } } } ... Is a cheep way to do grounding yet it does not work in all instances (also gravity is enabled)... but this might give you an idea. Its not a final example at all due to it not taking side collisions into account.
  22. Physics Movement

    @MackeyK24 Impostor Mass = 0;
  23. OBJ file not loading correctly?

    I'm the guy here to argue with if your looking for that! (listen to raan)
  24. @Wingnut word round the block is energy.js is gonna be coming round here soon.