Jump to content

  • Log In with Google      Sign In   
  • Create Account


Passing TexCoords to the shader, always get grey textures - Solved


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 Muzzy A   Members   -  Reputation: 622

Like
0Likes
Like

Posted 18 October 2012 - 08:26 PM

EDIT:
I erased everything because i realized my texcoords are just fine, but my texture is always rendering grey.

I started passing in texcoords manually to the sampler, and it was giving me parts of the texture like it should... I think.

/*HLSL*/
// My list of texcoords, they're getting passed correctly i've debugged this
float2 gTexCoord[4];

struct InVertex
{
	float3 position : POSITION0;
	int	nIndex : TEXCOORD0;
};

struct OutVertex
{
	float4 position : POSITION0;
	float2 texCoord : TEXCOORD0;
};

OutVertex VertexShader(InVertex input)
{
	OutVertex output;
	
	output.position = float4(input.position,1);

	// Setting the texcoord for this vert.
	output.texCoord = gTexCoord[input.nIndex];

	return output;
}
float4 PixelShader(float2 texCoord : TEXCOORD0) : COLOR0
{
	return tex2D(gSampler,texCoord);
}

// The vertex declaration
D3DVERTEXELEMENT9 decl[] =
{
	{ 0,0,D3DDECLTYPE_FLOAT3,D3DDECLMETHOD_DEFAULT,D3DDECLUSAGE_POSITION,0 },
	{ 0,12,D3DDECLTYPE_FLOAT1,D3DDECLMETHOD_DEFAULT,D3DDECLUSAGE_TEXCOORD,0 },
	D3DDECL_END()
};

I'm going to try to test the index, to see if it's getting correct values

EDIT: SOLVED

It was indeed the vertex declaration, i was sending it a D3DDECLTYPE_FLOAT1, i changed it to a D3DDECLTYPE_SHORT2 and it worked just fine. I can see why it works, but i feel like it still should work with FLOAT1

Edited by Muzzy A, 18 October 2012 - 10:49 PM.


Sponsor:

#2 kubera   Members   -  Reputation: 861

Like
0Likes
Like

Posted 18 October 2012 - 10:08 PM

Once again, maybe something to do with D3D9 on VS 2012?

It would not be a problem in my opinion.

Could you show the vertex declaration, please?

#3 phil_t   Crossbones+   -  Reputation: 3197

Like
0Likes
Like

Posted 18 October 2012 - 11:35 PM

It was indeed the vertex declaration, i was sending it a D3DDECLTYPE_FLOAT1, i changed it to a D3DDECLTYPE_SHORT2 and it worked just fine. I can see why it works, but i feel like it still should work with FLOAT1


Why? You have it defined as an integer in your vertex shader input.

#4 Muzzy A   Members   -  Reputation: 622

Like
0Likes
Like

Posted 18 October 2012 - 11:38 PM

I assumed it copied by value, so i'm guessing it doesnt?




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