<p>Passing interpolated values that don't produce any result(other then the original value) is a waste of bandwidth and yes, it should be passed directly to the fragment shader in those cases. Point it out to the author and they will (usually) thank you for their simple mistake, or point out how they are leading up to something, or point out some easily over looked bit of code. I personally have submitted several bug reports to authors of books and shaders which have all been well received. (and a couple of them pointed out how and why I was actually mistaken)</p>

CC BY-SA 4.0
2021-07-24T23:49:16.757Z
2021-07-24T23:49:16.757Z
pmw1234
<p>I am looking at a sample code from a respected source and the <em>mipmap level-of-detail</em> parameter (float) is passed to the vertex shader as a uniform which then passes to the fragment shader <em>without</em> using the <strong>flat</strong> keyword, thus subject to interpolation(but all the vertex shaders are providing the same value-what would be the point of interpolation). What could I be missing here?</p>
<p>Is it not better to pass a such a variable as a uniform to the fragment shader?</p>

CC BY-SA 4.0
2021-07-23T19:09:34.670Z
Can you share the sample code? Generally speaking, yeah there is no reason to pass a value through interpolators if it's just coming from a uniform anyway.
Nathan Reed
<glsl><vulkan><fragment-shader><mipmap><uniform-buffer-object>
Level of detail passed from vertex shader to fragment shader
Vectorizer
# Level of detail passed from vertex shader to fragment shader

(Asked by: username_0 on 2021-07-23)

I am looking at a sample code from a respected source and the *mipmap level-of-detail* parameter (float) is passed to the vertex shader as a uniform which then passes to the fragment shader *without* using the **flat** keyword, thus subject to interpolation(but all the vertex shaders are providing the same value-what would be the point of interpolation). What could I be missing here?

Is it not better to pass a such a variable as a uniform to the fragment shader?

**Tags:** glsl, vulkan, fragment-shader, mipmap, uniform-buffer-object

> **Comments:**
> **username_1**: Can you share the sample code? Generally speaking, yeah there is no reason to pass a value through interpolators if it's just coming from a uniform anyway.  

---

## 1 answers

### Answer by username_2 on 2021-07-24. Score: 1 | Accepted answer

Passing interpolated values that don't produce any result(other then the original value) is a waste of bandwidth and yes, it should be passed directly to the fragment shader in those cases. Point it out to the author and they will (usually) thank you for their simple mistake, or point out how they are leading up to something, or point out some easily over looked bit of code. I personally have submitted several bug reports to authors of books and shaders which have all been well received. (and a couple of them pointed out how and why I was actually mistaken)


---

