Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Portal Rendering - graph traversal


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Deliverance   Members   -  Reputation: 348

Like
0Likes
Like

Posted 27 August 2006 - 09:01 PM

I experience some problems when trying to perform portal rendering. First of all doing portal rendering with the clipping phase in world space is not an option, because this would be too slow. So as wondering on the internet I read somewhere that John Carmack's take on this was: to clip the portals in window space. That's clever :) and really fast. Anyway I did this but there are some problems, maybe I'm doing something wrong. Here are the problems: I transform every portal in window coordinates, find the bounding box(rectangle in fact) and then clip it against the (0,0,width,height) orthogonal frustum. Well this seemed right to me (before I implemented), but in fact it isn't. Sometimes when the clipping plane is spanning the portal, problems arise, even if there is a small portion of the portal Visible, the transformed portal (in window coordinates) does not fit in this: (0,0,width,height) I'm transforming the portal in window coordinates using gluProject passing the current modelview, projection and viewport (retrieved with glGet..) and I'm positive gluProject returns the correct results based on the information passed. I'm also considering implementing PVS, this would be faster(rendering) but it would require additional code to write, and more memory(a LOT on todays huge game levels) , I think that the portal alternative is a better option considering modern hardware and it is faster to achieve in code due to it's simplicity. And one more thing :) what does the Z component returned by gluProject stands for? I was hoping that some of you who already done this could point me in the right direction( please :) ) [Edited by - Deliverance on September 1, 2006 5:28:13 AM]

Sponsor:

#2 SimmerD   Crossbones+   -  Reputation: 1110

Like
0Likes
Like

Posted 28 August 2006 - 10:15 AM

What i do is that if the portal crosses the near plane, I just treat the clipped portal as [0,0]->[w-1, h-1] in size.



#3 PlayerX   Members   -  Reputation: 279

Like
0Likes
Like

Posted 29 August 2006 - 08:59 AM

You could also try clipping the portal against the view plane prior to gluProject'ing. In the end, though, as SimmerD says, you might as well just consider it takes up the full-screen because if it's intersecting the view plane it must be taking up a lot of screen area anyway. :)


#4 Deliverance   Members   -  Reputation: 348

Like
0Likes
Like

Posted 31 August 2006 - 11:25 PM

Thanks guys, making the portal as big as the screen solved the problem, I did not understand how can I figure out if a polygon in clip space is intersecting the near clip plane, and that was the source of error and confusion. Anyway the problem is solved now, and the portal rendering works really nice.

However, there is a BIG performance hit on fairly small levels (4000-5000 poly) polygons and I think the problem is due to the portal graph traversal: it traverses the same leaves more than once, even if sometimes these traversals are redundant.
Solving this with a "visited" flag for each leaf is not the way to go, this way drawing will be incorrect sometimes, missing some visible leaves.

Here's how I'm rendering:
1.0 Build for every portal a duplicate one(this way assigning directions to every portal) and then assign every leaf a list of portals. This is alsaw called sometimes: building the portal flow.

2.0 The actual rendering is as follows:


// No leaf visible
ZeroMemory(LeafVisible, NumLeaves);

void RenderWithPortals(int Portal, int Leaf, CVector3D Position, Rectangle2D Frustum)
{

LeafVisible[Leaf] = true;

// This computes the bounding rectangle in window coordinates
Rectangle2D NewFrustum = GetRectangle(Portal);
Rectangle2D Intersection;

if (!IntersectRect(NewFrustum, Frustum, Intersection))
return;

for every portal "NextPortal" that belongs to Leaf do
{
if (Portal can see NextPortal)and (Position is at the back of NextPortal's Plane) then
{
RenderWithPortals(NextPortal, the leaf next portal is pointing to,
Position, Intersection);
}
}
}

After the function is called for every portal in the current leaf LeafVisible[] will contain the visibility information.


I was wondering if this is the way to go, are there any better options, or maybe is this approach wrong in some way?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS