WorldViz User Forum linear transform in 2D screen space
 Register FAQ Search Today's Posts Mark Forums Read

#1
10-09-2009, 07:36 AM
 stefs Member Join Date: Mar 2008 Posts: 10
linear transform in 2D screen space

I intend to do some linear transform in 2D window (screen) space in order to do on-the-fly h-/v-keystone correction. I have all the code ready to calculate the linear distortion matrix from four registered corner points of the projection image. At the moment I choose this approach:

Code:
```current_pm = viz.MainWindow.getProjectionMatrix()
current_pm.postMult(distortion_matrix)
viz.MainWindow.setProjectionMatrix(current_pm)```
Where distortion_matrix is a 4x4 matrix that leaves the z untouched. The distortion in 2D space works fine but I still get some strange clipping artifacts.

My question: Is there a more elegant way in Vizard to implement this final viewport distortion as a 2D transform only rather than as a distortion of the 3D projection matrix?
#2
10-09-2009, 11:15 AM
 farshizzo WorldViz Team Member Join Date: Mar 2003 Posts: 2,849
You can use a post-process shader to perform your keystone correction. A shader may be overkill for a simple linear transformation, but it allows for more flexibility for distortion correction. The vizlens module that comes with Vizard uses a post-process shader to perform the lens correction. Here is a simple example of a post-process shader:
Code:
```import viz
import vizpp
viz.go()

uniform sampler2D vizpp_InputTex;
uniform float osg_FrameTime;
void main (void)
{
float s = gl_TexCoord[0].s + (gl_TexCoord[0].t * sin(osg_FrameTime) * 0.3);
float t = gl_TexCoord[0].t;
gl_FragColor = texture2D( vizpp_InputTex, vec2(s,t) );
}
"""

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements Vizard Precision Position Tracker (PPT) Plug-in development

 Similar Threads Thread Thread Starter Forum Replies Last Post honey006 Vizard 3 05-21-2009 10:57 AM erchrastil Vizard 8 06-27-2008 12:45 PM active_world Vizard 1 05-16-2008 08:24 PM masaki Vizard 2 01-13-2008 12:22 PM aaThomas Precision Position Tracker (PPT) 3 05-31-2007 11:59 AM

All times are GMT -7. The time now is 08:33 PM.