   [Solved] VPOS Shader Semantic
  I've been trying to find some more information on this, but the most I seem to be able to get from Google is "The pixel location (x,y) in screen space."Could anyone give me some more information on how it works?When constructing a float4 output (to be used as a VPOS input to the pixel shader) from a vertex shader, what range of values should I be returning? (-1 ... 1?)What values will be comin into my pixel shader from a VPOS semantic? (-1 ... 1 again, or does something happen before it gets there?)Finally, why do my values need to be offset by 0.5f when they come into the pixel shader? (This will probably be obvious once the above two question have been answered)Thanks for any help in advance.[Edited by - adt7 on May 27, 2009 3:49:52 AM]
Quote:Original post by adt7When constructing a float4 output (to be used as a VPOS input to the pixel shader) from a vertex shader, what range of values should I be returning? (-1 ... 1?)From what I remember you can't specify the input in a vertex shader as its not a valid output semantic. It's a system generated, not interpreted value.I honestly can't remember the range of inputs, but it would make sense for it to be screen-space pixels I suppose. 0-1023, 0-767 for example. Failing that it may well be projection space -1..+1. A simple debug shader mapping it to the output colour should tell you quite quickly.Quote:Original post by adt7Finally, why do my values need to be offset by 0.5f when they come into the pixel shader? (This will probably be obvious once the above two question have been answered)Have you read the 'directly mapping pixels to texels' article in the SDK? D3D9 and D3D10 have differing definitions for texture coordinates. D3D9 refers to the middle of a texel and D3D10 refers to the top-left. A difference of 1/2 a texel.hthJack;  Yeah VPOS just tells you the screen-space position of a pixel.  It will be of the range [0, viewPortSize], not [-1, 1].   ;Quote:Original post by jollyjeffersHave you read the 'directly mapping pixels to texels' article in the SDK? D3D9 and D3D10 have differing definitions for texture coordinates. D3D9 refers to the middle of a texel and D3D10 refers to the top-left. A difference of 1/2 a texel.I've not read the article, but now you mention it, it's so obvious.Quote:Original post by MJPYeah VPOS just tells you the screen-space position of a pixel. It will be of the range [0, viewPortSize], not [-1, 1].Okay. So if I'm using a rendertarget it would be renderTargetSize instead, right?Thanks to both of you. I'm going to continue using TexCoords though, as well, I understand them better. I just saw VPOS in someone else's shader and thought it might be more elegant, but probably better to stick to what I know.;Quote:Original post by adt7Okay. So if I'm using a rendertarget it would be renderTargetSize instead, right?Sure, assuming you didn't adjust the viewport to be smaller than the size of the render target.  Either way you'd divide it by renderTargetSize to get a [0,1] texture coordinate.Quote:Original post by adt7Thanks to both of you. I'm going to continue using TexCoords though, as well, I understand them better. I just saw VPOS in someone else's shader and thought it might be more elegant, but probably better to stick to what I know.Yeah I mean it's a little nicer to use VPOS and you save an interpolant, but it probably won't matter at all in the long run.  Plus VPOS is only for ps_3_0, so if you want to support ps_2_0 you can't use it anyway.;Quote:Original post by MJPYeah I mean it's a little nicer to use VPOS and you save an interpolant, but it probably won't matter at all in the long run.  Plus VPOS is only for ps_3_0, so if you want to support ps_2_0 you can't use it anyway.I need to use VTF, so I'm bound to SM3.0 already.I've been doing a little more research too, and apparently VPOS doesn't play so well with tiling on the Xbox 360. Within normal conditions my code shouldn't trigger a tiling bracket, but if someone wants to push my code to the extremes when I release it... it'll break.Thanks once again for the help.