[SOLVED] Rendering in X-Ray mode
-
- Posts: 41
- Joined: Thu Feb 27, 2014 10:55 am
[SOLVED] Rendering in X-Ray mode
Lets say I've two nodes one behind the other. I need to see both the objects together. I can add transparency. But I need to see the object in the back without any color mix with the object in the front.
Is there a simple way to do this?
Is there a simple way to do this?
Last edited by cegprakash on Wed Jul 23, 2014 5:02 am, edited 2 times in total.
Re: Rendering in XRay mode
Can you draw a quick example of what you mean?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Rendering in XRay mode
If it's the case that one object is always shown above the rest, you could draw that node separately after you draw your regular scene manager.
-
- Posts: 18
- Joined: Thu Apr 24, 2014 3:01 am
Re: Rendering in XRay mode
It sounds to me like he means something along the lines of this:
Re: Rendering in XRay mode
Maybe it can be drawn later and with z-buffer disabled?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 41
- Joined: Thu Feb 27, 2014 10:55 am
Re: Rendering in XRay mode
FlyingSauce is right.. How to disable z buffer? Is it possible to revert it back?
Re: Rendering in XRay mode
You can change the z-buffer with the materials. When SMaterial.ZBuffer is false then it should ignore what other objects have written in there. But depending on what it's used for this situation might be a little tricky. If this is for example for a 3d cursor then you can just draw it last - either with a second scenemanger or by a manual render call for that node. But if it should be only in front of _some_ other objects and not all other objects then it starts to get rather difficult.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 41
- Joined: Thu Feb 27, 2014 10:55 am
Re: Rendering in XRay mode
I want some particular nodes to appear in front of all other nodes. All the nodes are in the same sceneManager.
Re: Rendering in XRay mode
You have to take those out of the scenemanager and render them later so you can render them above other nodes. But thinking about it some more - it will probably not work for most nodes because disabling z-buffer also means you disable z-buffer for the the node itself (so if it is a real 3d model it will no longer be able to distinguish between stuff in front and back). It depends on what this is for. It will likely work for a 3d cursor or a simple 3d-text element which should always stay visible. It will work bad if you want for example a house model (or any other real 3d model) to render that way.
I'm not exactly sure how to avoid that. But basically those kind of objects would have to render in an own own scenemanger. I guess the z-buffer information could help. Don't know how to do that with the fixed-function pipeline, but with shaders I'd probably approach it like that: Render the results of the first and the second scenemanager into a texture and also render the results of the z-buffer of the second rendering (the one with the models on top) in a z-buffer. And then combining those 3 textures in a shader by checking on each pixel if the second rendering has writting something in the z-buffer texture and only use it's color-values in that case for the fragments.
Maybe there are better ways - I'm just typing this down while thinking and never run into this exact problem...
I'm not exactly sure how to avoid that. But basically those kind of objects would have to render in an own own scenemanger. I guess the z-buffer information could help. Don't know how to do that with the fixed-function pipeline, but with shaders I'd probably approach it like that: Render the results of the first and the second scenemanager into a texture and also render the results of the z-buffer of the second rendering (the one with the models on top) in a z-buffer. And then combining those 3 textures in a shader by checking on each pixel if the second rendering has writting something in the z-buffer texture and only use it's color-values in that case for the fragments.
Maybe there are better ways - I'm just typing this down while thinking and never run into this exact problem...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 41
- Joined: Thu Feb 27, 2014 10:55 am
Re: Rendering in XRay mode
It's true that it's possible by RTT using shaders. Rendering only the front nodes (by making setVisible(false) for all other nodes) can act as a texture. I'm looking for easier/efficient ways.
Re: Rendering in XRay mode
Ah, I guess there is. Render the scene without those nodes first. Clear the z-buffer. Then render the scene with the nodes which should be in front. You don't even need to use 2 scenemanager, but you can hide/show the corresponding nodes in the first and second pass. IVideoDriver::beginScene has parameters for that (don't clear backbuffer but clear z-buffer on second pass).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 41
- Joined: Thu Feb 27, 2014 10:55 am
Re: [SOLVED] Rendering in XRay mode
Thank you