🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.graphics.algorithms
Article #60

Re: GL Rasterization & Homogenous coordinates

#60
From: Andy Vesper
Date: Mon, 30 Mar 1998 00:00
55 lines
3058 bytes
olivier.brunet@capway.com wrote:
> 
> I would like to use in rasterization only mode, ie I do all the
> transformation/projection maths, and then I use GL to rasterize. I want to
> keep the
> perspective correctness of mapping too.
> 
> To achieve this I have the following data:
> - GL_MODELVIEW is identity
> - GL_PROJECTION is identity
> - for each vertex I have X in screen space, Y in screen space, and 1/Z (where
> Z is the world
> coordinates Z)

When your model-view and projection matrices are identity, have
only perspective divide and viewport transform to worry about.
Ignoring perspective divide, this will map -1.0 to 1.0 to the
viewport limits in x and y. You may want to change the model-view
or projection matrix to give you object space coordinates equal
to their screen space coordinates.

> So to setup mapping coordinates I do something like this:
> 
> glTexCoord4f(u * (1/z), v * (1/z), 0, 1/z)

u and v usually refer to the texture coordinates scaled up to
the base texture array size -- glTexCoord takes s,t,r,q coordinates
nominally in the range 0.0 to 1.0. The 'q' coordinate is used
when projecting the texture onto the surface, you don't need q
if you are just projecting the surface onto the screen UNLESS you
are doing the perspective division yourself.

> But I got a probelm to specify vertexes in order to appear where they should
> (and have the
> depth buffer work correctly too)
> 
> I don't manage to get the correct formula for the glVertex call ...
> 
> glVertex3f(x,y,1/(1/z)) or glVertex(x,y,?,(1/z))

1. If you are performing the perspective division yourself,
you can use glVertex3f. Your z values can be 'world coordinates Z'
if you have your transformations set up to scale z to the range
0.0 to 1.0. Or, you can perform that transformation yourself.

2. If you want OpenGL to do the perspective divide, you want to 
set up the projection matrix as a perspective one and specify
x,y and z. I would be hesitant about using an ortho matrix
and 4D coordinates for fear that some implementation doesn't
do this correctly.
-- 
Andy V, OpenGL Alpha Geek  (never a Digital spokesperson)
mailto:andrew.vesper@digital.NoSpamPlease
(To send mail to me, change "NoSpamPlease" to "com".)
Technical Details
Message-ID: <351F6E2F.14B914EB@digital.NoSpamPlease>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6fe5sr$tr9$1@nnrp1.dejanews.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f65bb,a3a9fc4118ec9349
X-Google-Attributes: gidf65bb,public
X-Google-Thread: 100291,a3a9fc4118ec9349
X-Google-Attributes: gid100291,public
X-Google-Thread: fdc2a,a3a9fc4118ec9349
X-Google-Attributes: gidfdc2a,public
From: Andy Vesper <andrew.vesper@digital.NoSpamPlease>
Subject: Re: GL Rasterization & Homogenous coordinates
Date: 1998/03/30
Message-ID: <351F6E2F.14B914EB@digital.NoSpamPlease>
X-Deja-AN: 339217757
Content-Transfer-Encoding: 7bit
References: <6fe5sr$tr9$1@nnrp1.dejanews.com>
To: olivier.brunet@capway.com
Content-Type: text/plain; charset=us-ascii
Organization: Digital Equipment Corporation
Mime-Version: 1.0
Newsgroups: comp.graphics.algorithms,comp.graphics.api.opengl,3dfx.opengl