MasterK Posted February 23, 2016 Share Posted February 23, 2016 like this. i want add some sprites in this area, and i only want sprites displayed in the (alpha==1) pixels... what should i do? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 23, 2016 Share Posted February 23, 2016 A transparent png image and the sprite takes into account the transparency without that there is to do anything. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 23, 2016 Share Posted February 23, 2016 I think you can use a foreground Babylon.Layer with this texture Quote Link to comment Share on other sites More sharing options...
MasterK Posted February 24, 2016 Author Share Posted February 24, 2016 @Dad72 yeah, i know it's the method. but dont know how to realize it... @Deltakosh not just this mask picture. it's a mask, and i want add more sprites and they can only display in the mask(aplha=1) place. i think i should use blend_func thing, to make a render buffer make sprites and mask together. then render the buffer to screen. and i dont know how... Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 24, 2016 Share Posted February 24, 2016 Perhaps you can try to build a playground so I can better understand what you want to achieve Quote Link to comment Share on other sites More sharing options...
MasterK Posted February 25, 2016 Author Share Posted February 25, 2016 @Deltakosh yeah, like this. now u understand? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 25, 2016 Share Posted February 25, 2016 So in this case why my technique with layer does not work? http://www.babylonjs-playground.com/#UCFKM (Ok actually they are displayed only if alpha = 0 but is this a problem?) Quote Link to comment Share on other sites More sharing options...
MasterK Posted February 25, 2016 Author Share Posted February 25, 2016 http://www.goodboydigital.com/pixijs/examples/14/ mask mean things should be limited by the shape of mask... for example, i designed a rectangle, and there is a sprite in the rectangle, when move sprite to edge of rectangle, outside sprite not display. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 25, 2016 Share Posted February 25, 2016 Then use a texture with alpha = 0 where you want to display your sprites and alpha = 1 outside and my technique works Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 25, 2016 Share Posted February 25, 2016 Like this: http://www.babylonjs-playground.com/#UCFKM#1 Quote Link to comment Share on other sites More sharing options...
MasterK Posted February 26, 2016 Author Share Posted February 26, 2016 8 hours ago, Deltakosh said: Like this: http://www.babylonjs-playground.com/#UCFKM#1 aaaaaamazing...... you made a excellent trick. almost cheated me... i know there is always way to use pictures to cover pictures to finish the mask thing... Layer always in the front, can't do everything...i have lots of words but speak slow, very anxious, u know... But the clip/stencil/mask things is useful and i want to make something to avoid use "cover layer" method. i think this is the basic method to do: http://stackoverflow.com/questions/24687437/how-to-use-stenciling-to-create-a-2d-clipping-mask-in-webgl Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 26, 2016 Share Posted February 26, 2016 But what is the difference between the stencil and my technique? Quote Link to comment Share on other sites More sharing options...
MasterK Posted February 26, 2016 Author Share Posted February 26, 2016 you're killing me... how to realize this by your technique ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 26, 2016 Share Posted February 26, 2016 Like this? (rotate the camera to see it) http://www.babylonjs-playground.com/#UCFKM#2 Quote Link to comment Share on other sites More sharing options...
MasterK Posted February 26, 2016 Author Share Posted February 26, 2016 two scenes, nice, i haven't thought it. so i should improve my question. you cant take bg as mask, because it's acting/animation/has lots of elements...(example, background has particles, and the mask should cover particle) Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 26, 2016 Share Posted February 26, 2016 Viewport? http://www.babylonjs-playground.com/#UCFKM#3 MasterK 1 Quote Link to comment Share on other sites More sharing options...
MasterK Posted February 29, 2016 Author Share Posted February 29, 2016 hmmmmmmmmmmmmmm..... you got it.... you are my hero! It satisfied my requirement... but... when the viewport is not a regular rectangle, but a circle? or other strange shape. your technique also can't resolve the problem. Did you confess it? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 29, 2016 Share Posted February 29, 2016 For a circle or strange shape I guess I can still find a way with a texture mask Quote Link to comment Share on other sites More sharing options...
MasterK Posted February 29, 2016 Author Share Posted February 29, 2016 try it. send the topic to the end. i have no idea how can you do it. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 29, 2016 Share Posted February 29, 2016 I have to admit this one was a little bit more challenging (I had to update the layer to support alpha testing :)) http://www.babylonjs-playground.com/#UCFKM#6 MasterK and jerome 2 Quote Link to comment Share on other sites More sharing options...
SQ Posted March 24, 2016 Share Posted March 24, 2016 Hi, I have a related question: If I use a foreground layer with alpha, is there a way to see the objects behind it? Say I have a sphere and want to add a decorative border to my scene, like this: var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene); var layer = new BABYLON.Layer("top", "textures/mask.png", scene, false); http://www.babylonjs-playground.com/#13PUAK I can see the border as white, and the center, that should be transparent, is grey. What is the best way to get the center to be transparent? ---- Ah I already found the answer: layer.alphaTest = true; Quote Link to comment Share on other sites More sharing options...
mojojojo Posted January 17, 2017 Share Posted January 17, 2017 Hi guys, one more on the topic - can I use 2d mask like this http://www.babylonjs-playground.com/#TEIFS but prevent the higher ground from rendering above the mask? 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.