I'm using my own engine to create a world editor.. Whats the best way to render 4 viewports from 4 different directions?
I've been thinking about rendering from 4 different cameras either to texture or to different viewports.. are there other ways? Whats the pros and cons of the different solutions?
3 replies to this topic
Sponsor:
#3 Crossbones+ - Reputation: 1067
Posted 01 March 2012 - 08:51 AM
If you're using DirectX 10 or 11 you can render everything in a single pass to a single render target using the geometry shader.
In the vertex shader output each vertex world position. Then in the geometry shader you can output a triangle to be rendered to each viewport using the SV_ViewportArrayIndex semantic...
In the vertex shader output each vertex world position. Then in the geometry shader you can output a triangle to be rendered to each viewport using the SV_ViewportArrayIndex semantic...
struct GS_OUT
{
float4 position : POSITION;
uint viewportIndex : SV_ViewportArrayIndex;
//... other attributes
};
[maxvertexcount(12)]
void GS(riangle GS_IN input[3], inout TriangleStream<GS_OUT> VStream
{
//4 viewports and camera
for(uint i = 0; i < 4; i++)
{
GS_OUT output;
//select the correct viewport
output.viewportIndex = i;
//generate a triangle
for(int v = 0; v < 3; v++)
{
//transform the vertex to view space using the correct view matrix
output.position = mul(input[v], gViewMatrix[i]);
//transfrom to homogenous space
output.position = mul(input[v], gProjMatrix);
//other attributes here
VStream.append(output);
}
VStream.RestartStrip();
}
}
}
Tiago Costa
Aqua Engine - my DirectX 11 game "engine" - In development
Aqua Engine - my DirectX 11 game "engine" - In development






