   [GLSL] Get the direction vector between my camera and a vertex
  Hi,I'd like to get the direction vector between my camera and the actual point in the vertex shader.Imagine that the black square is my terrain, the green circle is my camera, the red line is my current view direction vector, and the purple line is the vector i'd like to have (to calculate the angle between both lines : the blue one).I have no idea how to do it.   
  What's wrong with just subtracting camera position from the vertex position, or am i missing something here? Maybe if you post your shader i can be more helpful.   ;  My vertex shader is pretty empty, because i dont know what to do...[Vertex Shader]uniform vec3 cameraPosition, viewDirection;void main(){gl_TexCoord[0] = gl_MultiTexCoord0;gl_Position = ftransform();}I think my frangment shader is useless for my problem but here it is[Fragment Shader]uniform sampler2D maTexture,  maTextureDetail,  lignes,  stripes,  vertStripes,  contour;uniform vec3 maCamera, viewDirection;varying vec3 eyeVec;void main(void){const float testCouleur = 0.9, nbRepetHerbe = 40.0;float direction_z    = viewDirection.z,  direction_x   = viewDirection.x,  niveauLignes   = 1.0,  niveauLignesVert = 1.0;//Création des texturesvec4 herbe = texture2D(maTexture,  gl_TexCoord[0].st * nbRepetHerbe), herbeDetail = texture2D(maTextureDetail, gl_TexCoord[0].st * nbRepetHerbe), lignesBlanches = texture2D(lignes,  gl_TexCoord[0].st), contourMasque= texture2D(contour,  gl_TexCoord[0].st), bandesVert = texture2D(vertStripes,  gl_TexCoord[0].st * 18.0), bandes = texture2D(stripes,  gl_TexCoord[0].st * 24.0);vec4 rendu = (lignesBlanches + herbe) * herbeDetail;if(contourMasque.r > testCouleur){rendu = (lignesBlanches + herbe) * herbeDetail;}else{if(direction_z <  0.001 && direction_z > 0.0) { direction_z = 0.0; }if(direction_z > -0.001 && direction_z < 0.0) { direction_z = 0.0; }if(direction_x <  0.001 && direction_x > 0.0) { direction_x = 0.0; }if(direction_x > -0.001 && direction_x < 0.0) { direction_x = 0.0; }if(direction_z >= 0.0){if(bandes.r >= testCouleur){niveauLignes -=  direction_z / 10.0;rendu = (lignesBlanches + herbe) * herbeDetail / vec4(niveauLignes, niveauLignes, niveauLignes, 0.0);if(direction_x >= 0.0){if(bandesVert.b >= testCouleur){niveauLignesVert -=  direction_x / 20.0;rendu /= vec4(niveauLignesVert, niveauLignesVert, niveauLignesVert, 0.0);}}else if (direction_x < 0.0){direction_x *= -1.0;if(bandesVert.b < testCouleur){niveauLignesVert -=  direction_x / 20.0;rendu /= vec4(niveauLignesVert, niveauLignesVert, niveauLignesVert, 0.0);}}}else{rendu = (lignesBlanches + herbe) * herbeDetail;if(direction_x >= 0.0){if(bandesVert.b >= testCouleur){niveauLignesVert -=  direction_x / 20.0;rendu /= vec4(niveauLignesVert, niveauLignesVert, niveauLignesVert, 0.0);}}else if (direction_x < 0.0){direction_x *= -1.0;if(bandesVert.b < testCouleur){niveauLignesVert -=  direction_x / 20.0;rendu /= vec4(niveauLignesVert, niveauLignesVert, niveauLignesVert, 0.0);}}}}else if (direction_z < 0.0){direction_z *= -1.0;if(bandes.r < testCouleur){niveauLignes -=  direction_z / 10.0;rendu = (lignesBlanches + herbe) * herbeDetail / vec4(niveauLignes, niveauLignes, niveauLignes, 0.0);if(direction_x >= 0.0){if(bandesVert.b >= testCouleur){niveauLignesVert -=  direction_x / 20.0;rendu /= vec4(niveauLignesVert, niveauLignesVert, niveauLignesVert, 0.0);}}else if (direction_x < 0.0){direction_x *= -1.0;if(bandesVert.b < testCouleur){niveauLignesVert -=  direction_x / 20.0;rendu /= vec4(niveauLignesVert, niveauLignesVert, niveauLignesVert, 0.0);}}}else{rendu = (lignesBlanches + herbe) * herbeDetail;if(direction_x >= 0.0){if(bandesVert.b >= testCouleur){niveauLignesVert -=  direction_x / 20.0;rendu /= vec4(niveauLignesVert, niveauLignesVert, niveauLignesVert, 0.0);}}else if (direction_x < 0.0){direction_x *= -1.0;if(bandesVert.b < testCouleur){niveauLignesVert -=  direction_x / 20.0;rendu /= vec4(niveauLignesVert, niveauLignesVert, niveauLignesVert, 0.0);}}}}}gl_FragColor = rendu;};  So what exactly are you trying to achieve, what do you need this direction vector for?   ;  Well, I need this vector to calculate the angle between the two lines.The final goal is complicated to explain, it's for the dark stripes of a soccer field.   ;  As Dave already mentionned, the standard way of doing this is:vertex position (in world space) - camera position.float4x4 world;float4x4 view;float4x4 projection;float3 cameraPosition;...struct VS_IN{float4 position : POSITION;   ...};struct PS_IN{float4 pos : SV_POSITION;float3 Position : TEXCOORD0;   ...};PS_IN VS( VS_IN input ){PS_IN output = (PS_IN)0;float4 worldPos = mul(input.pos, world);float4 viewPos = mul(worldPos, view);output.pos = mul(viewPos, projection);output.Position = worldPos.xyz;   ...return output;}float4 PS( PS_IN input ) : SV_Target{   //This is actually the distance between the vertex (the surface point actually) and camera   float3 vertexToCameraVector = input.Position - cameraPosition;   //You'll probably want to normalize this to get the direction   //instead of the distance   vertexToCameraVector = normalize(vertexToCameraVector);   ...}Edit: sorry, this is hlsl, not glsl, but the idea is the same :)[Edited by - Hyunkel on May 4, 2010 1:35:20 PM];  Thanks a lot, i'm going to try this !   