Jump to content

  • Log In with Google      Sign In   
  • Create Account


HLSL postion only semantic, no color


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 Burnt_Fyr   Members   -  Reputation: 1214

Like
0Likes
Like

Posted 25 April 2014 - 05:11 PM

I'm encountering a weird issue that I'm having trouble understanding.

 

I'm using DX9, and am attempting to render a position only vertex. in the vertex shader. In the vertex shader stage I add a COLOR0 semantic to the output, which I fill in with float4(y,y,y,1) where y is the world space position of the vertex. In the pixel shader I just output that color. I am getting only white, no matter what height of the vertex.

 

However if i set the color to (1,0,0,y) I end up with the vertices colored properly, with variation between  Black -> Grey -> White with a world space y of <0 -> 0..1 -> >1. I'm perplexed, as this is the output I'd expect from shader described in the previous paragraph, while i would expect the range from black to red with this.

 

So I'm pretty sure the vertex shader is working, but the pixel shader is not getting, or not using the correct value. Is this due to the vertices' declaration as a position only vertex? If so, can anyone explain why?

 

I know I can add the COLOR0 semantic to the vertices vertex declaration, and bring it through the shader stages if necessary, I just can't comprehend why I should need to in this situation.

 

 



Sponsor:

#2 MJP   Moderators   -  Reputation: 10665

Like
1Likes
Like

Posted 25 April 2014 - 06:18 PM

Back in D3D9 the COLOR semantic was special, and was treated as a low-precision value that was clamped to [0, 1]. It was suitable for RGBA colors, but not general-floating point data. Use TEXCOORD0 instead.



#3 Burnt_Fyr   Members   -  Reputation: 1214

Like
0Likes
Like

Posted 25 April 2014 - 07:23 PM

Back in D3D9 the COLOR semantic was special, and was treated as a low-precision value that was clamped to [0, 1]. It was suitable for RGBA colors, but not general-floating point data. Use TEXCOORD0 instead.

That was the trick, can you elaborate on your response though?

 

-how low precision exactly?

-an n digit number can still be clamped between 0..1  so i'm not sure what you mean? was it a 1 bit per channel sort of thing?

-again, "RGBA colors" doesn't scream out anything obvious to me., so i'm not sure what your saying.



#4 MJP   Moderators   -  Reputation: 10665

Like
0Likes
Like

Posted 26 April 2014 - 12:38 PM

See the docs here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb219859(v=vs.85).aspx

 

"Each register contains four-component RGBA values iterated from input vertices. They have lower precision than most registers, guaranteed to have 8 bits of unsigned data in the range (0, +1)."

 

So you're guaranteed a minimum of 8 bits per component, giving you the same precision as an R8G8B8A8 texture. This is what I meant by "RGBA colors", as in a color that you could store in in a standard R8G8B8A8 texture. In practice I don't know if modern hardware actually uses low-precision for this value, I would think it's more likely that they keep it at full 32-bit floating point precision and just clamp it to [0, 1].


Edited by MJP, 26 April 2014 - 12:39 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