Reply To: After watching the video there were a few points I wanted to clarify if that was ok.

Forum Archive After watching the video there were a few points I wanted to clarify if that was ok. Reply To: After watching the video there were a few points I wanted to clarify if that was ok.

#28758
Grant
Participant

    I was just going through this series, and I saw your question and decided to take a shot at answering.

    COLOR versus SV_Target

    COLOR and SV_Target are roughly the same thing, though with a noteable difference.

    COLOR is a Semantic that represents a float4 with color information. Semantics are just a fancy way of saying data type. For a fragment shader, specifing a return type of COLOR means you’re returning a pixel to the screen.

    SV_Target is a System-Value Semantic, which means it is a semantic like COLOR, but with a slightly different usage. It indicates that the type is a render target. Render targets can either be a draw buffer(aka, the screen), or a texture. Like color, you’re still returning a pixel, it’s just you may not be returning a pixel directly to the screen. This concept was introduced in DirectX 10.

    Where things get confusing: a semantic like SV_Target is now interchangeable with COLOR. If you are writing specifically for DX9, you have to use COLOR. If you are writing for DX10 or DX11, you can use either COLOR or SV_Target. The shader compiler will intrinsicly know what to do based on your target platform and your shader type. Another example of this interchange-ability would be POSITION and SV_Position.

    As far as I can tell, with respect to Unity, it doesn’t really matter. Best practices would be to use SV_Target exclusively, as it’s newer. COLOR shouldn’t hurt you though, unless doing something legacy platform dependent.