Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rendering 4 viewports


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Nanook   Members   -  Reputation: 473

Like
0Likes
Like

Posted 29 February 2012 - 05:40 PM

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?

Sponsor:

#2 turch   Members   -  Reputation: 590

Like
0Likes
Like

Posted 01 March 2012 - 08:33 AM

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.

#3 TiagoCosta   Crossbones+   -  Reputation: 1911

Like
0Likes
Like

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...
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

#4 Nanook   Members   -  Reputation: 473

Like
0Likes
Like

Posted 02 March 2012 - 05:49 AM

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..




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS