Help us understand the problem. What is going on with this article?

vertex shader -> fragment shaderで整数型を渡す

More than 3 years have passed since last update.

intをそのままin/outで渡そうとするとコンパイルエラーになる.

// vertex shader
out int id;

void main() {
  // snip.
}
// fragment shader
in int id;

void main() {
  // snip.
}

回避するにはoutinの手前にflatをつけてあげる必要がある.

 // vertex shader
-out int id;
+flat out int id;

 void main() {
   // snip.
 }
 // fragment shader
-in int id;
+flat in int id;

 void main() {
   // snip.
 }

そもそもintを渡すこと自体があまりお行儀よくない気もするので,struct等に詰めたほういい気がしている.

References

wantedly
「シゴトでココロオドル」ためのビジネスSNS「Wantedly」の開発・運営をしています。
https://wantedlyinc.com/ja/presentations
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away