🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Help with visibility determination portals in Unity

Started by
0 comments, last by Tharrior 2 years, 5 months ago

I am trying to get perfect portal rendering in Unity.

The portals are visibility portals instead of transformative portals.

In Unity I have impossible space working by turning sectors on and off.

A clipping shader is used on sector materials when the portal frustum is on it, clipping away anything outside the frustum.

I've been using lists to store visible portals and moving the sectors into a current sectors list then copy that to another list.

The sector portals target sector are put into a sector list and when the portal frustum intersects another portal axis aligned bounding box the portal is added to the visible portal list.

The portals have mathematical planes around the four sides of the portal with two vertices of the portal and the camera make three points to form one plane.

All portal vertices are in world space along with the camera point, the frustum moves with the player.

The sectors are turned on when they are in the current sectors list.

Sectors are turned off when the sectors are in the old sectors list and not in the current sectors list.

Old sectors list sectors check if they are in the current sectors list and if they are not then the sector turns itself off.

I use distance to portal plane to check if the player is on the positive side of the portal or on the negative side.

Only portals with the player on the positive side are added to the visible portal list.

When the player is on the negative side the portal is removed from the visible portal list.

Sectors turn off other portal sectors and only the portals that the player is on the positive side of the plane turn off connected sectors.

The sectors turning off turn off other sectors that are on the sector list.

The camera script keeps track of what sector the player currently inside and that changes when the player moves to a new sector.

Lists use Contains(), Add(), Remove() and Clear().

I am having problems moving the player to another sector with the code that turns off sectors, the connected sectors turn off then on quickly.

Do you have any ideas that could help?

All of this is for impossible space using a clipping shader.

This topic is closed to new replies.

Advertisement