• Content count

  • Joined

  • Last visited

  1. (Edited out into its own post, because, messiness.) A further discovery I'd love to have verified: It appears that the uniforms above do not need to be declared when creating a shaderMaterial -- Babylon.js supplies them for you. So rather than declaring: var shaderMaterial = new BABYLON.ShaderMaterial("shader", scene, {vertex: "custom", fragment: "custom"}, {attributes: ["position", "normal", "uv"], uniforms: ["world", "worldView", "worldViewProjection", "view", "projection"]} ); You can omit the attributes section, unless supplying your own custom data to the shader: var shaderMaterial = new BABYLON.ShaderMaterial("shader", scene, {vertex: "custom", fragment: "custom"}, {attributes: ["position", "normal", "uv"], uniforms: ["capybaras"]} );
  2. Kosh's link. Based on the CYOS examples, I can verify that the following are available: // Attributes attribute vec3 position; //vertex x,y,z attribute vec3 normal; //normal x,y,z attribute vec2 uv; //uv (texture map) 2d coordinates // Uniforms uniform mat4 world; //convert from model space to world space uniform mat4 view; //convert world space to camera-relative space uniform mat4 projection; //flatten camera space to frame view uniform mat4 worldView; //world and view, pre-multiplied for you uniform mat4 worldViewProjection; //world, view & projection pre-multiplied uniform sampler2D textureSampler; //texture data uniform vec3 cameraPosition; //camera x,y,z uniform float time; //time Are there any predefined shader attributes or uniforms that I'm missing?
  3. Dead link. Has this been added to the documentation? I wasn't able to find it. If not, maybe someone wouldn't mind pasting the relevent information into this thread for posterity's sake?
  4. What's next?

    I'd love to see any of the following: LOD enhancements: LOD blending. Not sure what the "cheapest" method to reduce pop-in is. 1-bit pattern masks? Load and dispose at LOD. A "set it and forget it" method to load a model/scene file into the current scene when needed, then dispose of it when no longer needed. This would be quite helpful for building large/streaming type worlds, but useful even for small scenes to reduce load times. (Everyone hates a loading screen!) More user-friendly shaders: Built-in primitives. Rather than Road, Fire, Brick, etc. a set of option-heavy primitives like SimplexNoise, CellTurb, Gradient, Tiles, SphereMap, PlanarMap, etc. Primitive combiners. In prerendered 3d, nesting nodes like gradients, noise patterns and falloff types allows for the creation of extremely rich non-repeating textures from very short descriptors. Could something similar be done to generate pixel shaders? A simpler method to remap keys and other input methods (as opposed to just adding and removing keys). (On background, I'm working on a virtual museum of Earth history, in which every step you take represents a million years. So, a mesh-heavy scene that's almost 2 miles long. I'm an old hat at animation, but new to realtime 3D. What I'm mainly finding is that the bottleneck isn't the amount of content to be rendered, but getting that content to the user's browser in the first place.)
  5. Altering the Vertices of an Imported Mesh

    Ahh! Good point, Kosh. Object.setVerticesData() does not update normals. Unless that's desirable (or you're also creating a normals array manually), object.updateMeshPositions() may still be the best way to go. I'll leave my four-step answer alone.
  6. Altering the Vertices of an Imported Mesh

    Appreciate the help, crew. (And yeah, my Float32 conclusion came from a coding typo on my part!) What I'm really trying to do is map out the "gotchas" around editing vertex data in bjs. What I'm mostly finding is that the better-documented updateMeshPositions() method is rather delicate and unnecessarily complex--at least in my specific case of using a webworker to generate the new vertex arrays. Possibly in most cases.
  7. Altering the Vertices of an Imported Mesh

    Thanks, JC. In other words--to surface the lede from your code--you can replace vertex data directly with object.setVerticesData(), but only if your new data is in an [explicitly created] Float32 array. Is there any advantage to using an object.setVerticesData() function?
  8. Altering the Vertices of an Imported Mesh

    Hmm. Might be a bug. In Chrome and Firefox, at least, only editing the values of the position array in situ appears to work. Regardless, for anyone using this thread for future reference, you'll need to take the following steps to alter an imported mesh. (Here's a working playground to follow along.) Kosh (All Kosh?) Thanks again! Rip out the mesh's vertex position data & stuff it back in, with updateable set to true: var pos = bb.getVerticesData(BABYLON.VertexBuffer.PositionKind); bb.setVerticesData(BABYLON.VertexBuffer.PositionKind, pos, true); Rip out the mesh's vertex normals & stuff them back in, with updateable set to true: var nm = bb.getVerticesData(BABYLON.VertexBuffer.NormalKind); bb.setVerticesData(BABYLON.VertexBuffer.NormalKind, nm, true); Call updateMeshPositions() on the mesh: bb.updateMeshPositions(positionFunction, true); Create a function to edit the vertex positions, for updateMeshPositions() to trigger. Note that updateMeshPositions() automatically passes the vertex position array of the mesh that calls it as an argument to your position function: var positionFunction = function(positions) { var numberOfVertices = positions.length/3; for (var i = 0; i < numberOfVertices; i++) { positions[i*3] = Math.random(); positions[i*3+1] = Math.random(); positions[i*3+2] = Math.random(); }; };
  9. Altering the Vertices of an Imported Mesh

    Very elegant! Is it possible to replace all of the existing vertex positions in a single copy operation, like existingVertices = newPositionArray; or would I always need to loop through the vertex array replacing values one by one?
  10. Hey crew. I've run up against trouble trying to move the vertices of an imported mesh. (So far I've tried a .babylon file and .glb.) Here's a Playground example where I've added a randomize-vertex-positions function to the glTF Importer (Boombox) example. Upon loading the scene file, we do this: //Add a "do this once the mesh loads" function to the example: var bb = scene.getMeshByName("BoomBox"); //Get the newly-loaded mesh bb.updateable = true; //Not clear if this does anything var positions = bb.getVerticesData(BABYLON.VertexBuffer.PositionKind); //Copy the mesh's vertex positions into an array var numberOfVertices = positions.length/3; //Randomize the vertex coordinates in the array for(var i = 0; i<numberOfVertices; i++) { positions[i*3] = Math.random()*5; positions[i*3+1] = Math.random()*5; positions[i*3+2] = Math.random()*5; }; var positionFunction = function() { //Create a function for updateMeshPositions to call... bb.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions); //...where we replace the old vertex data with our array }; bb.updateMeshPositions(positionFunction, true); //Call that updateMeshPositions function //And... nothing happens. The boombox remains as it was at import. No change. Any thoughts on what I might be doing wrong?
  11. Referencing Lights Imported From Blender

    Your intuition was right, Wingnut. Not a Babylon problem. It was one of those Javascript issues I can never seem to keep straight: BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, function() {console.log(scene.getLightByName("sun"));}); ...creates a find-the-sun function that will be called when the loader finishes. This works! BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, console.log(scene.getLightByName("sun"))); ...fires console.log() immediately when Append() runs, rather than waiting for the loader to finish. Hence, so sun!
  12. How would I reference a light imported from Blender? I'm appending a scene with a directional light (sun) as follows: BABYLON.SceneLoader.Append("", "museumScene.babylon", scene); Now, if I add a "fire when fully imported" function to return the array of lights in the scene, I see my sun in the console just as I'd expect: BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, console.log(scene.lights)); However, if I try to reference the sun in the normal way, I only get null: BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, console.log(scene.getLightByName("sun")));
  13. Excellent! Output works perfectly now. Thanks, JC.
  14. Does anyone have experience using the Tower of Babel exporter with the Mac version of Blender? My test scenes fail with the following log error (in both Bforartists and the "mainline" Blender app). Is there perhaps a file-writing peculiarity under OS-X? I'm too weak at Python to dig any deeper before reaching out, I'm afraid... [snip] ========= Writing of files started ========= ========= An error was encountered ========= File "/Users/me/Library/Application Support/Bforartists/2.79/scripts/addons/tower-of-babel/", line 177, in execute self.to_script_file() File "/Users/me/Library/Application Support/Bforartists/2.79/scripts/addons/tower-of-babel/", line 217, in to_script_file, typescript_file_handler, self.needPhysics, self) File "/Users/me/Library/Application Support/Bforartists/2.79/scripts/addons/tower-of-babel/", line 84, in initScene_script file_handler.write(indent + 'scene.fogMode = ' + self.fogMode + ';\n') ERROR: Can't convert 'int' object to str implicitly ========= end of processing ========= elapsed time: 0 min, .0047 secs test_scene.blend
  15. Normal Map Intensity?

    Is there a method of altering the intensity of a bump map (normal map) from within Babylon.js? Something along the lines of: var bumpyMaterial = new BABYLON.StandardMaterial("bumpy", scene); bumpyMaterial.bumpTexture = new BABYLON.Texture("bumpy_normal_map.jpg", scene); bumpyMaterial.bumpTexture.alpha = 0.5; More generally I suppose, how would one fade a texture map of any kind during runtime?