Jump to content
  • Advertisement
Sign in to follow this  
timothyjlaird

texture lookup in a vertex shader?

This topic is 2344 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

I'm trying to access a texture in my vertex shader so that I can change the amplitude of my water waves based on said texture's 'b' (blue) value. Unfortunately, I get this error:

"error X4545: vs_2_0 target does not support texture lookups"

This is the part of my code that triggers the error (and I was careful not to have any pixels set to 0):


float4 amplitudeColor = tex2D(AmplitudeTextureSampler, inTexCoords2);
float amplitudePerMap = 255 / amplitudeColor.b;
input.Position.y = amplitudePerMap * sin(theta * freq + time * phase);


Further down I have this:


technique Technique1
{
pass Pass1
{
// TODO: set renderstates here.
VertexShader = compile vs_2_0 VertexShaderFunction();
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}


Is there any way around this?

Share this post


Link to post
Share on other sites
Advertisement
No, as the error says, SM2 doesn't support texture lookups in the vertex shader. You'll have to upgrade to at least vs_3_0 and ps_3_0 if you want to use this feature.

What's your minimum GPU hardware requirement?

Share this post


Link to post
Share on other sites
You can't do texture fetches in vs_2_0. Period. The only alternatives that come to mind are

A) Switch to vs_3_0 or higher

and

B) Use Render-To-Vertex-Buffer on AMD hardware to put your texture data into a vertex buffer

Share this post


Link to post
Share on other sites
My target is high performance windows and XNA...hidef I think is what it is called.

I got the per-vertex texture access working. Ran into some problems (had to convert my Texture2D from the default format to Vector4 and change the shader to use point filtering)...but it seems to work. I'm not impressed with the HLSL documentation though...you'd think that switching shader models would be easier (not changing the number, fixing all the stuff that changing models breaks). Edited by timothyjlaird

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!