Nacheitor Posted September 29, 2017 Share Posted September 29, 2017 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. Quote Link to comment Share on other sites More sharing options...
Arte Posted September 29, 2017 Share Posted September 29, 2017 This is exactly what I need right now. @RaananW, @Deltakosh, @Wingnut and ....... Any suggestions? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 29, 2017 Share Posted September 29, 2017 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? Quote Link to comment Share on other sites More sharing options...
Arte Posted September 29, 2017 Share Posted September 29, 2017 Three js have webgl_clipping_intersection. clipping-with-caps Can we have something similar? Quote Link to comment Share on other sites More sharing options...
thrice Posted September 30, 2017 Share Posted September 30, 2017 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) Quote Link to comment Share on other sites More sharing options...
Arte Posted October 1, 2017 Share Posted October 1, 2017 @thrice Can you make simple PG with you strategy? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted October 2, 2017 Share Posted October 2, 2017 Another way would be to rely on stencil buffer and play a bit with the different shapes in the scene: https://playground.babylonjs.com/#XU86GQ#2 not the most efficient but depending on your use case, could be the fastest to put in place. NasimiAsl, RaananW and Arte 3 Quote Link to comment Share on other sites More sharing options...
Arte Posted October 2, 2017 Share Posted October 2, 2017 @Sebavan Can we hide small box corners? PG I'm just playing around Quote Link to comment Share on other sites More sharing options...
thrice Posted October 4, 2017 Share Posted October 4, 2017 @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. Arte 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.