Jump to content

Boolean operations with meshes in a shader


Nacheitor
 Share

Recommended Posts

I,m trying to develop something like this using Babylon.js (The example is implemented in Unity 3D):

I suppose this can be implemented using a shader. The user can move a sphere with the inverted normals, and the shader will have to calculate if this sphere is painted depending on its position in the z buffer.

Is it possible to do this using babylon ShaderMaterial?

Thanks in advance.

Link to comment
Share on other sites

Really interesting. This is not supported at shader level so far but we have a (slow) software solution with CSG.

Why not creating an issue on github for this feature? Please add all info you may have regarding how you configure it in Unity. For instance, how do you define the internal texture of the mesh?

Link to comment
Share on other sites

I would think theoretically it would be possible to do using shader material / discard keyword, and passing a uniform into the shader with the spheres bounding info. I've done, much much simpler things, using a similar strategy (i.e. discard pixel if color.r < threshold, which I pass to shader). But maybe I'm missing something and/or don't know what the hell I'm talking about (probably both).

(Actually, I guess in my situations, I was cutting out the shell of the object, there was no inner material as pictured. That seems much harder now that I think about it)

Link to comment
Share on other sites

@Arte

Don't click this if you have epilepsy (really), but: any example of passing variables to the shader to use as a discard threshold. https://playground.babylonjs.com/#AFUQKR

A more practical example on cyos I was working on, I was trying to get a decent looking 2d smoke plane shader working, almost looks decent but not quite:

http://cyos.babylonjs.com/#09CV0F--

Point is, I would imagine there is some way to pass the dimension of the sphere in the scene to the shader, and use the discard keyword to cutout the pixels that are not relevant. Whether by redrawing the sphere via the dimension in GSGL, or to recreate the area you want to discard, or what not. Although I'm barely able to understand building 2d shaders at this point, so I'm just the idea guy. :) I still haven't fully grasped the vertex shader side of things yet, and I'd imagine that would somehow be important as that seems to manipulate the shape. 

Also it looks like discard doesn't work w/ vertex shader, so IDK.

 

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...