0
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$ Jul 23, 2021 at 19:09

1 Answer 1

1
$\begingroup$

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)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.