   CubeMapping without shaders
  Hi,I would like to use the idea of cube mapping for texturing an object (simply by sampling the cubemap using the normals instead of the reflection vectors), without using shaders (so no texCube instruction). I know that the texture would be very stretched in curved areas using that method but that should give me acceptable results considering the kind of meshes I have. The faces of my cubemap would all be the same texture (my point is just texturing a freehand object, not create any reflection effect).Ok so the point here is to do what the Cg TexCube instruction does to sample a cubemap, but do it myself on the CPU and access my single texture as if it was a cube map... I implemented a first version that did not work as well as I expected. My idea was to use the biggest component of the normal to figure out what face to sample, and them compute the UVs by scaling the 2 other coordinates within the range [0, 1]. Here is my code, n is my normal and texindex is the index of the cube face I will sample.n.normalize();float x = n[0], y = n[1], z = n[2];assert( !( fabs( x ) < 0.00001f && fabs( y ) < 0.00001f && fabs(z ) < 0.00001f )if ( fabs( x ) > fabs( y ) && fabs( x ) > fabs( z ) ){   if ( x > 0.0f ) {  u = 0.5f - z / ( 2.0f * x );  v = 0.5f - y / ( 2.0f * x );  texindex = 0; // px    } else {  u = 0.5f - z / ( 2.0f * x );  v = 0.5f + y / ( 2.0f * x );  texindex = 1; //nx    }} else if ( fabs( y ) > fabs( z ) ) {    if ( y > 0.0f ) {  u = 0.5f + x / ( 2.0f * y );  v = 0.5f + z / ( 2.0f * y );  texindex = 2; // py    } else {  u = 0.5f - x / ( 2.0f * y );  v = 0.5f + z / ( 2.0f * y );  texindex = 3; // ny    }} else {   if ( z > 0.0f ) {  u = 0.5f + x / ( 2.0f * z );  v = 0.5f - y / ( 2.0f * z );  texindex = 4; // pz   } else {  u = 0.5f + x / ( 2.0f * z );  v = 0.5f + y / ( 2.0f * z );  texindex = 5; // nz   }}The problem comes from the triangles with some vertices on one face and other vertices on another face (in red). Considering the coordinate systems of a cube map (especially the flip with some axis), the 2 vertices on the left have a U coord around 0.9 but the vertex on the next face has a U coord around 0.1. This ends up with almost the whole texture in a single triangle. And it gets even worse as the axis flip again for the top faces.Does anyone has ever successfully tried such a thing? Or any thought?Thanks!   
  How about instead of using UV range in all six squares from 0 to 1 you let their UV range from N to N+1, and enable texture wrapping?You'll have to do some creative indexing given all of the s/t orientation flipping, but I think it should be doable.So for your red triangle instead of having coordinates like (0.9,0.4)(0.9,0.6)(0.1,0.5) (in neighboring face)You could have something like this:(1.9,1.4)(1.9,1.6)(2.1,1.5) (in neighboring face).I think this should put you on the right track to fix your problem.   ;  That could actually work, I'll try this out tomorrow and I'll keep you posted. Thanks!   ;  I tried this solution and figured out that this is actually a much harder problem, which might be unsolvable when doing a per-vertex cubemap fetching. I doubt I can get the coordinates right in every case. By doing a per-fragment fetching as a shader does, things come together naturally.   