Jump to content
  • Advertisement
Sign in to follow this  

xna 4 hardware instancing

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

can you explain me in what order data from my instanced vertex is passed to the shader, and why?

this is my vertex declaration for instanced models:

[color=#4A4A4A] [StructLayout(LayoutKind.Sequential)]
[color=#4A4A4A] public struct PointLightDataVertex
[color=#4A4A4A] {
[color=#4A4A4A] public Vector4 LightPosAndRadius;
[color=#4A4A4A] public Vector4 LightColorAndFallof;

[color=#4A4A4A] public PointLightDataVertex(Vector4 a, Vector4 b)
[color=#4A4A4A] {
[color=#4A4A4A] LightPosAndRadius = a;
[color=#4A4A4A] LightColorAndFallof = b;
[color=#4A4A4A] }

[color=#4A4A4A] public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration(
[color=#4A4A4A] new VertexElement(0, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 5),
[color=#4A4A4A] new VertexElement(sizeof(float) * 4, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 6));
[color=#4A4A4A] }

and this is how i initialize them:
[color=#4A4A4A] (...) PointLightDataVertex(new Vector4(123.0f, 124.0f, 125.0f, 126.0f), new Vector4(3.0f, 4.0f, 5.0f, 6.0f));

[color=#4A4A4A]struct VSIn
[color=#4A4A4A] float4 Position : POSITION0;
[color=#4A4A4A] // per instance
[color=#4A4A4A] float4 LightPosAndRadius : TEXCOORD5;
[color=#4A4A4A] float4 LightColor : TEXCOORD6;

[color=#4A4A4A]what i get in vertex shader (checked with pix) :
[color=#4A4A4A]LightPosAndRadius (125.000, 126.000, 3.000, 4.000)
[color=#4A4A4A]LightColor (5.000, 6.000, 123.000, 124.000)

[color=#4A4A4A]why the order is so strange?

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!