Forums > Jitter

gl.render offset(offaxis) message? Perspective correction…


Spa
December 21, 2006 | 6:10 am

What is the message and way to use it for renderind an offset (offaxis) gl view? (camera is not moving!!!)
after web search I thought perhaps it’s : glTranslated. I also remenber (years ago that gl had such function)

I’ll use it to simulate the offaxis projection viewpoint of video beamer. Generally 50/70% down the central vertical axis.

Example:I use a 1024×1536 window of a render context, and display only the half upper part to simulate a video beamer(w. 50% offset).
It would be better if i could work with a 1024×768 window of an offsetted render

thanks

Spat



Spa
December 21, 2006 | 6:16 am

sorry for double post….


December 21, 2006 | 6:16 am

Have you tried jit.gl.render @camera for positioning the camera?

wes

On 12/20/06, patrice

wrote:
>
> What is the message and way to use it for renderind an offset (offaxis) gl view? (camera is not moving!!!)
> after web search I thought perhaps it’s : glTranslated. I also remenber (years ago that gl had such function)
>
> I’ll use it to simulate the offaxis projection viewpoint of video beamer. Generally 50/70% down the central vertical axis.
>
> Example:I use a 1024×1536 window of a render context, and display only the half upper part to simulate a video beamer(w. 50% offset).
> It would be better if i could work with a 1024×768 window of an offsetted render
>
> thanks
>
> Spat
>



Spa
December 21, 2006 | 6:22 am

Hey wes,
I’m not talking about moving the camera but of ‘cutting’ a part of the gl render. (offaxis render).
The perspective view point stay the same.
So that an 1024×768 window with 50% offaxis render will display exactly the same view than the upper part of a 1024×1536 window..

I don’t know if it’s clear

It’s also called perspective correction
thanks



Spa
December 21, 2006 | 6:49 am

After a bit more search it seems that the function is glFrustum().
Is it possible to access it through jitter, how?

source: Silicongraphics
The OpenGL glFrustum() function can be altered to do an asymmetric frustum projection. Here’s how: glFrustum (FrustumLeft + FrustumAsymmetry, FrustumRight
+ FrustumAsymmetry, FrustumBottom, FrustumTop,
NearClipDistance, FarClipDistance);

http://www.reald.com/scientific/downloads/pcsdk.htm#6


December 21, 2006 | 7:21 am

I don’t know why you keep calling it offaxis render. I’ve never heard
this term used before. You can access most of the OpenGL commands via
jit.gl.sketch. To have it take effect for your scene, you can use it
in immediate mode or draw everything in your scene with jit.gl.sketch
through the drawobject message after you set glfrustum.

wes

On 12/20/06, patrice

wrote:
>
> Hey wes,
> I’m not talking about moving the camera but of ‘cutting’ a part of the gl render. (offaxis render).
> The perspective view point stay the same.
> So that an 1024×768 window with 50% offaxis render will display exactly the same view than the upper part of a 1024×1536 window..
>
> I don’t know if it’s clear
>
> It’s also called perspective correction
> thanks
>


December 22, 2006 | 4:32 pm

Quote: wesley.hoke@gmail.com wrote on Thu, 21 December 2006 08:21
—————————————————-
> I don’t know why you keep calling it offaxis render. I’ve never heard
> this term used before.

Me neither, but for me it’s clear what you’re after. In fact I would definitly like to see this working (I didn’t try yet), because this would make it possible to render one scene on multiple windows without the perspective problem. See also the discussion on

http://www.cycling74.com/forums/index.php?t=msg&goto=84416&rid=3579&S=0a103c49025b2c5f17265f4145584a92

Mattijs


December 22, 2006 | 5:50 pm

Here’s a demo patch that shows how to do asymmetric projections with
glfrustum. And the JS that you’ll need

