Calculating Normals

leodeus
Unregistered
 
Post: #1
Sorry the basic question!!!!

How get the normal value in a x,y,z pixel of a polygon?

Leo
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #2

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
leodeus
Unregistered
 
Post: #3
ok.. but they don´t answer this:

Supose:
I have a cube with vertices, faces and normals.
Can i retrieve the normal value for any pixel(x,y,z)?... (supose: i want get the normal value for the pixel (not vertice or face) x=21,y=10,z=1, or other pixel)...

There is a command to get the normal value in certain pixel of a polygon?
Quote this message in a reply
Member
Posts: 153
Joined: 2004.12
Post: #4
Is this for a fragment shader?

There was a long silence...
'I claim them all,' said the Savage at last.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #5
What on earth do you need that for?

It sounds to me like you'll want to unproject the pixel location from which you want to retrieve the normal, project that onto the face, and find the normal by interpolating appropriately between the normals of the face's vertices at that point. There's no way built into OpenGL to do it, unless I'm missing something.
Quote this message in a reply
leodeus
Unregistered
 
Post: #6
No...
it is for detecting a polygon face (in all pixels) (in a top and ortographic view) when the view frustum in less than a height of a polygon...

like this : http://labsim.estig.ipb.pt/test.jpg
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #7
Well for a face, the normal will be the same over the entire thing.
So you can use OpenGL picking to find out which face was clicked and then get the normal you have precalculated for that face.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
leodeus
Unregistered
 
Post: #8
ok... is that..
and now the initial basic question:

how can get the normal value in a some pixel of a face? using opengl... (i defined the normal by 3 points(x,y,z) (face)... and now i want retrieve this normal value pixel by pixel... (to know if some pixel belongs to a face or not)....

Thanks again.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #9
I dont understand what you mean,
what is the input and expected output you want,
do you want to calculate the normal of the face that is at some pixel?

There is no OpenGL call that gives you a normal from a pixel, but there is one that can give you a face from a pixel.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
leodeus
Unregistered
 
Post: #10
If there is one that give me a face from a pixel better... How?

My input: pixel coordinates
The Output: norlmal value or face (if belongs a face)
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #11
There are a few different ways to do it. OpenGL provides a facility known as selection mode, which allows you to determine whether or not a particular primitive or set of primitives is drawn in a particular pixel location. You can read up on it in chapter 13 (if I'm remembering correctly) in the red book. You can do the math yourself as I suggested in my earlier post. They both have their pros and cons; learn about both and choose the one that works best for you.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Calculating tangent coords for arbitrary poly meshes TomorrowPlusX 8 5,548 Jul 9, 2007 03:10 PM
Last Post: Hog
  Normals Nick 20 8,298 Mar 25, 2005 09:31 AM
Last Post: tigakub
  calculating normals ghettotek 10 5,664 Feb 13, 2003 09:40 AM
Last Post: lpetrich
  Normals? Quicksilver 3 2,874 Jan 13, 2003 05:31 PM
Last Post: henryj