zsort around decilined plane

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!

zsort around decilined plane

Postby lumirion » Mon Feb 20, 2012 7:10 pm

In Irrlicht is there a way on the fly to split a sloping plane mesh so that other meshes arn't dumped either to the front or back of it if it passes through them? I have a model (not mine) with such a mesh representing light rays passing over a mountain rendered on a vertical plane with an alphablended wall mesh in front of it. The mountains keep rendering in front of the wall. I have two such light ray meshes in this model the closest one begins where the other ended and ends at a hill in the forground but my render corrupts with the sky box bleeding through. So I disabled zwrite on my alphablend function and the foreground hill dissapears, the skybox stops showing through, and the mountains moved in front of the wall. The model loads perfectly in its native engine.
lumirion
 
Posts: 21
Joined: Tue Sep 13, 2011 7:35 am

Re: zsort around decilined plane

Postby REDDemon » Tue Feb 21, 2012 9:05 am

you problably need to set the correct render pass. light rays should be rendered in transparent render passes irrlicht already have materials for that. If the mesh is just 1 mesh you have to Z sort triangle (not possible for all mesh since certain triangles are overlapping in strange ways..) try that. :)
OpenGL is not hard. What you have to do is just explained in specifications. What is hard is dealing with poor OpenGL implementations.
User avatar
REDDemon
 
Posts: 831
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: zsort around decilined plane

Postby lumirion » Wed Feb 22, 2012 7:34 am

my material for the light rays is a EMT_ONETEXTURE_blend so they should be in the transparent renderpass. Does Irrlicht have a triangle sorting function? or one to break big triangles into smaller ones? I thought I read somewhere that bsp sorting selectively brakes up triangles and sorts them but is slow and out dated. I alo heard octrees are faster. Do we have those in Irrlict? If we do where can I find out how to use them?
lumirion
 
Posts: 21
Joined: Tue Sep 13, 2011 7:35 am

Re: zsort around decilined plane

Postby REDDemon » Wed Feb 22, 2012 12:44 pm

irrlicht already sorts scene nodes. you can decide to implement a custom octree for sorting your stuff (sort groups of triangles instead of single triangles can be much faster, but can also lead to visual artifacts) or maybe you can decide that is more viable sorting directly all triangles (if there are not to much triangles). Irrlicht arrays (irr::core::array) already have sorting capabilities, you have "just" to compute the distance from the camera at every frame. try both quicksort and heapsort for sorting. Until you try them you never know wich is faster. (theorically heapsort should be faster because is O(n*logn) vs O(n^2). in practice quicksort is faster in most cases).

Also avoid to use a separate scene node for each triangle.
OpenGL is not hard. What you have to do is just explained in specifications. What is hard is dealing with poor OpenGL implementations.
User avatar
REDDemon
 
Posts: 831
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: zsort around decilined plane

Postby lumirion » Wed Feb 22, 2012 9:57 pm

thankyou for the advice :D that gives me a lot more thoughts to work with.

also I have a screenshots from a couple angles
Image
Image

[EDIT] Also what is the name of the array the triangles are stored in? Is it the vertex array?
lumirion
 
Posts: 21
Joined: Tue Sep 13, 2011 7:35 am

Re: zsort around decilined plane

Postby REDDemon » Fri Feb 24, 2012 6:31 am

both vertex and index arrays. without indices vertices is just acloud of points.
OpenGL is not hard. What you have to do is just explained in specifications. What is hard is dealing with poor OpenGL implementations.
User avatar
REDDemon
 
Posts: 831
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: zsort around decilined plane

Postby lumirion » Fri Feb 24, 2012 8:49 am

k I will study the triangle selector code as I saw that it uses both arrays.

Since this is a single model file containing both solids and transparents will I need to parse the indices and vertexs by what submeshes contain them and then reorder by submesh id? Or am i just divideing the arrays into blocks by corelating 3 indices elements with their 3 vertex elements and sorting the blocks by vertex z values?
lumirion
 
Posts: 21
Joined: Tue Sep 13, 2011 7:35 am

Re: zsort around decilined plane

Postby hendu » Fri Feb 24, 2012 10:32 am

You're trying it the hard way, why not just separate the transparent parts to a different mesh?
hendu
 
Posts: 1555
Joined: Sat Dec 18, 2010 12:53 pm

Re: zsort around decilined plane

Postby lumirion » Fri Feb 24, 2012 5:22 pm

Im trying to implement a coustom loader for .m2 So I want to make a fix that will work for any model of this type incase there are other models with this problem. :D

It would also probably be posible to use the render triangle list function from device but I havent looked into that yet.
lumirion
 
Posts: 21
Joined: Tue Sep 13, 2011 7:35 am

Re: zsort around decilined plane

Postby REDDemon » Fri Feb 24, 2012 6:03 pm

would be nice to patch your loader to irrlicht also :)
OpenGL is not hard. What you have to do is just explained in specifications. What is hard is dealing with poor OpenGL implementations.
User avatar
REDDemon
 
Posts: 831
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: zsort around decilined plane

Postby lumirion » Sat Feb 25, 2012 5:04 am

Currently it is called through pseuwows memorydataholder so there might need to be some modification to call it directly form Irrilicht. It's not finished but if anyone wants to see it, it is in https://github.com/shlainn/pseuwow/tree ... lient/GUI/ Im also not shure if I got the blend functions perfect since I was trying to recreate them by parsing functions for gl blending.
lumirion
 
Posts: 21
Joined: Tue Sep 13, 2011 7:35 am


Return to Advanced Help

Who is online

Users browsing this forum: Google [Bot] and 0 guests