Thank you very much guys, that will be an interesting read!
Reconnoiter@ that screen looks pretty great! it's really increadible to hear, that they've done this back in 1998.
I found this on the forum so far, it seems that making portals were in vogue back in 2007
Portal Madness [Demo] Portal Tech 2 And I even found a shader made by XxXGuitar511:
texture mtlSkin1;
float4x4 matWorldViewProj;
float4x4 matWorldView;
float fAlpha;
sampler imageTex = sampler_state
{
Texture = <mtlSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};
struct vIn
{
float4 Pos : POSITION;
};
struct vOut
{
float4 Pos : POSITION;
float3 Tex : TEXCOORD0;
};
struct pIn
{
float3 Tex : TEXCOORD0;
};
vOut pVS (vIn In)
{
vOut Out = (vOut)0;
Out.Pos = mul(In.Pos, matWorldViewProj);
Out.Tex = mul(In.Pos, matWorldView).xyz;
//
return(Out);
}
float4 pPS (pIn In) : COLOR
{
float2 tPos = In.Tex.xy/In.Tex.z;
//
tPos.y = 1 - (tPos.y*1.135 + 0.5);
tPos.x = tPos.x*0.855 + 0.5;
//
float4 color = tex2D(imageTex, tPos);
color.a *= fAlpha;
//
return(color);
}
technique portalView
{
pass one
{
VertexShader = compile vs_1_1 pVS();
PixelShader = compile ps_2_0 pPS();
}
}
But I don't have any use for it yet. I'm still researching!
Edit: there were even some threads with open sources for portals, but all links are dead
OPEN SOURCE PROJECT - REAL TIME PORTALS Portal Madness... WIP Edit2: I guess I found some tips over the net:
Render your portal space scene with same camera orientation, but camera position shifted by the same vector that describes the camera's offset from the portal in local space.
Edit3: I found a 'little' but in my code, I'm passing same positions/angles for source and destination portals to updateView function. To fix that just change the following line:
updateView(portalEnt[i].portalView, portalEnt[i].linkedEnt.x, portalEnt[j].ownerEnt.x, portalEnt[i].linkedEnt.pan, portalEnt[j].ownerEnt.pan);
TO:
updateView(portalEnt[i].portalView, portalEnt[i].linkedEnt.x, portalEnt[i].ownerEnt.x, portalEnt[i].linkedEnt.pan, portalEnt[i].ownerEnt.pan);
Plus I found a good tutorial:
Tom's Programming BlogAnd I'm trying to get the matrix calculations from it correctly working in my project.