View Full Version : Vector to eye position
05-15-2007, 09:05 AM
Can anyone tell me how to determine a vector from a vertex to the eye/camera in the vertex or geometry shader?
05-15-2007, 10:45 AM
vec3 eyeVec = (gl_ModelviewMatrix * gl_Vertex).xyz;
05-15-2007, 12:07 PM
Shouldn't you put a "-" before?
05-16-2007, 01:38 AM
Shouldn't you put a "-" before?Yeah, the question was about the opposite vector, so I guess "-" should be there.
I alsways calclate vector from eye to vertex because it's better for reflect() and refract().
05-20-2007, 05:17 AM
I'll give it a try on monday.
I was trying this actually in the Geometry Shader. However it seems that this:
vec4 pos = gl_ModelViewMatrix * vertex;
gl_Position = pos;is different from:
vec4 pos = vertex;
gl_Position = gl_ModelViewMatrix * pos;Any idea why?
05-20-2007, 11:41 AM
It is different. gl_Position is same but pos is different in case 1 and case 2.
05-20-2007, 02:04 PM
Ok, but the actual result is different. And that is based on the gl_Position. I would expect no visual difference.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.