Vertex Texture problems in SM3

Started by
1 comment, last by jollyjeffers 15 years, 4 months ago
So I am rendering some terrain and the heightmap is stored in a texture that's passed to the graphics card. On my laptop and machine it draws the terrain fine w/ heights but on a friends machine who has a GeForce 7900 it only draws a flat surface. Think I've narrowed it down to the tex2Dlod command because if I set it to a value such as 1 it does draw a higher flat surface. The HLSL code for the VS is: VS_OUTPUT Transform(VS_INPUT In) { VS_OUTPUT Out = (VS_OUTPUT)0; float4x4 viewProj = mul(view, proj); float4x4 worldViewProj = mul (world, viewProj); float height = tex2Dlod ( displacementSampler, float4(In.uv.xy, 0, 0 )); In.position.y = height * maxHeight; Out.worldPos = mul(In.position, world); Out.position = mul(In.position, worldViewProj); return Out; } I get a compile warning: "warning X3083: Truncating 4-vector to size 1" referring to the tex2Dlod line. Thanks for any help.
Advertisement
bump for the day crowd
Whilst it may not be the cause or solution of your problem, your tex2Dlod() call is wrong as per the error message. The return value is a float4 but you're assigning it to a float. Whilst the rules for this sort of thing are defined (I forget for SM3 though) it isn't very clear code so it'd be best to define it better.

Something like:

tex2Dlod ( displacementSampler, float4(In.uv.xy, 0, 0 )).r;

or

dot(float4(0.25,0.25,0.25,0.25),tex2Dlod ( displacementSampler, float4(In.uv.xy, 0, 0 )));

Should do the trick depending on your source data.

Also, from memory only Nvidia hardware supports this operation and I think it has to be a single- or quad-channel FP32 texture. You need to be very careful with your enumeration here as its not the best supported feature of SM3. It may well be that some combination of your casting and different format supports are causing your shader to behave in an unexpected way.

Check the debug output if you can - see if its warning you about incompatible featuresets or similar...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement