acarvallo

Members
  • Content Count

    14
  • Joined

  • Last visited

About acarvallo

  • Rank
    Member

Recent Profile Visitors

372 profile views
  1. acarvallo

    Inspector v2.0 is ready for testing

    I am using webpack 4, but it's not the reason behind the issue, see: https://codepen.io/anon/pen/ZmvEbV (I just used the template https://doc.babylonjs.com/babylon101/first#html-template and called scene.debugLayer.show() )
  2. acarvallo

    Inspector v2.0 is ready for testing

    Well, I can't since the inspector is loaded by default in one of the <script> tag of the playground page. You can see at the bottom of the screenshot that the URL is already here, the error appears after loading the script, URL is fine
  3. acarvallo

    Inspector v2.0 is ready for testing

    Hello, I recently updated to BabylonJS v4.0.0-alpha.9 and the new Inspector/Debug Layer doesn't work for me, I'm calling "scene.debugLayer.show()" and I get "Uncaught TypeError: Cannot read property 'Inspector' of undefined" after it loads the script because it's trying to call isVisible() but this.BJSINSPECTOR is undefined at that time:
  4. acarvallo

    Babylon shows a different result

    Hi @fdeng It looks like many CAD/3D software (mainly for buildings) have the height on the Z axis, while Babylon or other WebGL libraries have Y. I encountered the same issue and I used a pivot matrix on my mesh to flip the two axis : https://playground.babylonjs.com/#4QU0BY#2 On lines 25-26 you can see the 1's are switched, an untouched matrix would look like this : 1, 0, 0, 0 0, 1, 0, 0 0, 0, 1, 0 0, 0, 0, 1 (You can also put values different than 1, and it will scale on the corresponding axis) There might be others/better solutions but in my case it seems to work great, and allows to keep original positions.
  5. acarvallo

    rendering only when needed

    Hey, You probably just want to not run the render loop. Instead, only call scene.render() at the start, and after each of your requests.
  6. acarvallo

    Transparency & alpha issues

    Hi, thanks for the link, I wasn't aware of this feature ! Updated PG : https://playground.babylonjs.com/#BQLAVV#3 It's for sure better, but there still seems to be some artifacts : It's strange because they should all be similar elements, so I would think they will render the same. I guess it's because the faces touching each other have the same positions. Not sure if there is much more doable with facets data, another possible option could be to depth sort particles, but use, for example, the center of the bounding box of each particle instead of its position.
  7. acarvallo

    Transparency & alpha issues

    Hm, I should have activated notifications, could have answered earlier :| So, thanks @jerome for the SPS particle depth sort, but it does nothing in my case due to all my particles's position being Zero (only using position buffer from the original mesh for each particle). And you're absolutely right about having 2 SPS @Deltakosh, it's indeed what I have in my actual project, but I can't seem to have a perfect (or decent) looking render. Here is a playground to see what's going on : https://playground.babylonjs.com/#BQLAVV#2 And 2 screenshots, camera looking from one side, then the opposite one : I would basically like to have the render on the right be of the same type as the one on the left. Tried to play a bit with depth/culling options and alphaMode (as you can see starting from line 48), but I couldn't find a really good combination.
  8. acarvallo

    Transparency & alpha issues

    It totally makes sense, unfortunately the PG is just a part of my geometry, I can have a lot of objects both transparent and opaque for their initial state. I used a SPS because it makes picking easier thanks to particles/pickedParticles, but the thing I'm really looking for is performance, may it be using a SPS, a regular mesh or something else. Maybe you have another idea or magic property (like forceDepthWrite) in your bag of knowledge that could help ? Again, thanks for the answers !
  9. acarvallo

    Transparency & alpha issues

    Yes I can : https://sendvid.com/3yjykjzf You don't see the grey box behind, when the front one becomes transparent, and you don't see it as well when looking through one of the yellow-ish ones for example. That is my issue , not /always/ seeing through transparent particles inside the same SPS.
  10. acarvallo

    Transparency & alpha issues

    Hi, Yes the one from the issue, when you specifically mentioned that it could be used to maybe solve my problem : https://www.babylonjs-playground.com/#JB6H3P#5 As I also said, forceDepthWrite really helps but is not perfect for my real usage example, and setting separateCullingPass doesn't seem to change it as well : https://playground.babylonjs.com/#MNZ2VS#1
  11. acarvallo

    Transparency & alpha issues

    Hello (sorry for the late reply, been a bit busy), First, finally was able to put part of my viewer in a PG: https://playground.babylonjs.com/#MNZ2VS Found what was going wrong again, before starting the render loop I was copying the SPS (without their meshes being built), and building the mesh of the copy (but the copy was dropping get/set prototypes...), so setting computeBoundingBox did nothing (not setting the actual _computeBoundingBox attribute). So all is good on Babylon's side regarding bounding box stuff, and what is depending on it (ray/intersect). It is now working well with my 2 SPS (but is not optimal for performance). Then I wanted to try with only a single one (having both opaque & transparent objects in it), using forceDepthWrite=true on the material used for the SPS seems to do wonderful ! Only thing is that for some cases (one opaque object in front of another), setting the front one as transparent won't make the back one visible at all (see the PG for that). Also, as of now I feel like the separateCullingPass property of a material does nothing, I can't really spot a change when setting its value to false in the PG of that comment : https://github.com/BabylonJS/Babylon.js/issues/2832#issuecomment-331647665
  12. acarvallo

    Transparency & alpha issues

    Well, it would appear that after trying a bunch of things I messed up . I was basically doing this when adding meshes as particles in the SPS : // If original mesh is transparent if (shape.material.alpha < 1.0) { SPSO.particles[index].isVisible = false; } else { SPST.particles[index].isVisible = true; } So opaque original meshes added resulted in both opaque & transparent particles being drawn, which leads to strange transparency issues. Just changing previous code, replacing "SPST.particles[index].isVisible = true;" by "SPST.particles[index].isVisible = false;" fixes my issue, but create another one... Now I just have a "blink" effect when I highlight opaque particles, like this : https://sendvid.com/ogdv46mn And *sigh* I finally found the issue by debugging, it was because the bounding box/sphere was empty for the SPST in case (as it was in the video I linked just before) there are only opaque objects, I tried setting SPST.computeBoundingBox = true; But if I call the following function (refreshVisibleSize();) each time I switch visibility of a particle, it works ! SPST.refreshVisibleSize(); So sorry for my mistakes, thanks for the implication, I really appreciate it. One more question, shouldn't setting computeBoundingBox to true refresh the bounding box or is it because I call setParticles(id, id) (so updating a single particle and not updating whole SPS's particles) ?
  13. acarvallo

    Transparency & alpha issues

    Well, I see more or less the idea (the ALPHA_PREMULTIPLIED isn't on the page about blend modes though), and I guess the scale() on the color is to counter the ghost/glow effect, produced by the ALPHA_PREMULTIPLIED :p Side note, I didn't include in my first post, my objects can have different vertex colors, when I add an object, I create a blank mesh, assign a BABYLON.VertexData with positions, indices, normals, colors and then add that mesh to the SPS, setting computeParticleColor to false. I multiplied each vertex color by its matching alpha though, and it is kind of working, here is the behaviour (a video is better than trying to explain with words) : https://sendvid.com/0wsdq652 In short, it works if I start by highlighting one of the grey box behind. Here is how I "highlight" an object : var colors = new Float32Array(vertexCount * 4); for (var j = 0; j < vertexCount; j++) { colors[j * 4 + 0] = color.r; colors[j * 4 + 1] = color.g; colors[j * 4 + 2] = color.b; colors[j * 4 + 3] = color.a; } SPST.mesh.geometry.updateVerticesDataDirectly(BABYLON.VertexBuffer.ColorKind, colors, startIndex * 4 * 4); // If object is opaque if (obj.geometry.sps.name == "SPSO") { var pIndex = obj.geometry.particleIndex; SPST.particles[pIndex].isVisible = true; SPST.setParticles(pIndex, pIndex); SPSO.particles[pIndex].isVisible = false; SPSO.setParticles(pIndex, pIndex); } And the "unhighlight" : // Omitted, colors is filled with original vertex colors for the matching object if (obj.geometry.sps.name == "SPSO") { var pIndex = obj.geometry.particleIndex; SPSO.particles[pIndex].isVisible = true; SPSO.setParticles(pIndex, pIndex); SPST.particles[pIndex].isVisible = false; SPST.setParticles(pIndex, pIndex); } else { obj.geometry.sps.mesh.geometry.updateVerticesDataDirectly(BABYLON.VertexBuffer.ColorKind, colors, startIndex * 4 * 4); } So basically, the scene is always correct at first, it's just wrong when switching alpha/visibility, again thanks for any reply, and if you have a better way of doing what I want to achieve I'll be glad to read your suggestions (Also replied in the issue)
  14. Hello Babylon.js people, I am trying to make a viewer for working with BIM stuff (building and all the stuff inside), so there can be quite a lot of objects and having each one in its own mesh isn't really an option. So I tried to use two SPS, a single mesh and two meshes, one mesh/sps for opaque objects and another for transparent ones (saw the idea in another post on the forum). Thing is I need to "highlight", hide and have transparent not pickable objects too. Here is what I have for now : There is a space (big transparent blue-ish), with objects in it (yellow-ish opaque ones in the front) and also transparent grey "boxes". To be able to switch objects visibility/color quickly I tried to put all objects in both meshes : opaque ones hidden in the transparent mesh transparent ones hidden in the opaque mesh Then just toggle visibility, but then this kind of thing can happen : The front box is now transparent with a red color, the other "yellow-ish" box is partly hidden with a red tint (that's correct), but the grey opaque box isn't hidden/tinted (that's not ok) at all and keeps its grey color, looking like it is closer to the camera while it is actually not. I feel like I tried quite a lot of things and combinations so I may have missed the working one. I also posted an issue trying to have a simple example to demonstrate what felt like a bug : https://github.com/BabylonJS/Babylon.js/issues/2832 As I wrote there, using needDepthPrePass kind of fixes it, but not really since it messes up transparent objects inside another transparent object. Alpha mode is promising but the ghost/shiny effect is too powerful : I would need the behaviour, without the side effect... Any help/suggestions is welcome, and if you have questions or need more details, feel free to ask References : https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered https://doc.babylonjs.com/resources/how_to_use_blend_modes