Rendering a scene cross two computers

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!
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Rendering a scene cross two computers

Post by robmar »

Has anyone setup irrlicht on two computers having them render the same scene across two screens, left and right portion images?

The idea would be to render only one half of the scene to reduce the cpu load, rather than render the whole scene and view only the left side.

Is there a way to set up cameras to render exactly one half the scene, like having the left side of the fustrum, rather than a new smaller fustrum.
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Rendering a scene cross two computers

Post by robmar »

This would be like having a camera with a normal fustrum but say 32:9 ratio, then moving the right-side frustrum points to the centre, and rendering the 16:9 left or right sides.
chronologicaldot
Competition winner
Posts: 685
Joined: Mon Sep 10, 2012 8:51 am

Re: Rendering a scene cross two computers

Post by chronologicaldot »

Or you could just render the scene twice, changing the camera angle, so that it excludes the right, and then changing it again so it excludes the left. Overlap can be eliminated by cropping. Make the frustrum small for normal viewing.
Mind you, I'm just pulling these ideas out of mid-air. I haven't thought about it much. But it seems simpler than modding the engine, lol.
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Rendering a scene cross two computers

Post by robmar »

Yes but that causes extra work, which I am trying to avoid. Is there an efficient way just to render the objects in the exact left or right half of the screen, or in fact quadrants?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Rendering a scene cross two computers

Post by hendu »

1) Use a suitable frustum. Or,
2) Block half the screen with a stencil.
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Rendering a scene cross two computers

Post by robmar »

The problem as I see it is to have a frustum cut in half so to say, yet with the camera centered on the right-side centre, to obtain an exact half-screen render... if you follow me, i.e. half of the render achieved with the same camera pos and target, and with normal frustum.

I think that if I create a fustrum of the area of a normal fustrum, its centred on the camera, offsetting the render.

Not sure if I am explaining this very well.

I am trying to render the exact same left or right half the screen only, with the exact same image as if I had a normal fustrum.

I'm not sure this is possible without rendering the whole image, then masking or copying just the required side, which means a full render, and unnecessary drawing.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Rendering a scene cross two computers

Post by hendu »

There is no unnecessary drawing with a stencil, and splitting a frustum just requires you to calculate the proper math. It was done by Nintendo to create GameCube screenshots for posters, for example.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Rendering a scene cross two computers

Post by mongoose7 »

I'm thinking that a normal projection matrix maps the view frustum into the cube { (-1, -1, -1) (1, 1, 1) }, so all we need is a matrix to map this into the cube { (-1, -1, -1) (3, 1, 1) }, which will cause the right half to be clipped. Then just combine the two for the new projection matrix (remembering to use the transpose of the matrix for the final result).
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Rendering a scene cross two computers

Post by devsh »

Its basically a case of doing a 2D transform after projection on the NDC (normalized device coords) image

make another matrix that enlarges and moves a 2d image sector (where the whole image ranges between (-1,-1) and (1,1)) onto the space of the full image

i.e. enlarging the left half of the screen to cover the whole thing
2,0,0,1
0,1,0,0
0,0,1,0
0,0,0,1
this 4x4 matrix relates the translation of scale in X axis by 2 and then afterwards move 1 unit right

now if you get your projection matrix and pre-multiply the above with it (so that it gets applied AFTER proojection) and set that as your new projection matrix, you will get the desired effect


also you may want to consider using a specific view-port to get the number of pixels right etc. (doesn't matter the Aspect Ratio of your viewport, the entire viewport is still -1 to 1 XY NDC)
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Rendering a scene cross two computers

Post by robmar »

So a 2D transform on the projection matrix, effectively zooming in on any area? Sounds so simple like that.

Would that prevent nodes that were outside that zoomed area from being rendered, or would that need an adjusted clipping area?
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Rendering a scene cross two computers

Post by mongoose7 »

Clipping is done post projection. The vertex shader would run but the pixel shader would not. Irrlicht user space clipping would not be aware of the smaller space.
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Rendering a scene cross two computers

Post by devsh »

you are probably talking about frustum culling... the answer is, if you set the camera projection matrix to the adjusted matrix then adjusted furstum planes will be calculated and the irrlicht frustum/box culling will work ok
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Rendering a scene cross two computers

Post by robmar »

The problem is that if the frustum is adjusted the effective half/quarter part of the image rendered will be different to the same part of the screen created when using one larger frustum a the camera to objects "perspective" changes.

As devsh mentioned, the 2D transform allows a zoom-up on the required part of the screen, but it seems that the system will still render the full frustum area, which wastes processor time.

The 2D transform sound like the only way to render just one part of the screen, while another instance on another PC renders the other side (dual monitor).

But to improve FPS, both should not render nodes (do sub-meshes of a node get clipped or just the whole node?) that are not visible in the zoomed area.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Rendering a scene cross two computers

Post by mongoose7 »

The 2D transform is applied to the projection matrix and so modifies the frustum (and the projection matrix). I hope I don't have to yell - the frustum is modified by the 2D (1D actually) transform.
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Rendering a scene cross two computers

Post by robmar »

Got it! Sorry for my neurons, they are not very fast with 3D math :oops:

So the new frustum then covers the left or right side of the original "full" frustum, the camera is in the same spot, so the half rendered would be identical to the half that would be rendered by the original unmodified frustum?
Post Reply