Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


texture lookup in a vertex shader?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 timothyjlaird   Members   -  Reputation: 404

Like
0Likes
Like

Posted 16 July 2012 - 08:09 PM

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?

Sponsor:

#2 Hodgman   Moderators   -  Reputation: 30885

Like
1Likes
Like

Posted 16 July 2012 - 08:12 PM

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?

#3 MJP   Moderators   -  Reputation: 11568

Like
1Likes
Like

Posted 16 July 2012 - 08:14 PM

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

#4 timothyjlaird   Members   -  Reputation: 404

Like
0Likes
Like

Posted 18 July 2012 - 07:45 PM

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, 18 July 2012 - 07:47 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS