I have a 512*512 grayscale GL_RGBA noise texture that I lookup in the vertex program:
struct vertex_input
{
float4 position : POSITION;
float2 uv : TEXCOORD0;
float4 normal : NORMAL;
};
struct vertex_output
{
float4 position : POSITION;
float3 normal : TEXCOORD1;
float change : TEXCOORD2;
};
vertex_output main(
vertex_input IN
, uniform float4x4 ModelViewProj
, uniform float4x4 ModelViewIT
, uniform sampler2D height_texture
)
{
vertex_output OUT;
float h = tex2D(height_texture, IN.uv).a;
OUT.position = mul(ModelViewProj, IN.position);
OUT.normal = normalize(mul(ModelViewIT, IN.normal).xyz);
OUT.change = h;
return OUT;
}
I would like to know the following:
1) What are the dimension of the 'height_texture'? In the application it was 512*512, but in the OpenGL manual I have read that textures are in the range
u \in [0,1], v \in [0,1]
How do I verify what the valid ranges are to lookup in the texture?
2) The texure is grayscale so I assume what tex2D returns is something like:
(0.0, 0.0, 0.0, a)
where 'a' is the intensity of the texel ranging from black (0) to white (1), but is this correct and how do I verify this?
3) What are the range of the texture coordinates IN.uv? From the application I have:
static int offset_coord = 0;
static int offset_normal = sizeof(vector3_type) + offset_coord;
static int offset_color = sizeof(vector3_type) + offset_normal;
static int offset_tex0 = sizeof(vector4_type) + offset_color;
static int offset_tex1 = sizeof(vector2_type) + offset_tex0;
static int offset_tex2 = sizeof(vector2_type) + offset_tex1;
GLsizei stride = sizeof(vertex_type);
#define OFFSET(x) ((char *)NULL+(x))
glClientActiveTexture(GL_TEXTURE0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer( 2, GL_FLOAT, stride, OFFSET(offset_tex0) );
But I don't see anything about the range of the texure coordinates.