Portal effect

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!
Post Reply
Xharock
Posts: 71
Joined: Wed May 10, 2006 3:50 pm

Portal effect

Post by Xharock »

Hi, I've been trying to create a portal affect similar to what is seen in the game Narbacular Drop (And Prey it seems) whereby there are two portals and as you look out of one you see whats on the other side of the other. I haven't done very well. I've been looking at the tech docs for the game and it describes the technique for doing it but I just can't seem to get it into Irrlicht. Here is the extract from the document:
Essentially, a portal is just a textured quad. But the contents of the texture are dynamic and the texture coordinates change based on how you're looking at the quad.

To create the contents of the texture:
1. Convert the current camera position and look vector into coordinates relative to the portal.
2. Find this position and rotation in relation to the portal's exit.
3. Move the camera to the point and rotation found in step 2.
4. Render the scene while culling all objects between the camera and the portal exit.
5. The render surface is now the source texture for the portal and the camera should be moved back to where it was before step 1.

To render the quad with the proper texture coordinates:
1. Convert each coordinate into screen space.
2. Copy the normalized screen space x and y components into the u and v coordinates of each vertex.
3. Render the quad.
Any ideas on how this could be achieved in Irrlicht? I am not familiar with the process of changing a models texture coordinates in this engine. My portal quad meshes are simply on sided planes in an IAnimatedMeshSceneNode. I am pretty sure that to convert a World Space coordinate to Screen Space all I have to do is multiply the vector by the projection matrix?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

This has been done before. Search for 'Prey AND Portal'.

Travis
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Blizportals is what was done previously, a few versions using RTT, DirectX or OpenGL, I also made some portals based on those in my Curse of the Pharoah project.

Irrlicht+DirectX
Irrlicht+OpenGL
Curse of the Pharoah
Image Image Image
Post Reply