Amarth2Estel

Members
  • Content Count

    45
  • Joined

  • Last visited


Reputation Activity

  1. Thanks
    Amarth2Estel reacted to Deltakosh in Transparent object shadows   
    Here we are: https://www.babylonjs-playground.com/#1KF7V1#19
  2. Thanks
    Amarth2Estel reacted to Deltakosh in Transparent object shadows   
    Well this is because shadows are computed as light removal. They remove light intensity where they are applied. So where the 2 shadows combine you receive no light at all hence the dark
    Your best option would be to use the ShadowOnlyMaterial: https://github.com/BabylonJS/Babylon.js/blob/master/materialsLibrary/src/shadowOnly/babylon.shadowOnlyMaterial.ts and probably update the shader to add color instead of blocking light
  3. Like
    Amarth2Estel reacted to Deltakosh in showBoundingBox & renderingGroupId   
    Fixed!!! It will be in next nightly. Thanks for the heads up!
  4. Thanks
    Amarth2Estel reacted to Deltakosh in showBoundingBox & renderingGroupId   
    This is because the bounding box renderer is rendered AFTER all the renderingGroup. 
    This is the "expected" behavior. Let me check if I can move them inside the renderingGroup...
  5. Like
    Amarth2Estel got a reaction from Wingnut in AR : Placing 3D Object in 2D picture using picked points   
    Hi Wingnut !
    Thank you for your answer !
    Yes, this is an augmented reality project and you are completly right, I should have mention it. I will edit my post.
    But, from what I saw, it seems that most of AR apps uses a video stream and a marker with a specific pattern. Using pattern recognition, the marker can be found.. and the magic of math appends !
    I won't use a specific marker because I cannot ask users to print a carpet-wide pattern and because I only want to use static images. However, I am well aware of the relation between these two approaches.
    I found an algorithm named "POSIT" which seems to fit my needs and data. It seems compute the pose of the camera from points taken in 2D.. It exists for non coplanar points (the case of my problem) and coplanar points (markers with specific patterns).
    Video
    Source code 
    Maths and algorithm alternatives
    I will go on eating math all day until I found an answer ! I will post here!
    About your freeway-reduising-noise-project, it seems great ! Too bad you cannot continue this work 😕 !

    I completely agree with you about spatialization data. I hope it will become commonplace as soon as possible !
  6. Like
    Amarth2Estel reacted to distraub in Having an issue with Ray.intersectsMesh   
    Thank you @Amarth2Estel
    This does solve my issue, if I use multiPickWithRay and then check for the id of my mesh, then it works as expected.
    I was hoping intersectsMesh would work the same way.
    Here is an example https://www.babylonjs-playground.com/#KNB069#3
    If you intersectsMesh with those coordinates it seems to use the other end, which almost looks like it is shooting the ray from the target to the source and using that picked point.
  7. Like
    Amarth2Estel got a reaction from distraub in Having an issue with Ray.intersectsMesh   
    Hello Distraub !

    I did some test with your PG.
    First thing I can say is that even with a negative Y position, the picked point may be the one you are looking for : https://www.babylonjs-playground.com/#KNB069#1 When using pickWithRay method instead of intersectWithMesh, even with not-working-Y-position on your alternate sphere, it is working as expected. I think it is because pickWithRay get the first hit from source to target while intersectWithMesh has another behaviour : https://www.babylonjs-playground.com/#KNB069#2 Hope it will help
  8. Like
    Amarth2Estel reacted to Jose Vicente in Mesh clone and BackFace culling   
    Thanks Amarth2Estel, I still doesn't know why the cloned mesh is not visible but with your help I've been able to find a workaround.
    Kind Regards.
  9. Thanks
    Amarth2Estel got a reaction from Jose Vicente in Mesh clone and BackFace culling   
    Hello Jose Vicente !

    I don't know why your code doesn't have the expected behaviour.

    BUT, to deal with your face orientation issue, I think you should use the flipFaces method on your mesh.

    Here is a PG :  https://playground.babylonjs.com/indexStable.html#VI428J#4

    Because cloned mesh uses the same vertexData as the "original" mesh it has been cloned from, flipping the faces of the clone will flip the faces of the original mesh as well. The same thing apply for the instanced mesh.
    To change the orientation of the cloned mesh only, you should try to use makeGeometryUnique on it to un-link its vertexData and the vertexData of the original mesh.. but it will loose the interest of cloning.
    You can comment line 42 to see this behaviour

    To apply a change (scaling, rotation or position) in the vertexData directly, then you can use bakeCurrentTransformIntoVertices. Keep in mind that if you call this method on a mesh, all the meshes sharing its geometry (instances and clones) will also be affected.

    Hope it will help !
     
  10. Like
    Amarth2Estel got a reaction from Deltakosh in Mesh clone and BackFace culling   
    Hello Jose Vicente !

    I don't know why your code doesn't have the expected behaviour.

    BUT, to deal with your face orientation issue, I think you should use the flipFaces method on your mesh.

    Here is a PG :  https://playground.babylonjs.com/indexStable.html#VI428J#4

    Because cloned mesh uses the same vertexData as the "original" mesh it has been cloned from, flipping the faces of the clone will flip the faces of the original mesh as well. The same thing apply for the instanced mesh.
    To change the orientation of the cloned mesh only, you should try to use makeGeometryUnique on it to un-link its vertexData and the vertexData of the original mesh.. but it will loose the interest of cloning.
    You can comment line 42 to see this behaviour

    To apply a change (scaling, rotation or position) in the vertexData directly, then you can use bakeCurrentTransformIntoVertices. Keep in mind that if you call this method on a mesh, all the meshes sharing its geometry (instances and clones) will also be affected.

    Hope it will help !
     
  11. Like
    Amarth2Estel got a reaction from Deltakosh in LODs and CSG   
    Thank you very much @Deltakosh !

    This perfectly fits my needs !
    http://www.babylonjs-playground.com/#4LX0VC#1
  12. Thanks
    Amarth2Estel reacted to Deltakosh in LODs and CSG   
    1. I think that would be the more performant option
    2. You can get activeLOD at any time with meshLOD = mesh.getLOD(this.activeCamera);
  13. Like
    Amarth2Estel reacted to babbleon in dispose unused textures   
    Great! Thank you @Amarth2Estel,
    Works a treat. Solved!
    function removePiece(rand) { var meshes = scene.getMeshesByTags('mesh' + rand); for (var i = 0; i < meshes.length; i++) { console.log(meshes[i].name); meshes[i].dispose(); } var materials = scene.getMaterialByTags('material' + rand); for (var i = 0; i < materials.length; i++) { console.log(materials[i].name); materials[i].dispose(false, true); } }  
  14. Thanks
    Amarth2Estel got a reaction from babbleon in dispose unused textures   
    Hello Babbleon !

    I don't know about dealing with Texture only, but the dispose method of material accepts additionnal parameters to force the dispose of textures.
    Take a look at : https://doc.babylonjs.com/api/classes/babylon.material#dispose
  15. Like
    Amarth2Estel got a reaction from leanderr in Best performing material/light combinaton   
    Hi Leanderr !

    Optimization is the key ! 

    To say it fast, to improve performances, you should reduce the draw calls.

    You can use instances, merge meshes, using light (not heavy) texture files etc..
    You should freeze matrices and materials, when it is possible to avoid useless computation.
    Especially in static scene, there is a lot of "manual" optimization you can do to improve the performance. 

    Of course, having as less lights as possible in your scene. 1 can be enough in a lot of scenario if you use tricks like ambient lighting or illumination maps.

    From the screenshot of the debug layer, I can see that there is 6 materials for 16 active meshes. You should try to merge meshes sharing the same material.
    ------- 
    Once every little optimization done in your scene, if the hardware is still not powerful enough to render the scene smoothy, you may disable rendering features.
    BabylonJS has its own Scene Optimizer to do it.
    You should have a look there : https://doc.babylonjs.com/how_to/optimizing_your_scene
    and here : https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer

    To conclude, you can render your scene in a tiniyer resolution than your canvas, but the result will be streched to the canvas resolution so it will of course be blurry.
    In my opinion, this is something you should do only if you know you have already done every other optimization.
    To do so, just use 
    engine.setHardwareScalingLevel = n (with n < 1);
    See http://doc.babylonjs.com/api/classes/babylon.engine


    Hope it helps!
  16. Like
    Amarth2Estel reacted to legallon in Change the color of an imported obj   
    Hey man , 
    Thanks for the suggestion concerning the material !  I comentend the line 3 and it works. I didn't really think it was about the mtl file because I thought I was forced to import it with my object ( now I can see that I'm not).
    Thanks again , it helped a lot
  17. Like
    Amarth2Estel got a reaction from legallon in Change the color of an imported obj   
    Hi Legallon !

    Concerning the import from you git repo to the playground, I think that is only a CORS problem.
    Concerning the wrong material, I think the problem is that your .OBJ says which material to use (line 3 : mtllib camion.mtl). Just remove the link of .mtl when you export from Blender (or directly remove this line from your .OBJ) to make sure the material used will be the one you define with babylon. This should fix your problem.

    Hope it helps
  18. Like
    Amarth2Estel got a reaction from timetocode in Load mesh without rendering it, then adding it to the world many times   
    Hi Timetocode ! 

    Well, for points 1 and 2.. I don't think there is a perfect solution. it depends of what you need. I suggest that if you want to have a 'master' tree model to spawn on your scene, then using a OBJ loader (https://doc.babylonjs.com/how_to/obj) should be enough. But maybe GLTF or .babylon could be better, especially if you want additional information like lights etc...
    3. You just have to disable the mesh. try setEnabled(false) and your mesh won't appear.
    It is better way than just setting the opacity to 0 or isVisible to false because a disabled mesh is not taking in account during hidden babylon computation.

    4. You may use instances : https://doc.babylonjs.com/how_to/how_to_use_instances
    From my experience, you will get better performances by cloning your 'master' mesh, and then merging all the clones : https://doc.babylonjs.com/how_to/how_to_merge_meshes
    It is incredibly powerful if theses clones don't need to be edited later, but then it is gonna be harder to remove/modify individual objects as said in 5. (Do not forget to make sure clones or instances are enabled !)
    5. Easy using instances. You may use subMesh to do it while working with a big mesh made from merged clones, but it is way heavier.

    To conclude : I guess you should use instances if you know your loaded-and-spawned meshes will be modified later. Clones and Merge otherwise.

    Hope it will help !
  19. Like
    Amarth2Estel reacted to babbleon in Scene displays before material changes are ready   
    I think I have sorted this. Can't show all of it in PG, so have pasted below in case anyone else can make use of it.
    var createScene = function() { engine.enableOfflineSupport = false; var scene = new BABYLON.Scene(engine); var camera = new BABYLON.ArcRotateCamera('Camera', null, null, null, BABYLON.Vector3.Zero(), scene); camera.setPosition(new BABYLON.Vector3(1.00, 1.00, -1.50)); camera.minZ = 0; camera.panningDistanceLimit = 1; camera.pinchPrecision = 60.00; camera.wheelPrecision = 60.00; camera.upperAlphaLimit = (Math.PI * (90.00 + 270) / 180); camera.lowerAlphaLimit = (Math.PI * (-90.00 + 270) / 180); camera.upperBetaLimit = 95.00 * (Math.PI / 180); camera.lowerBetaLimit = 0.00 * (Math.PI / 180); camera.lowerRadiusLimit = 0.50; camera.upperRadiusLimit = 2.00; camera.target = new BABYLON.Vector3(0.00, 0.30, 0.00); camera.fov = 50.00 * (Math.PI / 180); camera.attachControl(canvas, false); var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 4, 0), scene); light.intensity = 0.7; var assetsManager = new BABYLON.AssetsManager(scene); //load json file with specification for each material to be applied var textTask = assetsManager.addTextFileTask('materialsjson', 'https://raw.githubusercontent.com/babbleon/babylon/master/materials.json'); assetsManager.load(); textTask.onSuccess = function(task) { parts = JSON.parse(textTask.text).material; //babylon file has materials, but all are white BABYLON.SceneLoader.Append('', 'https://raw.githubusercontent.com/babbleon/babylon/master/testcubes.babylon', scene, function() { for (var i = 0; i < parts.length; i++) { for (var j = 0; j < scene.meshes.length; j++) { //loop thru each mesh's material and if it matches that in the json file, then we change it if (scene.meshes[j].material.name === parts[i].par_path) { //rand added to texture path to avoid caching on playground scene.meshes[j].material.diffuseTexture = new BABYLON.Texture('https://raw.githubusercontent.com/babbleon/babylon/master/' + parts[i].mat_id + '.jpg?rand=' + Math.round(Math.random() * 100000), scene); scene.meshes[j].material.diffuseTexture.coordinatesIndex = 1; scene.meshes[j].material.diffuseTexture.uScale = 5; scene.meshes[j].material.diffuseTexture.vScale = 2; scene.meshes[j].material.diffuseColor = BABYLON.Color3.FromHexString(parts[i].mat_diffuseColor); scene.meshes[j].material.specularColor = BABYLON.Color3.FromHexString(parts[i].mat_specularColor); scene.meshes[j].material.ambientColor = BABYLON.Color3.FromHexString(parts[i].mat_ambientColor); scene.meshes[j].material.emissiveColor = BABYLON.Color3.FromHexString(parts[i].mat_emissiveColor); scene.meshes[j].material.ambientTexture = new BABYLON.Texture('https://raw.githubusercontent.com/babbleon/babylon/master/Job%201_FULL.png', scene); scene.meshes[j].material.ambientTexture.coordinatesIndex = 0; } } } }); } return scene; }; var scene = createScene(); engine.runRenderLoop(function() { if (!scene.isReady()) { engine.displayLoadingUI(); } if (scene.isReady()) { scene.render(); } });  
  20. Like
    Amarth2Estel got a reaction from babbleon in Scene displays before material changes are ready   
    Hello !

    I think you may use the 'onSuccess' callback of your sceneLoader to do your material changes.
    This way, the scene is not ready.
    Then, you just have to stop the renderLoop if the scene is not ready, and wait until it is ready to start it again.

    I was not able to test it, because well.. my internet connection is too fast (I can't believe I am actually complaining about that).
    https://playground.babylonjs.com/#X6KVNY#4
     
    I guess you can also force the LoadingUI to be displayed instead of stoping the renderLoop
    https://playground.babylonjs.com/#X6KVNY#5
    I think that in your own code (working out of the playground) might be easier as you have complete control on the moment you launch the renderLoop.
     
  21. Like
    Amarth2Estel got a reaction from Deltakosh in Scene displays before material changes are ready   
    Hello !

    I think you may use the 'onSuccess' callback of your sceneLoader to do your material changes.
    This way, the scene is not ready.
    Then, you just have to stop the renderLoop if the scene is not ready, and wait until it is ready to start it again.

    I was not able to test it, because well.. my internet connection is too fast (I can't believe I am actually complaining about that).
    https://playground.babylonjs.com/#X6KVNY#4
     
    I guess you can also force the LoadingUI to be displayed instead of stoping the renderLoop
    https://playground.babylonjs.com/#X6KVNY#5
    I think that in your own code (working out of the playground) might be easier as you have complete control on the moment you launch the renderLoop.
     
  22. Like
    Amarth2Estel got a reaction from efxlab in Shadow caster and model proportion in babylon scene unit   
    Hi !

    Your shadows are here. But because of the camera direction you don't see them.
    Using an arc rotate with control, you can see your shadows are projected, but outside of your original camera view.
    https://www.babylonjs-playground.com/indexstable#10D6YT#93

    You will see that the shadow is not natural.. it is because your character is litteraly flying. There is 2 babylon units between him and the ground (Y componant). Try working on their position
    https://www.babylonjs-playground.com/indexstable#10D6YT#95
    By the way, don't forget to set sizeAuto to false when you create your default environment, otherwise your skyboxSize and groundSize are not taken.
  23. Like
    Amarth2Estel reacted to efxlab in dispose Mesh and ram release   
    Hello Amarth2Estel ! its perfect great just tested.
    Just for info,  I will : mesh.dispose(false, true) instead of true/true, for recurse release on the mesh's children.
  24. Thanks
    Amarth2Estel got a reaction from ziguri in Render Glitch when using alpha on StandardMaterial   
    Hi maecky !

    I think you will find interesting info here : https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered

    To fix your problem, you just need to set mesh.material.needDepthPrePass to true 

    PG fixed : http://www.babylonjs-playground.com/#AFH1MN#2
     
    Edit : As written in doc linked above, if you have to work with "real" transparency (I mean, not 0.9999) , then setting separateCullingPass to true is better!
    PG with alpha 0.2 : http://www.babylonjs-playground.com/#AFH1MN#3
  25. Thanks
    Amarth2Estel got a reaction from maecky in Render Glitch when using alpha on StandardMaterial   
    Hi maecky !

    I think you will find interesting info here : https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered

    To fix your problem, you just need to set mesh.material.needDepthPrePass to true 

    PG fixed : http://www.babylonjs-playground.com/#AFH1MN#2
     
    Edit : As written in doc linked above, if you have to work with "real" transparency (I mean, not 0.9999) , then setting separateCullingPass to true is better!
    PG with alpha 0.2 : http://www.babylonjs-playground.com/#AFH1MN#3