royibernthal Posted June 20, 2016 Share Posted June 20, 2016 Is there a way to mask a certain part of a box in a 3d environment? (not masking 2d sprites with a 2d mask) For instance, I create a box, I mask its lower part, in runtime the upper part is not rendered - only the lower part, and the upper face of the box is not cut - in other words, only the height of the box is cut, keeping the upper face, unlike 2d masking a 3d shape which would look very bad. I attached a sketch to help you picture what I mean. Does something like that exist? If not, do you perhaps have an idea how to approach that problem? Playing with the box's height won't do the trick for me, because I need the texture diffused in its material to not be resized - just cut. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted June 20, 2016 Share Posted June 20, 2016 hi i dont understand finaly but make this http://babylonjs-playground.com/#QO7CR#0 adam 1 Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 20, 2016 Share Posted June 20, 2016 Will CSG work for you? https://github.com/CraigFeldspar/BabylonCSG http://doc.babylonjs.com/classes/2.4/CSG Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 20, 2016 Author Share Posted June 20, 2016 JohnK - Using CSG, will the material be cut at the area of the substraction? Will it be able to produce a result like in NasimiAsl's example? NasimiAsl - Hi, yeah looks good. My final goal would be to support masking a parent mesh (invisible - for the sole purpose of containing other meshes) that contains multiple boxes, I should've probably said that from the start I didn't think you'd go through the trouble of creating an example so soon. Would your solution be able to handle that? Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted June 20, 2016 Share Posted June 20, 2016 yes it is possible (everything is possible ) just make a PG with your wanted Meshes let me work on GameMonetize, royibernthal, dbawel and 1 other 4 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 20, 2016 Author Share Posted June 20, 2016 http://www.babylonjs-playground.com/#QHMT1#1 If you'll be able to also help me understand what you do there it'd be great Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 21, 2016 Author Share Posted June 21, 2016 @NasimiAsl tagging you in case you didn't notice I replied. NasimiAsl Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted June 21, 2016 Share Posted June 21, 2016 wait i see it Now Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted June 22, 2016 Share Posted June 22, 2016 really sorry for don't notice @royibernthal http://www.babylonjs-playground.com/#QHMT1#7 Wingnut, gryff, V!nc3r and 2 others 5 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 22, 2016 Author Share Posted June 22, 2016 @NasimiAsl Thank you There is a little lag / jump between each box whenever a box becomes visible, is there a way to avoid that? Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted June 22, 2016 Share Posted June 22, 2016 Great job NasimiAsl ! Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted June 22, 2016 Share Posted June 22, 2016 46 minutes ago, royibernthal said: @NasimiAsl Thank you There is a little lag / jump between each box whenever a box becomes visible, is there a way to avoid that? yes i see that it is because i use Math.Sin so you need define your function and when you do that use this range [0..2] + [2.2 .. 4.2] + [4.4 .. 6.4] + ... try to fix it and let us know about your result thats good task i wait you try yourself thanks adam 1 Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted June 22, 2016 Share Posted June 22, 2016 31 minutes ago, V!nc3r said: Great job NasimiAsl ! thanks Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 25, 2016 Author Share Posted June 25, 2016 @NasimiAsl No problem, I'll try to learn more about shaders in BabylonJS before experimenting with this specific example. One question though - do you have to keep creating new instances with this call or is there a way to re-use one instance (taken from scene.registerBeforeRender)? Is it negligible to do that? Won't it have a negative effect on performance / garbage collection rate? new BABYLONX.ShaderMaterialHelper().SetUniforms( scene.meshes, camera.position, camera.target, { x: 0, y: 0 }, { x: 100, y: 100 }, time); }); Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted June 26, 2016 Share Posted June 26, 2016 @royibernthal absolutely you right but i don't work about optimization 10 or 20 byte of ram per frame in playground but you can define this instance out of registerBeforeRender and use that anyway thanks for your advise Quote Link to comment Share on other sites More sharing options...
gryff Posted June 26, 2016 Share Posted June 26, 2016 @NasimiAsl : I think I have told you before - fascinating stuff, though I don't pretend to understand the coding. Understanding shaders is pretty close to trying to understand the math of Einstein's Relativity On 2016-06-22 at 8:40 PM, NasimiAsl said: really sorry for don't notice @royibernthal http://www.babylonjs-playground.com/#QHMT1#7 cheers, gryff Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted June 26, 2016 Share Posted June 26, 2016 @gryff yes you right my friend but all request is need math and no one don't ask simple task (Why ) Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 26, 2016 Author Share Posted June 26, 2016 @NasimiAsl It was more of a question than an advise Thank you again for the help. NasimiAsl 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.