<p>They represent the same operation, but <code>Sample</code> is what it's called in D3D10 and newer versions of HLSL, while <code>tex2D</code> is what it's called in D3D9 HLSL, and NVIDIA's (defunct) Cg language. By the way, the operation is also called <a href="http://docs.gl/sl4/texture" rel="noreferrer"><code>texture</code></a> in GLSL.</p>

CC BY-SA 3.0
2016-12-19T07:13:29.160Z
Thanks Nathan ! Is this just a new call or does it also include some performance boost. I mean what does this call imply compared to the D3D9 version ?
MaT
CC BY-SA 3.0
2016-12-19T14:51:52.943Z
@MaT It implies you're using D3D10+. ;) It's literally the same operation in hardware; they just redesigned the API and called it a different name.
Nathan Reed
CC BY-SA 3.0
2016-12-16T18:34:32.290Z
2016-12-16T18:34:32.290Z
Nathan Reed
<p>I am mainly using Unity but I think that it's not related to this engine, and I am wondering what's the difference between using <a href="http://http.developer.nvidia.com/Cg/tex2D.html" rel="noreferrer"><code>tex2D</code></a> and <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb509695(v=vs.85).aspx" rel="noreferrer"><code>Sample</code></a> for sampling a texture.</p>

<shader><texture><directx11><unity>
What's the difference between Sample and tex2D
MaT
# What's the difference between Sample and tex2D

(Asked by: username_0 on 2016-12-16)

I am mainly using Unity but I think that it's not related to this engine, and I am wondering what's the difference between using [`tex2D`](http://http.developer.nvidia.com/Cg/tex2D.html) and [`Sample`](https://msdn.microsoft.com/en-us/library/windows/desktop/bb509695(v=vs.85).aspx) for sampling a texture.

**Tags:** shader, texture, directx11, unity


---

## 1 answers

### Answer by username_1 on 2016-12-16. Score: 7 | Accepted answer

They represent the same operation, but `Sample` is what it's called in D3D10 and newer versions of HLSL, while `tex2D` is what it's called in D3D9 HLSL, and NVIDIA's (defunct) Cg language. By the way, the operation is also called [`texture`](http://docs.gl/sl4/texture) in GLSL.

> **Comments:**
> **username_0**: Thanks username_1 ! Is this just a new call or does it also include some performance boost. I mean what does this call imply compared to the D3D9 version ?  
> **username_1**: @username_0 It implies you're using D3D10+. ;) It's literally the same operation in hardware; they just redesigned the API and called it a different name.  

---

