Sign in to follow this  
timothyjlaird

texture lookup in a vertex shader?

Recommended Posts

timothyjlaird    599
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):

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

Further down I have this:

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

Is there any way around this?

Share this post


Link to post
Share on other sites
MJP    19754
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
timothyjlaird    599
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

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