Discussion in 'Shaders' started by JohnSonLi, Jan 8, 2013.
why do we need sv_position?
SV_Position is a semantic, they're used to tell the engine how to move data through the graphics pipeline. You can't just send data between steps (e.g.: from vertex shader to pixel shader), because there are steps in between that you don't see in Shaderlab code.
As I remember,it is the second time you ask this question,Martin answered it fews month ago
Also cross-posted in Scripting with a slightly different wording: http://forum.unity3d.com/threads/165342-why-do-we-need-quot-TEXCOORD0-quot-after-quot-float2-uv-quot
I am a dull boy,and computer graphics is not my major,it is however sometimes too abstract for me...... Thank you all............it takes time
is sv_position something from the hardware?like video card???some data slot or bus from the video card???
SV_Position is one of "predefined" semantics, that is telling the GPU "this is the position". That's how it knows which value, well, determines the position on the screen.
I love you Aras.......
What I never understood is why the Unity documentation is using "SV_POSITION" instead of "POSITION" for the output of the vertex shader (and the input of the fragment shader). Is there a particular reason? Or was it just to use something different to distinguish the vertex attribute from the transformed position?
Why doesn't whatever you give the POSITION / SV_POSITION semantic work with the inout keyword? (i.e. you use that as a vert shader parameter instead of passing in a struct.) It compiles, but doesn't render, or at least in the expected way.
all of you are masters.......
Yes, the reason is compatibility with DX11.
SV_POSITION expands to just POSITION on all other platforms, and SV_Position on DX11. Why Microsoft made DX11 have "SV_Position" for the output position? I don't know
I assume because they want to group together all System Values. I don't really understand what their definition for a System Value is, though. At first they mention that:
But then they go on to list all the exceptions, where system values are NOT valid at other parts of the pipeline...
Hopefully NVIDIA documents this stuff at some point. I usually prefer the way they explain things.
I have the same issue.
When to use POSITION and when to use SV_POSITION?
SV seems to be a screenspace x y position, with z not doing very much. i do sin(svpos.x) it does straight bars in line with the screen sides.
Best use SV_POSITION. This will work on all platforms; whereas "POSITION" will work only on "most of them". For example, I think shaders on PS4 require SV_POSITION.