Jump to content
  • Advertisement
Sign in to follow this  
Nanook

Rendering 4 viewports

This topic is 2480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Render to viewports. If you render to textures, you then have to copy the data to the back buffer as an additional step. When you render to viewports, you render directly to the back buffer.

Share this post


Link to post
Share on other sites
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...

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);
//transfrom to homogenous space
output.position = mul(input[v], gProjMatrix);

//other attributes here

VStream.append(output);
}
VStream.RestartStrip();
}
}
}

Share this post


Link to post
Share on other sites
TiagoCosta:
Aah right.. hmm.. I guess I would be able to do that in a CG shader? Then It will work for both dx11 and opengl? I'm writing a renderer that can use both api's..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!