Hi,
Pardon me as I know a solution for this issue might be somewhere on board.
I just can't find the right solution.
I'm using irrlicht and irredit 1.4.2.
As in image, the trees behind the fence are rendered in front of the fence.
I use trans_alphach as material type for both trees and fence.
How can I fix this problem?
Thanks in advance.
Last edited by aungsithu on Fri Nov 21, 2008 6:50 am, edited 1 time in total.
Try playing around with the ZBuffer and ZWriteEnable parameters of the node's material. It's probably ZBuffer set to false that is causing the problem, so try setting it to true.
Thanks.
ZWriteEnable is set to True and ZBuffer is already set to 1 for all the trees and fences. It still doesn't solve the problem and I still see this 'incorrect' rendering in irrEdit.
What did I miss something?
You have to use the new scene parameter ALLOW_ZWRITE_ON_TRANSPARENT set to true. This allows to toggle the zwrite flag for transparent materials. If it's not set Irrlicht will override this setting to always false
Also make sure you're applying the changes to the correct material of the tree... do you just have one material or two... possibly there's two materials if you have seperate materials for the trunk and the leaves
Thanks all for inputs.
Right now, I'm just using irredit to construct and visualize the scene.
Setting to trans_alpharef make some trees to be correctly rendered.
But some trees are still being rendered in front of the fence.
I'll check the other ways posted here when I render the scene from code.
I've been playing about with this a bit today while integrating trees into my wrapper project. Hybrid's advice is the complete solution and I implemented a command in the wrapper to use: -
smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
EMT_TRANSPARENT_ALPHA_CHANNEL_REF does seam to correct the problem but probably only by chance in the implementation, it is however the better option to use as it is intended to be the faster implementation for foliage. It does have the draw back of not being effected by vertex lighting as far as I can see though.
After using ALLOW_ZWRITE_ON_TRANSPARENT as Hybrid suggests, IRR_EMT_TRANSPARENT_ALPHA_CHANNEL also seams to work properly and is effected by vertex lighting too.
When using ALLOW_ZWRITE_ON_TRANSPARENT and EMT_TRANSPARENT_ALPHA_CHANNEL_REF with textures that have alpha channels that contain aliased pixels, these pixels seam to pick up the background color giving them an oddly colored edge. Changing the textures so the alpha value was just 0 or 255 would clear up the problem I think.
[quote="Frank EMT_TRANSPARENT_ALPHA_CHANNEL_REF does seam to correct the problem but probably only by chance in the implementation, it is however the better option to use as it is intended to be the faster implementation for foliage. It does have the draw back of not being effected by vertex lighting as far as I can see though.
[/quote]
yes i know this is by chance, and hybrid advice is correct one. but im too afraid to change source in irrlicht and compile :p
You can place the smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true); in your own code after your createDevice call, you wont need to change the irrlicht dll.
ohhh... i thought i need change irrlicht code. i remember someone (i think one of the irrlicht devs) said to change headers or something... forgot the post