SpaceToast

Members
  • Content Count

    27
  • Joined

  • Last visited

  1. SpaceToast

    Importing Animations with an AssetContainer?

    Hi Kosh, I tried looping through all the imported meshes, looking for one with mesh.animations.length > 0, but nothing comes up. Am I looking in the wrong place?
  2. SpaceToast

    Loading assets directly from passed files

    Hi Nikita, EDIT: I was wrong! See below. BJS does indeed provide an easier method. This should be quite doable (I believe the Playground performs a similar trick.) but Babylon doesn't provide a method by itself. Mine the code in these examples to upload the file to browser memory. You may then need to call window.URL.createObjectURL() on the uploaded file to attach it (invisibly) to the DOM first. After that, you can pass the object URL the browser generates to the AssetManager as the rootUrl for Append() or AppendAsync() -- the sceneFilename property can be ignored. Sorry I'm not at a machine I can test this on, but I think the above will work. Let me know!
  3. Is importing animations (in this case, from Blender) in an assetContainer currently supported? I can see the animation data in the .babylon file, but scene.animations, container.animations, and all mesh.animations arrays come up empty.
  4. SpaceToast

    Ideas: Best Way to Extend the StandardMaterial?

    That's not a drawback in this case. Unfortunately, after 6 hours trying to understand the source code, I'm no closer to figuring how to inject a new uniform into the StandardMaterial object at runtime. It's just too amazingly complicated. Afraid I'll have to go back to my previous method. 😔
  5. SpaceToast

    Ideas: Best Way to Extend the StandardMaterial?

    I was 100% wrong about that last comment. Replacing the StandardMaterial's shaders is as simple as: BABYLON.Effect.ShadersStore["defaultVertexShader"] = ` //Copy the StandardMaterial's vertex shader code in here, and modify away. //Template literals are your friend. `; BABYLON.Effect.ShadersStore["defaultPixelShader"] = ` //Copy the StandardMaterial's pixel shader code in here, and modify away. `;
  6. SpaceToast

    Ideas: Best Way to Extend the StandardMaterial?

    Thanks @Pryme8, @Sebavan and @NasimiAsl. CustomMaterial looks like exactly what I need. Unfortunately, it doesn't seem to be production-ready just yet, based on the other forum threads. I could see saving a bit of trouble by replacing the StandardMaterial object with a custom version at runtime--one containing my changes. I'm not really familiar with JavaScript modules, however: They seem to be designed specifically to prevent code from tinkering around inside their scope.
  7. I'm picking up an older project again, and moving it to the current version of BJS. This is a pain, though, because I'd been extending the StandardMaterial shader within a copy of the BJS framework itself. The project made extensive use of noise and shape functions to simulate textures within the GPU by altering the diffuse, specular and normal values of the StandardMaterial, based on a flag hacked into the framework. The advantage of this method vs. ShaderMaterial was getting unlimited resolution textures at no bandwidth cost without having to reimplement all the goodies in the StandardMaterial--SSAO2, fog, shadows, etc. The disadvantage: Lack of portability, and having to find a way to re-minify everything myself before deployment. (My kingdom for uglify.js to support the `` multiline literal...) Before I start migrating my hacks, I wanted to ask this of the smart people around the water cooler: Can anyone suggest a more elegent way to do this, without modifying BJS itself?
  8. SpaceToast

    Getting the Results of SceneLoader.Append()

    I'll migrate over to the 3.2 preview and experiment with it! Looks like a great tool.
  9. What is the best way to get the results--the appended bits--from BABYLON.SceneLoader.Append() ? The function for a single model, BABYLON.SceneLoader.ImportMesh(), and the function to load a new scene BABYLON.SceneLoader.Load(), both return their result, but Append() seems to only return the existing scene. I believe I understand the concept in this thread--mark everything that's already loaded before calling BABYLON.SceneLoader.Append(), at which point everything that's not marked can be assumed to come from the file load. The trouble is, if multiple files are being loaded, there's no guarantee that all of the new meshes, lights and cameras in the scene come from the same file when onSuccess fires. (This is assuming file loading happens async.) I suppose it would be possible to use BABYLON.SceneLoader.Load() to instead put the results into a new (hidden) scene, loot that scene for parts to the main scene, then delete it. That feels like a lot of overhead though. Any better ideas? [Peeling this out into its own topic, as Q&A threads don't "bump" anyway!]
  10. SpaceToast

    Babylon Scene vs some Model

    Sorry to "bump" an old topic, but is there a better way to get the results--the appended bits--from BABYLON.SceneLoader.Append() ? I believe I understand the concept above--mark everything that's already loaded before calling BABYLON.SceneLoader.Append(), at which point everything that's not marked can be assumed to come from the file load. The trouble is, if multiple files are being loaded, there's no guarantee that all of the new meshes, lights and cameras came from the same file when this append's onSuccess fires. (This is assuming file loading happens async.) I suppose it would be possible to use BABYLON.SceneLoader.Load() to instead put the results into a new (hidden) scene, loot that scene for parts, then delete it. That feels like a lot of overhead though. Any ideas?
  11. (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"]} );
  12. 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?
  13. 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?
  14. SpaceToast

    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.)
  15. SpaceToast

    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.