Try as I might, I can't seem to get a vertex shader to be able to sample values from a texture. I'm using an FX 9200 which reports 4 possible texture in a vertex shader, so it should be possible. My program gets the following error message (after compiling the shader source):
Vertex info
-----------
<stdlib>(9542) : error C1115: unable to find compatible overloaded function "tex2D"
<stdlib>(9542) : error C1016: expression type incompatible with function return type
Vertex shader:
// Uniform (global) vars
uniform vec3 windDirection;
uniform sampler2D windStrengthSampler;
// Per-vertex attributes
attribute float windInfluence;
void main()
{
// Pass through all texture coords
gl_TexCoord[0] = gl_MultiTexCoord0 * gl_TextureMatrix[0];
gl_TexCoord[1] = gl_MultiTexCoord1 * gl_TextureMatrix[1];
// vec4 colour = gl_Color;
vec4 colour = vec4(1.0, 1.0, 1.0, 1.0);
gl_FrontColor = colour;
gl_BackColor = colour;
// Vertex position
vec4 pos = gl_Vertex;
// Wind displacement
vec2 texCoord = pos.xy / 32.0;
vec4 windStrengthVec = texture2D(windStrengthSampler, texCoord);
// vec4 windStrengthVec = texture1D(windStrengthSampler, 1.0);
// vec4 windStrengthVec = vec4(1, 0, 0, 0);
vec3 displacement = windStrengthVec.r * windDirection * windInfluence;
pos.xyz += displacement;
gl_Position = gl_ModelViewProjectionMatrix * pos;
}
I'm at something of a loss. The glslValidate program from 3dlabs tells me everything in my source is fine.