Jump to content

Real 3D Mask


royibernthal
 Share

Recommended Posts

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.

 

 

sketch.jpg

Link to comment
Share on other sites

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?

sketch2.jpg

sketch3.jpg

Link to comment
Share on other sites

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

  

Link to comment
Share on other sites

@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);  });

 

Link to comment
Share on other sites

@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 :lol:

 

On 2016-06-22 at 8:40 PM, NasimiAsl said:

cheers, gryff :)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...