   giving a coordinate of an object to glsl
  Hy I created a scene: it is a simple box with a sphere inside. I'm using shaders to texture the sphere (it is reflecting the box). Now i need to know in the shader where the center of the box is located. In my application, the center of the box is the origin of the coordinate system.Should i pass the center of the box by uniform variables?Is there a buildt in variable i could use? In which space will it be when it is loaded into the shader?   
  Hi, Try this site for great GLSL-tutorials.http://www.lighthouse3d.com/opengl/glsl/;  Pass in den center as global variable (should be uniform in GLSL but I am more into HLSL). Its in exactly the same space it was in when you send it to the shader. Those global shader vaiables are not modified automatically. You get the same coordinates you filled in. Its up to you to transform the coordinates if you need to.   ;  "Its in exactly the same space it was in when you send it to the shader. Those global shader vaiables are not modified automatically. You get the same coordinates you filled in. Its up to you to transform the coordinates if you need to."So the question is: i have a vertex position, known to me as the built in variable gl_Vetrex. It is in object space. i can transform this gl_Vertex to Eye Space by the built in matrix gl_ModelViewMatrix. But i dont know where the origin of the object space is by default. Is this defined by the application?If i knew where the origin of the object space is, i could transform the center of my cube to the objectspace and afterwards with help of gl_ModelViewMatrix to Eye Space....   ;  EitherA) Transform the vertices in the shader onlyorB) Supply the original position to the shader "A" gives the benefit of letting the GPU do all the work. simply plug in the object matrix in your shader code and let the graphicsprocessor do the work. "B" requires double work, part CPU and part GPU.   ;  at Rasmadrak: I dont understand what you try to explain to me. Could you try it in another way?I spoke to someone in the Company, he gave me an idea which could work:In my application the position of the cube-center is known. also the camera/eye-position is known. The eye-position is in Eye coordinates the position (0,0,0). I am going to use the eye position which is known in the vertex shader to calculate the cube-center in eye coordinate.I will try this and post whether it works or not.write me if you think you have a better idea.   ;Quote:Original post by DISLBut i dont know where the origin of the object space is by default. Is this defined by the application?No, the origin is always at (0, 0, 0) and gets translated by the translational part of your MODELVIEW matrix. But I assume you are talking about the Bounding Box and its center you have for this object? If your cube is already in world space you just need to set the cube's center as uniform variable and multiply this with the gl_ModelViewMatrix. Then its in the same space as the vertices. Which again leads me to believe that the build in GLSL variables kinda ... well ... suck. If you would be required to actually send your transformation matrices to the shader as uniform variables as well (as in HLSL) you would have quite a better understanding of what you are actually doing with those shader calls. No offense against you implied just against this OpenGL mixture of fixed function pipeline calls redirecting automatically to the shader pipeline. [grin];  Im not using OpenGl. I'm using Xith3d to creating the environment. Xith3d using a Scene-graph-concept based on OenGl. I created this scene: A Box built around the origin of the scene. I positioned the camera in postion (6,0,6) and  i positioned the Sphere, which is going to be textured by the shader, to (1,1,0). Then afterwards i call the shader to texture the sphere. The shader has a object space in which the gl_vertex and a eye space everithing is calculated. this is maybe more a question for xith3d community....   