wes

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 547 191 157 196617 3) call glFrustum();
#P comment 547 177 157 196617 2) load the identity matrix;
#P comment 547 163 157 196617 1) set matrixmode to projection;
#P window linecount 5;
#P comment 517 93 253 196617 Making asymmetric frustums requires doing
a bit more than just calling glFrustum. glFrustum multiplies the
perspective matrix it generates by the current matrix in whatever
matrix mode OpenGL is in. Here are the steps to properly create
asymmetric frustums.;
#P window linecount 1;
#P comment 275 432 141 196617 default glFrustum params =>;
#P window linecount 2;
#P message 422 425 288 196617 reset , glmatrixmode projection ,
glloadidentity , glfrustum -0.11 0.11 -0.0414 0.0414 0.1 100 ,
drawobject golf 0 , draw;
#P window linecount 1;
#P message 406 369 70 196617 calc_frustum;
#P newex 406 347 64 196617 r draw_half;
#P newex 406 388 90 196617 js CalcFrustum.js;
#P button 26 56 15 0;
#P newex 72 340 64 196617 r draw_half;
#P window linecount 2;
#P message 72 362 283 196617 reset , glmatrixmode projection ,
glloadidentity , glfrustum -0.0552 0.0552 0. 0.0414 0.1 100 ,
drawobject golf 0 , draw;
#P window linecount 1;
#N vpatcher 20 74 223 253;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P newex 74 91 64 196617 s draw_half;
#P window linecount 1;
#P newex 50 50 58 196617 t b b erase;
#P inlet 50 30 15 0;
#P outlet 50 91 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P fasten 2 2 0 0 103 79 55 79;
#P connect 2 1 3 0;
#P pop;
#P newobj 72 164 42 196617 p Draw;
#P newex 72 394 148 196617 jit.gl.sketch half @automatic 0;
#P window linecount 2;
#P newex 72 288 290 196617 jit.gl.gridshape half @shape torus @color 1
1 0 1 @lighting_enable 1 @position 0 0 -2 @name golf @automatic 0;
#P window linecount 1;
#P newex 72 260 405 196617 jit.gl.gridshape whole @shape torus @color
1 1 0 1 @lighting_enable 1 @position 0 0 -2;
#P newex 72 210 283 196617 jit.window half @depthbuffer 1 @pos 10 320
@size 320 120;
#P newex 72 186 85 196617 jit.gl.render half;
#P newex 72 129 215 196617 jit.window whole @depthbuffer 1 @pos 10 50;
#P toggle 55 36 15 0;
#P newex 55 55 57 196617 qmetro 30;
#P newex 72 80 50 196617 t b erase;
#P newex 72 105 94 196617 jit.gl.render whole;
#P message 258 61 34 196617 reset;
#P newex 258 80 194 196617 jit.gl.handle whole @inherit_transform 1;
#P window setfont "Sans Serif" 18.;
#P comment 517 57 192 196626 Asymmetric Frustum;
#P window setfont "Sans Serif" 9.;
#P window linecount 2;
#P comment 505 388 254 196617 < = gets the perspective matrix and
calculates what the glFrustum params to generate that matrix would be;
#P connect 7 0 6 0;
#P connect 17 0 5 0;
#P fasten 6 0 5 0 60 76 77 76;
#P connect 2 0 4 0;
#P fasten 5 0 4 0 77 101 77 101;
#P fasten 5 1 4 0 117 101 77 101;
#P connect 17 0 14 0;
#P fasten 6 0 14 0 60 156 77 156;
#P connect 2 0 9 0;
#P connect 14 0 9 0;
#P connect 16 0 15 0;
#P connect 15 0 13 0;
#P connect 3 0 2 0;
#P connect 19 0 20 0;
#P connect 20 0 18 0;
#P window clipboard copycount 27;

——————CalcFrustum.js
autowatch = 1

var sketch = new JitterObject("jit.gl.sketch", "half");
sketch.automatic = 0;

function calc_frustum()
{
var projection = sketch.glget("projection_matrix")

var clipRatio = (projection[10] – 1.)/(1. + projection[10]);

//near + far calculations
var near = projection[14]*(1-clipRatio)/(2.*clipRatio);
var far = clipRatio * near;

//left + right calculations
var left = -near*(1. – projection[8])/projection[0];
var right = 2*near/projection[0] + left;

//bottom + top calculations
var bottom = -near*(1. – projection[9])/projection[5];
var top = 2*near/projection[5] + bottom;

post("nStandard glFrustum params based on jit.gl.render settings:n")
post("glFrustum( " + left.toPrecision(3) + ", " +
right.toPrecision(3) + ", " +
bottom.toPrecision(3) + ", " + top.toPrecision(3) + ", " +
near.toPrecision(3) + ", " + far.toPrecision(3) + " )n")
}



Spa
December 23, 2006 | 5:09 pm

thanks a lot for the patch and js.
It’s clearly not straightforward.

It seems that those opengl commands are accessible only through jit.gl.sketch.
Or, is there a way to pass them to a render? (in a typical videoplane>render chain)

thanks again
spat


December 23, 2006 | 5:18 pm

Most of the OpenGL API is only available via jit.gl.sketch. If you
want your 3D stuff to be affected by the glFrustum commands, you’ll
have to render them in sketch as well with the drawobject message.

wes

On 12/23/06, patrice

wrote:
>
> thanks a lot for the patch and js.
> It’s clearly not straightforward.
>
> It seems that those opengl commands are accessible only through jit.gl.sketch.
> Or, is there a way to pass them to a render? (in a typical videoplane>render chain)
>
> thanks again
> spat
>


Viewing 10 posts - 1 through 10 (of 10 total)