🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.graphics.algorithms
2 messages
2 total messages Started by olivier.brunet Thu, 26 Mar 1998 00:00
GL Rasterization & Homogenous coordinates
#61
Author: olivier.brunet
Date: Thu, 26 Mar 1998 00:00
32 lines
1637 bytes
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)

So to setup mapping coordinates I do something like this:

glTexCoord4f(u * (1/z), v * (1/z), 0, 1/z)

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

If you have ideas ...

Thanks,
Olivier

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading
Re: GL Rasterization & Homogenous coordinates
#60
Author: 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".)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads