Wingnut Posted August 26, 2016 Share Posted August 26, 2016 Thanks p8. As long as TD is happy with that solution, then I'm happy, too. Rock on! My method has more problems than I thought, anyway. http://playground.babylonjs.com/#21TQJT#45 I removed all the gaps in the tiles, and made another ground (blue) that is not tiled (uses the whole image instead of portions)... and as you can see, tile hm_3x3 is perfect... good z-fighting... indicates a one-to-one match. But the rest of the tiled ground doesn't match the non-tiled full ground. I was hoping to "borrow" a copy of the normals from the full ground... to chop-up and apply to the tile normals. *sigh*. Oh well, I tried. Failing is part of the fun. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 26, 2016 Share Posted August 26, 2016 I think with what you were doing it would be smarter to combine all the meshs into a new buffer optimize it and recalc its normals then dispose all the old ones. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
TheDude Posted August 26, 2016 Author Share Posted August 26, 2016 @Pryme8 So I'm right in saying that it will be editable as in digging/mining? If so I'll be happy to see a demo some point in the future. In the mean time I will work on other parts of the game like building and rockets and stuff. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 26, 2016 Share Posted August 26, 2016 Yes, the land will be editable (to and extent) and you will be able to define custom regions in the editor as well when you are building it. Quote Link to comment Share on other sites More sharing options...
TheDude Posted August 26, 2016 Author Share Posted August 26, 2016 @Pryme8 that is awesome (and also my end goal too)! Quote Link to comment Share on other sites More sharing options...
TheDude Posted August 26, 2016 Author Share Posted August 26, 2016 In case anyone would like to see a demo of what project I'll include this is, view it here Maybe someone might find some useful code in there for one of the projects there working on who knows? Controls: arrows/WSAD to move. Left click to place block/ right click to remove block. Tab to toggle between mining and placing blocks and same controls as block placing for mining.Going to work on ui. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 26, 2016 Share Posted August 26, 2016 why are you not doing a voxel system? Quote Link to comment Share on other sites More sharing options...
TheDude Posted August 26, 2016 Author Share Posted August 26, 2016 @Pryme8 is that more efficient or easier?, because i'll look into it if it is. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 26, 2016 Share Posted August 26, 2016 Yes this will be ideal for what you are trying to do.https://sites.google.com/site/letsmakeavoxelengine/ this is easily transferred to BJS, a lot you can ignore. but it gives you the basic concept. TheDude 1 Quote Link to comment Share on other sites More sharing options...
TheDude Posted August 27, 2016 Author Share Posted August 27, 2016 @Pryme8 So you would create a mesh out of cubes? I saw a babylon.js voxel mesher that could be edited to support textures and other stuff, but if I can get away with it I would use do it the way that WorldMonger does mining. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 27, 2016 Share Posted August 27, 2016 Yes, and your not going to render them all at once. You also need to turn them into a single buffer once you know their locations before you start drawing them to the screen. Quote Link to comment Share on other sites More sharing options...
TheDude Posted August 29, 2016 Author Share Posted August 29, 2016 @Pryme8 I will look into adding new features to the babylon.js voxel mesher I found but I'm back off to school so don't know how much free time I'll have. Quote Link to comment Share on other sites More sharing options...
TheDude Posted September 2, 2016 Author Share Posted September 2, 2016 I'm keeping this forum open though. Quote Link to comment Share on other sites More sharing options...
TheDude Posted September 14, 2016 Author Share Posted September 14, 2016 @Wingnut Sorry there's been no updates. Just had an idea though. If you forget that there is normal issues fro now, but what is when you are mining and your are close to the edges of a chunk you could possibly merge them together and do mining like that and then you could delete that mesh on mouse up and update the vertices of that other to meshes? Maybe if there was an array of edge of chunk vertices to check if you are near the edge and then if (vetices == edge) then merge, else dont merge? It might by inefficient for doing LOD every frame but maybe every few frames or not at all for now?Like this idea or is there other ideas you might have. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 15, 2016 Share Posted September 15, 2016 Hi TD. I bailed on this project. I thought @Pryme8 had you taken care-of... with his "Teriable" thing. Anyway, I have no ideas about "mining"... nor about mining edges. Sorry. If you remember from earlier, I suggested that you switch to "mining mode" and create a brand new chunk of ground (essentially, a new scene). Do your mining on that... using a single ground. Then, when exiting mining mode, update the big terrain... based upon the "mining terrain". If, by chance, the mining was happening at a place where 4 tiles intersected, then you would need to update 4 tiles, upon exiting mining mode. No merging involved. Merging defeats the purpose of tiling. I can't see why you would want to delete a mesh/tile during/after mining. LOD is not applicable when user is near the mine location. All terrain mesh should always be ON and at full rez... in a certain diameter around the user location, I would think. LOD is for far-away things. Nope, I have no idea what you and Pryme8 have going, now. I didn't get far enough on my version... to even consider "mining". Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 15, 2016 Share Posted September 15, 2016 What you want to do is keep the chunk as a solid mesh and then when a user interacts with it have it calculate that chunk as spectate blocks and identify which ones need to be active, which would be the ones touching the box the user interacted with,. You then run what ever calculations on the voxels and after a certain amount of time at rest or when the user is at a certain distance re unify the voxels into a single draw. Quote Link to comment Share on other sites More sharing options...
TheDude Posted September 15, 2016 Author Share Posted September 15, 2016 @Wingnut fair enough and @Pryme8 I'll look into it. Quote Link to comment Share on other sites More sharing options...
kohai Posted September 27, 2016 Share Posted September 27, 2016 Hi all ... I was just searching the forum for some terrain matters and finally found this thread. @Pryme8 do you happen to have TERIABLE infinite version working ? your example seems to be broken ( only flat terrain ). Not looking for some LOD feature, only needs a low-poly version ( kinda like this : https://github.com/dlubarov/webgl-infinite-terrain-demo ) Thx a bunch Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 27, 2016 Share Posted September 27, 2016 Um easy answer No, locally yes, full answer which would be more relevant to you: Ok Infinity was just a prototype to benchmark and test different ways of spawing the blocks to a infinite terrain the only thing it is missing is the displacement of the plane meshes which could be easily incorporated. var canvas = document.querySelector("#renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var createScene = function () { var scene = new BABYLON.Scene(engine); scene.clearColor = new BABYLON.Color3(0.2, 0.2, 0.3); var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); camera.setTarget(BABYLON.Vector3.Zero()); camera.attachControl(canvas, false); var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0.15, 50, 0.5), scene); light.intensity = .5; //SHADERS? 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"+ "//http://stackoverflow.com/questions/4200224/random-noise-functions-for-glsl\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(0.15, 60.0, 0.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"; teriableBasic = new BABYLON.ShaderMaterial("teriableBasic", scene, { vertex: "teriableBasic", fragment: "teriableBasic", }, { attributes: ["position", "normal", "uv"], uniforms: ["world", "worldView", "worldViewProjection", "view", "projection"] }); var height = 100; var NoiseBase = new dN('Simple2','test2',{scale:100}); var Noise2 = new dN('Worley2','newSeed',{width:100, height: 100, scale:30}); var ground = BABYLON.Mesh.CreateGround("ground", 100, 100, 100, scene, true); ground.material = teriableBasic; var vertexData = ground.getVerticesData(BABYLON.VertexBuffer.PositionKind); for (var i = 0; i < vertexData.length; i += 3) { var x = vertexData[i], y = vertexData[i+1],z = vertexData[i+2]; vertexData[i+1] = (-height*0.5) + (dN.filter.smooth(0.65, dN.Multiply(NoiseBase.getValue({x:x, y:z}), Noise2.getValue({x:x, y:z})))*height); //console.log(vertexData[i+1]); }; ground.updateVerticesData(BABYLON.VertexBuffer.PositionKind, vertexData, 0, 0); var positions = ground.getVerticesData(BABYLON.VertexBuffer.PositionKind); var indices = ground.getIndices(); var normals = ground.getVerticesData(BABYLON.VertexBuffer.NormalKind); ground.updateVerticesData(BABYLON.VertexBuffer.NormalKind, normals, true, true); BABYLON.VertexData.ComputeNormals(positions, ground.getIndices(), normals); /* function createTerrain(name, numberOfNoises, width, depth, height, args){ numberOfNoises = numberOfNoises || 3; function tRand(s){ s = Math.sin(t) * 10000; return parseFloat(s - Math.floor(s)); } };*/ return scene; }; var scene = createScene(); engine.runRenderLoop(function () { scene.render(); }); window.addEventListener("resize", function () { engine.resize(); }); sorry for the sloppy formatting the copy and paste was not good for it... um you could pretty much copy and paste this in and get it working, your gonna need DAS NOISE though. Now for the off topic response. Teriable is a child project of the main goal Project Celest. I posted a little bit about it a while back then got hush hush about it. I had to deviate from its development for a while becuase it is not a single system and had to obtain the knowledge to develop the full gambit of tools. The end goal (which I have already accomplished in prototypes) is to generate an entire solar system off a single seed, down to the tiniest details. So far I have accomplished: Celestial : Generates a star of with correct rates for real world star types, its mass, its spectrum, its output, its habitability range, its gravitational effects in correlation to all other elements in the system, and its chemical composition all accurate to real world numbers. It also generates the features around the star including Planets the planets moons and asteroid belts along with other exotic features and figures out all similar things as it did for the star like chemical composition, gravity etc. But also goes the extra level to define its environment if it has any and if it is habitable, with a force habitable option. All planets and stars generated are from the known types to science and I have all the stars done and like 80% of the planets. Teriable: Terrain generation system, you guys have seen the most of this current versions are being reworked to bend the planes around a central point to simulate planetary curve and the systems for generating water and mineral deposits along with biom identification. I will also be introducing my new procedural method I am developing called MIPS or Modular and Independent Procedural Systems which you will hear more about soon, and I have started documenting in a article I will mention later in this post. I want to introduce this method to handle the subsurface tunneling. Citi-eZ: City generation starting from the road level based on sub maps for population density and elevation along with regions for different construction styles. This part is in its infancy, and will soon be incorporated into Teriable. This will be the main use of my new MIPS system: https://pryme8.github.io/citiez/. more on this one later... Secret Project**: This one is super Hush Hush... but yeah ill say something about it... Plants and Creatures ^_^... and I already have the basic components working so yeah.... Im just waiting to bite of a section of this because it will be highly dependent on its environment, which all of that structure is not in place yet. Ive been writing in my notebook about this for like 10 years, and have been actively working on it since day 1 I found BJS. Its all going to be wrapped in my convenient Tower Editor that is pretty close to fully functional now. Lets just say I have been busy and you guys only get to see a fraction of what I produce. Currently I am working on a paid BJS contract and like4 websites now (just got a new one) so Im a busy busy guy and really have not had any time to work on my stuff... soo yeah well see if this is all a pipe dream or not, but ill stick to it and if It gets even fractionally more done it should handle most of your guys terrain needs. ***PS I feel like @Wingnut is gonna roast me for this one... kohai and webGLmmk 2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 27, 2016 Share Posted September 27, 2016 Actually, I'm not paying much attention. But I would like to maintain my #1 ranking for... people who talk about themselves. I'm kind of proud of that. Sometimes... though, @pryme8 is hot on my heels. Pryme8 types fast. I know he does. I think he has my butt kicked on typing/coding speed. But I can still "thought-wander" better than he can. He usually just talks about himself/his-stuff. But he DID talk about a complete virtual reality inside of a woodpecker hole... and spoke of enfolded space. So, he's not far behind in Weirdoville, either. Ok, just came to visit. Bye again. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
kohai Posted September 28, 2016 Share Posted September 28, 2016 @Pryme8 thanx for your answer, i'll look at your code and see what i can do with it. @Wingnut i think you'll keep your record for the highest post count and/or longest answers in this forum anyway ! Man, you are legend ! Wingnut 1 Quote Link to comment Share on other sites More sharing options...
TheDude Posted October 1, 2016 Author Share Posted October 1, 2016 @Pryme8 Wow, you basically described my whole game idea! Though mine includes a playable character and building. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 1, 2016 Share Posted October 1, 2016 Already got that stuff, that was the easy part ;). im putting all that on pause for a second while I figure out the math for Magnus slip. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.