texture lookup in a vertex shader?

Started by
2 comments, last by timothyjlaird 11 years, 9 months ago
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?
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?
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
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).

This topic is closed to new replies.

Advertisement