shader problem

Hi !
I’m currently trying to make a little displacement mapping shader.

it goes like this:

void vshader( in float4 vtx_position  : POSITION,
              in float3 vtx_normal    : NORMAL,
              in float2 vtx_texcoord  : TEXCOORD0, 
              in uniform sampler2D tex_0   : TEXUNIT0,

              in uniform float4x4 mat_modelproj,

              out float4 l_position : POSITION,
              out float2 l_texcoord : TEXCOORD0,
    float tex_pos = tex2D( tex_0, vtx_texcoord ) ;
    float3 displacement = vtx_normal * tex_pos ;
    float4 true_pos = vtx_position + float4(displacement,0.0) ;
    l_position = mul( mat_modelproj, true_pos );
    l_texcoord  = vtx_texcoord ;

but I have an error:

:gobj(error): Cg program too complex for driver:/home//shader/displacement_map.sha

Investigating, I found that was the was “tex2D” command that crash ( the shader works without it).
According to the cg reference manual, “tex2D” command can be used in vertex shader since profile vp4.0

It seams that the one I’m using: ( with notify-level-glgsg debug )

Cg vertex profile = vp40  id = 7001
Cg pixel profile = fp40  id = 6151
shader model = 4

so,… why there was this error ?

I’m on ubuntu hardy heron with nvidia drivers 169.12 on a 8800GT


yeah tex2D cant be in vertex shader.

It a relatively new feature - my card has it its a 9800 GX2. Its mostly the the nix driver does not support this or the Cg you got does not support this for your card.

Very view games use tex2D in vertex shader and they are usually the DX10 games.

What also is an option to achieve kind of this effect, is to make your mesh deform based on vertex colors. (I believe FarCry does this too.)
Since you can access the vertex colors fine within your vertex shader, even the oldest card will support it.

Yes pro is right, the popping effect with vertex colors is almost standard, you can also attach other vertex “columns” if 4 floats is not enough.