Dai Posted May 26, 2016 Share Posted May 26, 2016 Hello guys, This is my first message on this forum and I am a pure noob regarding to Babylon so please, don't kill me if the answer to my question is obvious Here's my problem: if I set material.hasAlpha to true and set the same texture as opacity texture and diffuse texture*, some meshes disapear according to the camera position. Like if they were considered as out of the frustrum or something. I attached a webm showing what's going on. Do you have any idea how to fix it ? I am using Babylon 2.4.0 beta. Thanks ! * I said diffuse, but I lied. I'm actually using emissive because I want no shading, so there's no lights in my scene. Is this the right way ? PS: I have another question: is it possible to load a mesh without appending it to the scene ? So far all solutions I saw (ImportMesh, AssetManager) instantiate the mesh on the fly. I took a look to the ImportMesh function to see if I could extract any code that's just preloading the object, but it seems the append-the-mesh stuff goes pretty deep. Animation.webm Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 26, 2016 Share Posted May 26, 2016 Hello I have no tool to display .webm (and even chrome does not want to display it Oo). The best way to help you is to provide a repro case on the Playground For your second question, you can import a mesh and immediately flag it as disabled with mesh.setEnabled(false). This way, the scene won't consider it anymore Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted May 26, 2016 Share Posted May 26, 2016 @Dai Hi & welcome to BabylonJs! On one hand, It looks like it could be a camera issue, try setting minZ & maxZ with the values below and de/increase if needed. camera.minZ = 0.5; //Minimum distance of view. (decrease if there's still issues) camera.maxZ = 100; //Maximum distance of view. (increase if there's still issues) Hopefully that solves it.. But on the other hand, your plane/ground doesn't seem to be affected, so if it doesn't work, could you please share some of your code with us? it might help a great deal As for your other question, you can simply set yourMesh.isVisible = false; when loading, and set it true when you need to display it, anything you want to edit can be done "on the go" so to speak, really no need to "pre-load" and not add it to the scene Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 27, 2016 Share Posted May 27, 2016 mesh.alwaysSelectAsActiveMesh = true ; test it maybe work Quote Link to comment Share on other sites More sharing options...
Dai Posted June 6, 2016 Author Share Posted June 6, 2016 Hi, thank you for your help. And sorry for the late answer, I had a holiday week. I tried your solutions, but it didn't work. I investigated on the problem and it turned out the meshes don't disapear: they are rendered behind the ground (cf. the attached gif). I've re-created the scene on the playground. It is an horizontal square (the ground) with vertical squares (cf. the other attached file). If you drag the camera in order to move the meshes to the top right corner, the bug will occur (it depends on your resolution, mine's 1920x1080). The textures don't load, but it "works" the same. The bug also occurs when I'm using jpeg textures without alpha. Thanks ! Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted June 6, 2016 Share Posted June 6, 2016 Maybe it's just the zOffset that you have to fix ? Quote Link to comment Share on other sites More sharing options...
gryff Posted June 6, 2016 Share Posted June 6, 2016 Croeso Dai . I have seen this effect before - but have no idea why it happens. However, I added a few lines to your playground (marked them "added line") that set the rendering order. That seems to stop the effect you are observing. Playground cheers, gryff Quote Link to comment Share on other sites More sharing options...
Kesshi Posted June 6, 2016 Share Posted June 6, 2016 The problem is that you also assigned the opacityTexture to the ground. If you don't use a opacityTexture for the ground it should work. If you use a opacityTexture it means the object will be handled as an transparent object. Transparent objects are rendered after opaque objects. In your case all your objects are transparent. I'm not so sure but i think BJS tries to render transparent objects from back to front (using the bounding box to determine the position) but in some cases the ordering will not give the correct result. Especially if you have big transparent objects which overlap some smaller ones (like your ground). Quote Link to comment Share on other sites More sharing options...
adam Posted June 6, 2016 Share Posted June 6, 2016 https://doc.babylonjs.com/tutorials/Transparency_and_How_Meshes_Are_Rendered gryff 1 Quote Link to comment Share on other sites More sharing options...
Dai Posted June 6, 2016 Author Share Posted June 6, 2016 You're right, it's an alpha blend problem. I don't know what I'll use yet (alpha test instead of alpha blend or alphaIndex (better than render groups I guess)) but now I know what the problem is and what solutions I have. I think we can tag this thread as solved ! Thank you all, you're great <3 Boz 1 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.