Sign in to follow this  
Nextgenneo

Vertex Texture problems in SM3

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this