Jump to content

[SOLVED] How to display an object only on a different object


arek3D
 Share

Recommended Posts

Hello,

what do you think, what is the best way to show this green tree only at this gray box. I would like to hide every pixel which is outside the box, even if I will rotate a camera.

http://www.babylonjs-playground.com/#2L76JS#1

This plane will be pickable and the user will be able to move it above 3D object, but it is necessary to hide pixel outside.

I tried to make a layer/foreground, put there a texture made by RenderTargetTexture of gray box and mask every planes which I will add. But this solution is not good, because in this function I need to have an URL of the image, not a texture:

new Layer(name, imgUrl, scene, isBackground, color)

Do you have any ideas how to get this effect?

Thank you in advance!

 

what I want.jpg

Link to comment
Share on other sites

I don't have any idea, how it is possible, but I had implemented this in my project and it didn't work.

After many hours I decided to download this scene from Playground, and test it on my HDD, and it didn't work too. It is a big surprise for me :/ 

@Deltakosh, do you have any idea what is going on here? :) 

Chrome doesn't show any errors.
The only error message I got, was in Mozilla Firefox console, but I doubt that it is related to this issue.

 Error: WebGL: Failed to create WebGL context: WebGL creation failed: 
* Error during ANGLE OpenGL init.
* Error during ANGLE OpenGL init.
* Error during ANGLE OpenGL init.
* Error during ANGLE OpenGL init.
* Error during ANGLE OpenGL init.
* Exhausted GL driver caps.  babylon.js:4:12713
BJS - [14:20:55]: Babylon.js engine (v3.0-alpha) launched  babylon.js:3:22931
Error: WebGL: texImage2D: Conversion requires pixel reformatting.

 

Link to comment
Share on other sites

I have tested it on this sample scene on my HDD, and it WORKS! So I think it will be similar in my project, I will check it tomorrow ;D

I didn't know about this parameter in engine costructor, but I tried to set stencil's flags by myself, and there was not any effects:

engine.isStencilEnable = true;
engine._isStencilEnable = true ;

 

Anyway, thanks a lot @Deltakosh!!

 

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