Jump to content
  • Advertisement
Sign in to follow this  

Vertex Texture problems in SM3

This topic is 3617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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;


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...


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!