Jump to content
  • Advertisement
Sign in to follow this  
danromeo

Damndest problem, HLSL, XNA 4

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

Hiya.

I'm sending a variable to my effect: [font="Consolas"][font="Consolas"]effect.Parameters[[font="Consolas"][color="#a31515"][font="Consolas"][color="#a31515"][font="Consolas"][color="#a31515"]"Speed"[/font][/font][/font][font="Consolas"][font="Consolas"]].SetValue(Object[/font][/font][font="Consolas"][font="Consolas"].Position.X);
[/font][/font][/font][/font]
where Object.Position is a Vector3 vector.

If I send static float values, [font="Consolas"]effect.Parameters[[color="#a31515"][color="#a31515"][color="#a31515"]"Speed"].SetValue(0.00244[/font][font="Consolas"]), everything is fine.

But if I send the vector variable, effect.Parameters[[font="Consolas"][color="#a31515"][font="Consolas"][color="#a31515"][font="Consolas"][color="#a31515"]"Speed"[/font][/font][/font][font="Consolas"][font="Consolas"]].SetValue(Object[/font][/font][font="Consolas"][font="Consolas"].Position.X), the results have no discernible relationship to the value being sent....almost as if I'm sending random values.

Any idea what the HECK this is all about????

On Topic, please...I want to know why the expected values aren't getting to the shader.

The full function is below:

[font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]public[/font][/font][/font][font="Consolas"][font="Consolas"] [/font][/font][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]void[/font][/font][/font][font="Consolas"][font="Consolas"] Draw([/font][/font][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"]Matrix[/font][/font][/font][font="Consolas"][font="Consolas"] viewprojection, [/font][/font][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"]Effect[/font][/font][/font][font="Consolas"][font="Consolas"] effect)

{

effect.CurrentTechnique = effect.Techniques[[/font][/font][font="Consolas"][color="#a31515"][font="Consolas"][color="#a31515"][font="Consolas"][color="#a31515"]"Draw"[/font][/font][/font][font="Consolas"][font="Consolas"]];

Game.GraphicsDevice.BlendState = [/font][/font][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"]BlendState[/font][/font][/font][font="Consolas"][font="Consolas"].NonPremultiplied;

[/font][/font][font="Consolas"][font="Consolas"][/font][/font][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]foreach[/font][/font][/font][font="Consolas"][font="Consolas"] ([/font][/font][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"]EffectPass[/font][/font][/font][font="Consolas"][font="Consolas"] pass [/font][/font][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]in[/font][/font][/font][font="Consolas"][font="Consolas"] effect.CurrentTechnique.Passes)

{

[/font][/font][font="Consolas"][font="Consolas"]effect.Parameters[[/font][/font][font="Consolas"][color="#a31515"][font="Consolas"][color="#a31515"][font="Consolas"][color="#a31515"]"Speed"[/font][/font][/font][font="Consolas"][font="Consolas"]].SetValue(MyObject[/font][/font][font="Consolas"][font="Consolas"].Position.X * 0.01f);

[/font][/font][font="Consolas"][font="Consolas"]pass.Apply();

Game.GraphicsDevice.DrawUserIndexedPrimitives([/font][/font][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"]PrimitiveType[/font][/font][/font][font="Consolas"][font="Consolas"].TriangleStrip,Vertices,0,Vertices.Length,Indices,0,Triangles);

}

}

[/font][/font][/font][/font][/font]

Share this post


Link to post
Share on other sites
Advertisement
I'm not exactly a guru, but it looks like this is sending a double into your effect:
effect.Parameters["Speed"].SetValue(0.00244)

whereas here you're sending a float:
effect.Parameters["Speed"].SetValue(MyObject.Position.X * 0.01f);

Share this post


Link to post
Share on other sites
How is Speed declared in the shader? Have you checked to make sure the contents of MyObject.Position are correct? How is Speed used in the shader?

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!