Jump to content

  • Log In with Google      Sign In   
  • Create Account


Creating a custom vertex for use in 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 porters   Members   -  Reputation: 117

Like
0Likes
Like

Posted 14 March 2012 - 09:10 PM

Hi,

Basically i'm trying to create a custom vertex and use it in my vertex shader. The vertex is simply a standard position colored vertex, but i want to add an integer value as well. I cant seem to figure out what vertexformat and vertex semantic to use for this integer value. I've tried using the pointsize and blendindices formats/semantics, but the shader doesnt seem to recognize any value a set for scale.

How can i use an integer value in my custom vertex?

Heres an example of my vertex structure as defined in my program (VB.Net):

<System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> _
			Public Structure PositionColoredScale
				Public Position As Vector3
				Public Color As Integer
				Public Scale As Integer
				Public Shared ReadOnly Format As VertexFormat = VertexFormat.Position Or VertexFormat.Diffuse Or VertexFormat.None
				Public Shared ReadOnly Property SizeInBytes() As Integer
					Get
						Return System.Runtime.InteropServices.Marshal.SizeOf(GetType(PositionColoredScale))
					End Get
				End Property
			End Structure


Here's the structure in my shader:

struct VSInputVcScl
{
float4 Position : POSITION;
float4 Color  : COLOR;
uint Scale : BLENDINDICES0;
};

Thanks guys.

Sponsor:

#2 Jeason   Members   -  Reputation: 96

Like
0Likes
Like

Posted 15 March 2012 - 07:14 AM

How about using float in the struct and then cast to int in shader if you don't care the speed hit?

#3 porters   Members   -  Reputation: 117

Like
0Likes
Like

Posted 15 March 2012 - 05:45 PM

I could do that, but i dont see how that solves my problem. I'm after the correct semantic/vertex format to use for passing an arbitary integer (or a float) value to the shader. I want the GPU to ignore this value, it will only be used by me in some calculations.

#4 Jeason   Members   -  Reputation: 96

Like
0Likes
Like

Posted 20 March 2012 - 02:26 AM

I think there may be something wrong at other places.

Additionally,I find D3DFVF_SPECULAR is DWORD, but i haven' never used.




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